akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int a,b,c,ans;
int main()
{
    cin>>a>>b>>c;
    if(a>b){
        cout<<0;
        return 0;
    }
    ans=b/a;
    if(ans>=c)
        cout<<c<<endl<<endl;
    else
        cout<<ans<<endl<<endl;
    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut dv = vec![0i32; n];
    for i in 0..n - 1 {
        dv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    dv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    dv.sort();

    let ml = dv[dv.len() / 2 - 1];
    let mr = dv[dv.len() / 2];
    let ans = if ml == mr { 0 } else { mr - ml };
    println!("{}", ans);
}


Measured memory_bytes: 4352
k = gets.to_i
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts a[k-1]

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
using namespace std;
vector <int> v ;
int dp[100006]; 
int n , a ,  k ; 
int solve (int idx)
{
	
	if (idx >=n )
	return 1e9+7; 
	
	if (idx==n-1) return 0; 
	
	if(dp[idx]!=-1)
	return dp[idx]; 
	
	int mn =1e9; 
	for (int i=1; i<=k ; i++)
	{
		int a = abs(v[idx]-v[idx+i])+solve(idx+i) ;
		 mn = min( mn , a ) ; 
	}
	return dp[idx]= mn; 
}
int main() {
	cin>>n >> k  ; 
	for (int i=0 ; i<n ; i++)
	{
		cin>>a ; 
		v.push_back(a);
	}
	
	memset (dp, -1 , sizeof dp ); 
	
	int ans = solve(0); 
	
	printf("%d",ans ); 
	return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define int long long
#define abs(a) llabs(a)
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int x, cnt = 0, a;
   cin >> x;
   cnt = x / 100;
   cnt = (cnt * 100) + (cnt * 5);
   if (cnt >= x)
      cout << 1 << '\n';
   else
      cout << 0 << '\n';
}

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

using namespace std;

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

  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define min(a,b) (a>b? b:a)
int main()
{
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  for(int i=0;i<min(t.size(),s.size());i++){
    if(t[i]-s[i]<0) {
      cout<<"No";
      return 0;
    }
    else if(t[i]-s[i]>0){
      cout<<"Yes";
      return 0;
    }
  }
  if((int)t.size()-(int)s.size()>0){
    cout<<"Yes";
    return 0;
  }
  cout<<"No";
}
  

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

using namespace std;

using ll = long long;

constexpr int N = 5e5 + 5;

char buf[N];

int solve() {
    auto sum_to = [](ll n) {
        return (n > 1 ? n * (n - 1) / 2 : 0);
    };
    scanf("%s", buf);
    int n = strlen(buf);
    ll res = 0;
    int o_count = 0, c_count = 0;
    for (int i = 0; i < n; ++i) {
        const char c = buf[i];
        if (c == '<') {
            if (c_count != 0) {
                res +=
                    sum_to(o_count) + sum_to(c_count) + max(o_count, c_count);
                o_count = 1;
                c_count = 0;
            } else {
                ++o_count;
            }
        } else {
            ++c_count;
        }
    }
    res += sum_to(o_count) + sum_to(c_count) + max(o_count, c_count);
    cout << res << endl;

    return 0;
}

int main() {
#ifdef LOCALHOST
    freopen("input", "r", stdin);
#endif
    while (solve()) {
    }

    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 2005;
const ll MOD = 1e9 + 7;

int n, m;
ll dp[N][N];

int main() {
	cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m;
    vector<int> a(n), b(m);
    for (auto& i : a) cin >> i;
    for (auto& i : b) cin >> i;
    
    rep(i, 0, N) {
        dp[0][i] = 1;
        dp[i][0] = 1;
    }

    rep(i, 1, n + 1) {
        rep(j, 1, m + 1) {
            if (a[i - 1] == b[j - 1]) {
                dp[i][j] = (2 * dp[i - 1][j - 1]) % MOD + (dp[i - 1][j] + dp[i][j - 1] - 2 * dp[i - 1][j - 1]);
                if (dp[i][j] < 0) dp[i][j] += MOD;
                dp[i][j] %= MOD;
            } else {
                dp[i][j] = ((dp[i - 1][j] + dp[i][j - 1]) % MOD - dp[i - 1][j - 1] + MOD) % MOD;
                if (dp[i][j] < 0) dp[i][j] += MOD;
                dp[i][j] %= MOD;
            }
        }
    }
    
    cout << dp[n][m];
}


Measured memory_bytes: 34904
#include <stdio.h>
#include <math.h>
#include <vector>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m, be = 0, now = 0, ans = 1;
  vector<ll> v;
  scanf("%lld%lld", &n, &m);
  if(m == 1) {
    printf("1");
    return 0;
  }
  for(i = 2; i <= sqrt(m); ++i) {
    if(!(m % i)) m /= i, be = i--, now++;
    else if(now) v.push_back(now), now = 0;
  }
  if(be == m) now++, v.push_back(now);
  else {
    if(now) v.push_back(now);
     v.push_back(1);
  }
  ll com[40], tmp[40];
  for(i = 0; i < 40; ++i) com[i] = 1;
  for(i = 1; i < n; ++i) {
    for(j = 0; j < 32; ++j) tmp[j] = 0;
    for(j = 0; j < 32; ++j) for(k = j; k < 32; ++k) tmp[k] += com[j], tmp[k] %= mod;
    for(j = 0; j < 32; ++j) com[j] = tmp[j];
  }
  for(i = 0; i < v.size(); ++i) ans *= com[v[i]], ans %= mod;
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().strip().split()))
count = 0
for i in range(1,n-1):
  if A[i]!=max(A[i-1],A[i],A[i+1]) and A[i]!=min(A[i-1],A[i],A[i+1]):
    count += 1
  else:
    count += 0
