akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 998244353;

int powM(int x, int n){
    if(n == 0){
        return 1;
    }
    if(n % 2 == 0){
        return powM(x * x % MOD, n / 2);
    }
    return powM(x, n-1) * x % MOD;
}

int factM(int n){
    static vector<int> t = {1};

    if((int)t.size() > n){
        return t[n];
    }

    for(int i = t.size(); i <= n; i++){
        t.push_back(t[i-1] * i % MOD);
    }
    return t[n];
}

class combination{
    private:
        vector<int> t;

    public:
        combination(int n): t(n+1){
            t[n] = powM(factM(n), MOD-2);

            for(int i = n-1; i >= 0; i--){
                t[i] = t[i+1] * (i+1) % MOD;
            }

        }

        int comb(int n, int k){
            if(n < k){
                return 0;
            }
            return factM(n) * t[k] % MOD * t[n-k] % MOD;
        }
};

signed main(){
    int n, a, b, k;
    cin >> n >> a >> b >> k;

    combination c(n);

    int aa = min(a, b);
    int bb = max(a, b);

    int x = k / aa;
    if(x > n){
        x = n;
    }

    int ans = 0;
    while(x >= 0){
        int r = k - x * aa;
        int y = r / bb;
        if(r % bb != 0){
            x--;
            continue;
        }

        int t1 = c.comb(n, x);
        int t2 = c.comb(n, y);
        int tmp = t1 * t2 % MOD;
        ans = (ans + tmp) % MOD;
        x--;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8816
var
  s:longint;
  ch:char;
begin
  while not eoln do
    begin
      read(ch);
      if ch='C' then s:=1;
      if (s=1)and(ch='F') then
        begin
          writeln('Yes');
          halt;
        end;
    end;
  writeln('No');
end.

Measured memory_bytes: 128
# https://www.hamayanhamayan.com/entry/2020/04/26/232032
s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力

Measured memory_bytes: 9268
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int A[105],B[105];
int main()
{
	int N;
	while( ~scanf(" %d",&N) ){
		for( int i = 1 ; i <= N ; i++ ){
			scanf(" %d",&A[i]);
		}
		for( int i = 1 ; i <= N ; i++ ){
			scanf(" %d",&B[i]);
		}
		int max = 0 , sum;
		for( int i = 1 ; i <= N ; i++ ){
			sum = 0;
			int flag = 0;
			for( int j = 1 ; j <= N ; j++ ){
				if( flag == 0 ){
					sum += A[j];
					if( j == i )
						sum += B[i];
				}
				else if( flag == 1 ){
					sum += B[j];
				}
				if( j == i )
					flag = 1;
			}
			if( max < sum )
				max = sum;
		}
		printf("%d\n",max);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) (m*n)/GCD(m,n)
# define mod 1000000007
 
int main()
{
    IOS;
    ll i,j,k,t,n,sum=0,prod=1,flag=0,mark=0,marker=0,m;
    cin >> n >> m;
    ll a[n];
    priority_queue<ll> q;
    for(i=0;i<n;i++)
        {
            cin >> a[i];
            q.push(a[i]);
            sum+=a[i];
        }
    ll value=0;
   for(i=0;i<m;i++)
   {
       ll x = q.top();
       q.pop();
       value+=x-x/2;
       x/=2;
       q.push(x);
   }
  
   cout << sum-value<< endl;
}

Measured memory_bytes: 5000
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
using namespace std;
typedef pair<double,double> P;
typedef long long ll;

ll gcd(ll a, ll b) {if (b==0) return a; else return gcd(b, a%b);}
const ll m = 998244353; vector<ll> sm(200005), inv(200005);
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % m; x = x * x % m; a >>= 1;} return an;}
void sm_build() {
	sm[0]=1;for(ll i=1;i<200005;i++) sm[i]=sm[i-1]*i%m;
	inv[200004]=mod_pow(sm[200004],m-2);for(ll i=200003;i>=0;i--) inv[i]=inv[i+1]*(i+1)%m;
}
ll ncr(ll n, ll r) {return sm[n] * inv[n-r] % m * inv[r] % m;}
ll ncr2(ll n, ll r) {return sm[n] * mod_pow(sm[n-r], m-2) % m * mod_pow(sm[r], m-2) % m;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}

int main(){
	sm_build();

  ll n,mm,k; cin>>n>>mm>>k;
  ll an = 0;
  for(int i=0;i<=k;i++) {
    an += ncr(n-1, i) * mm % m * mod_pow(mm-1, n-i-1) % m;
    an %= m;
    //cout<<an<<endl;
  }
  cout<<an<<endl;
}

Measured memory_bytes: 6284
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 1100005, INF = 1<<25;

int in[N], n, cc[129];
bool used[N];
char str[N];
vector<int>g[129];

int lowbit(int t)
{
    return t&(t^(t-1));
}

int sum(int end)
{
    int ans=0;
    while(end>0)
    {
        ans+=in[end];
        end-=lowbit(end);
    }
    return ans;
}

void add(int pos ,int num)
{
    while(pos<=n)
    {
        in[pos]+=num;
        pos+=lowbit(pos);
    }
}

void solve()
{
    memset(in, 0, sizeof(in));
    for(int i=1; i<=n+1; i++)
    {
        add(i,1);
    }
    LL ans = 0;
    int v, u, size;
    char s;
    memset(used, 0, sizeof(used));
    for(int i=1; i<=n; i++)
    {
        if(!used[i])
        {
            s = str[i];
            size = g[s].size();
            u = g[s][size-1];
            if(i == u)
            {
                ans += (sum(n) - sum(i))/2;
            }
            else
            {
                ans += sum(n) - sum(u);
            }
            add(u, -1);
            add(i, -1);
            used[i] = used[u] = 1;
            g[s].erase(g[s].end()-1);
        }
    }
    printf("%lld", ans);
    puts("");
}

int main()
{
    scanf("%s", str+1);
    
        n = strlen(str+1);
        memset(cc, 0, sizeof(cc));

        for(int i=1; i<129; i++)
            g[i].clear();

        for(int i=1; i<=n; i++)
        {
            cc[str[i]]++;
            g[str[i]].push_back(i);
        }

        int flag = 0;
        for(int i=0; i<26; i++)
        {
            if(cc['a'+i]%2) flag++;
            if(cc['A'+i]%2) flag++;
        }
        if(flag > 1)
        {
            puts("-1");
            return 0;
        }
        else
        {
            solve();
        }
    return 0;
}



Measured memory_bytes: 6904
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int k;
    scanf("%d",&k);
    int n=0;
    for(int i=1;i<=1000010;i++){
        n=n*10+7;
        n%=k;
        if(n==0){
            printf("%d",i);
            return 0;
        }
    }
    printf("-1");
}


