akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ers erase
#define ins insert
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cout << #x << "= " << x << '\n';
#define kill(x) return cout << x, 0;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 1e3 + 10;
const ll INF = 1e18;
const ll LOG = 25;

ll Cnt[N];

int main(){
	ll n;
	cin >> n;
	for (int i = 2; i <= n; i++){
		ll u = i;
		for (int j = 2; j * j <= u; j++){
			if (u % j == 0){
				ll cnt = 0;
				while (u % j == 0){
					cnt ++;
					u /= j;
				}
				Cnt[j] += cnt;
			}
		}
		if (u != 1) Cnt[u] ++; 
	}
	ll ans = 1;
	for (int i = 2; i <= n; i++){
		ans *= Cnt[i] + 1;
		ans %= MOD;
	}
	cout << ans;




	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
using namespace std;

int main() {

	string res = "Yes";

	string S, T; cin >> S >> T;
	int mylen = (int)S.length();

	int isused[10000]; //(isused[(int)'a'] == (int) 'c' )なら、「aをcに変えるべき。」
    // SからTまで単射
	for (int i = (int)'a'; i <= (int)'z'; i++) isused[i] = 0;//初期化

	for (int i = 0; i <= mylen - 1; i++) { 
		if (isused[(int)T[i]] == 0 || isused[(int)T[i]] == (int)S[i]) isused[(int)T[i]] = (int)S[i]; else res = "No";
    }
    // TからSまで単射
    for (int i = (int)'a'; i <= (int)'z'; i++) isused[i] = 0;//初期化
    for (int i = 0; i <= mylen - 1; i++) {
		if (isused[(int)S[i]] == 0 || isused[(int)S[i]] == (int)T[i]) isused[(int)S[i]] = (int)T[i]; else res = "No";
    }
	cout << res << endl;
}

Measured memory_bytes: 776
(h, w) = map(int, input().split(" "))

ans=[]
### case1  000
ans.append(0 if h%3==0 else w)
###case 2 tate 000
ans.append(0 if w%3==0 else h)

def getmin(h, w):
    area=9999999999999
    for i in range(h//3-3, h//3+2):
        for j in range(w//2 -3, w//2 +3):
            areas=[ i * w, j * (h-i), (w-j)*(h-i)]
            area = max(areas)-min(areas) if area > max(areas)-min(areas) else area
    return area

ans.append(getmin(h, w))
ans.append(getmin(w, h))

print(min(ans))


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;
 
// Binary Index Treeは長さnの数列に対して
// 1. 区間[a,b)にxを加算する
// 2. 区間[a,b)の総和を求める
// という操作をO(log(n))で処理できる
 
// 区間加算にも対応したBinary Index Tree(1-indexで使うことに気をつける)
template <class Abel> struct BIT {
 
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;
    
    BIT(ll n) { 
        init(n);
    }
 
    void init(ll n) { 
        for(ll iter = 0; iter < 2; ++iter) {
            dat[iter].assign(n+1, UNITY_SUM); 
        }
    }
    
    inline void sub_add(ll p, ll a, Abel x) {
        for(ll i = a; i < (ll)dat[p].size(); i += i & -i) {
            dat[p][i] = dat[p][i] + x;
        }
    }
    // 区間[a,b)にxを加算する(a,bは1-index)
    inline void add(ll a, ll b, Abel x) {
        sub_add(0, a, x * -(a - 1)); 
        sub_add(1, a, x);
        sub_add(0, b, x * (b - 1));
        sub_add(1, b, x * (-1));
    }
    
    inline Abel sub_sum(ll p, ll a) {
        Abel res = UNITY_SUM;
        for(ll i = a; i > 0; i -= i & -i) {
            res = res + dat[p][i];
        } 
        return res;
    }
    // 区間[a,b)の総和を計算する(a, bは1-index)
    inline Abel getsum(ll a, ll b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
};
 
// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}
 
ll inverse(ll a) {
    return modpow(a, mod-2);
}
 
ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];
 
void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i * fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n;
    cin >> n;
    
    vl p(n), q(n);
    rep(i, n) {
        cin >> p[i];
    }
    rep(i, n) {
        cin >> q[i];
    }
    
    init();

    BIT<ll> biTree1(n+10), biTree2(n+10);
    ll a = 1, b = 1;
    rep(i, n) {
        a += ((p[i]-1) - biTree1.getsum(1, p[i]))*fact[n-i-1];
        biTree1.add(p[i], p[i]+1, 1);
        b += ((q[i]-1) - biTree2.getsum(1, q[i]))*fact[n-i-1];
        biTree2.add(q[i], q[i]+1, 1);
    }  
    
    out(abs(a-b));
    re0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	string s;
	cin >> s;
	vector<char> v;
	for(int i=0;i<s.length();i+=2) v.push_back(s[i]);
	string ans(v.begin(), v.end());
	cout << ans << endl;
	
	
	
	
	
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dis[2005][2005];
ll vis[2005];
int main()
{
	int n,x,y;
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			dis[i][j]=abs(i-j);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			dis[i][j]=min(dis[i][j],dis[i][x]+dis[y][j]+1);
			dis[i][j]=min(dis[i][j],dis[i][y]+dis[x][j]+1);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i;j<=n;j++)
		{
			vis[dis[i][j]]++;
		}
	}
	for(int i=1;i<n;i++)
	{
		printf("%lld\n",vis[i]);
	}
	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int n,d;
    cin >> n >> d;
    print(rp(n, d * 2 + 1));
    
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

pair<int, int> solve(int n, int m) {
    vector<int> taro(n);
    vector<int> hanako(m);
    int sum_taro = 0;
    int sum_hanako = 0;
    for (int i = 0; i < n; i++) {
        cin >> taro[i];
        sum_taro += taro[i];
    }
    for (int i = 0; i < m; i++){
        cin >> hanako[i];
        sum_hanako += hanako[i];
    }
    int diff = sum_hanako - sum_taro;

    pair<int, int> ret = {-1, -1};
    if (diff & 1) {
        return ret;
    } else {
        sort(taro.begin(), taro.end());
        sort(hanako.begin(), hanako.end());
        diff = (diff >> 1);
        for(auto i: taro) {
           auto j  = lower_bound(hanako.begin(), hanako.end(), i + diff); 
           if (sum_hanako + i - *j == sum_taro + *j - i) return ret = {i, *j};
        }
    }
    return ret;
}

int main(){
    int n, m;
    vector<pair<int, int>> ans;
    while (1) {
        cin >> n >> m;
        if (!n && !m) break;
        ans.push_back(solve(n, m));
    }
    for (auto i: ans) {
        if (i.first == -1) {
            cout << -1 << endl;
        } else {
            cout << i.first << " " << i.second << endl;
        }
    }
}




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

const int N = 1e5 + 10;
typedef pair<int, int> P;
vector<int> G[N];
P p[N];
int fa[N], a[N], b[N], vis[N], dp[N];
long long sz[N];
int F(int x) { return x == fa[x] ? x : (fa[x] = F(fa[x])); }
int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
        p[i] = P(max(0, a[i] - b[i]), i);
        fa[i] = i;
        sz[i] = b[i];
    }
    for(int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    sort(p + 1, p + n + 1);
    for(int i = 1; i <= n; i++) {
        int x = p[i].second, mn = p[i].first;
        vis[x] = 1;
        for(int v : G[x]) {
            if(vis[v]) {
                int fv = F(v);
                mn = min((long long)mn, max(p[i].first - sz[fv], 1LL * dp[fv]));
            }
        }
        for(int v : G[x]) {
            if(vis[v]) {
                int fv = F(v);
                if(fv == x) continue;
                fa[fv] = x;
                sz[x] += sz[fv];
            }
        }
        dp[x] = mn;
    }
    cout << dp[F(1)] + sz[F(1)] << endl;
    return 0;
}

Measured memory_bytes: 9468
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <list>
#include <string>
#include <set>

using namespace std;


long gcd(long a, long b) {
    long r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}


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


int main()
{
    long l, n, m, tmp1, tmp2;
    string s, t;
    
    cin >> n >> m;
    cin >> s >> t;
    l = lcm(n, m);
    set<long> s_char;
    set<long> t_char;
    set<long> result;
    
    for (long i=0; i<n; ++i){
        tmp1 = 1 + (l/n) * i;
        s_char.insert(tmp1);
    }
    for (long j=0; j<m; ++j){
        tmp2 = 1 + (l/m) * j;
        t_char.insert(tmp2);
    }
    set_intersection(s_char.begin(), s_char.end(), t_char.begin(), t_char.end(), inserter(result, result.end()));
    /*
    for (auto itr=result.begin(); itr != result.end(); ++itr){
        cout << *itr << endl;
    }
    */
    for (auto itr=result.begin(); itr != result.end(); itr++){
        tmp1 = ((*itr - 1) * n) / l;
        tmp2 = ((*itr - 1) * m) / l;
        //cout << *itr << " -> (" << tmp1 << ", " << tmp2 << ")" << endl;
        if(s[tmp1] != t[tmp2]){
            l = -1;
            break;
        }
    }
    cout << l << endl;
}

Measured memory_bytes: 8960
a,b,c=map(int,input().split())
t1=0
t2=0
t3=0
t4=0
t1=t1+a
t2=t2+b
b=t1
a=t2

t3=t3+a
t4=t4+c
a=t4
c=t3
print(a,b,c)

Measured memory_bytes: 3060
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		sc.close();

		Queue<Long> que = new PriorityQueue<Long>();
		List<Long> list = new ArrayList<Long>();
		for (long i = 1; i <= 9; i++) {
			que.add(i);
		}

		while (list.size() < K) {
			int c = (int) (que.peek() % 10);
			long next = que.poll();
			for (int i = Math.max(0, c - 1); i <= Math.min(c + 1, 9); i++) {
				que.add(next * 10 + i);
			}
			list.add(next);
		}

		System.out.println(list.get(K - 1));
	}
}


