akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 100005
const int MOD = 998244353;

ll mod_pow(ll x, ll n, ll mod){ // x ^ n % mod
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

// ax + by = gcd(a, b) となるような (x, y) を求める
// a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰
    y -= a / b * x;
    return d;
}


// 負の数に対応した mod
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}


// 逆元計算 (a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // x % m だが、x が負かもしれないので
}

int main() {
    int n;
    cin >> n;
    int a[n] = {};
    int sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }

    ll ans = mod_pow(3,n,MOD);

    ll dp[MAX_N] = {};
    ll dp2[MAX_N] = {};
    dp[0] = 1;

    rep(i,n){
        drep(j,91000){
            dp2[j+a[i]] += dp[j];
            dp2[j+a[i]] %= MOD;
            dp2[j] += dp[j] * 2;
            dp2[j] %= MOD;
        }
        rep(j,MAX_N){
            dp[j] = dp2[j];
            dp2[j] = 0;
        }
    }

    srep(i,sum/2+1,MAX_N){
        ans += (MOD - dp[i]) * 3;
        ans %= MOD;
    }
    if(sum % 2 == 0){
        ans += (MOD - dp[sum/2]) * 3;
        ans %= MOD;
    }

    rep(i,MAX_N)dp[i] = 0;
    dp[0] = 1;

    rep(i,n){
        drep(j,91000){
            dp[j+a[i]] += dp[j];
            dp[j+a[i]] %= MOD;
        }
    }

    if(sum % 2 == 0){
        ans += dp[sum/2] * 3 % MOD;
    }

    ans %= MOD;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 5172
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

int k, x;

int main(){

    cin >> k >> x;

    if((k*500) >= x){
        cout << "Yes";
    } else{
        cout << "No";
    }













}

//g++ -std=c++14 comp.cpp -o b; ./b.exe

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

string s;
int l[225816],lmax[225816],r[225816],rmax[225816];
priority_queue<P> pq;

int main(void){
	int n,k,c,i,j,cnt=0;
	cin >> n >> k >> c; ++c;
	cin >> s;
	for(i=0; i<n; ++i){
		l[i+1] = (s[i]=='o');
		cnt += l[i+1];
	}
	if(c==1){
		if(cnt==k){
			for(i=0; i<n; ++i){
				if(s[i]=='o'){
					cout << (i+1) << endl;
				}
			}
		}
		return 0;
	}
	for(i=1; i<=n; ++i){
		l[i] += lmax[max(0,i-c)];
		lmax[i] = max(lmax[i-1],l[i]);
	}
	for(i=0; i<n; ++i){
		r[i+1] = (s[i]=='o');
	}
	for(i=n; i>0; --i){
		r[i] += rmax[min(n+1,i+c)];
		rmax[i] = max(rmax[i+1],r[i]);
	}
	for(i=2; i<=c; ++i){
		pq.push(P(rmax[i],i-c));
	}
	for(i=1; i<=n; ++i){
		if(s[i-1]=='o'){
			j = pq.top().second;
			while(!(j<i && i<j+c)){
				pq.pop();
				j = pq.top().second;
			}
			if(pq.top().first < k){
				cout << i << endl;
			}
		}
		pq.push(P(lmax[i]+rmax[i+c],i));
	}
	return 0;
}


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