Measured memory_bytes: 3792
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n, m;
	cin >> n >> m;
	for(int i=m/n; 0<i; i--){
		if(m%i==0){
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n;
  cin >> n;
  bool flag = true;
  int m;
  for(int i=1;i<500;i++){
    if(n == i*(i+1)/2){
      flag = false;
      m = i;
      break;
    }
  }
  if(flag)cout << "No" << endl;
  else{
    vector<vector<int>> s(m+1,vector<int>(m));
    for(int i=0;i<m+1;i++){
      if(i == 0){
      for(int j = 1;j<=m;j++){
        s.at(i).at(j-1) = j;
      }
      }
      else{
        for(int j=0;j<i;j++){
          s.at(i).at(j) = s.at(j).at(i-1);
        }
        for(int j=i;j<m;j++){
          s.at(i).at(j) = s.at(i-1).at(m-1) + (j - i + 1);
        }
      }
    }
    cout << "Yes" << endl;
    cout << m+1 << endl;
    for(int i=0;i<=m;i++){
      cout << m;
      for(int j=0;j<m;j++){
        cout << ' ' << s.at(i).at(j);
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 4260
#include<iostream>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int l,r;
  int lb=0,rs=n;
  for(int i=0;i<m;i++)
  {
   
    cin>>l>>r;
    if(l>lb) lb=l;
    if(r<rs) rs=r;
  }
  if(rs>=lb)
  cout<<rs-lb+1;
  else cout<<"0";
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))


const int MOD = 1e+9+7;
const double PI  = acos(-1.0);

int main(){
    int n,c,k;
    cin>>n>>c>>k;
    vi lst;
    int num;
    REP(i,n){
        cin>>num;
        lst.push_back(num);
    }
    sort(lst.begin(),lst.end());
    int ret=1;
    int l=0;
    REP(r,n){
        if(lst[r]-lst[l]>k || r-l+1 >c){
            ret++;
            l=r;
        }
    }
    cout<<ret<<"\n";
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  cout << "ABC" << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
signed main(){
    int x,y;
    cin>>x>>y;
    int ans=1;
    while(x*2<=y){
        ans++;
        x*=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&a!=c)||(a==c&&b!=a)||(b==c&&b!=a)){
		cout<<"Yes"<<endl;
	} 
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
int N, M;
void func()
{
    cin >> N;
    int ans(0), min(0);
    int x[N];
    rep(i, 0, N)
    {
        cin >> x[i];
        ans += x[i];
    }
    // ans /= N;
    ans = (double)(ans) / N + 0.5;
    rep(i, 0, N)
    {
        min += (x[i] - ans) * (x[i] - ans);
    }
    cout << min << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 256
s = input()
l = len(s)

ans = 'Yes'
isOdd = True
for i in range(l):
    if isOdd:
        if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
            isOdd = False
            continue
        else:
            ans = 'No'
            break
    else:
        if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
            isOdd = True
            continue
        else:
            ans = 'No'
            break

print(ans)

Measured memory_bytes: 3064
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

l = [a, b, c, d, e]
cnt = 0

for i in l:
    for j in l:
        if abs(i-j) > k:
            print(':(')
            exit()

print('Yay!')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,X;
  cin >> K >> X;
  int A;
  A = X - K + 1;
  for(int i=0;i<K*2 - 1;i++){
   cout << A<<" ";
    A++;
      }
  }
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll h,a;
    cin>>h>>a;
    ll sum=0;
    while (a--){
        ll b;
        cin>>b;
        sum+=b;
    }
    (sum>=h) ? cout<<"Yes": cout<<"No";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
static int n;
static int[] check;//checked ->1,yet-> 0checking->2
static int[][] m;
final static int MAX=100; 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
     int i,j;
     Scanner sca=new Scanner(System.in);
     m=new int[MAX][MAX];
     n=sca.nextInt();
     for(i=0;i<n;i++){
    	 for(j=0;j<n;j++){
    		 m[i][j]=sca.nextInt();
    	 }
     }
     System.out.println(prim());
	}
	public static int prim(){
		int i,u,min,sum=0;
		int d[]= new int[MAX];
		int  p[]=new int[MAX];
		check=new int[MAX];
		for(i=0;i<n;i++){
			d[i]=Integer.MAX_VALUE;
			p[i]=-1;
		}
		d[0]=0;
		while(true){
			min=Integer.MAX_VALUE;
			u=-1;
			for(i=0;i<n;i++){
				if(min>d[i]&&check[i]!=1){
					u=i;
					min=d[i];
				}
			}
			if(u==-1)break;//finished
			check[u]=1;
			for(i=0;i<n;i++){
				if(check[i]!=1&&m[u][i]!=-1){
					if(d[i]>m[u][i]){
						d[i]=m[u][i];
						p[i]=u;
						check[i]=2;
					}
				}
			}
		}
		sum=0;
		for(i=0;i<n;i++){
			if(p[i]!=-1)sum+=m[i][p[i]];
		}
		return sum;
	}
}




Measured memory_bytes: 40984
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
	int n;cin>>n;
    int x;
    if(n%2) x=n/2+1;
    else x=n/2;
    double ans=(1.0*x)/n;
    printf("%0.9f",ans);
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);	 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


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

int main() {
  string str;
  int sum;
  while(1) {
    cin >> str;
    if(str == "0") break;
    sum = 0;
    for(int a = 0; a < str.size(); ++a) {
      sum = sum + str[a] - '0';
    }

    cout << sum << endl;
  }
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std ;
int main()
{ string s ;
   
   long long int x,y,n,k,i,sum ;
    cin>>k>>n ; 
   long long int arr[n] ;
   k=k ;
   sum=0 ;
   for(i=0;i<n;i++)
   { cin>>arr[i] ; 
   }  sort(arr,arr+n) ;
     x=arr[n-1]-arr[0] ;
     for(i=1;i<n-1;i++)
     { x=min(x,k-(arr[i+1]-arr[i])) ; 
       x=min(x,k-(arr[i]-arr[i-1])) ; }
    cout<<x ;
 return 0  ;}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



ll greedy(string s){
  ll n = s.size();
  ll cnt = 0;
  rep(i, n-1){
    if(s[i] == '?') continue;
    if(s[i] == s[i+1]) cnt++, s[i+1] = '?';
  }
  return cnt;
}

ll solve(string s, ll k){
  string tw = s + s;
  string th = s + s + s;
  string fr = tw + tw;
  ll g2 = greedy(tw);
  ll g3 = greedy(th);
  ll g4 = greedy(fr);
  ll d1 = g3 - g2;
  ll d2 = g4 - g2;

  return g2 + (k-2)/2*d2 + (k%2)*d1;
}

int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;


  ll n = s.size();
  ll cnt = 0;
  if(k <= 1e5){
    string t = "";
    rep(i, k) t += s;
    rep(i, t.size()-1){
      if(t[i] == '?') continue;
      if(t[i] == t[i+1]) cnt++, t[i+1] = '?';
    }
    cout << cnt << endl;
    return 0;
  }


  ll minn = solve(s, k);
  reverse(all(s));
  minn = min(minn, solve(s, k));
  
  cout << minn << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long int ll;
ll GCD(ll x,ll y){if(x%y==0)return y;else return GCD(y,x%y);}
ll LCM(ll x,ll y){return x*y/GCD(x,y);}
int main(){
	ll A,B,C,D,ans;
	cin>>A>>B>>C>>D;A--;
	ans=B-(B/C+B/D-B/LCM(C,D));
	ans-=A-(A/C+A/D-A/LCM(C,D));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
D, G = [int(str) for str in input().strip().split()]
pc = [[int(str) for str in input().strip().split()] for _ in range(D)]

ans = float('Inf')
sums = [100 * (i + 1) * pc[i][0] + pc[i][1] for i in range(D)]
for bit in range(2 ** D):
    score = 0
    cnt = 0
    for i in range(D):
        if bit & (0x01 << i):
            score += sums[i]
            cnt += pc[i][0]

    i = D - 1
    while score < G and i >= 0:
        if not(bit & (0x01 << i)):
            cnt_now = min(-(-(G - score) // (100 * (i + 1))), pc[i][0])
            cnt += cnt_now
            score += cnt_now * 100 * (i + 1)
        i -= 1

    if score >= G:
        ans = min(ans, cnt)

print(ans)

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

int main() {

  int a, b;
  char op;
  int ans;

  for(;;) {
    scanf("%d %c %d", &a, &op, &b);

    if( op == '?' ) {
      break;
    }
  
    switch( op ) {
    case '+':
      ans = a + b;
      break;
    case '-':
      ans = a - b;
      break;
    case '*':
      ans = a * b;
      break;
    case '/':
      ans = a / b;
      break;
    }

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

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define size (1<<21)
using namespace std;
int a[22][22];
ll dp[22][size+1];
ll solve(int i,ll no,int n)
{
	if(i>n)
	return 1;
   // auto p=mp(i,x);
	if(dp[i][no]!=-1)
	return dp[i][no];
	ll ans=0;
	for(int k=1;k<=n;k++)
	{
        ll mask=1<<(k-1);
        if(a[i][k]==1 && (no&mask))
        {
            no-=mask;
            ans=(ans+solve(i+1,no,n))%mod;
            no+=mask;
        }

	}
	return dp[i][no]=ans;
}
int main() {
    int n;
    cin>>n;
    
    //set<int> x;
    ll no=(1<<n)-1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            cin>>a[i][j];
        //x.insert(i);
    }
    memset(dp,-1,sizeof(dp));
    
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
    	if(a[1][i]==1)
    	{
            no-=1<<(i-1);
    		ans=(ans%mod+solve(2,no,n)%mod)%mod;
            no+=1<<(i-1);
            //x.insert(i);
    		//col[i]=false;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 364044
INFTY = 1 << 21
WHITE = 0
GRAY = 1
BLACK = 2

def prim(n, m):
    d = [INFTY] * n
    p = [-1] * n
    color = [WHITE] * n

    d[0] = 0

    while True:
        minv = INFTY
        u = -1
        for i in range(n):
            if minv > d[i] and color[i] != BLACK:
                u = i
                minv = d[i]
        if u == -1:
            break
        color[u] = BLACK
        for v in range(n):
            if color[v] != BLACK and m[u][v] != INFTY:
                if d[v] > m[u][v]:
                    d[v] = m[u][v]
                    p[v] = u
                    color[v] = GRAY

    w_sum = 0
    for i in range(n):
        if p[i] != -1:
            w_sum += m[i][p[i]]

    return w_sum


n = int(input())
m = []
for i in range(n):
    line = [int(v) for v in input().split()]
    for j in range(n):
        if line[j] == -1:
            line[j] = INFTY
    m.append(line)

print(prim(n, m))


Measured memory_bytes: 5892
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf-8");

function Main(input: string) {
  const [O, E] = input.split("\n").map((str) => str.split(""));
  let ans: string = "";
  O.forEach((o, i) => {
    ans += o;
    if (E[i]) ans += E[i];
  });
  console.log(ans);
}

Main(input);

Measured memory_bytes: 29616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main(){
//    int a, b , c, d, e, k;
//    cin >> a >> b >> c >> d >> e >> k;
    long long X, Y, Z, K;

    cin >> X >> Y >> Z >> K;
    long long A[X], B[Y], C[Z];
    for(int i=0;i<X;i++){
        cin >> A[i];
    }
    for(int i=0;i<Y;i++){
        cin >> B[i];
    }
    for(int i=0;i<Z;i++){
        cin >> C[i];
    }

    vector<long long> ab;
    for(int i=0;i<X;i++){
        for(int j=0;j<Y;j++){
            ab.push_back(A[i] + B[j]);
        }
    }
    sort(ab.begin(), ab.end(), greater<long long>());
    //上位のK個
    ab.resize(K);

    vector<long long> res;
    for(int i=0;i<ab.size();i++){
        for(int k=0;k<Z;k++){
            res.push_back(ab[i] + C[k]);
        }
    }

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

//    cout << "----------------" << endl;
    for(int i=0;i<K;i++){
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 42852
/* ****revpro**** */
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;  
//#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
signed main()
{
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
   // freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output1.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n;
		cin>>n;
		ll a[n];
		ll b[n],c[n];
		ll cnt=1,x,y;
		rep(i,0,n) a[i]=i+1;
		rep(i,0,n) cin>>b[i];
		rep(i,0,n) cin>>c[i];
		do{
			ll f=1;
			rep(i,0,n)  if(a[i]!=b[i]) f=0;
			if(f) x=cnt;
			f=1;
			rep(i,0,n)  if(a[i]!=c[i]) f=0;
			if(f) y=cnt;
			cnt++;
		}
		while(next_permutation(a,a+n));
		cout<<abs(x-y);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

using namespace std;

int main() {
    
    int n;
    cin >> n;
    
    vector<int> a(n);
    vector<int> x(n+1);
    
    int cnt=0;
    FOR(i, 0, n){
        cin >> a[i];
        if(i==0){
            x[0] = abs(a[i]);
            cnt += x[0];
        }else if(i>=1){
            x[i] = abs(a[i]-a[i-1]);
            cnt += x[i];
        }
    }
    x[n] = abs(a[n-1]);
    cnt += x[n];
    
    vector<int> ans(n,cnt);
    FOR(i, 0, n){
        if(i==0){
            ans[i] = ans[i] - x[i] - x[i+1];
            ans[i] = ans[i] + abs(a[i+1]);
            cout << ans[i] << endl;
        }else if(i==n-1){
            ans[i] = ans[i] - x[i] - x[i+1];
            ans[i] = ans[i] + abs(a[i-1]);
            cout << ans[i] << endl;
        }else{
            ans[i] = ans[i] - x[i] - x[i+1];
            ans[i] = ans[i] + abs(a[i+1]-a[i-1]);
            cout << ans[i] << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll gcd(ll x, ll y){
    return y ? gcd(y, x%y) : x;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    ll g;
    ll ma = 0;
    REP(i,N){
        ll A;
        cin >> A;
        if(i == 0) g = A;
        else g = gcd(g, A);
        chmax(ma, A);
    }

    if(K <= ma && K % g == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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

#define ll long long

using namespace std;

int main(){
    int a, b, c;

    cin >> a >> b >> c;

    if(a > b && a > c)      cout << (b*c)/2 << "\n";
    else if(b > c && b > a) cout << (a*c)/2 << "\n";
    else                    cout << (a*b)/2 << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;
 
int main(){
    int n;
    cin >> n;
    int p=0,o=1;
    while (true){
        p+=o;
        if (p>=n) break;
        o++;
    }
    int u=p-n;
    rep(i,o){
        if (i+1==u) continue;
        cout << i+1 << endl;
    }
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: u32 = read();
    let av: Vec<f64> = read_vec();
    let mut mult: f64 = 1.0;
    for a in &av {
        mult *= *a;
    }
    let mut shita: f64 = 0.0;
    for a in &av {
        shita += mult / *a;
    }
    println!("{}", mult / shita);
}


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

int main() {
  vector<int> v(3);
  cin>>v[0]>>v[1]>>v[2];
  sort(v.begin(),v.end());//v[0]のコストを0,v[1]はv[1]-v[0]、v[2]はv[2]-v[1].足すとv[2]-v[0]
  cout<<v[2]-v[0]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
map<pair<pair<int,int>,pair<int,int>>,ll> vis;
char c[100],c1[100],c2[100];
int main()
{	int n; ll ans=0; cin>>n;
	scanf("%s",c+1);
	for(rint i=1;i<=n;i++) c1[i]=c[i];
	for(rint i=n+1;i<=n+n;i++) c2[i-n]=c[i];
	for(rint i=0;i<(1<<n);i++)
	{	ll h1=0,h2=0; int n1=0,n2=0;
		for(rint j=1;j<=n;j++)
		if(i&(1<<j-1)) h1=h1*233LL+c1[j]-'a'+1,n1++;
		for(rint j=n;j>=1;j--)
		if(!(i&(1<<j-1))) h2=h2*233LL+c1[j]-'a'+1,n2++;
		vis[mp(mp(n1,h1),mp(n2,h2))]++;
	}
	for(rint i=0;i<(1<<n);i++)
	{	ll h1=0,h2=0; int n1=0,n2=0;
		for(rint j=1;j<=n;j++)
		if(i&(1<<j-1)) h1=h1*233LL+c2[j]-'a'+1,n1++;
		for(rint j=n;j>=1;j--)
		if(!(i&(1<<j-1))) h2=h2*233LL+c2[j]-'a'+1,n2++;
		ans+=vis[mp(mp(n2,h2),mp(n1,h1))];
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

int main()  {
    int flag = 0;
    string s;
    cin >> s;
    for(int i = 1; i <= s.length(); i++) {
        if (i % 2  == 1){
            if((s[i - 1] == 'R' || s[i - 1] == 'U' || s[i - 1] == 'D' ))
                flag = 1;
            else {
                flag = 0;
                break;
            }
        }
     if (i % 2  == 0){
            if((s[i - 1] == 'L' || s[i - 1] == 'U' || s[i - 1] == 'D' ))
                flag = 1;
            else {
                flag = 0;
                break;
            }
        }
    }
    if(flag == 0) cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var s = next();
	var len = s.length;
	var max = 100005;
	var dp = new Array(max);
	for(var i = 0; i < max; i++){
		dp[i] = new Array(13).fill(0);
	}
	dp[0][0] = 1;
	var mod = 1000000007;
	for(var i = 0; i < len; i++){
		for(var j = 0; j < 13; j++){
			var tmp = s[i];
			if(tmp == "?"){
				for(var k = 0; k < 10; k++){
					dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
					dp[i + 1][(j * 10 + k) % 13] %= mod;
				}
			}else{
				var k = myconv(s[i], 1);
				dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
				dp[i + 1][(j * 10 + k) % 13] %= mod;
			}
		}
	}
	myout(dp[len][5]);
}


Measured memory_bytes: 65320
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

vs input(string& s)
{
	int t = s.find('-');
	string l = s.substr(0, t);
	string r = s.substr(t + 1);
	vs res;
	res.push_back(l); res.push_back(r);
	return res;
}

int main()
{
	int n;
	while (cin >> n, n)
	{
		vector<vs> v(n);
		map<string, int> mp;
		REP(i, n)
		{
			string s; cin >> s;
			v[i] = input(s);
		}
		int p = 0;
		REP(i, n)REP(j, 2)
		{
			string tmp = v[i][j];
			if (mp.count(tmp)) continue;
			mp[tmp] = p;
			p++;
		}
		Graph g(p);
		Matrix dist(p, Array(p));
		REP(i, n)
		{
			int l = mp[v[i][0]], r = mp[v[i][1]];
			add_edge(g, l, r, 1);
			add_edge(g, r, l, 1);
			dist[r][l] = 1;
		}
		vector<pii> same;
		REP(i, p)REP(j, i)
		{
			bool f1 = false, f2 = true;
			REP(k, p)
			{
				if ((dist[i][k] || dist[k][i]) && (dist[j][k] || dist[k][j])) f1 = true;
				if ((dist[i][k] && dist[k][j]) || (dist[k][i] && dist[j][k])) f2 = false;
			}
			if (f1&&f2) same.emplace_back(i, j);
		}
		for (auto i : same)
		{
			dist[i.first][i.second] = 1;
			dist[i.second][i.first] = 1;
		}
		REP(k, p)REP(i, p)REP(j, p)
		{
			if (dist[i][k] && dist[k][j]) dist[i][j] = 1;
		}
		vi color(p);
		int col = 1;
		REP(i, p)
		{
			if (color[i]) continue;
			queue<int> que;
			que.push(i);
			int c = col, d = -col;
			color[i] = c;
			while (que.size())
			{
				int t = que.front();
				que.pop();
				int nx = (color[t] == c ? d : c);
				REP(j, g[t].size())
				{
					if (color[g[t][j].to]) continue;
					color[g[t][j].to] = nx;
					que.push(g[t][j].to);
				}
			}
			col++;
		}
		cout << p << endl;
		int q;
		cin >> q;
		REP(i, q)
		{
			string s; cin >> s;
			vs t = input(s);
			if (!mp.count(t[0]) || !mp.count(t[1]))
			{
				puts("NO");
				continue;
			}
			int l = mp[t[0]], r = mp[t[1]];
			if (color[l] == -color[r] && dist[r][l])
			{
				puts("YES");
			}
			else
			{
				puts("NO");
			}
		}
	}
	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<unsigned long> good(N, 1), H(N);
    for(auto&& i : H)cin >> i;
    for(unsigned long i{0}, A, B; i < M; ++i){
        cin >> A >> B;
        --A;--B;
        if(H[A] <= H[B])good[A] = 0;
        if(H[B] <= H[A])good[B] = 0;
    }
    cout << accumulate(good.begin(), good.end(), 0UL) << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main(){
    int N,K,a;
    cin>>N>>K;
    map<int,int> A;
    for(int i=0;i<N;i++){
        cin>>a;
        A[a]++;
    }
    a=0;
    int Ele=A.size();
    int B[Ele];
    for(auto itr=A.begin();itr!=A.end();itr++){
        B[a]=itr->second;
        a++;
    }
    a=0;
    sort(B,B+Ele);
    for(int i=0;i<Ele-K;i++){
        a+=B[i];
    }
    cout<<a;
    return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	if((a+b)%2==1)
		printf("%d\n",(a+b)/2+1);
	else
		printf("%d\n",(a+b)/2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

struct event {
    int time;
    // true:スタート、false:終了
    bool kind;
    int place;
    event(int t, bool k, int p) : time(t), kind(k), place(p) {
    }
    event() {
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    vector<event> flow(n * 2);
    for (int i = 0; i < n; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        flow[2 * i] = event(s - x, true, x);
        flow[2 * i + 1] = event(t - x, false, x);
    }
    vector<int> d(q);
    for (int i = 0; i < q; i++) {
        cin >> d[i];
    }
    sort(all(flow),
         [](const event x, const event y) { return x.time < y.time; });
    multiset<int> roadworks;
    int next = 0;
    for (int i = 0; i < q; i++) {
        while (flow[next].time <= d[i] && next < 2 * n) {
            if (flow[next].kind) {
                roadworks.insert(flow[next].place);
            } else {
                roadworks.erase(roadworks.find(flow[next].place));
            }
            next++;
        }
        if (roadworks.size() > 0) {
            cout << *roadworks.begin() << endl;
        } else {
            cout << -1 << endl;
        }
    }
}

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

int main(){
  int a,b,c; cin>>a>>b>>c;
  int K; cin>>K;
  vector<ll> AA(a);
  vector<ll> BB(b);
  vector<ll> CC(c);
  
  vector<ll> ab(a*b);
  
  for(int i=0;i<a;i++){
    cin>>AA[i];
  }
  for(int i=0;i<b;i++){
    cin>>BB[i];
  }
  for(int i=0;i<c;i++){
    cin>>CC[i];
  }
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      ab[i*b+j]=AA[i]+BB[j];
    }
  }
  sort(ab.begin(),ab.end());
  vector<ll> SSab(K);
  int wr=min(K,a*b);
  for(int i=0;i<wr;i++){
    SSab[i]=ab[a*b-1-i];
  }
  vector<ll> bc(wr*c);
  for(int i=0;i<c;i++){
    for(int j=0;j<wr;j++){
      bc[i*wr+j]=CC[i]+SSab[j];
    }
  }
  sort(bc.begin(),bc.end());
  for(int i=0;i<K;i++){
    cout<<bc[wr*c-1-i]<<endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  rep(i, n) cin >> a[i + 1];
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1 && a[i] % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q,l,r, x, y, u, v, n, m;
    cin>>n;

    unordered_map<string,ll> mp;

    string s;

    Ff(i,0,n)
    {
      cin>>s;
      mp[s]++;
    }

    cout<<mp.size();
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 24720
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	m := intScanner()
	s := Scanner()
	t := Scanner()
	g := gcd(n, m)
	f := true
	for i := 0; i < g; i++ {
		if s[i*(n/g)] != t[i*(m/g)] {
			f = false
		}
	}
	if f {
		fmt.Println(n * m / g)
	} else {
		fmt.Println(-1)
	}
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


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

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main () {
    lli N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    B = B - A;
    REP (i, 0, N - 1) {
        int res = N - i - 1;
        if (-D * i + C * res <= B && B <= -C * i + D * res) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

int main( void ) {
  int N, ans, mod;
  bool flg = false;
  cin >> N;

  for( int i = 0; i < 9; i++ ) {
    ans = N / ( i + 1 );
    mod = N % ( i + 1 );
    if( mod == 0 && ans < 10 )  {
      flg = true;
    }
  }
  if( flg == true )  cout << "Yes" << endl;
  else  cout << "No" << endl;
  
  return ( 0 );
}


Measured memory_bytes: 256
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	int x=1;
	int  n;
	cin>>n;
	rep(i,0,n){
		int k;
		cin>>k;
		if(k==x){
			++x;
		}
	}
	if(x==1){
		cout<<-1<<endl;
		return;
	}
	else cout<<n-x+1<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
using Graph =vector<vector<int>>;
//xor


int main(){
  int K,N;cin>>K>>N;
  int A[N];
  int dis[N];
  REP(i,N){
    cin>>A[i];
  }
  dis[0]=K-A[N-1]+A[0];
  for(int i=1;i<N;i++){
    dis[i]=A[i]-A[i-1];
  }
  int max=0;
  REP(i,N){
    if(max<dis[i]){
      max=dis[i];
    }
  }
  cout<<K-max<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

	ll a, b, n;
	cin >> a >> b >> n;

	ll x=min(n, b-1);

	cout << (a*x)/b << endl;

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long a, std::string s){
   if(a>=3200)op(s)
   else op("red")
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    std::string s;
    std::cin >> s;
    solve(a, s);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
int n, m, dp[100000];
vector<int> adj[100000];
int calc(int u) {
	if (dp[u] != -1) return dp[u];
	int res = 0;
	for (auto v : adj[u]) res = max(res, calc(v) + 1);
	return dp[u] = res;
}
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u - 1].push_back(v - 1);
	}
	memset(dp, -1, sizeof(dp));
	int ans = 0;
	for (int u = 0; u < n; u++) ans = max(ans, calc(u));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    map<string, set<int> > m;
    string t;
    int n;
    while (cin >> t >> n) m[t].insert(n);
    for(map<string, set<int> >::iterator i = m.begin(); i != m.end(); ++i) {
        cout << i->first << endl;
        ostringstream os;
        for(set<int>::iterator j = i->second.begin(); j != i->second.end(); ++j)
            os << " " << *j;
        cout << os.str().substr(1) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main () {
  int i,j,num;
  int ts=0,hs=0;
  char tc[101],hc[101];

  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s %s",tc,hc);
    for(j=0;;j++){
      if(tc[j]<hc[j]){
	hs+=3;
	break;
      }

      else if(tc[j]>hc[j]){ 
	ts+=3;
	break;
      }
      if(tc[j]=='\0' && hc[j]=='\0'){
	hs++;
	ts++;
	break;
      }
    }
  }
  printf("%d %d\n",ts,hs);
  return 0;
}

Measured memory_bytes: 596
a = [False,False,False,False]
for x in input().split():
  x = int(x)
  if(x == 1):
    a[0] = True
  elif(x == 9):
    a[1] = True
  elif(x == 4):
    a[2] = True
  elif(x == 7):
    a[3] = True
 
all = True
for x in a:
  all &= x
 
print('YES' if all else 'NO')


Measured memory_bytes: 3060