print(count)
  

Measured memory_bytes: 3060
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  string s;
  cin >> s;

  LL y = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0') * 1;
  LL m = (s[5] - '0') * 10 + (s[6] - '0') * 1;
  LL d = (s[8] - '0') * 10 + (s[9] - '0') * 1;

  bool f = false;
  if (y >= 2020)
  {
    f = true;
  }
  else
  if(y==2019){
    if(m>=5){
      f = true;
    }else
    if(m==4){
      if(d>=31){
        f = true;
      }
    }
  }
  if(f){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
}


Measured memory_bytes: 256
a, b, c, k = map(int, input().split())

cards = k
sum = 0

while (True):
    if cards > a:
        sum += a
        cards -= a
        if cards > b:
            sum += 0
            cards -= b
            if cards > c:
                sum -= c
                cards -= b
            else:
                sum -= cards
                print(sum)
                break
        else:
            print(sum)
            break

    else:
        sum += cards
        print(sum)
        break



Measured memory_bytes: 9200
using System;
 public class Hello{
     static void sort(int[] x){
         for(int a = 0;a < x.Length - 1;a++){
             for(int b = a + 1;b < x.Length;b++){
                 if(x[a] < x[b]){
                     int temp = x[a];
                     x[a] = x[b];
                     x[b] = temp;
                 }
             }
         }
     }
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        int[] mochi = new int[N];
        for(int x = 0;x < N;x++){
            mochi[x] = int.Parse(Console.ReadLine());
        }
        sort(mochi);
        int count = 1;
        for(int j = 0;j < mochi.Length - 1;j++){
            if(mochi[j] > mochi[j + 1]){
                count++;
            }
        }
        /*foreach(int i in mochi){
            Console.WriteLine(i);
        }*/
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 13140
from collections import *
from heapq import*
import sys
input=lambda:sys.stdin.readline()

n=int(input())
d=[[]for _ in[0]*-~n]

for s in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])
#defaultdict(<class 'list'>, {1: [[2, 1], [3, 1]], 2: [[1, 1], [3, 3]], 3: [[1, 1], [2, 3]]})

def DIJKSTRA(point,d):
    cost      = [float("inf") for _ in range(len(d))]
    Q         = []  #頂点のリスト
    cost[point]=0  #開始地点のコストをゼロとする（当たり前
    heappush(Q,(point,cost[point]))
    while Q:
        prefnd,tmpC=heappop(Q)
        if cost[prefnd]<tmpC:
            continue
        for node,c in d[prefnd]:
            altC=c+tmpC
            if cost[node]>altC:
                cost[node]=altC
                heappush(Q,(node,altC))
    return cost

q,k=map(int,input().split())
y=DIJKSTRA(k,d)

for i in range(q):
    a,b=map(int,input().split())
    print(y[a]+y[b])