Measured memory_bytes: 35444
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];
		for (int i = 0; i < N; i++) {
			d[i] = sc.nextInt();
		}
		sc.close();

		Arrays.sort(d);
		int l = d[N/2 - 1];
		int r = d[N/2];
		System.out.println(r - l);
	}
}


Measured memory_bytes: 50676
#include <bits/stdc++.h>
using namespace std;
 
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; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
 
int main(){
 string s,s2,left1,left2,right1,right2;
 cin >> s;
 int n = s.size();
 s2 = s;
 reverse(s2.begin(),s2.end());
 left1 = s.substr(0,(n-1)/2);
 left2 = left1;
 reverse(left2.begin(),left2.end());
 right1 = s.substr((n+3)/2-1,(n-1)/2);
 right2 = right1;
 reverse(right2.begin(),right2.end());
 if(s==s2&&left1==left2&&right1==right2){
   cout << "Yes" << endl;
 }else{
   cout << "No" << endl;
 }
}

Measured memory_bytes: 3556
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(a,b,c,d) REP(a,0,b)REP(c,0,d)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
#define N 1000

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
typedef vector<vector<int>> Matrix;

int main() {

    int n,k;
    string s;
    cin>>n;
    cin>>s;
    cin>>k;
    
    rep(i, n) {
        if(s[i] == s[k-1]) {
            putchar(s[i]);
        } else {
            cout<<"*";
        }
    }
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int x, n, t, p[102] = {}, ans, j=0;
  	cin >> x >> n;
	for (int i = 0; i < n; i++){
		cin >> t;
		p[t] = 1;
    }
  	while(j < 200){
    	if(p[x-j] == 0){
        	ans = x-j;
          	break;
        }
        if(p[x+j] == 0){
        	ans = x+j;
          	break;
        }
        j++;
    }	
  
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };

void chmax(ll &a,ll b) {
	if (a < b)a = b;
}

ll n, c;
ll x[101010], v[101010];
ll y[101010];
ll A[101010], B[101010], D[101010];

ll solve() {
	A[0] = v[0];
	rep(i, 1, n)A[i] = A[i - 1] + v[i];
	rep(i, 0, n)y[i] = c - x[i];
	B[n - 1] = v[n - 1];
	rrep(i, n - 2, 0)B[i] = B[i + 1] + v[i];
	D[n - 1] = B[n - 1] - y[n - 1];
	rrep(i, n - 2, 0) {
		D[i] = B[i] - y[i];
		chmax(D[i], D[i + 1]);
	}
	ll ans = 0;
	rep(i, 0, n) {
		ll sm = 0;
		sm -= x[i];
		sm += A[i];
		chmax(ans, sm);
		sm -= x[i];
		if (i < n - 1)sm += D[i + 1];
		chmax(ans, sm);
	}

	return ans;
}


int main(){
	cin >> n >> c;

	rep(i, 0, n)cin >> x[i] >> v[i];

	ll ans = 0;
	chmax(ans, solve());

	reverse(v, v + n);
	rep(i, 0, n)x[i] = c - x[i];
	reverse(x, x + n);

	chmax(ans, solve());
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    double a = 0;
    REP(i, N){
        double b;
        cin >> b;
        a += 1.0/b;
    }
    pr(1/a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    ll m=n;
    ll ord=0,ans=0;
    vector<ll> lis={3,5,7};
    while(m>0){m/=10; ord++;}
    rep(i,ord-1){
        vector<ll> newlis={};
        for(ll j:lis){
            newlis.push_back(j*10+3);
            newlis.push_back(j*10+5);
            newlis.push_back(j*10+7);
        }
        lis=newlis;
        for(ll j:lis){
          	//cout<<j<<endl;
            if(j>n)continue;
            vector<ll> cnt(3,0);
            while(j>0){
                if(j%10==3)cnt[0]++;
                if(j%10==5)cnt[1]++;
                if(j%10==7)cnt[2]++;
                j/=10;
            }
            if(cnt[0]*cnt[1]*cnt[2]!=0)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 764
from math import log10, floor

N = int(input())

if N % 2 == 1:
    print(0)
    exit()

# def f(n):
#     if n < 2:
#         return 1
#     else:
#         return n * f(n - 2)
# def ff(n):
#     if n <= 1:
#         return 1
#     else:
#         return n * ff(n - 1)
# for i in range(1, 50):
#     if i % 2 == 0:
#         print(i, f(i), 2 ** (i // 2) * ff(i // 2))

# f(i) = 2 ** (i // 2) * f(i // 2) なので， (i // 2)!を数える
NN = N // 2
count = 0
i = 1
# print(NN)
while True:
    ans = NN // 5 ** i
    if ans == 0:
        break
    # print(NN, i, ans)
    NN = NN // 5
    # count += (5 ** i) * ans
    count += ans
    # i += 1
print(count)

Measured memory_bytes: 38384
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

set<string>s;
set<string>visit;
map<string,vector<string> >m;

void solve(string &key){
	int i;
	vector<string> &z=m[key];
	for(i=0;i<z.size();i++)
		if(m.find(z[i])!=m.end()){
			if(visit.find(z[i])==visit.end()){ /////
				visit.insert(z[i]); ///// avoid recursive lol
				solve(z[i]);
			}
		}else
			s.insert(z[i]);
}

main(){
	string str,group,g1,arg;
	int n,i,j;
	for(;cin>>n,n;cout<<s.size()<<endl){
		m.clear();
		s.clear();
		visit.clear();
		for(i=0;i<n;i++){
			cin>>str;
			for(j=0;j<str.length();j++)if(str[j]==':'||str[j]==','||str[j]=='.')str[j]=' ';
			istringstream is(str);
			vector<string>v;
			is>>group;
			if(!i)g1=group;
			for(;is>>arg;)v.push_back(arg);
			m[group]=v;
		}
		visit.insert(g1);
		solve(g1);
	}
}

Measured memory_bytes: 1368
#!/usr/bin/env python3
#CODEFESTIVAL2017qualB B

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
d = LI()
m = I()
t = LI()
x = defaultdict(lambda : 0)
y = defaultdict(lambda : 0)
for i in range(n):
    x[d[i]] += 1
for i in range(m):
    y[t[i]] += 1
for i,j in y.items():
    if x[i] < j:
        print('NO')
        quit()
print('YES')


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

int n, m;

int main() {
	scanf("%d%d", &n, &m);

	int ans = 0;
	for(int i = 1; i * i <= m; i++) {
		if(m % i)
			continue;

		int d = i;

		if(m / d >= n)
			ans = max(ans, d);

		d = m / i;

		if(m / d >= n)
			ans = max(ans, d);
	}

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

Measured memory_bytes: 256
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;

typedef long long int ll;
const ll mod = 1e9+7;
const ll INF= 1e18;
const long double PI=3.1415926;

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

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

vector<ll>v;
vector<ll>::iterator it;
map<ll,ll>mp;
ll arr[301];
long double dp[301][301][301];
ll n;
long double solve(ll x, ll y, ll z) {
	if(x<0 || y<0 || z<0){
		return 0;
    }
	else if (x == 0 && y == 0 && z == 0){
		return 0;
    }
	else if (dp[x][y][z] >= 0.0){
		return dp[x][y][z];
    }
    else{
        dp[x][y][z] = ((n + x * solve(x - 1, y, z) + y * solve(x+1, y-1 , z) + z * solve(x, y+1 , z - 1)));
        dp[x][y][z]/=(x+y+z);
    }
	return dp[x][y][z];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    #ifndef ONLINE_JUDGE
        freopen("inp.txt", "r", stdin);
        freopen("out.tex", "w", stdout);
    #endif

    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        cin >> n;
	    ll x=0, y=0, z=0;
        for (ll i = 0; i < n; i++){	
            cin >> arr[i];
            if (arr[i] == 1)
                x++;
            else if (arr[i] == 2)
                y++;
            else if (arr[i] == 3)
                z++;
        }
        memset(dp,-1.0,sizeof(dp));
        cout<<fixed<<setprecision(20)<<solve(x,y,z)<<endl;
        mp.clear();  
        v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

Measured memory_bytes: 430016
program main
   implicit none
   character(1) X, Y
   read(*, *) X, Y
   if(X == Y) then
       write(*, *) '='
   else if(LGT(X, Y) .eqv. .TRUE.) then
       write(*, *) '>'
   else
       write(*, *) '<'
   end if
end program main

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    int ans = 0;
    ll sum = 0;

    cin >> n;

    vector<int> m(n), a(n);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }

    for (int i = 1; i < n; i += 2)
    {
        ans += a[i] * 2;
    }

    ans = sum - ans;

    m[0] = ans;

    for (int i = 0; i < n; i++)
    {
        cout << m[i] << endl;
        m[i + 1] = a[i] * 2 - m[i];
    }
}

Measured memory_bytes: 2048
#region bcf
# code section by Barry Fam
#
# pylint: disable= reimported
#region unionfind.py
# class DisjointSetForest:
class DisjointSetForest(object):  # pylint: disable= useless-object-inheritance
    def __init__(self, iterable=(), **kwarg):
        # super().__init__(**kwarg)
        super(DisjointSetForest, self).__init__(**kwarg)
        self._p = {}
        self._ranks = {}

        for x in iterable: self.make_set(x)

    def make_set(self, x):
        assert x not in self._p
        self._p[x] = x
        self._ranks[x] = 0

    def find(self, x):
        if self._p[x] != x:
            self._p[x] = self.find(self._p[x])
        return self._p[x]

    def union(self, x, y):
        xr, yr = self.find(x), self.find(y)

        if self._ranks[xr] > self._ranks[yr]:
            self._p[yr] = xr
        else:
            self._p[xr] = yr
            if self._ranks[xr] == self._ranks[yr]:
                self._ranks[yr] += 1

#endregion unionfind.py
#endregion bcf
###############################################################################

import sys
def input(itr=iter(sys.stdin.readlines())):  # pylint: disable= redefined-builtin
    return next(itr).rstrip('\n\r')
###############################################################################

import collections

N, M = map(int, input().split())

dsf = DisjointSetForest(range(N))
for _ in range(M):
    A, B = map(int, input().split())
    dsf.union(A-1, B-1)

counts = collections.Counter(dsf.find(u) for u in range(N))
print(max(counts.values()))


Measured memory_bytes: 155544
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000007
# define INF 2000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	int ans = 0, counter = 0, maxi = -1, mini = INF, pass = 0;
	//new
	int n;
	string in1, in2;
	cin >>n>> in1 >> in2;
	rep(i, n) {
		cout << in1[i] << in2[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[32]={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},
    *p=&a[0];
    int K;
    scanf("%d",&K);
    printf("%d",*(p+K-1));
    return 0;
}


Measured memory_bytes: 128
n = int(input())
A = list(map(int, input().split()))

INF = float('inf')

ans = INF

for sign in (1, -1):
    res, total_a = 0, 0
    for a in A:
        total_a += a
        if total_a * sign <= 0:
            res += abs(total_a - sign)
            total_a = sign
        sign *= -1
    ans = min(ans, res)

print(ans)

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

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

typedef long long ll;

//#define INF 0x3fffFFFF
//#define INF_NEG (INF * -1)

//int isFirst = 1;
//template <class T> void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

signed main()
{
    string w; cin >> w;

    vector<int> albe(26,0);

    rep(i,w.size()){
        ++albe[w[i]-'a'];
    }

    int ans = 0;
    rep(i,26){
        ans += albe[i] & 1;
    }

    if (ans) puts("No");
    else puts("Yes");

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	p := scanInts(n)
	sort.Ints(p)
	ans := p[n-1]/2
	for i := 0; i < n-1; i++ {
		ans += p[i]
	}
	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 1780
#include <stdio.h>

long ChocolateBar(long h, long w){
  long diff=h*w;

  for(long i=1;i<h;i++){
	long s1 = i * w;
    long s2 = ((h-i+1)/2) * w;
	long s3 = ((h-i)/2) * w;
	long d1 = s1 < s2 ? s2 - s1: s1 - s2;
	long d2 = s1 < s3 ? s3 - s1: s1 - s3;
	long d = d1 < d2 ? d2 : d1;
	//printf("1 %ld %ld %ld\n", s1, s2, s3);
	if(d < diff){
	  diff = d;
	}
	
	s2 = (h-i)*((w+1)/2);
	s3 = (h-i)*(w/2);
	d1 = s1 < s2 ? s2 - s1: s1 - s2;
	d2 = s1 < s3 ? s3 - s1: s1 - s3;
	d = d1 < d2 ? d2 : d1;
	//printf("2 %ld %ld %ld\n", s1, s2, s3);
	if(d < diff){
	  diff = d;
	}
  }

  for(long i=1;i<w;i++){
	long s1 = i * h;
    long s2 = ((w-i+1)/2) * h;
    long s3 = ((w-i)/2) * h;
	long d1 = s1 < s2 ? s2 - s1: s1 - s2;
	long d2 = s1 < s3 ? s3 - s1: s1 - s3;
	long d = d1 < d2 ? d2 : d1;
	//printf("3 %ld %ld %ld\n", s1, s2, s3);
	if(d < diff){
	  diff = d;
	}
	
	s2 = (w-i)*((h+1)/2);
	s3 = (w-i)*(h/2);
	d1 = s1 < s2 ? s2 - s1: s1 - s2;
	d2 = s1 < s3 ? s3 - s1: s1 - s3;
	d = d1 < d2 ? d2 : d1;
	//printf("4 %ld %ld %ld\n", s1, s2, s3);
	if(d < diff){
	  diff = d;
	}
  }
  return diff;
}

int main(int argc, char *argv[]){
  long h, w;
  scanf("%ld %ld", &h, &w);
  printf("%ld", ChocolateBar(h, w));

  return 0;
}

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> v(H+1);
	for(int i=0; i<H; ++i){
	    cin >> v[i];
	    v[i] += "#";
	}
	for(int i=0; i<=W; ++i) v[H] += "#";
	vector<vector<int>> r(H, vector<int>(W, 0)), f(H, vector<int>(W, 0));
	for(int i=0; i<H; ++i){
	    int now=0;
	    for(int j=0; j<=W; ++j){
	        if(v[i][j]=='.') ++now;
	        else{
	            for(int k=j-now; k<j; ++k){
	                r[i][k]=now;
	            }
	            now=0;
	        }
	    }
	}
	for(int i=0; i<W; ++i){
	    int now=0;
	    for(int j=0; j<=H; ++j){
	        if(v[j][i]=='.') ++now;
	        else{
	            for(int k=j-now; k<j; ++k){
	                f[k][i]=now;
	            }
	            now=0;
	        }
	    }
	}
	int ans=0;
	for(int i=0; i<H; ++i){
	    for(int j=0; j<W; ++j){
	        ans=max(ans, r[i][j]+f[i][j]-1);
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35712
#include <stdio.h>
int main(void) {
    int a, b, c, d;
    scanf("%1d%1d%1d%1d", &a, &b, &c, &d);
    
    if(a-b-c-d==7) printf("%d-%d-%d-%d=7", a, b, c, d);
    else if(a-b-c+d==7) printf("%d-%d-%d+%d=7", a, b, c, d);
    else if(a-b+c-d==7) printf("%d-%d+%d-%d=7", a, b, c, d);
    else if(a-b+c+d==7) printf("%d-%d+%d+%d=7", a, b, c, d);
    else if(a+b-c-d==7) printf("%d+%d-%d-%d=7", a, b, c, d);
    else if(a+b-c+d==7) printf("%d+%d-%d+%d=7", a, b, c, d);
    else if(a+b+c-d==7) printf("%d+%d+%d-%d=7", a, b, c, d);
    else  printf("%d+%d+%d+%d=7", a, b, c, d);
    return 0;
}


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

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	int p, q;
	cin >> p >> q;
	p = gcd(p, q);
	q /= p;
	set<int> s;
	for (int i = 2; i <= q;) {
		if (i * i > q) {
			i = q;
		}
		if (q % i == 0) {
			q /= i;
			s.insert(i);
		} else {
			i++;
		}
	}
	int r = 1;
	for (auto it = begin(s); it != end(s); it++) {
		r *= *it;
	}
	cout << r << endl;
	return 0;
}

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

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

    if (s.size()%2) {
        cout << "No" << endl;
    }
    else {
        bool ok = true;
        for (int i=0; i<s.size(); i+=2) {
            if (s[i] != 'h' or s[i+1] != 'i') ok = false;
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 256
from collections import deque
from functools import lru_cache

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append((i, n//i))

    # divisors.sort()
    return divisors

#gはaと-bが近いときに最小？？
@lru_cache(maxsize=None)
def g(a, b):
    return a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4

def check(s, t):
    #a > b
    a = s//2
    b = a - s
    q = deque()
    q.append((a,b))
    q.append((a+1,b+1))
    q.append((a-1,b-1))
    while True:
        (a, b) = q.popleft()
        if g(a, b) == t:
            print(f'{a} {b}')
            exit()
        elif g(a, b) < t:
            #print(f'inner{s}: {a}, {b} -> {g(a,b)} < {t}')
            if a > s//2:
                q.append((a+1, b+1))
            elif a < s//2:
                q.append((a-1, b-1))
            else:
                pass
        else:
            #print(f'outer{s}: {a}, {b} -> {g(a,b)} > {t}')
            return

def main():
    X = int(input())
    factor = make_divisors(X)
    #print(factor)
    for s, t in factor:
        check(s, t)
        check(t, s)

if __name__ == "__main__":
    main()

Measured memory_bytes: 68528
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int a,b,n, m,k;
	char str[5];
	scanf("%lld%lld",&a,&b);
	n = a + b;
	m = a - b;
	k = a * b;

	printf("%lld", big(big(n,m),k));
}


Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	char name[21];
	int length;
};


int POW[21];
int N,num_line,TEXT_LENGTH;
char buf[101],TEXT[5001];
bool is_match[5001],pattern_match[5001][20];
Info info[20];
map<int,bool> MAP;


void recursive(int start_loc,int loc,int state){
	if(is_match[start_loc])return; //すくなくとも1つがマッチしたならreturn

	if(state == POW[N]-1){ //全文字一致
		is_match[start_loc] = true;
		return;
	}

	int next_state,next_loc;

	for(int loop = 0; loop < N; loop++){
		if(state & (1 << loop)){ //使用済
			//Do nothin
		}else{ //TEXT[loc]から、info[loop]との一致比較
			if(pattern_match[loc][loop]){
				next_state = state+POW[loop];
				auto at = MAP.find(next_state);
				if(at != MAP.end())continue;
				MAP[next_state] = true;
				next_loc = loc+info[loop].length;
				recursive(start_loc,next_loc,next_state);
			}
		}
	}
}

void func(){

	int length,sum_length = 0;

	for(int i = 0; i < N; i++){
		scanf("%s",info[i].name);
		for(length = 0; info[i].name[length] != '\0'; length++);
		info[i].length = length;
		sum_length += length;
	}

	//テキストの読み込み
	int index = 0;
	for(int loop = 0; loop < num_line; loop++){
		scanf("%s",buf);
		for(int k = 0; buf[k] != '\n' && buf[k] != '\0'; k++){
			TEXT[index++] = buf[k];
		}
	}
	TEXT_LENGTH = index;

	for(int i = 0; i < TEXT_LENGTH; i++)is_match[i] = false;

	bool FLG;
	//場所と文字の一致を先に計算しておく
	for(int loc = 0; loc < TEXT_LENGTH; loc++){
		for(int i = 0; i < N; i++)pattern_match[loc][i] = false;
	}

	for(int loc = 0; loc < TEXT_LENGTH; loc++){
		for(int i = 0; i < N; i++){
			if(loc+info[i].length > TEXT_LENGTH)continue;
			FLG = true;
			for(int k = 0; k < info[i].length; k++){
				if(TEXT[loc+k] != info[i].name[k]){
					FLG = false;
					break;
				}
			}
			if(FLG)pattern_match[loc][i] = true;
		}
	}



	//一致の先頭となりえる箇所を全探索
	for(int start_loc = 0; start_loc <= TEXT_LENGTH-sum_length; start_loc++){
		MAP.clear();
		recursive(start_loc,start_loc,0);
	}

	int ans = 0;
	for(int i = 0; i < TEXT_LENGTH; i++){
		if(is_match[i])ans++;
	}

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

int main(){

	for(int i = 0; i < 21; i++)POW[i] = pow(2,i);

	while(true){
		scanf("%d %d",&N,&num_line);
		if(N == 0 && num_line == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3544
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

template<typename T>
struct Seg{
private:
    vector<T> node;
    int n;
    function<T(T,T)> f;
    T def;

public:
    Seg(int siz, T d, function<T(T,T)> f) : def(d), f(f) {
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, def);
    }
    Seg(vector<T> v, T d, function<T(T,T)> f) : def(d), f(f){
        n = 1;
        while(n < v.size())  n *= 2;
        node.resize(2*n-1);
        for(int i = 0; i < v.size(); i++)   node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = f(node[2*i+1], node[2*i+2]);
    }

    void update(int x, T val){
        x += n-1;
        node[x] = f(node[x],val); /* ! */
        while(x){
            x = (x-1)/2;
            node[x] = f(node[2*x+1], node[2*x+2]);
        }
    }

    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        if(b <= l || r <= a)    return def;
        if(a <= l && r <= b)    return node[k];
        T lx = query(a, b, 2*k+1, l, (l+r)/2);
        T rx = query(a, b, 2*k+2, (l+r)/2, r);
        return f(lx, rx);
    }
};

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> h(n), a(n);
    for(int i = 0; i < n; i++)  cin >> h[i];
    for(int i = 0; i < n; i++)  cin >> a[i];
    vector<int> z = h;
    z.push_back(0); z.push_back(1<<30);
    sort(z.begin(), z.end());
    z.erase(unique(z.begin(),z.end()),z.end());
    int siz = z.size();
    auto f = [&](int val)->int{
        return lower_bound(z.begin(),z.end(),val)-z.begin();
    };
    Seg<ll> seg(siz, 0, [](ll x, ll y){return max(x,y);});
    for(int i = 0; i < n; i++){
        seg.update(f(h[i]), seg.query(0, f(h[i]))+a[i]);
    }
    cout << seg.query(0, siz+1) << endl;
    return 0;
}

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

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;

const int T = 1e5 + 3;
ll v[T];
 
int main() {
    ios_base::sync_with_stdio(false);
    ll n,k,q;
    cin >> n >> k >> q;

    for(int i = 0; i < q; i++) {
        int x; cin >> x;
        v[x]++;
    }

    for(int i = 1; i <= n; i++) 
        cout << (k - q + v[i] > 0? "Yes" : "No") << endl;
    
    return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string a,b;
int dp[3005][3005];
pair < int , int >  gdzie[3005][3005];
int main(){
cin>>a>>b;
int n=a.size();
int m=b.size();
a='3'+a;
b='3'+b;
for(int i=1;n>=i;i++)
	for(int j=1;m>=j;j++)
{
	if(a[i]==b[j])
	{
		dp[i][j]=1+dp[i-1][j-1];
		gdzie[i][j]={i-1,j-1};
	}
	if(dp[i-1][j]>dp[i][j])
	{
		dp[i][j]=dp[i-1][j];
		gdzie[i][j]={i-1,j};
	}
	if(dp[i][j-1]>dp[i][j])
	{
		dp[i][j]=dp[i][j-1];
		gdzie[i][j]={i,j-1};
	}
}
int i=n;
int j=m;
vector < char > v;
while(i>0 and j>0)
{
	if(dp[i][j]>dp[gdzie[i][j].first][gdzie[i][j].second])
		v.push_back(a[i]);
	int nx,ny;
	nx=gdzie[i][j].first;
	ny=gdzie[i][j].second;
	i=nx;
	j=ny;
}
reverse ( v.begin() , v.end() ) ;
for(auto it: v)
	cout<<it;
return 0;
}


Measured memory_bytes: 105984
import sys
import itertools


def resolve(in_):
    n, m, q = map(int, next(in_).split())
    abcd = tuple(tuple(map(int, row.split())) for row in in_)
    # print(abcd)

    ans = 0
    for seq_a in itertools.combinations_with_replacement(range(1, m + 1), n):
        # print(seq_a)
        point = 0
        for a, b, c, d in abcd:
            if seq_a[b - 1] - seq_a[a - 1] == c:
                point += d
        ans = max(ans, point)

    return ans


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9112
# include <iostream>
# include <cstdio>
# include <cstring>
using namespace std;

const int N=105;

char c[N];
int l;
bool f;

int main ()
{
	scanf ("%s",c+1);
	l=strlen (c+1);
	for (int i=1;i<=l;i++)
	{
		if (c[i]=='C')
			f=1;
		if (c[i]=='F'&&f==1)
		{
			printf ("Yes\n");
			return 0;
		}
	}
	printf ("No\n");
	return 0;
}


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

using namespace std;

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

  vector<int> A(N);
  int l, ii=0;
  while (cin >> l) {
    A[ii] = l;
    ii++;
  }

  sort(A.begin(), A.end());

  string answer="YES";
  for (int i=0; i<N-1; i++) {
    if (A[i]==A[i+1]) {
      answer="NO";
      break;
    }
  }

  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <iterator>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <sstream> 
#include <vector>
#include <cmath>
#include <map>
#include <set>

#include <queue>
#include <iomanip>
#include <functional>

using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sp system("pause");
#define MOD 998244353 
#define mxN 2005



using namespace std;


int main()
{
	fast;
	int sum = 0, n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		ll ss = sum / (4 * m);
		if (sum % (4 * m))
			ss++;
		if (a[i] >= ss)
			ans++;
	}
	if (ans >= m)
		cout << "Yes";
	else
		cout << "No";


	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

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

	int N;
	cin >> N;

	vector<int> march(5);
	string stmp, m = "MARCH";
	for (int i = 0; i < N; i++) {
		cin >> stmp;
		for (int i = 0; i < 5; i++) {
			if (stmp[0] == m[i]) march[i]++;
		}
	}

	vector<int> use{ 0,0,1,1,1 };
	lint ans = 0, num;
	do {

		num = 1LL;
		for (int i = 0; i < 5; i++) {
			if (use[i]) num *= march[i];
		}

		ans += num;

	} while (next_permutation(use.begin(), use.end()));

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <limits>
#include <numeric>

#if defined(__GNUC__) && !defined(__clang__)
#  pragma GCC optimize("Ofast")
#  pragma GCC target("sse4.2", "tune=native")
#endif


namespace
{

template<typename U, typename V>
static inline U
calcAligned(U val, V alignment) noexcept
{
  return alignment * ((val + alignment - 1) / alignment);
}

}


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

  std::array<int, 5> times;
  for (auto&& e : times) {
    std::cin >> e;
  }

  auto answer = std::numeric_limits<int>::max();
  do {
    auto sum = std::accumulate(
      std::cbegin(times),
      std::cend(times),
      decltype(times)::value_type{},
      [](const auto& acc, const auto& e) {
        return calcAligned(acc, 10) + e;
      });
    answer = std::min(answer, sum);
  } while (std::next_permutation(std::begin(times), std::end(times)));

  std::cout << answer << std::endl;
}


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

#define int long long

int a, b, c, d, g;

int gcd(int aa, int bb) {
	return !bb? aa: gcd(bb, aa % bb);
}

int get(int l, int r, int x) {
	l = ((l + x - 1) / x) * x;
	r = (r / x) * x;
	return (r - l) / x + 1;
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b >> c >> d;
	g = (c * d) / gcd(c, d);
	cout << (b - a + 1) - get(a, b, c) - get(a, b, d) + get(a, b, g) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int r,c;
	int a[101][101]={0};
	int x=0;
	int y=0;
	
	cin>>r>>c;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>a[i][j];
			x+=a[i][j];
		}
		a[i][c]=x;
		x=0;
	}
	for(int j=0;j<=c;j++){
		for(int i=0;i<r;i++){
			y+=a[i][j];
		}
		a[r][j]=y;
		y=0;
	}
	for(int i=0;i<=r;i++){
		for(int j=0;j<=c;j++){
			cout<<a[i][j];
			if(j<c)
				cout<<" ";
		}
		cout<<endl;
	}
}
	

Measured memory_bytes: 1208