akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<algorithm>
using namespace std;
int sovle(){
    int n;
    cin>>n;
    vector<vector<int>> dp(n,vector<int>(n,-1));
    for(int i=0;i<n;i++){
        int tn;
        cin>>tn;
        for(int j = 0;j<tn;j++){
            int x;
            int tag = 0;
            cin>>x>>tag;
            dp[i][x-1] = tag;
        }
    }
    int res = 0;
    for(int i=1;i<(1<<n);i++){
        bool flag = true;
        int cnt = 0;
        for(int j = 0;j<n;j++){
            int m = 1<<j;
            if((m&i) == 0) continue;
            cnt++;
            for(int k=0;k<n;k++){
                if(dp[j][k]==-1) continue;
                if(dp[j][k] ^ ((1<<k)&i)>>k) {
                    // cout<<dp[j][k]<<"  "<<((1<<k)&i)<<endl;
                    flag = false;
                    break;
                }
            }
            // cout<<endl;
            if(!flag) break;
        }
        // cout<<"****"<<endl;
        // if(i==3 && flag) cout<<cnt<<endl;
        if(flag) res = max(cnt,res);
    }
    return res;
}


int main(){
    int T = 1;
    while(T--){
        int re = sovle();
        cout<<re<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] s = new String[N];
        for (int i = 0; i < N ; i++) {
            s[i] = sc.next();
        }
        int M = sc.nextInt();
        String[] t = new String[M];

        for (int i = 0; i < M ; i++) {
            t[i] = sc.next();
        }

        Set<String> set = new HashSet<String>();
        for (String ss : s) {
            set.add(ss);
        }
        for (String ts : t) {
            set.add(ts);
        }

        int max = 0;
        Iterator<String> it = set.iterator();
        while (it.hasNext()) {
            String word = it.next();
            int sCount = 0;
            for (String sWord : s) {
                if (word.equals(sWord)) {
                    sCount++;
                }
            }
            int tCount = 0;
            for (String tWord : t) {
                if (word.equals(tWord)) {
                    tCount--;
                }
            }
            max = Math.max(max, sCount + tCount);
        }
        System.out.println(max);

    }

}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define Rep(i,a,n) for (int i=a;i<=n;i++)
#define Per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

signed main(){
   int n;cin>>n;
   bool f=true;
   rep(i,0,n){
       int tmp;cin>>tmp;
       if(tmp%2==0){
           if(tmp%3&&tmp%5){
               f=false;
           }
       }
   }
   puts(f?"APPROVED":"DENIED");
    return 0;
}

Measured memory_bytes: 256
[<EntryPoint>]
let main argv =
    let n = System.Console.ReadLine() |> int
    let a = System.Console.ReadLine().Split() |> Array.map int
    let b = System.Console.ReadLine().Split() |> Array.map int
    let c = System.Console.ReadLine().Split() |> Array.map int
    let ans =
        List.sumBy (fun i -> b.[i] + if i<>0 && a.[i-1]+1=a.[i] then c.[a.[i-1]-1] else 0) [0 .. n-1]

    printfn "%d" ans
    0

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int c[3][3];
  for(int i=0;i<3;i++) {
    for(int j=0;j<3;j++) {
      int ci;
      cin >> ci;
      c[i][j] = ci;
    }
  }

  bool flag = true;
  for(int i=1;i<3;i++) {
    int x = c[i][0] - c[i-1][0];
    int y = c[0][i] - c[0][i-1];
    for(int j=1;j<3;j++) {
      if((c[i][j]-c[i-1][j]) != x) {
        flag = false;
        break;
      }
      if((c[j][i] - c[j][i-1]) != y) {
        flag = false;
        break;
      }
    }
  }

  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main (){
    int N, K, X;
    cin>>N>>K>>X;
    int color=3;
    if(N==K){
        color --;
    }
    if(N==X){
        color --;
    }
    if(X==K){
        color --;
    }
    if(color==0){
        color ++;
    }
    cout<<color<<endl;
    
}