Measured memory_bytes: 52772
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,s,t,i,res;
  cin >> n;
  cin >> t;
  res=t;
  s=t;
  for(i=1;i<n-1;i++){
    cin >> t;
    res+=min(s,t);
    s=t;
  }
  res+=t;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            int n = int.Parse(Console.ReadLine());
            long[] a = ILongs();
            int ans = 0;
            for(int i=1;i<n-1;i++){
                if((a[i]>a[i+1]&&a[i]>a[i-1])||(a[i]<a[i+1]&&a[i]<a[i-1])){
                    //
                }else{
                    ans ++;
                }
            }
            Console.WriteLine(ans);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = Console.ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return Console.ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return Console.ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = Console.ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = Console.ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

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

using namespace std;

struct point {
    int left, right, block, id;
};

bool cmp(const point &lhs, const point &rhs) {
    if (lhs.block < rhs.block)
        return true;
    else if (lhs.block > rhs.block)
        return false;
    else
        return lhs.right < rhs.right;
}

int main(){
    int n, q;
    scanf("%d", &n);
    vector<int> A(n);
    scanf("%d", &q);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);

    int block_size = sqrt(n);

    vector<point> query(q);
    for (int i = 0; i < q; i++) {
        scanf("%d %d", &query[i].left, &query[i].right);
        query[i].left--, query[i].right--;
        query[i].block = query[i].left / block_size;
        query[i].id = i;
    }

    sort(query.begin(), query.end(), cmp);

    vector<int> solution(q);
    vector<int> hash(1000100);

    int left = 0, right = 0, answer = 1;
    hash[A[0]] = 1;

    for (const point &task : query) {
        while (left < task.left) {
            hash[A[left]]--;
            answer -= (hash[A[left]] == 0);
            left++;
        }
        while (left > task.left) {
            left--;
            hash[A[left]]++;
            answer += (hash[A[left]] == 1);
        }
        while (right < task.right) {
            right++;
            hash[A[right]]++;
            answer += (hash[A[right]] == 1);
        }
        while (right > task.right) {
            hash[A[right]]--;
            answer -= (hash[A[right]] == 0);
            right--;
        }
        solution[task.id] = answer;
    }

    for (int answer : solution)
        printf("%d\n", answer);

    return 0;
}

Measured memory_bytes: 19296
n=int(input())
A=list(map(int,input().split()))
A.sort()
Adict={}
q=int(input())
B=[]
C=[]
for i in range(q):
    b,c=map(int,input().split())
    B.append(b)
    C.append(c)

S=[]

last=0
for a in A:
    if last!=a:
        Adict[a]=1
    else:
        Adict[a]+=1
    last=a

sum=0
for a in Adict:
    sum+=Adict[a]*a


for index ,b in enumerate(B):
    if b in Adict:
        c=C[index]
        sum=sum-b*Adict[b]+c*Adict[b]
        if c in Adict:
            Adict[c]+=Adict[b]
        else:
            Adict[c]=Adict[b]
        del Adict[b]
        S.append(sum)
    else:
        S.append(sum)

for s in S:
    print(s)

Measured memory_bytes: 105388
#include<bits/stdc++.h>
#include<set>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define sort(v)	sort(v.begin(),v.end());
#define rsort(v) sort(v.rbegin(),v.rend());
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vb vector<bool>
#define vc vector<char>
#define vvll vector<vector<long long int> >
#define sll set<long long int>
#define mll map<long long int,long long int>
#define sllit set<long long int>::iterator
#define pll pair<long long int,long long int>
#define vpll vector<pair<long long int,long long int> >
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli mpower(lli a,lli b,lli m){lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli gcd(lli a,lli b){if(b==0) return a;if(a==0) return b;if(a>=b) return gcd(b,a%b);else return gcd(a,b%a);}
lli lcm(lli a,lli b){lli p=a*b;return p/gcd(a,b);}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}


/******************************START********************************/
int main()
{
	char ch1,ch2,ch3;
	double w,e;
	string s1,s2,s3;
    lli i,j,k,a,t,b,c,h,n,m,sum=0,ans=0,temp;
    cin >> h;
    if(h==1){
    	cout << "1" << endl; 
	}
	else{
		a=1;
		while(h!=0){
			ans+=a;
			if(h==1)	h=0;
			else{
				h/=2;
				a=a*2;
			}
		}
		cout << ans << endl;
	}
    
    
    
    
    
    
    return 0;
}





















/* UJJWAL KESHRI */

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