int main(){
    int n,a[100010];
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    ll ans = a[0]-1;
    int k = 2;
    for (int i = 1; i < n; ++i) {
        if (a[i]>k) ans += (a[i] - 1) / k;
        if (a[i]==k) k++;
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let x1 = read::<i32>();
  let y1 = read::<i32>();
  let x2 = read::<i32>();
  let y2 = read::<i32>();

  let dx = x2 - x1;
  let dy = y2 - y1;

  let y3 = y1 + dy + dx;
  let x3 = x1 + dx - dy;

  let y4 = y1 + dx;
  let x4 = x1 - dy;

  println!("{} {} {} {}", x3, y3, x4, y4);

}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    string s;
    cin>>k>>s;
    if(k>=s.size()){
        cout << s;
    }
    else{
        for(int i=0;i<k;i++){
            cout << s[i];
        }
        cout << "...";
    }
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;

void solve() {
	ll d,n;
	cin>>d>>n;vll A(n),dist;
	for(int i=0;i<n;i++) cin>>A[i];
	for(int i=0;i+1<n;i++)
		dist.pb(A[i+1]-A[i]);
	dist.pb(d-A[n-1]+A[0]);
	cout<<accumulate(all(dist),0)-*max_element(all(dist));
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


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

count = 0
while 1:
    if b > a:
        break
    b = 2*b
    count += 1
while 1:
    if c > b:
        break
    c = 2*c
    count += 1
if count <= k:
    print("Yes")
else:
    print("No")

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

const int INF=1e9;
int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for ( int i=0; i<m; i++ ) {
        int u,v;
        cin >> u >> v;
        --u; --v;
        g[u].push_back(v);
    }
    int s,t;
    cin >> s >> t;
    --s; --t;
    vector<vector<int>> dist(n, vector<int>(3,INF));
    dist[s][0]=0;
    vector<int> q;
    q.push_back(s);
    while ( q.size() ) {
        vector<int> nq;
        for ( int x:q ) {
            int k=x/n;
            int v=x%n;
            int nk=(k+1)%3;
            for ( int u:g[v] ) {
                if ( dist[u][nk]>dist[v][k]+1 ) {
                    dist[u][nk] = dist[v][k]+1;
                    nq.push_back(n*nk+u);
                }
            }
        }
        q=nq;
    }
    if ( dist[t][0]<INF ) cout << dist[t][0]/3 << '\n';
    else cout << -1 << '\n';
    return 0;
}

Measured memory_bytes: 14344
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N;
int A[(1<<20)];
int x;

int main(){
	scanf("%d" , &N);
	repm(i,(1<<N),0){
		scanf("%d" , A + x);
		++x;
	}
	int y = 0;
	while(y + 1 != x){
		A[x] = A[y] != A[y+1] ? abs(A[y]-A[y+1]) : A[y];
		++x;
		y += 2;
	}
	printf("%d\n" , A[y]);
	return 0;
}


Measured memory_bytes: 2176
fun main(args:Array<String>) {
    val weekday = mutableListOf("SUN","MON","TUE","WED","THU","FRI","SAT")
    weekday.addAll(weekday)
    val today = readLine()!!
    val idx = weekday.indexOf(today)
    val ans = weekday.drop(idx).indexOf("SUN")
    if(ans == 0) {
        println(7)
    } else {
        println(ans)
    }
}


Measured memory_bytes: 31900
from collections import Counter
n = int(input())
ball = sorted([list(map(int,input().split())) for i in range(n)])
diff = []
for k in range(1,n):
    for i in range(1,n):
        if i-k>=0:
            p,q = ball[i][0]-ball[i-k][0],ball[i][1]-ball[i-k][1]
            diff.append((p,q))
D = Counter(diff)
p = 0
for v in D.values():
    p = max(p,v)
print(n-p)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
        #include<functional>
   //    #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

 
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------
int dis[100005];
vector<pa> G[100005];
int V,E,r;
int main(){
	
cin>>V>>E>>r;
	for(int i=0;i<V;i++) dis[i]=inf;
	for(int i=0;i<E;i++){
		int z,zz,zzz;
		cin>>z>>zz>>zzz;
		G[z].push_back(make_pair(zz,zzz));
	}
	
	priority_queue<pa, vector<pa>, greater<pa> > pq;
	dis[r]=0;
	
	for(int i=0;i<G[r].size();i++){
		pq.push(make_pair(G[r][i].second,G[r][i].first));
	}
	
	
	while(pq.size()>0){
		pa w=pq.top();
		pq.pop();
		if(dis[w.second]<w.first) continue;
		dis[w.second]=w.first;
		for(int i=0;i<G[w.second].size();i++){
			pq.push(make_pair(dis[w.second]+G[w.second][i].second,G[w.second][i].first));
		}
	}
	for(int i=0;i<V;i++){
		if(dis[i]==inf) cout<<"INF"<<endl;
		else cout<<dis[i]<<endl;
	}
	
	
	return 0;
	
        }

Measured memory_bytes: 12328
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {



    int n;
    cin >> n;

    int s[14],h[14],c[14],d[14];
    
    char sign;
    int tmp;
    
    for(int i=1;i<=13;i++){
        s[i] = 0;
        h[i] = 0;
        c[i] = 0;
        d[i] = 0;
    }
    
    for(int i=1;i<=n; i++){
        cin >> sign >> tmp;
        if(sign == 'S')
            s[tmp]++;
        else if(sign == 'H')
            h[tmp]++;
        else if(sign == 'C')
            c[tmp]++;
        else if(sign == 'D')
            d[tmp]++;
    }
        
    for(int i=1;i<=13;i++){
        if(s[i] == 0)
            cout << "S " << i << endl;
    }
    
    for(int i=1;i<=13;i++){
        if(h[i] == 0)
            cout << "H " << i << endl;
    }

    for(int i=1;i<=13;i++){
        if(c[i] == 0)
            cout << "C " << i << endl;
    }

    for(int i=1;i<=13;i++){
        if(d[i] == 0)
            cout << "D " << i << endl;
    }
    return 0;
    
}



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

int main()
{
	int a,b;
	char op;

	for(int i=1;;i++){
		cin >> a >> op >> b;

		if(op == '?')
			break;
		
		else if(op == '+')
			cout << a+b << endl;

		else if(op == '-')
			cout << a-b << endl;

		else if(op == '*')
			cout << a*b << endl;

		else if(op == '/')
			cout << a/b << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        pair<int, int> n; cin >> n.first >> n.second;
        if(n.first == 0 and n.second == 0) return 0;
        else{
            vector<int> Card(n.first);
            int tmp = n.first;
            for(int i = 0; i < n.first; i++){
                Card[i] = tmp;
                tmp--;
            }
            REP(i, n.second){
                pair<int, int> cut; cin >> cut.first >> cut.second;
                vector<int> New(0);
                for(int i = cut.first - 1; i < cut.first + cut.second - 1; i++) New.push_back(Card[i]);
                REP(i, cut.first - 1) New.push_back(Card[i]);
                FOR(i, cut.first + cut.second - 1, n.first) New.push_back(Card[i]);
                REP(i, n.first) Card[i] = New[i];
            }
            cout << Card[0] << endl;
        }
    }
}


Measured memory_bytes: 3036
#include <iostream>
#include <cstring>
#include <algorithm>
#define MAX 1000
using namespace std;

int main(void){

  int n,W;
  int w[MAX+1];
  int v[MAX+1];
  int dp[MAX+1][MAX+1];
  char ten;
  int cnt = 1;

  while( cin >> W , W ){
    cin >> n;
    for( int i = 0 ; i < n ; i++ ){
      cin >> v[i] >> ten >> w[i];
    }

    for( int i = 0 ; i < MAX ; i++ ){
      for( int j = 0 ; j < MAX ; j++ ){
	dp[i][j] = 0;
      }
    }

    for( int i = 0 ; i < n ; i++ ){
      for( int j = 0 ; j <= W ; j++ ){
	if( j < w[i] ) dp[i+1][j] = dp[i][j];
	else dp[i+1][j] = max( dp[i][j] , dp[i][j-w[i]] + v[i] );
      }
    }
    
    cout << "Case " << cnt++ << ":" << endl;
    for( int i = W ; i >= 0 ; i-- ){
      if( dp[n][i] != dp[n][W] ){
	cout << dp[n][W] << endl << i+1 << endl;
	break;
      }
    }
  }  
  return 0;
}

Measured memory_bytes: 5080
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string a="";
	while (cin >> a) {
		int d, e = 0;
		a += "+";
		string l="";
		for (int i = 0; i < 10; i++) {
			string h = "",b[3];
			bool g = false;
			int  c = 0;
			string f = "", o = "";
			for (int j = 0; j < a.size(); j++) {
				if (a[j] == '+' || a[j] == '=') {
					if (h[0] == '0'&&h.length()!=1) goto stop;
					b[c]= h;
					c++;
					h = "";
				}
				else {
					if (a[j] == 'X')
						h += to_string(i);
					else
						h += a[j];
				}
			}
			f=b[0];
			for (int j = b[0].size()-1; j >=0; j--) 
				f[b[0].length() - 1-j] = b[0][j];
			b[0] = f;
			f = b[1];
			for (int j = b[1].size() - 1; j >= 0; j--)
				f[b[1].length() - 1 - j] = b[1][j];
			b[1] = f;
			f = "";
		g= false;
			for (int j = 0; j < max(b[0].size(), b[1].size()); j++) {
				if (j < b[0].size() && j < b[1].size()) {
					int k = (int)b[0][j] - '0' + b[1][j] - '0';
					if (g) {
						k++;
						g = false;
					}
					if (k >= 10) {
						k -= 10; g = true;
					}
					f += to_string(k);
				}
				else if (j < b[0].size()) {
					int k = (int)b[0][j] - '0';
					if (g) {
						k++;
						g = false;
					}
					if (k >= 10) {
						k -= 10;
						g = true;
					}
					f += to_string(k);
				}
				else {
					int k = (int)b[1][j] - '0';
					if (g) {
						k++;
						g = false;
					}
					if (k >= 10) {
						k -= 10;
						g = true;
					}
					f += to_string(k);
				}
			}
			if(g) f+="1";
			o = "";
			for (int i = f.length() - 1; i >= 0; i--)
				h += f[i];
			f = h;
			if (f == b[2]) {
				l = to_string(i);
				e++;
				break;
			}
		stop:;
		}
		if (e==0)
			cout << "NA" << endl;
		else
			cout << l << endl;
	}
}