Measured memory_bytes: 384
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
const ll INF=1000000000000000001;
int main(){
 string s;cin>>s;
 vector<ll> cnt(2,0);
 rep(i,s.size()){
    cnt[s[i]-'0']++;
 }
 ll q=min(cnt[0],cnt[1]);
 cout << q*2 << endl;
 return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
    ll N;
    cin >> N;
 
    vector<vector<ll>> num(10, vector<ll>(10, 0));
    for (ll i = 1; i <= N; i++) {
        string str_i = to_string(i);
        num[str_i.front() - '0'][str_i.back() - '0']++;
    }
 
    ll ans = 0;
    for (ll i = 0; i < 10; i++) {
        for (ll j = 0; j < 10; j++) {
            ans += num[i][j] * num[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1000000000000000007
#define pb emplace_back 
#define mx 1e9+2
#define all(s) s.begin(),s.end()
typedef vector<int> vi;
ll ans=0;
int gh[20];
ll dp[20][164][2];
ll getsum(int idx,int n,ll sum,bool flag){
		ans=max(sum,ans);
	if(idx>n)return sum;
	if(dp[idx][sum][flag]!=-1)return dp[idx][sum][flag];
	int limit=9;
	if(!flag)limit=gh[idx];
	ll res=0;
	for(int i=0;i<=limit;i++){
		if(i<limit||flag){
			res+=getsum(idx+1,n,sum+i,true);
		}
		else{
			res+=getsum(idx+1,n,sum+i,false);
		}
	}
	return dp[idx][sum][flag]=res;
}
void solve(){
	string b;
	cin>>b;
	for(int i=0;i<b.size();i++){
		gh[i+1]=b[i]-'0';
	}
	memset(dp,-1,sizeof dp);
  ll r=getsum(1,b.size(),0,0);
   cout<<ans<<"\n";
}

int main(){
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
   int t=1;
  // cin>>t;
     while(t--){
     	solve();
	 }
     return 0;
}

Measured memory_bytes: 3644
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int num[]=new int[n];
  for(int i=0;i<n;i++)num[i]=sc.nextInt();
  Arrays.sort(num);
  System.out.println(num[num.length-1]-num[0]);
}
}

Measured memory_bytes: 21588
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n, m[10], i, not0;
		
	while (scanf("%d", &n), n != 0){
		not0 = 0;
		
		for (i = 0; i < 10; i++){
			m[i] = 0;
		}
		
		i = 0;
		while (n != 0){
			m[i] = n % 8;
			n /= 8;
			i++;
		}
		
		for (i = 9; i >= 0; i--){
			if (not0 == 0 && m[i] != 0){
				not0 = 1;
			}
			
			if (not0 == 1){
				if (m[i] >= 4){
					m[i]++;
				}
				if (m[i] >= 6){
					m[i]++;
				}				
				printf("%d", m[i]);
			}
		}
		puts("");
	}
	
	return (0);
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,L;
  cin>>N>>L;
  vector<string>S(N);
  for(int i=0;i<N;i++)cin>>S[i];
  sort(rng(S));
  for(int i=0;i<N;i++){
    cout<<S[i];
  }
  cout<<endl;
  return 0;
}


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

#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)			    for(int i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh						while
#define mp						make_pair
#define le						length()
#define M						1000000007


void solve()
{
	ll n,m;
	cin>>n>>m;
	
	ll sum=0;
	fr(i,m)
	{
		int a;
		cin>>a;
		sum+=a;
	}
	if(sum>n)
	cout<<"-1";
	
	else
	cout<<n-sum;

}


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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int n;
vector<ll> a, b;

void input() {
    cin >> n;
    a = vector<ll>(n+1);
    b = vector<ll>(n);
    for(int i = 0; i < n+1; i++) {
        cin >> a.at(i);
    }
    for(int i = 0; i < n; i++) {
        cin >> b.at(i);
    }
//    cout << s;
}

void solve() {
    vector<ll> ori = a;
    ll tmp, diff;
    for(int i = 0; i< n; i++) {
        for(int j = 0; j < 2; j++) {
            //cout << "i: " << i << endl;
            //cout << "ori: " << ori.at(i) << endl;
            //cout << "a: " << a.at(i) << endl;
            //cout << "b: " << b.at(i) << endl;
            tmp = max(0LL, a.at(i+j) - b.at(i));
            diff = a.at(i+j) - tmp;
            a.at(i+j) = tmp;
            b.at(i) = b.at(i) - diff;
            //a.at(i+1) = min(0LL, a.at(i+1) - b.at(i));
            //b.at(i) = b.at(i) - (ori.at(i+1) - a.at(i+1));
        }
    }
    a.at(n) = max(0LL, a.at(n)-b.at(n-1));
    //cout << n << ": " << ori.at(n) << endl;
    //cout << n << ": " << a.at(n) << endl;
    ll beaten = 0;
    for(int i = 0; i < n+1; i++) {
        beaten += (ori.at(i) - a.at(i));
    }
    cout << beaten << endl;


}



int main() {
    input();
    solve();

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
//解説解答写し
int main(){
  int k;
  cin>>k;
  int x=7%k;
  set<int>s;
  int i=1;
  while(s.count(x)==0){
    if(x==0){
      cout<<i<<endl;
      return 0;
    }
    s.insert(x);
    x=(x*10+7)%k;
    ++i;
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 50468
// https://atcoder.jp/contests/abc137/tasks/abc137_d

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

int main (int argc, char* argv[]) {
	long long n, m;
	cin >> n >> m;

	vector<vector<long long>> day_to_earning(m + 1);

	for (auto i = 0ll; i < n; i++) {
		long long days, earning;
		cin >> days >> earning;
		if (days <= m) {
			day_to_earning[days].push_back(earning);
		}
	}

	priority_queue<long long> q;

	long long res = 0;
	for (auto i = 1ll; i <= m; i++) {
		for (long long earning : day_to_earning[i]) {
			q.push(earning);
		}
		if (!q.empty()) {
			res += q.top();
			q.pop();
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 5632
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

bool isprime (int n){

	if (n == 0 || n == 1){
		return false;
	}else if (n == 2){
		return true;
	}else if (n % 2 == 0){
		return false;
	} // end if
	
	for (int i = 3; i <= sqrt(n); i+= 2){
		if (n % i == 0){
			return false;
		} // end if
	} // end for
		
	return true;
}

int main()
{
	
//	cut here before submit 
//	freopen("testcase.prime", "r", stdin);
	string str = "";
	vector <int> prime(1000000, 0);

	int count = 0;
	for (int i = 2; i < 1000000; ++i){
		if (isprime(i)){
			++count;
		} // end if
		prime[i] = count;
	} // end for	

	while (getline (cin, str )){
		int n = 0;
		stringstream ssn(str);
		ssn >> n;
		cout << prime[n] << endl; 
	} // end while

	return 0;
}

Measured memory_bytes: 4704
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n;
double a[105];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	REP(i,n) cin>>a[i];
	double ans=0;
	REP(i,n) ans+=1.0/a[i];
	ans=1.0/ans;
	printf("%0.8lf",ans);
	return 0; 
}

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N=nextInt();
		int M=nextInt();
		int[][] s = new int[M][];
		for(int i=0;i<M;i++){
			s[i]=new int[nextInt()];
			for(int k=0;k<s[i].length;k++){
				s[i][k]=nextInt();
			}
		}
		int[] p = nextInts();
		int ans=0;
		int last = (int)Math.pow(2, N);
		for(int i=0;i<last;i++){
			boolean[] b = new boolean[N];
			int idx=0;
			for(int k=1;k<last;k=k<<1){
				b[idx]=((i&k)==k);
				idx++;
			}
			boolean flg=true;
			for(int k=0;k<M;k++){
				int num=0;
				for(int z=0;z<s[k].length;z++){
					if(b[s[k][z]-1]){
						num++;
					}
				}
				if(num%2!=p[k]){
					flg=false;
					break;
				}
			}
			if(flg){
				ans++;
			}
		}

		System.out.println(ans);
	}


	public static long[] disassemblyAlph(String s) {
		long[] alph = new long['z' - 'a' + 1];
		Arrays.fill(alph, 0);
		for (int i = 0; i < s.length(); i++) {
			alph[s.charAt(i) - 'a']++;
		}
		return alph;
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	long long n, p;
	long long n1 = 1;
	int ans = 0;
	cin >> n >> p;
	long long p1 = p;
	for (long long i = 2; i * i <= p1; i++) {
		while (p % i == 0) {
			p /= i;
			ans++;
		}
		if (ans >= n) {
			for (int j = 0; j < ans / n; j++) {
				n1 *= i;
			}
		}
		ans = 0;
	}
	if (n == 1) {
		n1 *= p;
	}
	cout << n1 << endl;
	return 0;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,m,ans=0;
  cin >>n >>m;
  long long int b[m],c[m];
  vector<long long int>a(n);
  vector<pair<long long int,long long int>> p;
  for(int i=0;i<n;i++){
    cin >>a[i];
  }
  for(int i=0;i<m;i++){
    cin >> b[i] >>c[i];
    p.push_back(make_pair(c[i],b[i]));
  }
  sort(a.begin(),a.end());
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  for(int i=0;i<m;i++){
    auto iter1=lower_bound(a.begin(),a.end(),p[i].first);
    long long int dist=iter1-a.begin();
    //cerr<<"n"<<endl;
    if(dist<=p[i].second){
      //cerr<<"s"<<endl;
      ans+=p[i].first*dist;
      a.erase(a.begin(),a.begin()+dist);
    }
    else{
      ans+=p[i].first*p[i].second;
      a.erase(a.begin(),a.begin()+p[i].second);
    }
  }
  for(int i=0;i<a.size();i++)ans+=a[i];
  cout <<ans<<endl;
}

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

struct point{
    int x;
    int y;
};

int main(void){
    // Your code here!
    point p[4];
    
    cin>>p[0].x>>p[0].y>>p[1].x>>p[1].y;
    
    point v;
    
    v.x=p[1].x-p[0].x;
    v.y=p[1].y-p[0].y;
    
 
    int t;
    t=v.y;
    v.y=v.x;
    v.x=-t;
    
    p[2].x=p[1].x+v.x;
    p[2].y=p[1].y+v.y;
    
    t=v.y;
    v.y=v.x;
    v.x=-t;
    
    p[3].x=p[2].x+v.x;
    p[3].y=p[2].y+v.y;
    
    cout<<p[2].x<<" "<<p[2].y<<" "<<p[3].x<<" "<<p[3].y<<endl;
    
}


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

using namespace std;
using ll = long long;

int main() {
    ll a;
    cin>>a;
    long double b;
    cin>>b;
    long double c=a*b;
    long double ans;
    modf(c,&ans);
    cout<<fixed<<setprecision(0);
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int A, B;
  cin >> A >> B;
  if(A == 1){
    A = A + 13;
  }
  if(B == 1){
    B = B + 13;;
  }
  if(A == B){
    cout << "Draw" << endl;
  }
  else if(A > B){
    cout << "Alice" << endl;
  }
  else{
    cout << "Bob" << endl;
  }
}
  

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import copy

input = sys.stdin.readline

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

N = int(input())

H = [int(x) for x in input().split()]

ans = 0

for i in range(N):
    good = True
    for j in range(i):
        if H[j] > H[i]:
            good = False
    ans += good

print(ans)





Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
int A[3][3];
int b[11];
int ok[3][3];

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  rep(i, 3) {
    rep(j,3) cin >> A[i][j];
  }
  cin >> N;
  rep(i, N) cin >> b[i];
  rep(i, N) {
    rep(j,3) {
      rep(k,3) {
        if (A[j][k]==b[i]) ok[j][k]=1;
      }
    }
  }
  rep(i,3){
    int sm = 0;
    rep(j, 3) sm+=ok[i][j];
    if (sm==3) {
      cout << "Yes" << "\n";
      return 0;
    }
  }

  rep(i,3){
    int sm = 0;
    rep(j, 3) sm+=ok[j][i];
    if (sm==3) {
      cout << "Yes" << "\n";
      return 0;
    }
  }

  if (ok[0][0]+ok[1][1]+ok[2][2]==3){
      cout << "Yes" << "\n";
      return 0;
  }

  if (ok[0][2]+ok[1][1]+ok[2][0]==3){
      cout << "Yes" << "\n";
      return 0;
  }

  cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

int power(int n, int t)
{
    int s = 1;
    repi(i, t, 0)
    {
        s *= n;
    }
    return s;
}
int main()
{
    int n, k;
    cin >> n >> k;
    double p = 0.;
    repi(i, n + 1, 1)
    {
        int point = i;
        int cnt = 0;
        while (point < k)
        {
            cnt++;
            point *= 2;
        }
        p += 1./(power(2, cnt) * n);
    }
    cout << fixed << setprecision(20) << p << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;
using uset = unordered_set<int>;

bool dfs(uset a, uset b, bool isTurnA){
    if(a.size() == 0 && b.size() != 0) return true;
    if(b.size() == 0 && a.size() != 0) return false;

    set<int> possible;
    vector<int> field(14, true);
    for(auto card : a) field[card] = false;
    for(auto card : b) field[card] = false;
    for(int i = 7; i > 0; i--) if(!field[i]){
        possible.insert(i);
        break;
    }
    for(int i = 7; i < 14; i++) if(!field[i]) {
        possible.insert(i);
        break;
    }

    uset x;
    if(isTurnA) x = a;
    else x = b;

    bool Awin;
    if(isTurnA) Awin = false;
    else Awin = true;
    bool touchField = false;
    for(auto card : x) {
        if(possible.count(card)){
            if(isTurnA) {
                a.erase(card);
                Awin |= dfs(a, b, !isTurnA);
                a.insert(card);
            } else {
                b.erase(card);
                Awin &= dfs(a, b, !isTurnA);
                b.insert(card);
            }
            touchField = true;
        }
    }

    if(!touchField) {
        if(isTurnA) Awin |= dfs(a, b, !isTurnA);
        else Awin &= dfs(a, b, !isTurnA);
    }

    return Awin;
}

int main(){
    int N;
    cin >> N;
    rep(i,N) {
        uset b{1,2,3,4,5,6,8,9,10,11,12,13};
        uset a;
        rep(i,6){
            int f; cin >> f;
            b.erase(f);
            a.insert(f);
        }

        bool yes = dfs(a, b, true);

        if(yes) cout << "yes" << endl;
        else cout << "no" << endl;
        
    }
}



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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int a,b,c;
  cin>>a>>b>>c;

  if(a==b)cout<<c<<endl;
  else{
    if(a==c)cout<<b<<endl;
    else cout<<a<<endl;
  }

return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <map>
using namespace std;

int main()
{
 int N;

 cin >> N;

 char S[2 * N];

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

 for(int i = N; i < 2*N; i++){
   cin >> S[i];
 }

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

 endl(cout);


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#define max(a,b) ((a < b) ? b : a)
#define min(a,b) ((a > b) ? b : a)
#define MOD 1000000007
using namespace std;

int main() {
  // 入力
  int n, m;
  cin >> n >> m;
  
  vector<long long int> F;
  F.push_back(0);
  F.push_back(1);
  F.push_back(1);
  for (int i = 3; i <= n + 1; i++)
    F.push_back((F[i-2] + F[i-1]) % MOD);
  
  long long int total = 1;
  int ap = -1;
  int an = -1;
  for (int i = 1; i <= m; i++) {
    cin >> an;
    int w = an - ap;
    
    if (w == 0)
      continue;
    if (w == 1) {
      cout << 0 << endl;
      return 0;
    }
    
    total *= F[w - 1];
    total %= MOD;
    ap = an;
  }
  total *= F[n - an];
  total %= MOD;
  
  // 出力
  cout << total << endl;
  
  return 0;
}


Measured memory_bytes: 1400
N = int(input())

def divisor(N):
    ret = []
    for i in range(1, int(N**0.5)+1):
        if N % i == 0:
            ret.append(i)
            if N // i != i:
                ret.append(N//i)
    return ret


div_N = divisor(N)
div_N_1 = divisor(N-1)

ans = 0

for k in div_N[1:]:
    n = N
    while n % k == 0:
        n //= k
    if n % k == 1:
        ans += 1

ans += len(div_N_1) - 1

print(ans)


Measured memory_bytes: 3188
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll C, ll mod){
  ll ans = 1; C = min(C, N - C);
  for (ll i = 1; i <= C; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}

int main(){
  ll X, Y; cin >> X >> Y;
  if (abs(X - Y) <= 1){
    cout << "Brown" << endl;
  }else{
    cout << "Alice" << endl;
  }
  
  return 0;
}


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

int main(){
    string s;
    cin>>s;
    int l,f;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='Z'){
            l=i;
            break;
        }
    }
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            f=i;
            break;
        }
    }
    cout<<l-f+1<<endl;
    return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>
int i,j,k,l,count,b,d=0,n=0,num[2000000];
void output(void);
void F(void);
void L(void);
void calc(void);
int main(void){
  scanf("%d",&n);
  char order[12];
  for(i=0;i<n;i++){
    scanf("%s %d",order,&b);
    switch(order[0]){
        case 'i':
            num[i]=b;
        break;
        case 'd':
            if(order[6]=='F'){
                F();
            }else if(order[6]=='L') {
                L();
            }else {
                calc();
            }
        break;
    }
  }
  output();
  return 0;
}
void F(void){
    i-=2;
    n-=2;
}
void L(void){
    i--;
    n--;
    d++;
}
void calc(void){
    i--;
    n--;
    l=0;
    for(j=i;j>=0;j--){
        if(l>0)break;
        if(b==num[j]){
            k=i-j;
            count=0;
            l++;
            while(k!=count++){
                num[j+count-l]=num[j+count];
            }
            i--;
            n--;
        }
    }
}
void output(void){
   for(i=0;i<n-d;i++){
    if(i==n-d-1){
      printf("%d\n",num[n-1-i]);
    }else{
      printf("%d ",num[n-1-i]);
    }
  } 
}


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
ll k, a[100010];
int n1[100010];

int main() {
    cin >> n >> k;
    rep(i, n) cin >> a[i];

    rep(i, n) {
        rep(j, 61) {
            n1[j] += a[i] >> j & 1;
        }
    }
    ll ans = 0, sum = 0;
    rrep(i, 60) {
        if (n - n1[i] > n1[i] && sum + (1LL << i) <= k) {
            sum += 1LL << i;
            ans += (n - n1[i]) * (1LL << i);
        } else {
            ans += n1[i] * (1LL << i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	double ans = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		ans += 1.0 / t;
	}
	cout << 1 / ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int n,m,q;
int a[50],b[50],c[50],d[50];

int dfs(vector<int> &v){
    if(v.size()==n){
        int sum=0;
        rep(i,q){
            if(v[b[i]]-v[a[i]]==c[i]) sum += d[i];
        }
        return sum;
    }
    int last = (v.empty()?1:v.back());
    int Max=0;
    for(int i=last;i<=m;++i){
        v.push_back(i);
        Max = max(Max,dfs(v));
        v.pop_back();
    }
    return Max;
}

int main(){
    cin >> n >> m >> q;
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    } 
    vector<int> v;
    cout << dfs(v) << endl;
    return 0;
}

Measured memory_bytes: 3600
import itertools

N = int(input())
P = list(map(int, input().split()))
tuple_P = tuple(P)
sorted_P = sorted(P)
Q = list(map(int, input().split()))
tuple_Q = tuple(Q)
sorted_Q = sorted(Q)

count_P = 1
for perm_P in itertools.permutations(sorted_P):
    if tuple_P == perm_P:
        break
    count_P += 1

count_Q = 1
for perm_Q in itertools.permutations(sorted_Q):
    if tuple_Q == perm_Q:
        break
    count_Q += 1

answer = abs(count_P - count_Q)
print(answer)

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	s[k-1] += 32;

	cout << s << endl;

	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll Ai, Bi;
    priority_queue<array<ll,2>> q1;
    priority_queue<ll> q2;
    for(int i=0;i<N;i++){
        cin >> Ai >> Bi;
        q1.push(array<ll,2>{-Ai, Bi});
    }
    ll res = 0;
    for(int i=0;i<M;i++){
        while(!q1.empty() && -q1.top()[0]<=i+1){
            q2.push(q1.top()[1]);
            q1.pop();
        }
        if(q2.empty()) continue;
        res += q2.top();
        q2.pop();
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 3568
#pragma GCC optimize "O3"

#define F first
#define S second

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

int n;
map<int, int> mp;

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    int x; scanf("%d", &x);
    ++mp[x];
  }
  LL ans = 0;
  for(auto it : mp) {
    if(it.S < it.F) {
      ans += it.S;
    } else if(it.S > it.F) {
      ans += (it.S - it.F);
    }
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 4736
import java.util.*;

public class Main {
        
  public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
   
       int N = sc.nextInt();
      
       int count = 0;
       
       HashSet<Integer> set = new HashSet<>();
       
       for(int i = 0;i < N;i++){
           int a = sc.nextInt();
           if(set.contains(a)){
               count++;
           }else{
              set.add(a);
           }
       }
              
       System.out.println(N - ( count + (count%2 == 0 ? 0 : 1 )));

  }  
}



Measured memory_bytes: 60740
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int x=h1*60+m1;
    int y=h2*60+m2;
    int len=24*60;
    int z=y-x;
    if(z<=0)
        z+=len;
    z-=k;
    cout<<z<<'\n';
    

} 



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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl;
#define CNO cout<<"No"<<endl;

typedef long long LL;
typedef long double LD;


class Solver{
private:
  int n,t,k;
  vector<vector<pair<int,int>>> e;
  vector<bool> isb;

  void dfs(int x, int p, vector<vector<int>> &v){
    v={{{0,IINF}}};
    vector<vector<int>> tmp;
    for(auto ed:e[x]){
      if(ed.first==p) continue;
      dfs(ed.first,x,tmp);
      tmp.push_back(vector<int>(2,IINF));
      int vsz = v.size();
      int tsz = tmp.size();
      rep(i,tsz-1){
        tmp[i+1][0]=min(tmp[i+1][0], tmp[i][1]+ed.second);
      }
      vector<vector<int>> nt(min(vsz+tsz-1,k+1),vector<int>(2,IINF));
      rep(i,vsz){
        rep(j,tsz){
          if(i+j>k) break;
          nt[i+j][0]=min(nt[i+j][0],v[i][0]+tmp[j][0]);
          nt[i+j][1]=min(nt[i+j][1],v[i][1]+tmp[j][0]);
          nt[i+j][1]=min(nt[i+j][1],v[i][0]+tmp[j][1]);
          nt[i+j][1]=min(nt[i+j][1],v[i][1]+tmp[j][1]);
        }
      }

      swap(v,nt);
    }
    int vsz=v.size();
    if(isb[x]){
      rep(i,vsz){
        v[i][1]=min(v[i][0],v[i][1]);
        v[i][0]=IINF;
      }
    }
  }

public:
  int solve(int nn,int tt,int kk,int cc){
    n=nn,t=tt,k=kk;
    e=vector<vector<pair<int,int>>>(n);
    int u,v,c;
    rep(i,n-1){
      cin >> u >> v >> c;
      u--,v--;
      e[u].push_back({v,c});
      e[v].push_back({u,c});
    }
    isb = vector<bool>(n);
    rep(i,t){
      cin >> u;
      isb[u-1]=true;
    }
    vector<vector<int>> ans;
    dfs(0,-1,ans);
    cout << "Case " << cc+1 << ": " << ans[k][1] << endl;
  }
};



int main(){
  Solver s;
  for(int c=0;1;c++){
    int n,t,k;
    cin >> n >> t >> k;
    if(n==0) return 0;
    s.solve(n,t,k,c);
  }
  return 0;
}



Measured memory_bytes: 7416
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {
	static boolean bElapsed = false;
	StringBuilder sb = new StringBuilder();
	List<Cake> list = new ArrayList<>();
	Set<String> set = new HashSet<>();
	Map<String,String> map = new HashMap<>();

	void solve(BufferedReader br) throws Exception {
		String line = br.readLine();
		String[] flds = line.split(" ");
		int k = Integer.parseInt(flds[0]);
		int t = Integer.parseInt(flds[1]);
		line = br.readLine();
		flds = line.split(" ");
		for (int i=0; i<t; i++) {
			int a = Integer.parseInt(flds[i]);
			list.add(new Cake(i, a));
		}
		int sum = 0;
		int prev = -1;
		while (list.size() > 0) {
			Collections.sort(list, new CakeComp());
			if (list.size() > 1) {
				Cake a = list.get(0);
				Cake b = list.get(1);
				prev = b.no;
				b.a--;
				if (b.a == 0) list.remove(1);
				a.a--;
				if (a.a == 0) list.remove(0);
			}
			if (list.size() == 1) {
				Cake a = list.get(0);
				if (prev < 0 || prev != a.no) {
					a.a--;
					prev = a.no;
				}
				sum += a.a;
				list.remove(0);
			}
		}
		pln(sum);
	}

	class Cake {
		int no;
		int a;
		public Cake(int no, int a) {
			this.no = no;
			this.a = a;
		}
	}
	class CakeComp implements Comparator<Cake> {
		public int compare(Cake o1, Cake o2) {
			return o2.a - o1.a;
		}
	}
	void p(char c) {
		System.out.print(c);
	}
	void pln(char c) {
		System.out.println(c);
	}
	void p(long l) {
		System.out.print(l);
	}
	void pln(long l) {
		System.out.println(l);
	}
	void p(String s) {
		System.out.print(s);
	}
	void pln(String s) {
		System.out.println(s);
	}
	//Integer.MAX_VALUE=2147483647>10^9
	//Long.MAX_VALUE=9223372036854775807L>10^18
	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		new Main().solve(br);
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.out.println((end-start) + "ms");
		}
	}
}


Measured memory_bytes: 11220
/*
    Ankit Singhal
 */
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/


const unsigned ll mod= (ll)1e9 + 7 ;
const ll inf = (ll)1e15 + 42;
const ll N = (ll)1e6 + 2;
 
ll power ( ll x , unsigned ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
 
/*struct node{
    ll x , y , z;
};
vector<set<ll>> tree;
vector<ll> ar , ans;
set<ll> s;
ll get(ll x)
{
    if(x == ar[x])
        return x;
    return ar[x] = get(ar[x]);
}
void merge(ll a ,ll b)
{
    a = get(a);
    b = get(b);
    if(a == b)
        return;
    ar[b] = ar[a];
    //ans[a] += ans[b];
 }

ll sev[1000001];


void seive()
{
    for(ll i = 2 ; i <= 1000000 ; i ++)
    {
        if(!sev[i])
        {
            for(ll j = i ; j <= 1000000 ; j += i)
            {
                if(!sev[j])
                    sev[j] = i;
            }
        }
    }
}
*/

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    while(t --)
    {
        string str;
        cin >> str;
        if(str == "SAT")
            print(1);
        if(str == "SUN")
            print(7);
        if(str == "MON")
            print(6);
        if(str == "TUE")
            print(5);
        if(str == "WED")
            print(4);
        if(str == "THU")
            print(3);
        if(str == "FRI")
            print(2);
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
    
}
 


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 14.12.2019 10:28:43       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  string t(s.rbegin(), s.rend());
  for (char& c : t) {
    if (c == 'b' || c == 'd') {
      c ^= 'b' ^ 'd';
    } else {
      c ^= 'p' ^ 'q';
    }
  }
  cout << (t == s ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int main(void){
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

long long dp[102][100005];
long long a[100005];
long long w[100005];
long long v[100005];

int main()
{
    long long n , W;

    cin >> n >> W;


    for(long long i = 0 ; i<n ; i++)
    {
        cin >> w[i] >> v[i];
    }

    for(long long i = 1 ; i<=n ; i++)
    {
        for(int j = 1 ; j<=W ; j++)
        {
            if(w[i-1]<=j)
            {
                dp[i][j] = max(dp[i-1][j] , dp[i-1][j-w[i-1]]+v[i-1]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout <<  dp[n][W];

    return 0;
}


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

namespace ABC089
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;

            n = int.Parse(Console.ReadLine());

            n = n / 3;

            Console.WriteLine(n);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220
#include<stdio.h>
int main(){
  int i,j,k,n,x,cnt;
  while(1){
    cnt=0;
    scanf("%d %d",&n,&x);
    if(n==0&&x==0)break;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
        for(k=j+1;k<=n;k++){
          if((i+j+k)==x)cnt++;
        }
      }
    }
    printf("%d\n",cnt);
  }
  return 0;
}

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

typedef long long int ll;
ll n;

int main() {
    scanf("%lld", &n);
    ll ans = 0;
    for(ll i = 1; i <= n; ++i) {
        ans += (i * (n/i) * (n/i + 1))/2;
    }

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

Measured memory_bytes: 3836
#include <iostream>
#include <vector>

using namespace std;

bool solve(const vector<int>& a){
    vector<int> cnt(a.size(), 0);
    for(auto& t : a) cnt[t]++;
    int idx = 0;
    while(cnt[idx] == 0) ++idx;
    if(cnt[idx] >= 3) return false;
    int m = 2*idx - cnt[idx] + 1;
    if(m >= a.size()) return false;
    for(int i=idx+1;i<=m;i++){
        if(cnt[i] < 2) return false;
    }
    for(int i=m+1;i<cnt.size();i++) if(cnt[i] > 0) return false;
    return true;
}

int main(){
    int N; cin >> N;
    vector<int> a(N);
    for(auto& t : a) cin >> t;
    cout << (solve(a) ? "Possible" : "Impossible") << endl;
}

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

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramC a = new ProgramC();
            a.main();//実行する

        }

    }
    //ABC178
    class ProgramA
    {
        public void main()
        {
            //入力
            string s = Console.ReadLine();
            //30以上ならYes、それ以外はNoを出力
            if(s == "0")
                Console.WriteLine(1);
            else
                Console.WriteLine(0);


        }
    }

    class ProgramB
    {
        public void main()
        {
            //入力

            string[] s = Console.ReadLine().Split(' ');
            long a = long.Parse(s[0]);
            long b = long.Parse(s[1]);
            long c = long.Parse(s[2]);
            long d = long.Parse(s[3]);
            long max1 = Math.Max(a * c, a * d);
            long max2 = Math.Max(b * c, b * d);

            Console.WriteLine(Math.Max(max1, max2));

        }
    }

    class ProgramC
    {
        public void main()
        {

            //入力
            long n = long.Parse(Console.ReadLine());
            long MOD = 1000000000 + 7;

            long ans = (modpow(10, n, MOD) + modpow(8, n, MOD) - 2 * modpow(9, n, MOD) % MOD )% MOD;

            Console.WriteLine((ans + MOD) % MOD);


        }

        static long modpow(long a, long n, long MOD)
        {
            if (n == 0)
                return 1;
            if (n % 2 == 0)
            {
                long temp = modpow(a, n / 2, MOD);
                return temp * temp % MOD;
            }

            return a * modpow(a, n - 1, MOD) % MOD;
        }
    }

    class ProgramD
    {
        public void main()
        {

        }
            
    }

    class ProgramE
    {

        public void main()
        {

        }


    }

}






Measured memory_bytes: 27496
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
    ll n;
    cin>>n;
    if(n%1000==0){
        puts("0");
    }else{
        ll temp = (n+1000-1)/1000;
        printf("%lld",temp*1000-n);
    }
    return 0;
}

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

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll a = 0, b = 0;
    cin >> a >> b;

    ll ans = 0;
    ll outlet = 1;
    while(outlet < b) {
        outlet--;
        outlet += a;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
h, w = map(int,input().split())
a = ["."+input()+"." for _ in range(h)]
a.insert(0,"."*(w+2))
a.append("."*(w+2))
y = [1,1, 1,-1,-1,-1,0, 0]
x = [0,1,-1, 0, 1,-1,1,-1]
for i in range(1,h+1):
    l =[]
    for j in range(1,w+1):
        if a[i][j] == "#":
            l += "#"
        else: l += str(sum([1 for k in range(8) if a[i+y[k]][j+x[k]] == "#"]))
    print("".join(l))

Measured memory_bytes: 3064