string s[100], t[100];
signed main(void)
{
	int n;
	cin >> n;
	REP(i, n) {
		int h, w;
		cin >> h >> w;
		REP(j, h) cin >> s[j];

		set<char> st;
		REP(j, h) REP(k, w) if(s[j][k] != '.') st.insert(s[j][k]);

		vector<char> v;
		for(char j: st) v.PB(j);
		sort(ALL(v));

		bool ans = true;
		do {
			REP(j, h) t[j] = s[j];
			ans = true;
			//cout << "v:"; for(char j: v) cout << j << " "; cout << endl;
			REP(j, v.size()) {
				ll le = INF, r = -INF, u = INF, d = -INF;
				REP(k, h) REP(l, w) {
					//cout << t[k][l] << " ";
					if(t[k][l] == v[j]) {
						//cout << "a" << endl;
						le = min(le, l);
						r = max(r, l);
						u = min(u, k);
						d = max(d, k);
					}
				}
				//cout << endl;
				//cout << v[j] << " " << le << " " << r << " " << u << " " << d << endl;
				bool flag = true;
				FOR(k, u, d+1) {
					FOR(l, le, r+1) {
						//cout << k << " " << l << " " << endl;
						if(t[k][l] != v[j] && t[k][l] != '-') {flag = false; break;}
					}
					if(!flag) break;
				}
				if(!flag) {ans = false; break;}
				REP(k, h) REP(l, w) if(t[k][l] == v[j]) t[k][l] = '-';
			}
			if(ans) break;
		} while(next_permutation(ALL(v)));

		if(ans) cout << "SAFE" << endl;
		else cout << "SUSPICIOUS" << endl;
	}

	return 0;
}

Measured memory_bytes: 3016
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    string s;
    cin >> s;
    rep(i, s.size()) if (s[i] == '?') s[i] = 'D';
    cout << s << endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a); i < (b); ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1); i >= (b); --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) RP(__i,n)
template<class T,class U>
bool cmax(T & a, const U & b) {return a < b ? a = b, 1 : 0;}
template<class T,class U>
bool cmin(T & a, const U & b) {return b < a ? a = b, 1 : 0;}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define CLR(a) (a).clear()
#define BK(a) ((a).back())
#define FT(a) ((a).front())
#define DB(a) (a).pop_back()
#define DF(a) (a).pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {cerr<<s<<endl;};
template<class T, class ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		for (char x : "([{") c += *s == x;
		for (char x : ")]}") c -= *s == x;
	}
	cerr<<" = "<<a;
	if (sizeof...(b)) {
		cerr<<", ";
        ++s;
    }
    _BG(s,b...);
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD() {return 1;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<class T, class ... TT>
bool RD(T & a, TT & ... b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define DR(T,...) T __VA_ARGS__; RD(__VA_ARGS__)
#define RI(...) DR(int,__VA_ARGS__)

/* For it's time for you to fulfill your output. */
void PT(const char & a) {putchar(a);}
void PT(char const * const & a) {fputs(a, stdout);}
void PT(const double & a) {printf("%.16f", a);}
void PT(const int & a) {printf("%d", a);}
void PT(const ll & a) {printf("%lld", a);}

/* The line will last forever! */
template<char s = ' ', char e = '\n'>
void PL() {if (e) PT(e);}
template<char s = ' ', char e = '\n', class T, class ... TT>
void PL(const T & a, const TT & ... b)
{PT(a); if (sizeof...(b) && s) PT(s); PL<s,e>(b...);}

/* Good Luck && Have Fun ! */
const int N = 1e5 + 87;
int p[N], d[N];
void find(int a)
{
	if (p[a] == a)
		return;
	find(p[a]);
	d[a] += d[p[a]];
	p[a] = p[p[a]];
}
bool meld(int a,int b,int w)
{
	find(a);
	find(b);
	if (p[a] == p[b])
		return d[b] - d[a] == w;
	w += d[a] - d[b];
	a = p[a];
	b = p[b];
	p[b] = a;
	d[b] = w;
	return 1;
}
int main()
{
	RI(n,m);
	RP1(i,n) p[i] = i;
	bool ok = 1;
	while (m-- and ok) {
		RI(l,r,w);
		ok = meld(l,r,w);
	}
	PL(ok ? "Yes" : "No");
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)
#define int long long

const int N = 2e5 + 2, inf = 1e18;
const int mod = 1e9 + 7;

int dp[2005];

int go(int id, int rem) {
    if (rem <= 0)
        return rem == 0;
    if (rem < 3) 
        return 0;

    int &ans = dp[rem];
    if (~ans)
        return ans;
    ans = 0;

    // rem >= 3 now
    for (int take = 3; take <= rem; take++){ 
        ans = (ans + go(id + 1, rem - take)) % mod;
    }
    return ans;
}

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

    int sum;
    cin >> sum;
    memset(dp, -1, sizeof(dp));
    cout << go(1,sum);
}


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

unsigned long  gcd(unsigned long x, unsigned long y)
{
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}

int a[100005];
int mod = 1000000007;

long long calc(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i)%mod;
    }
    return rtn;
}