Measured memory_bytes: 3168
from itertools import accumulate


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    a = list(accumulate(A))
    answer = N

    for i in range(N - 1):
        if a[i] * 2 < A[i + 1]:
            answer = N - (i + 1)

    print(answer)


if __name__ == '__main__':
    main()

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 110;
int n, k, x, d, ans;
bool mark[maxn];

int main()
{
    cin >> n >> k;
    for (int i = 0; i < k; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> x;
            x--;
            mark[x] = 1;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (!mark[i])
            ans++;
    }
    cout << ans;
	return 0;
}


Measured memory_bytes: 3596
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		WriteLine(OK() ? "Yes" : "No");
	}
	bool OK()
	{
		var N = F();
		var p = new int[3];
		var a = G();
		foreach (var x in a) if (x % 4 == 0) p[2]++; else if (x % 2 == 0) p[1]++; else p[0]++;
		if (p[0] == 0) return true;
		if (p[0] == 1) return p[2] >= 1;
		if (p[0] == 2) return (N == 3 && p[2] == 1) || p[2] >= 2;
		if (p[1] == 0) return p[0] <= p[2] + 1;
		return p[0] <= p[2];
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

Measured memory_bytes: 19680
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>
#include<set>
 
#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
#define Sort(X) sort(X.begin(), X.end())
#define RSort(X, T) sort(X.begin(), X.end(), greater<T>())
//#define MOD 998244353
#define MAX 100000
 
typedef long long int ll;
typedef unsigned long long int ull;
 
using namespace std;
 
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
 
 
int main() {

	ll N;
	cin >> N;

	cout << setprecision(10)<<(((N+1)/2)) / (double)N << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/
vvi gr;
int dfs(int dp[], int i)
{
    //cout<<i<<endl;
    if(dp[i]!=-1)
        return dp[i];
    int x = 0, ma = 0;
    if(gr[i].size()>0)
        x = 1;
    for(int j=0;j<gr[i].size();j++){
        int p = gr[i][j];
        ma = max(ma, dfs(dp, p));
    }
    dp[i]=x+ma;
    //cout<<i<<" "<<dp[i]<<endl;
    return dp[i];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    int n, m;
    cin>>n>>m;
    gr.resize(n+1);
    for(int i=0;i<m;i++){
        int x, y;
        cin>>x>>y;
        gr[x].push_back(y);
    }
    int dp[n+1];
    memset(dp, -1, sizeof(dp));
    for(int i=1;i<=n;i++){
        if(dp[i]==-1){
            int c = dfs(dp, i);
        }
    }
    int an = 0;
    for(int i=0;i<=n;i++)
        an = max(an, dp[i]);
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 11816
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

typedef vector<int> Ivec;
int main() {
	int n;
	
	while (scanf("%d", &n) != EOF) {
		if (n == 0)
			return 0;
		int Sum = 0, Max = -1, Min = 1001, num[2];
		for (int i = 0; n > i; i++) {
			int buf;
			scanf("%d", &buf);
			if (buf > Max) {
				Max = buf;
				num[0] = i;
			}
			if (buf < Min) {
				Min = buf;
				num[1] = i;
			}
			Sum += buf;
		}
		printf("%d\n", (int)((Sum - (num[0] == num[1] ? Max : Max+Min))/(n- (num[0] != num[1]) - 1)));
	}
	return 0;
} 

Measured memory_bytes: 3108
//
// Created on 2020/06/25.
//

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int n;
    cin>>n;
    vector<int>a(n);
    vector<int>b(n);
    vector<int>c(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin>>b[i];
    }
    for (int i = 0; i < n; ++i) {
        cin>>c[i];
    }
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        auto a_end = lower_bound(all(a),b[i]);
        auto c_star = upper_bound(all(c),b[i]);
        ll temp_ans = (a_end - a.begin()) * (c.end() - c_star);
        ans += temp_ans;
    }
    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 4584
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
map<ll,ll> mp;
const ll mod=1000000007;
int main(){
    ll a,b,c,d,n;
    cin>>a>>b>>c>>d>>n;
    a*=4;
    b*=2;
    ll L=min(a,min(b,c));
    ll ans=0;
    if(d<2*L){
         ans+=(n/2)*d;
         ans+=(n%2)*L;
    }
    else ans=n*L;
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> d(n, 0);
    for(int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int result = 0;
    for(int i = 1; i <= 100000; i++)
    {
        auto itr = lower_bound(d.begin(), d.end(), i);
        if(itr != d.end())
        {
            int pos = distance(d.begin(), itr);
            if(n - pos == pos){
                result++;
            }
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pr(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
#define BLACK 0
#define WHITE 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N;
ll a[100100];
ll ans=0;

void A() {
    ll i;
    
    ans+=a[N/2]-a[N/2-1];
    for(i=0; i<N; i++) {
        if(i==N/2 || i==N/2-1) continue;
        if(i>N/2) ans+=2*a[i];
        else ans-=2*a[i];
    }
}

void B() {
    ll i;
    
    ans-=a[N/2]+a[N/2-1];
    for(i=0; i<N; i++) {
        if(i==N/2 || i==N/2-1) continue;
        if(i>N/2) ans+=2*a[i];
        else ans-=2*a[i];
    }
    
    ll tmp=a[N/2]+a[N/2+1];
    for(i=0; i<N; i++) {
        if(i==N/2 || i==N/2+1) continue;
        if(i>N/2+1) tmp+=2*a[i];
        else tmp-=2*a[i];
    }
    
    ans=max(ans, tmp);
    
}

int main(void) {
    cin >> N;
    ll i;
    
    for(i=0; i<N; i++) {
        cin >> a[i];
    }
    sort(a, a+N);
    
    
    if(N%2==0) {
        A();
    }else {
        B();
    }
    
    pr(ans);
    
    
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    int ans = 0;
    rep(i,n){
        int num; cin >> num;
        ans += num-1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */



#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <limits>
#include <ctype.h>




#include <ostream>
#include <sstream>


using namespace std;
class A {
public:
	void solve(std::istream& in, std::ostream& out) {
    ios::sync_with_stdio(false);
    string res = "123";
    string tmp;
    for(int i = 0; i < 3; ++i){
      in >> tmp;
      res[i] = toupper(tmp[0]);
    }
    out << res << endl;
	}
};


int main() {
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int H , N , A;
    cin >> H >> N;
    int arr[N];
    for (int i = 0 ; i < N ; i++){
        cin >> arr[i];
        H  -=arr[i];
    }if (H <= 0){
        cout <<"Yes"<< endl;
    }else {
        cout<<"No"<<endl;
    }



    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
Pxが2番目となる範囲
*/

ll n,a[100010],ans=0;
map<ll,ll> m;
set<ll> s;

void init(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)m[a[i]]=i;
}

int main(void){
	init();
	s.insert(-1);
	s.insert(n);
	ireg(i,1,n){
		ll tmp=0,l2=-1,l=-1,r=n,rr=n;
		ll p = m[i];
		// cerr<<"==="<<i<<":"<<p<<"==="<<endl;
		if(i!=n){
			auto itl = s.lower_bound(p);
			itl--;
			if(*itl!=-1){
				l=*itl;
				itl--;
				l2=*itl;
			}
			auto itr = s.upper_bound(p);
			cerr<<*itr<<endl;
			if(*itr!=n){
				r=*itr;
				itr++;
				rr=*itr;
			}
			if(l!=-1){
				tmp+=(l-l2)*(r-p);
			}
			if(r!=-1){
				tmp+=(rr-r)*(p-l);
			}
			// printf("%lld,%lld,%lld,%lld,\n",l2,l,r,rr);
		}
		s.insert(p);
		// cerr<<"tmp: "<<tmp<<endl;
		ans+=tmp*i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11904
def check_ACGT(S):
    length = len(S)
    for i in range(length):
        if not(S[i] == "A" or  S[i] == "G" or S[i] == "C" or S[i] == "T"):
            return 0
    
    return length

S = input()

tmp = 0
length = len(S)
for i in range(length):
    for j in range(i+1, length):
        # print(S[i:j+1])
        tmp = max(tmp, check_ACGT(S[i:j+1]))
tmp = max(tmp, check_ACGT(S[-1]))
# print(S[-1])
print(tmp)




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 1111
#define MAX_M 111111
#define fi first
#define sc second
#define pb push_back
typedef pair<int,int> P;

int main()
{
	while(true){
	int N,M,H,K;
	int S_[MAX_N];
	int S[MAX_N];
	int des[MAX_N];
	bool f[MAX_N][MAX_N];
	P A[MAX_M];
	int score[MAX_N];
	scanf("%d%d%d%d",&N,&M,&H,&K);
	if(N==0)break;
	for(int i=0;i<N;i++){
		scanf("%d",&S_[i]);
	}
	for(int i=0;i<M;i++){
		int A1,B1;
		scanf("%d%d",&A1,&B1);A1--;B1--;
		A[i].fi=B1;A[i].sc=A1;
	}
	sort(A,A+M);
	for(int i=0;i<N;i++){
		des[i]=i;
	}
	for(int i=0;i<M;i++){
		f[des[A[i].sc]][des[A[i].sc+1]]=true;
		f[des[A[i].sc+1]][des[A[i].sc]]=true;
		//printf("%d %d\n",des[A[i].sc],des[A[i].sc+1]);
		swap(des[A[i].sc],des[A[i].sc+1]);
	}
	
	for(int i=0;i<N;i++){
		score[des[i]]=S_[i];
	}
	/*
	for(int i=0;i<N;i++){
		printf("%d %d\n",i,score[i]);
	}*/
	
	int ans=2000000000;
	/*
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(f[i][j]){
				printf("%d %d\n",i,j);
			}
		}
	}*/
	/*
	for(int i=0;i<=N-K;i++){
		int sum=0;
		for(int j=0;j<K;j++){
			sum+=score[i+j];
		}
		ans=max(ans,sum);
	}*/
	priority_queue<P,vector<P>,greater<P> >que[MAX_N];
	for(int i=0;i<K;i++){
		for(int j=K;j<N;j++){
			if(f[i][j]){
				que[i].push(P(score[j]-score[i],j));
			}
		}
	}
	for(int i=0;i<=0;i++){
		int sum=0;int ma=0;
		for(int j=0;j<K;j++){
			//printf("i=%d i+j=%d top=%d\n",i,i+j,que[i+j].top().sc);
			sum+=score[i+j];
			if(!que[i+j].empty())ma=min(ma,que[i+j].top().fi);
		}
		//printf("i=%d sum=%d ma=%d\n",i,sum,ma);
		sum+=ma;
		ans=min(ans,sum);
		if(i==N-K)break;
		for(int j=1;j<K;j++){
			//printf("i=%d i+j=%d top=%d i+K=%d size()=%d\n",i,i+j,que[i+j].top().sc,i+K,que[i+j].size());
			while((!que[i+j].empty())&&(que[i+j].top().sc>=i+1)&&(que[i+j].top().sc<=i+K)){
				//printf("114514\n");
				que[i+j].pop();
			}
			//printf("i=%d i+j=%d top=%d\n",i,i+j,que[i+j].top().sc);
			if(f[i][i+j])que[i+j].push(P(score[i]-score[i+j],i));
		}
		for(int j=0;j<N;j++){
			if(j>=i+1&&j<i+K+1)continue;
			if(!f[j][i+K])continue;
			que[i+K].push(P(score[j]-score[i+K],j));
		}
	}
	printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 5136
#include<iostream>

int main() {
    int a, b, c, t;
    std::cin >> a >> b >> c;
    if ( a > b ) {
        t = b;
        b = a;
        a = t;
    }
    if ( b > c ) {
        t = b;
        b = c;
        c = t;
    }
    if ( a > b ) {
        t = b;
        b = a;
        a = t;
    }

    std::cout << a << " " << b << " " << c << '\n';
    return 0;
}


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

long long power(long long a, long long b, long long MOD)
{
    if(b==0)
        return 1;
    else
    {
        long long temp=power(a,b/2,MOD);
        if(b%2==1)
        {
            return ((temp*temp)%MOD*a)%MOD;
        }
        else
        {
            return (temp*temp)%MOD;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long MOD = 1000000007;
    long long n;
    cin >> n;
    long long p1 = power(10,n,MOD);
    long long p2 = power(9,n,MOD);
    long long p3 = power(8,n,MOD);
    long long ans = (p1-2*p2+p3+3*MOD)%MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
    faster

    int n;
    cin>>n;
    string s[n];

    map<string,int> m;
    ull ans=0;

    for(int i=0; i<n; i++)
    {
        cin>>s[i];
        sort(s[i].begin(),s[i].end());

        m[s[i]]++;

        if(m[s[i]]>=2)
        {
            ans=ans+(m[s[i]]-1);
        }
    }

    /*for(int i=0; i<n; i++)
    {
        cout<<s[i]<<endl;
    }*/

    cout<<ans<<endl;






    return 0;
}


Measured memory_bytes: 16640
/**
 *   
 *   Date: 01 September 2019
 *   Time: 17:32:04
**/
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <cstring>
#include<queue>
#include<stack>
#include<climits>
#include<iomanip>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1000000007;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	string st,st1;
	ll co=0;
	cin>>st;
	cin>>st1;
	for(ll i=0;i<3;i++)
	{
		if(st[i] == st1[i])
			co+=1;
	}
	cout<<co<<endl;

return 0;
}

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

void solve (int test_case) {
   long long n , k ;
   cin >> n >> k ;
   vector<long long> v(n) ;
   for (int i = 0 ; i < n ; ++i) {
      cin >> v[i] ;
   }
   sort(v.begin() , v.end()) ;
   long long ans = 0 ;
   for (int i = 0 ; i < k ; ++i) {
      ans += v[i] ;
   }
   cout << ans ;
}

int main () {
   ios_base::sync_with_stdio(false) ;
   cin.tie(NULL) ;
   cout.tie(NULL) ;
   int tc = 1 ;
   //cin >> tc ;
   for (int i = 1 ; i <= tc ; ++i) {
      solve(i) ;
   }
}


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

int main() {
  long long n,a,b;
  cin >>n>>a>>b;
  vector<long long>x(n);
  for(long long i=0;i<n;i++)cin>>x[i];
  sort(x.begin(),x.end());
  long long kotae=0;
  for(long long i=1;i<n;i++){
    kotae+=min((x[i]-x[i-1])*a,b);
  }
  cout<<kotae<<endl;
  return 0;
}
       

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


int main(){

 long long int N,M;
  scanf("%lld %lld",&N,&M);

/*
  char A[];
  scanf("%s",A);
  */

  
  long long int A[M];
  int i;
  for(i=0;i<M;i++){
   scanf("%lld",&A[i]);
   }
  
  long long int W;
  W =0;
  for(i=0;i<M;i++){
    W += A[i];
   }
if(W <= N ){
  printf("%lld",N-W);
}
else{
  printf("-1");
}






 return(0);
 }


Measured memory_bytes: 1808
#include <stdio.h>
 
int main(void) {
    char c;
    int i;
 
    while((c = getchar()) != EOF) {
        if(c == '@') {
            char a, n;
            n = getchar();
            a = getchar();
            for(i = 0; i < n - '0'; i++) {
                putchar(a);
            }
        }
 
        else
            putchar(c);
    }
 
    return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#define MAX 1000000

int H, A[MAX + 1];

void maxHeapify(int);

int main(){
  int i;
  
  scanf("%d", &H);
  for(i = 1; i <= H; i++) scanf("%d", &A[i]);
  for(i = H / 2; i >= 1; i--) maxHeapify(i); //子を持つ節点の中で添え字が最大の節点を逆順にmaxHeapifyする。
  for(i = 1; i <= H; i++) printf(" %d", A[i]);
  printf("\n");
  
  return 0;
}

void maxHeapify(int i){
  int r, l, largest, temp;

  l = i * 2;
  r = i * 2 + 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){
    temp = A[largest];
    A[largest] = A[i];
    A[i] = temp;
    maxHeapify(largest);  //A[largest]とA[i]を入れ替えた後に、A[largest]にまだ子供がいて、入れ替える必要がある時もあるよ。
  }
}



Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

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

    int N, i;
    cin >> N >> i;

    cout << N-(i-1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll H,W;
    cin>>H>>W;
    
    VEC(string,a,0);
    VECi(bool,addf,W,false);
    REP(i,H){
        bool f=true;
        string t;
        cin>>t;
        REP(j,W){
            if(t[j]=='#'){
                if(f){
                    a.push_back(t);
                    f=false;
                }
                addf[j]=true;
            }
            //s(addf[j]);
        }
        //sl();
    }
    
    VEC(string,ans,0);
    REP(i,a.size()){
        ans.push_back("");
        REP(j,a[0].size()){
            if(addf[j]){
                ans[i]+=a[i][j];
            }
        }
    }
    
    REP(i,ans.size()){
        cout<<ans[i]<<endl;
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())
S = input()

# 求解処理
ans = 0
x_bit = [False for n in range(10)]
for x in range(N):
    S_x = int(S[x])
    if x_bit[S_x]:
        continue
    x_bit[S_x] = True
    y_bit = [False for n in range(10)]
    for y in range(x + 1, N):
        S_y = int(S[y])
        if y_bit[S_y]:
            continue
        y_bit[S_y] = True
        z_bit = [False for n in range(10)]
        for z in range(y + 1, N):
            S_z = int(S[z])
            if z_bit[S_z]:
                continue
            z_bit[S_z] = True
            ans += 1

# 結果出力
print(ans)


Measured memory_bytes: 9304
//
// Created on 2020/04/12.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    string ans = "No";
    string s;
    cin>>s;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] == '7'){

            ans = "Yes";
        }
    }

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll a,b,n;
    cin>>a>>b>>n;
    ll max=0;
    if(n>=b){
        cout<<a*(b-1)/b<<endl;
    }
    else{
        cout<<a*n/b<<endl;
    }
    return 0;
}




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

vector<pair <int,int> > tab;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c;
	cin >> a;
	long long suma = 0;
	int roznica=0,mroz=999999999;
	//int najb = 999999999;
	bool yes = true;
	for(int i=0;i<a;i++)
	{
		cin >> b >> c;
		if(b!=c)yes=false;
		if(b>c){
			mroz = min(mroz,c);
		}
		suma += b;

	}
	if(yes)cout << 0;
	else cout << suma - mroz;
	return 0;
}

Measured memory_bytes: 256
PROGRAM B
  IMPLICIT NONE
  CHARACTER(len=200000) :: S
  CHARACTER,dimension(1:200000):: l
  INTEGER :: i,sum=0,tmp=0

  READ *, S
  Do i=1,200000
  l(i) = S(i:i)
  IF(l(i)==" ")l(i)="0"
  read(l(i),*) tmp
  sum=sum+tmp
  End Do

  IF(mod(sum,9)==0)THEN
    PRINT *, 'Yes'
  ELSE
    PRINT *, 'No'
  END IF
END PROGRAM B


Measured memory_bytes: 3364
N, S = int(input()), input()

w_fwd, e_fwd, w_bwd, e_bwd = 0, 0, 0, 0
res = len(S)
for c in S:
    if c == 'W':
        w_fwd += 1
    else:
        e_fwd += 1

for c in S:
    if c == 'W':
        w_fwd -= 1
        res = min(res, w_bwd + e_fwd)
        w_bwd += 1
    else:
        e_fwd -= 1
        res = min(res, w_bwd + e_fwd)
        e_bwd += 1

print(res)


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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	string s, t;
	cin >> s >> t;
	int n = s.length();
	int m = t.length();
	s = '$' + s;
	t = '$' + t;
	vector<vector<int>> Dp(n + 1, vector<int>(m + 1));
	vector<vector<int>> Pad(n + 1, vector<int>(m + 1));
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			if (s[i] == t[j])
			{
				Dp[i][j] = 1 + Dp[i - 1][j - 1];
				Pad[i][j] = 1;
			}
			else if (Dp[i - 1][j] < Dp[i][j - 1])
			{
				Dp[i][j] = Dp[i][j - 1];
				Pad[i][j] = 2;
			}
			else
			{
				Dp[i][j] = Dp[i - 1][j];
				Pad[i][j] = 3;
			}
		}
	int i = n, j = m;
	string ans = "";
	while (i > 0 && j > 0)
	{
		db(i, j);
		switch (Pad[i][j])
		{
		case 1:
			ans += s[i];
			i--;
			j--;
			break;

		case 2:
			j--;
			break;

		case 3:
			i--;
			break;

		default:
			break;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 70912
import sys
import itertools
ABCDlist=list(map(int,list(input())))
#print(ABCDlist)

for bit in itertools.product(range(2),repeat=3):
  answer=ABCDlist[0]
  answer_list=[str(answer)]
  for i in range(3):
    if bit[i]==0:
      answer+=ABCDlist[i+1]
      answer_list.append("+"+str(ABCDlist[i+1]))
    else:
      answer-=ABCDlist[i+1]
      answer_list.append("-"+str(ABCDlist[i+1]))
      
  if answer==7:
    answer_list.append("=7")
    print("".join(answer_list))
    sys.exit(0)     

Measured memory_bytes: 3064
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   N : Integer;
   A : Integer;
   B : Integer;
begin
   Get (N);
   if N = 1 then
      Put_Line ("Hello World");
   else
      Get (A);
      Get (B);
      Put_Line (Integer'Image (A+B));
   end if;
end Solve;

Measured memory_bytes: 3664
#include "bits/stdc++.h"

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

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

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

	if (K % 2 == 0 || K % 5 == 0) {
		cout << -1;
		return 0;
	}

	int num = 0;
	int k = 1;
	int count = 0;
	while (true) {
		++count;
		num += 7 * k;
		num %= K;
		if (num == 0)break;
		k *= 10;
		k %= K;
	}
	cout << count;
}

Measured memory_bytes: 3632
#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() {
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int get_up = h1*60 + m1;
    int go_bed = h2*60 + m2;

    int diff = go_bed - get_up;

    if(diff <= k){
        cout << 0 << endl;
    }
    else{
        cout << diff - k << endl;
    }


    return 0;
}

Measured memory_bytes: 3676