int main(void){
    int r, g, b;
    int a;
    scanf("%d %d %d", &r, &g, &b);
    a = r*100+g*10+b;
    if (a%4 == 0){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 128
N = gets.to_i
UVWs = readlines.map{|l| l.split.map(&:to_i)}

h = UVWs.each_with_object(Hash.new{|h, k| h[k] = []}){|(u, v, w), h| h[u] << [v, w % 2]; h[v] << [u, w % 2]}
c, s = [nil, 0], [1]
until s.empty?
  t = s.pop
  h[t].each do |u, w|
    next if c[u]
    c[u] = (c[t] + w) % 2
    s << u
  end
end
puts c.drop(1)

Measured memory_bytes: 40044
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<ll>>;

// dijkstra　
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
// dijkstra end


class UnionFind
{
public:
  ll par[100005];
  ll depth[100005];
  ll nGroup[100005];
 
  UnionFind(ll n) {
    init(n);
  }
 
  void init(ll n) {
    for(ll i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  ll root(ll x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(ll x, ll y) {
    return root(x) == root(y);
  }
 
  void unite(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
// unionfind end

// nCr
const ll MAX = 500010;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// nCr end

// tree DP
vector<ll> depth;
vector<ll> g(10010,0);
ll c[10010];
void dfs(const Graph &G, ll v, ll p, ll &d) {
         g[v] = c[d-1];
    for (auto nv : G[v]) {
        if (nv == p) continue;
        d--;
        dfs(G, nv, v, d);
    }
}
// tree DP end
int main() {
  ll n; cin>>n;
  string s; cin>>s;
  if(n%2!=0){
    cout << "No" << endl;
    return 0;}
  string t = s.substr(0,n/2);
  string u = s.substr(n/2,n/2);
  if(t==u)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3648
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let S = get!(String).chars().collect::<Vec<_>>();

    let ans = if !(S.contains(&'N') ^ S.contains(&'S')) && !(S.contains(&'W') ^ S.contains(&'E')) {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


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

using namespace std;

int main()
{
	string a;
	while(cin >> a)
	{
		if(a == "Sunny")
		{
			cout << "Cloudy" << endl;
		}
		if(a == "Cloudy")
		{
			cout << "Rainy" << endl;		
		}		
		if(a == "Rainy")
		{
			cout << "Sunny" << endl;
		}
	}
	return 0;
} 


Measured memory_bytes: 256
s=chomp(readline())
ss=s[1:fld(length(s),2)]
function kai(s)
    l=length(s)
    return s[1:fld(l,2)]==s[end:-1:cld(l,2)+1] ? true: false
end
print(kai(s) && kai(ss)? "Yes": "No")

Measured memory_bytes: 111588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
ll x[5010][5010]={},p[10000],c[10000];
ll loop[5010];
int main(void){
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        ll pp;
        cin>>pp;
        pp--;
        p[i]=pp;
    }
    for(int i=0;i<n;i++) cin>>c[i];
    for(int i=0;i<n;i++){
        ll now=i;
        for(int j=1;j<=n;j++){
            now=p[now];
            x[i][j]=x[i][j-1]+c[now];
            if(now==i){
                loop[i]=j;
                break;
            }
        }
    }
    ll ans=-INF;
    for(int i=0;i<n;i++){
        if(k<=loop[i]){
            for(int j=1;j<=k;j++){
                ans=max(ans,x[i][j]);
            }
        }
        else{
            if(x[i][loop[i]]<=0){
                for(int j=1;j<=loop[i];j++){
                    ans=max(ans,x[i][j]);
                }
            }
            else{
                ll b=k/loop[i];
                ll kari=x[i][loop[i]]*b;
                ll amari=k%loop[i];
                for(int j=1;j<=amari;j++){
                    ans=max(ans,kari+x[i][j]);
                }
                b=k/loop[i]-1;
                kari=x[i][loop[i]]*b;
                for(int j=1;j<=loop[i];j++){
                    ans=max(ans,kari+x[i][j]);
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 199412
#include<cstdio>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
const int mod=1e9+7,inv2=(mod+1)/2;
using namespace std;
int n,q,x,y,ans;
int f[3011][3011],a[3011];
int main(){
	scanf("%d%d",&n,&q);
	rep(i,1,n)
		scanf("%d",a+i);
	rep(i,1,n)
		rep(j,1,n)
			f[i][j]=(a[i]<a[j]);
	rep(i,1,q){
		scanf("%d%d",&x,&y);
		f[x][y]=f[y][x]=1ll*(f[x][y]+f[y][x])*inv2%mod;
		rep(i,1,n)
			if(x!=i&&y!=i){
				f[x][i]=f[y][i]=1ll*(f[y][i]+f[x][i])*inv2%mod;
				f[i][x]=f[i][y]=1ll*(f[i][y]+f[i][x])*inv2%mod;
			}
	}
	rep(i,1,n)
		rep(j,1,i-1)
			ans=(ans+f[i][j])%mod;
	rep(i,1,q)
		ans=(ans<<1)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 35584
using System;
using System.Collections.Generic;
using System.Linq;

public class S
{

    private const long DP_INIT_MINUS1 = -1;
	private const long MOD = 1000000007;

    private static long[,] dp;
    private static List<long>[] paths;


    public static void Main()
	{
		/*
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var M = input[1];
        */
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        var H = input[0];
        var W = input[1];

        solver(H,W);
    }

    public static void solver(int H, int W){

        /*
            dp[H][W]

            dp[x][y] = 該当マスまでの到達手順数。
        
         */

        dp = new long[H+1,W+1];
        char[] input;
        for(int i = 0; i <= H; i++){
			if(i != 0)
            	input = Console.ReadLine().ToCharArray();
			else 
				input = null;
            for(int k = 0; k <= W; k++){
				if(i == 0 || k == 0){
					dp[i,k] = DP_INIT_MINUS1;
					continue;
				}
				if(input[k-1] == '#'){
					dp[i,k] = DP_INIT_MINUS1;
					continue;
				}
                dp[i,k] = 0;
				
            }
        }

        dp[H,W] = 1;

        for(int iH = H; iH > 0; iH--){
            for(int iW = W; iW > 0; iW--){
                if(dp[iH,iW] == DP_INIT_MINUS1) continue;
                dp[iH,iW] %= MOD;
                if(dp[iH,iW-1] != DP_INIT_MINUS1){
                    dp[iH,iW-1] += dp[iH,iW];
                }
                if(dp[iH-1,iW] != DP_INIT_MINUS1){
                    dp[iH-1,iW] += dp[iH,iW];
                }
            }
        }


        


        Console.WriteLine(dp[1,1] % MOD);


    }

}

Measured memory_bytes: 25040
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;
signed main(){
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  vint ans(n);
  ans[0] = 0;
  int count = 0;
  rep1(i,s.size()){
    if(s[i-1] == 'A' && s[i] == 'C'){
      count++;
    }
    ans[i] = count;
  }
  //rep(i,n) cout << ans[i] << " " << endl;
  //cout << endl;
  rep(i,q){
    int a,b;
    cin >> a >> b;
    if(a == 1) cout << ans[b-1] << endl;
    else cout << ans[b-1] - ans[a-1] << endl;
  }
}

Measured memory_bytes: 1920
import bisect

n = int(input())
nums = [-int(input()) for _ in range(n)]

colors = []
max_val = -1 * (10 ** 10)
for num in nums:
	if num >= max_val:
		colors.append(num)
		max_val = num
	else:
		idx_r = bisect.bisect_right(colors, num)
		colors[idx_r] = num
		max_val = min(colors[-1], max_val)

print(len(colors))



Measured memory_bytes: 55896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
	ll N;
	cin >> N;
	vector<int> A(N);
	rep(i, N) { cin >> A.at(i); }
	sort(A.begin(), A.end());
	ll answer = 0;
	for (int i = 0; i < N - 2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			for (int k = j + 1; k < N; k++) {
				if (A.at(i) + A.at(j) > A.at(k) && A.at(i) < A.at(j) && A.at(j) < A.at(k)) { answer++; }
			}
		}
	}
	cout << answer << endl;
}

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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

constexpr int N_MAX = 100;

int n;
int shape[N_MAX][2];
int dp[N_MAX][N_MAX];

int mcm() {
    FOR(d,0,n) {
        FOR(from,0,n-d) {
            int to = from + d;
            if (from == to) {
                dp[from][to] = 0;
            } else {
                int minval = -1;
                FOR(s,0,d) {
                    int cand = dp[from][from+s] + dp[from+s+1][to]
                        + shape[from][0] * shape[from+s][1] * shape[to][1];
                    if (minval == -1) {
                        minval = cand;
                    } else {
                        minval = min(cand, minval);
                    }
                }
                dp[from][to] = minval;
            }
        }
    }
    return dp[0][n-1];
}

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

    cin >> n;
    FOR(i,0,n) {
        cin >> shape[i][0] >> shape[i][1];
    }
    cout << mcm() << endl;

    return 0;
}

Measured memory_bytes: 3160
import java.util.*;

public class Main {
    static int border;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        border = m / n;
        
        List<Long> list = divisorList(m);
        
        for (int i = list.size() - 1; i >= 0; i--) {
            System.out.println(list.get(i));
            return;
        }
    }
    
    public static List<Long> divisorList(long n) {
        List<Long> res = new ArrayList<Long>();
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                if (border >= i) {
                res.add(i);
                }
                long j = n / i;
                if (j != i) {
                    if (border >= j) {
                    res.add(j);
                    }
                }
            }
        }
        res.sort(Comparator.naturalOrder());
        
        return res;
    }
}

Measured memory_bytes: 24148
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}



int main()
{
	long long n, m, ac_sum = 0, wa_sum = 0;

	cin >> n >> m;

	vector<bool> b(n);
	vector<int> wa(n);

	for (int i = 0; i < m; i++) {
		int p;
		string s;
		cin >> p >> s;

		if (!b[p - 1]) {
			if (s.compare("AC") == 0) {
				ac_sum++;
				wa_sum += wa[p - 1];
				b[p - 1] = true;
			}
			else {
				wa[p - 1]++;
			}
				
		}
	}
		

	cout << ac_sum << " " << wa_sum << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
char s[500];

int main()
{
    int n;
    cin>>n;
    scanf("%s",s+1);
    if(n&1)return puts("No"),0;
    for(int i=1;i<=n/2;++i)
    {
        if(s[i]!=s[i+n/2])return puts("No"),0;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
n = int(input())
R, maxv = [], None
for _ in range(n):
    R.append(int(input()))
minv = R[0]
for j in range(1,n):
    maxv = max(maxv, R[j]-minv) if maxv else R[j]-minv
    minv = min(minv, R[j])
print(maxv)



Measured memory_bytes: 13588
#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))
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--------------------*/

int n, m;
ld p;
vector<vi> g;
vector<ld> dp;

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> n >> m >> p;
	g.resize(n, vi(n));
	dp.resize(1 << n);
	p /= 100.0;
	REP(i, m)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		g[a][b]++;
		g[b][a]++;
	}
	REP(s, 1 << n)
	{
		int v = s&~s;
		dp[s] = 1.0;
		for (int t = (s - 1) & s; t > 0; t = (t - 1)&s)
		{
			if (!(t&(1 << v))) continue;
			int edge = 0;
			int u = s^t;
			REP(i, n)
			{
				if (!((t >> i) & 1)) continue;
				REP(j, n)
				{
					if (((u >> j) & 1) && g[i][j]) edge++;
				}
			}
			dp[s] -= dp[t] * pow(p, edge);
		}
	}
	cout << dp[(1 << n) - 1] << endl;
	return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
 
int input(){
  char str[10];
  scanf("%s",str);
   
  if(str[0]=='B'){
    return 11;
  }
   
  if(str[0]=='A'){
    if(str[1]=='#')return 10;
    return 9;
  }
 
  if(str[0]=='G'){
    if(str[1]=='#')return 8;
    return 7;
  }
   
  if(str[0]=='F'){
    if(str[1]=='#')return 6;
    return 5;
  }
 
  if(str[0]=='E'){
    return 4;
  }
 
  if(str[0]=='D'){
    if(str[1]=='#')return 3;
    return 2;
  }
   
  if(str[0]=='C'){
    if(str[1]=='#')return 1;
    return 0;
  }
 
  assert(0);
  return -1;
}
 
int n,m;
int t[50005];
int u[50005];
 
int dfs(int depth,int pos){
  if(depth==m&&n<pos+2)return 1;
  if(depth==m)return 0;
   
  if( 1<=pos-1  && (t[pos-1]+11)%12 == u[depth] ){
    if( dfs( depth+1, pos-1 ) ) return 1;
  }
 
  if( pos+1 <= n && t[pos+1]==u[depth] ){
    if( dfs(depth+1,pos+1) )return 1;
  }
 
  if( pos+2 <= n && (t[pos+2]+1)%12==u[depth] ){
    if( dfs(depth+1,pos+2) )return 1;
  }
 
  return 0;
}
 
int main(){
  int Tc;
  scanf("%d",&Tc);
  while(Tc--){
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)t[i]=input();
    for(int i=0;i<m;i++)u[i]=input();
     
    int ans=dfs(0,0);
    if(ans)printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 5804
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class Main {

  public void run() throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String in;
    int[] countData = new int[100];
    while ((in = reader.readLine()) != null) {
      int n = Integer.parseInt(in);
      countData[n-1]++;
    }

    //????????????y????????????
    int modeY = Arrays.stream(countData).max().getAsInt();

    //??????????????????
    List<Integer> datasOfMode = new LinkedList<>();
    for (int i = 0; i < countData.length; i++) {
      if (countData[i] == modeY)
        datasOfMode.add(i+1);
    }

    //??????????????????
    for (int dataOfMode : datasOfMode) {
      System.out.println(dataOfMode);
    }
  }

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

}

Measured memory_bytes: 30332
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll x[110000],y[110];
main(){
  string s;
  char x;
  cin>>s;
  ll k,cnt=0;
  cin>>k;
  rep(i,0,s.length()){
    if(s[i]=='1')cnt++;
    else {x=s[i];break;}
  }
  if(k<=cnt)cout<<1;
  else cout<<x;
}

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

int H, A[MAX + 1];

void maxHeapify(int i)
{
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if (l <= H && A[l] > A[i])
  {
    largest = l;
  }
  else
  {
    largest = i;
  }
  if (r <= H && A[r] > A[largest])
  {
    largest = r;
  }

  if (largest != i)
  {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main()
{
  cin >> H;
  for (int i = 1; i <= H; i++)
  {
    cin >> A[i];
  }

  for (int i = H / 2; i >= 1; i--)
  {
    maxHeapify(i);
  }

  for (int i = 1; i <= H; i++)
  {
    cout << " " << A[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 5040
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
long long mod = 1000000007;
int main(){
	long long n,m; cin >> n >> m;
	vector<bool> av = vector<bool>(n+10, false);
	for(long long i = 0; i < m; i++){
		long long a; cin >> a;
		av[a] = true; 
	}

	long long dp[n+10];
	dp[0] = 1;
	if(!av[1])dp[1] = 1;
	else dp[1] = 0;

	for(long long i = 2; i < n+1; i++){
		if(av[i]) dp[i] = 0;
		else dp[i] = (dp[i - 1]%mod + dp[i - 2]%mod)%mod ;
		//cout << i << ": "<< dp[i] << endl;
	}
	cout << dp[n]<< endl;
}	

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,c,i,sum,x,p;
	scanf("%d %d",&n,&c);
	sum=0;
	for(i=0;i<c;i++)	{
		scanf("%d",&p);
		sum+=p;
	}
	x=sum/(n+1);
	if(sum%(n+1)!=0)	x++;
	printf("%d\n",x);
	return 0;
}


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

int main(void){
    int i, j, N, f=0;
    scanf("%d", &N);
    for(i=0; i*4<=N; i++){
        for(j=0; (i*4+j*7)<=N; j++){
            if(N==i*4+j*7) f=1;
        }
    }
    if(f) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


int main(){
  ll k,t; cin >> k >> t;
  
  ll maxcake = 0;
  
  rep(i,t){
    ll x; cin >> x;
    maxcake = max(maxcake,x);
  }
  
  
  cout << max(0LL,maxcake -1 -(k-maxcake)) << endl;
  
}

Measured memory_bytes: 3588
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        StringBuilder sb = new StringBuilder(sc.next());
        int n = Integer.parseInt(sc.next());
        for (int i = 0; i < n; i++) {
            String order = sc.next();
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            if (order.equals("replace")) {
                String str = sc.next();
                sb.replace(a, b + 1, str);
            } else if (order.equals("reverse")) {
                StringBuilder sb2 = new StringBuilder(sb.substring(a, b + 1));
                sb.replace(a, b + 1, sb2.reverse().toString());
            } else {
                out.println(sb.substring(a, b + 1));
            }
        }

        out.flush();
    }
}


Measured memory_bytes: 28380