akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    double n,m,k;
    cin >> n >> m >> k;
    if(n==0) return 0;
    vector<int> v(n,1);
    double tmp=n;
    double sum=0;
    while(1){
      sum+=max(tmp-k,1.0);
      rep(i,n){
        if(v[i]<m){
          v[i]++;
          tmp++;
          goto next;
        }else{
          v[i]=1;
          tmp-=m-1;
        }
      }
      break;
      next:;
    }
    rep(i,n) sum/=m;
    cout << fixed << setprecision(10) << sum << endl;
  }
  return 0;
}



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

using namespace std;

int main() {
	string s;
	cin >> s;
	int q;
	cin >> q;
	bool rev = false;
	string b = "";
	string e = "";
	int t, f;
	char c;
	while(q--) {
		cin >> t;
		if(t == 1) {
			rev = !rev;
		} else {
			cin >> f >> c;
			if(f == 1) {
				if(rev) {
					e.push_back(c);
				} else {
					b.insert(b.begin(), c);
				}
			} else {
				if(rev) {
					b.insert(b.begin(), c);
				} else {
					e.push_back(c);	
				}
			}
		}	
	}
	s = b + s + e;

	if(rev) {
		reverse(s.begin(), s.end());
	}
	cout << s << "\n";
}


Measured memory_bytes: 1348
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    int H, W, i;
    string C[102];

    cin >> H >> W;

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

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

    return 0;
}

Measured memory_bytes: 256
//Author: QOEINDIEDIS
//Date: 10-27-2019
#include <bits/stdc++.h>
#define fill(x,c) memset(x,c,sizeof(x))
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const long long LL_INF = (long long) 2e18 + 5;
const int SIZE = 1e6+10;
ll n;
ll a[SIZE];
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	*/
	int a,b;
	cin>>a>>b;
	if(a>=1&&a<=9&&b>=1&&b<=9)
	{
		cout<<a*b;
	 } else
	 {
	 	cout<<-1;
	 }
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int n;
    cin >> n;
    set<string> s;
    rep(i,n){
        string t;
        cin >> t;
        s.insert(t);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 19256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
#define all(vec) vec.begin(), vec.end()
namespace mp = boost::multiprecision;
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};

class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}

	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)
				continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

	int find(int e) {
		return d[e];
	}
};

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

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

bool prime(int a) {
	if (a == 1)
		return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0)
			return false;
	}
	return true;
}

class Union_Find {
  private:
	vector<int> t, s;

  public:
	Union_Find(int max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(int x, int y) {
		if (same(x, y))
			return;
		int tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}

	int Find(int n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(int x, int y) {
		return Find(x) == Find(y);
	}

	int get_Size(int a) {
		return s[a];
	}
};

set<int> prime_num_factor(int n) {
	if (n < 2)
		return set<int>();
	set<int> prime;
	prime.insert(2);
	for (int i = 3; i <= n; i++) {
		for (int it : prime) {
			if (it * it > i) {
				prime.insert(i);
				break;
			}
			if (i % it == 0)
				break;
		}
	}
	return prime;
}
vector<int> primeFactorization(int n) {
	vector<int> re;
	int cnt = 2;
	while (n != 1) {
		if (n % cnt != 0) {
			cnt++;
			continue;
		}
		n /= cnt;
		re.push_back(cnt);
	}
	return re;
}
signed main() {
	int h,w;
	cin>>h>>w;
	vector<vector<int>> a(h,vector<int>(w));
	rep(i,h)
		rep(j,w)
			cin>>a[i][j];
	vector<pair<P,P>> ans;
	rep(i,h){
		rep(j,w-1){
			if(a[i][j]%2==1){
				a[i][j]--;
				a[i][j+1]++;
				ans.push_back({{i,j},{i,j+1}});
			}
		}
	}
	rep(i,h-1){
		if(a[i][w-1]%2==1){
			a[i][w-1]--;
			a[i+1][w-1]++;
			ans.push_back({{i,w-1},{i+1,w-1}});
		}
	}
	cout<<ans.size()<<endl;
	rep(i,ans.size())cout<<ans[i].first.first+1<<" "<<ans[i].first.second+1<<" "<<ans[i].second.first+1<<" "<<ans[i].second.second+1<<endl;
}


Measured memory_bytes: 8432
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=105;

int N,X,A[MAXN];

int main()
{
    scanf("%d%d",&N,&X);
    for(int i=1;i<=N;i++)
        scanf("%d",&A[i]);
    sort(A+1,A+N+1);
    int ans=0;
    for(int i=1;i<N;i++)
        if(X>=A[i])
            X-=A[i],ans++;
    if(X==A[N])
        ans++;
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 128
n = int(input())
a = [0] + [int(input()) for _ in range(n)]
i = 1
c = 0
while True:
  if i == 2:
    print(c)
    quit(0)
  if a[i] == i:
    print(-1)
    quit(0)
  c += 1
  tmp = a[i]
  a[i] = i
  i = tmp


Measured memory_bytes: 7852
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
c=list(input())
R=c.count('R')
RR=c[:R].count('R')
print(R-RR)

Measured memory_bytes: 78016
import java.util.Scanner;
import java.util.Arrays;

public class Main{

	public static void main(String args[]){
    	
      	Scanner sc = new Scanner(System.in);
      
        int n = sc.nextInt();
        int l = sc.nextInt();
      
        String ary[] = new String[n];
      
      	for(int i=0; i<n; i++){
        	ary[i] = sc.next();
        }
      
      	Arrays.sort(ary);
      
      	String answer = "";
      	for(int j=0; j<n; j++){
        	answer += ary[j];
        }
      
      	System.out.println(answer);
        
    }
}

Measured memory_bytes: 27156
S =input()
N =len(S)
i=0
while i>=0:
    if len(S)>=i+10 and S[i:i+10]=='dreamerase':
        i=i+5
    elif len(S)>=i+11 and S[i:i+11]=='dreameraser':
        i=i+5
    elif len(S)>=i+10 and S[i:i+10]=='eraseerase':
        i=i+5
    elif len(S)>=i+7 and S[i:i+7]=='dreamer':
        i=i+7
        if i==N:
            print('YES')
            break
    elif len(S)>=i+6 and S[i:i+6]=='eraser':
        i=i+6
        if i==N:
            print('YES')
            break
    elif len(S)>=i+5 and S[i:i+5]=='dream':
        i=i+5
        if i==N:
            print('YES')
            break
    elif len(S)>=i+5 and S[i:i+5]=='erase':
        i=i+5
        if i==N:
            print('YES')
            break
    else:
        print('NO')
        break


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n,m;
  cin >> n >> m;
  int ss[n],tt[n],p[m];
  REP(i,n) {
    cin >> ss[i] >> tt[i];
  }
  REP(i,m) cin >> p[i];
  sort(p,p+m);
  long long sum1[m], sum2[m];
  sum1[0] = 0;
  sum2[0] = p[0];
  for (int i=1; i<m; ++i) {
    int diff = p[i]-p[i-1];
    if (i%2) {
      sum1[i] = sum1[i-1] + diff;
      sum2[i] = sum2[i-1];
    } else {
      sum2[i] = sum2[i-1] + diff;
      sum1[i] = sum1[i-1];
    }
//    cout << sum1[i] << "  " << sum2[i] << endl;
  }
  long long res = 0;
  REP(i,n) {
    bool f = 0;
    int s = ss[i], t = tt[i];
    if (s>t) {
      f = 1;
      swap(s,t);
    }
    int ii = lower_bound(p, p+m, s) - p;
    int jj = lower_bound(p, p+m, t) - p - 1;
    if (ii>jj) {
      res += t-s;
      continue;
    }
    int tmp = 0;
//    printf("%d,%d,%d\n", i,ii,jj);
    if (ii%2) {
      tmp += sum1[jj]-sum1[ii];
    } else {
      tmp += sum2[jj]-sum2[ii];
    }
    tmp += p[ii] - s;
    if ((jj-ii) % 2) {
      tmp += t - p[jj];
    }
    if (f && (jj-ii)%2==0) {
      tmp = t-s - tmp;
    }
//    cout << tmp << endl;
    res += tmp;
  }
  cout << res << endl;
}

Measured memory_bytes: 0
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

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

using namespace std;

int t;
int n, k;
int x[100000];

int main(){
	scanf("%d", &t);
	rep(z, t){
		scanf("%d%d", &n, &k);
		k = min(k, n);
		rep(i, n){
			scanf("%d", &x[i]);
		}
		vector<int> v;
		rep(i, n - 1){
			v.push_back(x[i + 1] - x[i]);
		}
		sort(v.begin(), v.end(), greater<int>());
		int ans = x[n - 1] - x[0];
		rep(i, k - 1){
			ans -= v[i];
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2308
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



//bit全探索
vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


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

    ll x = min(b - 1, n);
    cout << floor(a * x / b) - a * floor(x / b) << endl;
}



Measured memory_bytes: 3224
#include <stdio.h>

int main()
{
	char s[101];	/* 英小文字からなる文字列s */
	char t[101];	/* 英小文字からなる文字列t */

	scanf("%s %s", &s, &t);

	printf("%s%s\n", t, s);
	return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
const int N=10005;
const int mod=1e9+7;
const int maxn=1e7;
ll a[101];
ll gcd(ll x,ll y)
{
    ll c;
    ll m=x,n=y;
    while(y!=0){
        c=x%y;
        x=y;
        y=c;
    }
    return m/x*n;
}
int main()
{
    int n;
    cin>>n;
    ll m,s,l;
    cin>>m;
    if(n==1) cout<<m<<endl;
    else if(n>1){
        cin>>l;
        s=gcd(l,m);
        for(int i=0;i<n-2;i++){
            cin>>m;
            s=gcd(s,m);
        }
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
using P = pair<ll, ll>;

int main() {
    init();
    ll N,K;
    cin >> N >> K;
    vc<P> p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;

    sort(all(p), [](P p1, P p2) { return p1.first < p2.first; });

    vc<P> I;
    ll ans = INF;
    rep(i, N - 1){
        repe(j, i + K, N + 1){
            I.clear();
            repe(k, i, j) I.eb(p[k]);
            ll isize = I.size();
            sort(all(I), [](P p1, P p2) { return p1.second < p2.second; });

            rep(k, isize - K + 1) chmin(ans, (p[j - 1].first - p[i].first) * (I[k + K - 1].second - I[k].second));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
from collections import defaultdict


def main():
    H, W, N = map(int, input().split())
    d = defaultdict(int)
    for _ in range(N):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        for y in range(-2, 1):
            for x in range(-2, 1):
                ny, nx = a + y, b + x
                if 0 <= ny < H - 2 and 0 <= nx < W - 2:
                    d[(ny, nx)] += 1
    ans = [0] * 10
    for v in d.values():
        ans[v] += 1
    ans[0] = (H - 2) * (W - 2) - sum(ans)

    print(*ans, sep="\n")

if __name__ == '__main__':
    main()


Measured memory_bytes: 166904
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
	int N, M, A[101], S = 0;
	scanf ("%d %d", &N, &M);
	for (int i = 0; i < N; i++){
		scanf ("%d", &A[i]);
		S += A[i];
	}

	int c = 0;
	for (int i = 0; i < N; i++){
		if (A[i] * 4 * M >= S) c++;
	}

	puts(c >= M ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
string s;
int n, x[27], y[27], res;
inline int cnt() {
	int res=0;
	for(int i=0;i<27;i++) if(x[i]>0 && y[i]>0) res++;
	return res;
}
int main(){
	cin>>n>>s;
	for(int i=0;i<n;i++) x[s[i]-'a']++;
	for(int i=0;i<n;i++) {x[s[i]-'a']--; y[s[i]-'a']++; res=max(res,cnt());}
	cout<<res;
}

Measured memory_bytes: 256
n = int(input())
s = input()
k = int(input())

s_list = list(s)


#print(s[0])

for i in range(n):
    if(s[i] != s[k-1]):
        #print(s[i])
        s_list[i] = '*'

answer = "".join(s_list)
print(answer)

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  string ans = "No";

  if(a == b && b != c){
    ans = "Yes";
  }
  if(a == c && a != b){
    ans = "Yes";
  }
  if(b == c && a != b){
    ans = "Yes";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n=0,k=0;
cin>>n>>k;
int ans=1;
for(int i=0;i<n;i++){
	if(ans>k){
		ans+=k;
	}else{
		ans*=2;
	}
} 
cout<<ans;
	return 0;
}

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

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

const long long MOD = 1000000007;

int main(){
  int n;
  int c=0;
  cin >>n;
  vector<int> p(n);
  rep(i,n) cin >> p.at(i);
  rep(i,n-2){
    if((p.at(i)<p.at(i+1) && p.at(i+1)<p.at(i+2))||(p.at(i)>p.at(i+1) && p.at(i+1)>p.at(i+2))){
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
const double PI=acos(-1);
using namespace std;
double han[12]={128,64,32,16,8,4,2,1,0.5,0.25,0.125,0.0625};
int main(){
  double n;
  while(cin>>n,n>=0){
    vector<int>out(12);
    rep(i,12){
      out[i]=n/han[i];
      if(out[i])n-=han[i];
    }
    if(!n){
      rep(i,8)cout<<out[i];
      cout<<".";
      rep(i,4)cout<<out[i+8];
      cout<<endl;
    }else cout<<"NA"<<endl;
  }
}

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


using namespace std;


int main() {
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    for(int i = 0; i < N; ++i){
        cin >> m[i];
    }
    
    sort(m.begin(), m.end());
    
    int cnt = N;
    
    for(int i = 0; i < N ; ++i){
        X -= m[i];
    }
    
    if(X > 0){
        cnt += X / m[0];
    }
    
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
number = str(input())[::-1]
remainderDictionary = {0: 1}
    
sum = 0
x = 1
for i in number:
  x = (x * 10) % 2019
  sum += int(i) * x
  sum %= 2019
  remainderValue = remainderDictionary.get(sum,0) + 1
  remainderDictionary[sum] = remainderValue
     
ans = 0
for i in remainderDictionary:
  value = remainderDictionary[i]
  ans += value * (value - 1) // 2 # N C 2
print(ans)

Measured memory_bytes: 9512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, l, t;
    cin >> n >> l >> t;
    vector<ll> x(n), w(n);
    REP(i, n) cin >> x[i] >> w[i];

    vector<ll> pos(n);
    REP(i, n) {
        if(w[i]==1) pos[i] = (x[i]+t)%l;
        else pos[i] = ((x[i]-t)%l+l)%l;
    }
    ll pos0 = pos[0];
    sort(ALL(pos));

    ll cnt = 0;
    REP(i, n) if(w[0] != w[i]) {
        if(w[0]==1 && x[i]-x[0] <= 2*t) {
            // (x[i]-x[0])/2 + kl/2 <= t を満たす最大のk
            ll k = (2*t-x[i]+x[0]) / l;
            cnt += k+1;
        } else if(l-x[i]+x[0] <= 2*t) {
            // (l-x[i]+x[0])/2 + kl/2 <= t
            ll k = (2*t-l+x[i]-x[0]) / l;
            cnt += k+1;
        }
    }
    dump(cnt);

    // 蟻0は位置pos0でゼッケンaになっている
    ll a = w[0]==1 ? cnt%n : ((-cnt)%n+n)%n;

    // 蟻0がans[base]に対応
    ll base = -1;
    REP(i, n) if(pos[i] == pos0) {
        base = i;
        if(w[0] == 2) break;
    }
    vector<ll> ans(n);
    REP(i, n) ans[(i+a)%n] = pos[(base+i)%n];

    dump(pos0, a, base);
    REP(i, n) cout << ans[i] << "\n";

    return 0;
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  char c;
  cin >> c;
  set<char> s = {'a', 'i', 'u', 'e', 'o'};
  if (s.count(c)) {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

void input(int [4][13]);
void init_card(int cardset[4][13]);
void check_cardset(int cardset[4][13]);

//void input(int **);
int main(void)
{

	int  in_cardset[4][13];
	init_card(in_cardset);
	input(in_cardset);
	check_cardset(in_cardset);
	
	return 0;
}

void init_card(int cardset[][13])
{

	for (int s=0; s<4; s++)
		for (int n=0; n<13; n++)
			cardset[s][n] = 0;
}

void input(int cardset[][13])
//	void input(int **cardset)
{
	char suit[3];
	char number[3];
	int numcards = 0;
	int s = 0;
	int n = 0;
	scanf("%d", &numcards);
	
	while(numcards--){
		
		//scanf("%2s %2s%*[^\n]", suit, number);
		scanf("%2s %2s", suit, number);
		// debug
		//printf("%s %s, ", suit, number); 
		switch(suit[0]){
		case 'S':s = 0; break;
		case 'H':s = 1; break;
		case 'C':s = 2; break;
		case 'D':s = 3; break;
		default:s=-1;
		}
		sscanf(number, "%d", &n);
		// something needed for error input handling
		cardset[s][n-1]=1;
		// debug
		//printf("cardset[%d][%d] was set\n", s, n);
	}
}

void check_cardset(int cardset[4][13])
{
	char c;
	for(int s=0; s<4; s++)
	for(int n=0; n<13; n++){
		if(cardset[s][n] == 0){
			switch(s){
				case 0:c = 'S'; break;
				case 1:c = 'H'; break;
				case 2:c = 'C'; break;
				case 3:c = 'D'; break;
			}
			printf("%c %d\n", c, n+1);
		}
	}
}



Measured memory_bytes: 2040
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D;
    string S,T;
    ll X[100];
int main(){
    cin>>A;
    if(A<1200)cout<<"ABC";
    else if(A<2800)cout<<"ARC";
    else cout<<"AGC";
    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int H = scanner.nextInt();
		int N = scanner.nextInt();
		int sum = 0;
		for (int i = 0; i < N; i++) {
			H -= scanner.nextInt();
			if (H <= 0) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
		return;
	}

}


Measured memory_bytes: 48732
#include<stdio.h>

int main()
{
	int a[3],i,j,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=1;;i++)
	{
		for(j=0;j<n;j++)if(a[j]<i)break;
		if(j!=n)break;
		for(j=0;j<n;j++)if(a[j]%i)break;
		if(j==n)printf("%d\n",i);
	}
	return 0;
}

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

int func(int x)
{
    long a = 7;
    int ans = 1;
    for (int i = 0; i < x; i++)
    {
        if (a % x != 0)
        {
            a = (a * 10 + 7) % x;
            ans++;
        }
        else
        {
            return ans;
        }
    }
    return -1;
}


int main() {
    long K;
    cin >> K;
    cout << func(K);
}

Measured memory_bytes: 3580
N = int(input())
S = list(input())

leftW = [0]*N
rightE = [0]*N
for i in range(N-1):
    if S[i] == "W":
        leftW[i+1] = leftW[i] + 1
    else:
        leftW[i+1] = leftW[i]
for i in range(N-1,0,-1):
    if S[i] == "E":
        rightE[i-1] = rightE[i] + 1
    else:
        rightE[i-1] = rightE[i]
minlw = N
for i in range(N):
    if leftW[i] + rightE[i] < minlw:
        minlw = leftW[i] + rightE[i]
print(minlw)

Measured memory_bytes: 20152
N = int(input())
a = [int(c) for c in input().split()]
c = [0]*8
over = 0
for i in range(N):
    if a[i]>=3200:
        over+=1
    else:
        c[a[i]//400]+=1
 
mi = 8-c.count(0)
ma = mi+over
if mi == 0:
    mi+=1
print(mi,ma)


Measured memory_bytes: 8956
n = int(input())
t,a = map(int,input().split())
H_list = list(map(int,input().split()))
t_list = [t-h*0.006 for h in H_list ]
a_list = [abs(a-x) for x in t_list]
print(a_list.index(min(a_list))+1)   

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;
 
const int maxn = 1e5 + 5;
vector<int>G[maxn];
bool ok = true;
int vis[maxn];
ll ans[5];
 
void dfs(int u,int fa,int k){//u 此时的位置  fa 上一个的位置  k是否去过 
	if(vis[u] == -1) vis[u] = k;
	else if(vis[u] != k){
		ok = false;
		return;
	}
	else return;
	for(int i = 0;i < G[u].size();i++){
		int v = G[u][i];
		if(v != fa) dfs(v,u,k ^ 1);
	}
}
 
int main(){
	ll n,m;
	scanf("%lld %lld",&n,&m); 
	memset(vis,-1,sizeof(vis));
	for(int i = 1;i <= m;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0,1);
	for(int i = 1;i <= n;i++){
		if(vis[i]) ans[1]++;
		else ans[0]++;
	}
	if(ok) printf("%lld\n",ans[0] * ans[1] - m);
	else printf("%lld\n",n * (n - 1) / 2 - m);
}

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

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

	const int inf = 1e9 + 5;

	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (auto& e : h)
		cin >> e;

	vector<int> dp(n, inf);
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= i + k && j < n; j++) {
			dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
		}
	}

	cout << dp.back() << "\n";
}

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


int main(){
  int N;
  cin >> N;
  vector<list<pair<int, int>>> A(N);
  for(auto& a : A){
    int m;
    cin >> m;
    for(int ii=0; ii<m; ii++){
      int x, y;
      cin >> x >> y;
      x--;
      a.push_back({x, y});
    }
  }
  
  int ans = 0;
  for(int bits=0; bits<(1<<N); bits++){
    bool check = true;
    for(int ii=0; ii<N; ii++){
      if((bits>>ii)&1){
        for(auto& b : A[ii]){
          if(((bits>>b.first)&1)!=b.second){
            check = false;
            break;
          }
        }
      }
      if(check==false) break;
    }
    if(check==false) continue;
    int num_honest = 0;
    for(int jj=0; jj<N; jj++){
      if((bits>>jj)&1) num_honest++;
    }
    ans = max(ans, num_honest);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, cnt, ans;
int main()
{
    scanf("%d",&n);
    ans = 0;
    for(int i=1; i<=n; i=i+2)
    {
        cnt = 0;
        for(int j=1; j<=i; j++)
        {
            if(i%j==0) cnt++;
        }
        if(cnt==8) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
res = 0

q = []
for i in range(m):
    q.append(list(map(int, input().split())))
p = list(map(int, input().split()))


#sのX桁目が1ならX個目のスイッチがON
for s in range(2**n):
    judge = True
    for i in range(m):
        cnt = 0
        for j in range(1, len(q[i])):
            w = q[i][j]
            if s>>(w-1) &1 == 1:
                cnt += 1
        if cnt%2 != p[i]:
            judge = False
    if judge:
        res += 1

print(res)

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

int main(){
                                                                     

    long long n, i;

    long long k = 1;

    
    cin >> n;

    vector<long long> t(n + 2);

    vector<long long> a(n + 2);


    for( i = 1 ; i <= n ; i = i + 1 ){

         cin >> t.at(i);

         }


    for( i = 1 ; i <= n ; i = i + 1 ){

         cin >> a.at(i);

         }


    for( i = 1 ; i <= n ; i = i + 1 ){

         if( t.at(i - 1) < t.at(i) ){

             if( t.at(i) > a.at(i) ){

                 cout << 0 << endl;

                 return 0;

                 }

             }       

         }


    for( i = 1 ; i <= n ; i = i + 1 ){

         if( a.at(i) < a.at(i + 1) ){

             if( t.at(i) < a.at(i) ){

                 cout << 0 << endl;

                 return 0;

                 }

             }       

         }


    for( i = 1 ; i <= n ; i = i + 1 ){

         if( t.at(i - 1) == t.at(i) && a.at(i) == a.at(i + 1) ){

             k *= min( t.at(i), a.at(i) );

             k %= 1000000007;

             }

         }


    cout << k % 1000000007 << endl;


    return 0;

    }

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define REP(i,a,b) for (int i=a; i<b; i++)
#define MAXN (int)1e5+5

using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pi;

int toggle(int u) {
  return u == 0 ? 1 : 0;
}

vector<int> conn[MAXN];
map<pair<int,int>,int> len;
bool visited[MAXN]={false};
int ans[MAXN]={-1};

void dfs(int u, int color) {
  ans[u] = color;
  visited[u] = true;
  for (auto e: conn[u]) {
    if (visited[e]) continue;
    if (len[{u, e}] % 2 == 0)
      dfs(e, color);
    else
      dfs(e, toggle(color));
  }
}

signed main() {
  IOS;
  int N,u,v,w;
  cin >> N;

  REP(i, 1, N) {
    cin >> u >> v >> w;
    conn[u].push_back(v);
    conn[v].push_back(u);
    len[{u, v}] = w;
    len[{v, u}] = w;
  }

  dfs(1, 0);

  REP(i, 1, N+1) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 23168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

vl a={1,2,3,4,5,6,7,8,9};


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

    int n,t,a;
    cin >> n >> t >> a;
    vector<double> h(n);
    vector<double> sa(n,0);
    rep(i,n){
        cin >> h[i];
        sa[i] =abs(a - (t - h[i]*0.006));
    }
    auto it = min_element(all(sa));
    size_t index = distance(sa.begin(),it);
    cout << index + 1<< endl;

    return 0;
}
    

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> nums(N+1, 0);
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (i-A[i] >= 0) {
            ans += nums[i-A[i]];
        }
        if (N >= A[i]+i) {
            nums[A[i]+i]++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 5592
#include<stdio.h>

#define N 100
#define MAX 2000
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2


int A[N][N];
int n;

int pri();

int main(){
  
  int i, j, s;
  
  scanf("%d", &n);
  
  for(i=0;i<n; i++){
    for(j=0;j<n;j++){
      scanf("%d", &s);
      A[i][j]=(s==-1) ? INFTY : s;
    }
  }

  printf("%d\n", pri());

  return 0;
}

int pri(){
  int i,x,y,min;
  int sum = 0;
  int d[N], p[N], color[N];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;

  while(1){
    min=INFTY;
    x=-1;
    for(i=0;i<n;i++){
      if(min>d[i]&&color[i]!=BLACK){
        x=i;
        min=d[i];
      }
    }
    if(x==-1) {
      break;
    }
    color[x] = BLACK;
    for(y=0;y<n;y++){
      if(color[y]!=BLACK&&A[x][y]!=INFTY){
        if(d[y]>A[x][y]){
          d[y]=A[x][y];
          p[y]=x;
          color[y]=GRAY;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum += A[i][p[i]];
    }
  }

  return sum;
}



Measured memory_bytes: 2088
use proconio::*;
use std::cmp::*;

fn run() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }
    let ans = max(a * c, max(a * d, max(b * c, b * d)));
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
//useful 
#define rep(i,n) for(int i = 0; i < (n); i++)
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    for(int i = 0; i < N; i++){
        cin >> V.at(i);
    }
    sort(V.begin(), V.end());
    int A = 0;
    for(int i = 0; i < K; i++){
        A = A + V.at(i);
    }
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(int)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define BUG(x) cout << #x << " = " << x << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto i:x) cout << i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

long long n, a, b, lis[55], high, low;
map<long long, long long> m;
long long c[55][55];

int main() {
  ios::sync_with_stdio(false);
  FOR (i, 1, 50) {
  	c[i][0] = 1;
  	FOR (j, 1, i) c[i][j] = c[i][j - 1] * (i - j + 1) / j;
  }
  cin >> n >> a >> b;
  REP (i, n) cin >> lis[i], m[lis[i]]++;
  sort(lis, lis + n);
  high = lis[n - 1];
  low = lis[n - a];
  long long s = 0;
  FOR (i, n - a, n - 1) s += lis[i];
  cout << setprecision(11) << 1.0 * s / a << endl;
  if (high == low) {
  	b = min(b, m[low]);
  	long long ans = 0;
  	FOR (i, a, b) ans += c[m[low]][i];
  	cout << ans;
  } else {
  	int tmp = 0;
  	FOR (i, n - a, n - 1) if (lis[i] == low) tmp++;
  	cout << c[m[low]][tmp];
  }
}

Measured memory_bytes: 256
arr = ["wa", "", "nn", "", "wo", "a", "i", "u", "e", "o", "ka", "ki", "ku", "ke", "ko", "sa", "si", "su", "se", "so", "ta", "ti", "tu", "te", "to", "na", "ni", "nu", "ne", "no", "ha", "hi", "hu", "he", "ho", "ma", "mi", "mu", "me", "mo", "ya", "", "yu", "", "yo", "ra", "ri", "ru", "re", "ro"]
h = {"T"=>0, "L"=>1, "U"=>2, "R"=>3, "D"=>4}
s = gets.chomp
0.upto((s.length / 2) - 1){|i|
    a, b = s[i * 2].to_i, h[s[i * 2 + 1]]
    print "#{arr[a * 5 + b]}"
}
puts


Measured memory_bytes: 6868
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  int diff_a = abs(a-x);
  int diff_b = abs(b-x);
  cout << ((diff_a<diff_b)?'A':'B') << endl;
  return 0;
}


Measured memory_bytes: 256
fun main() {
    val k = readLine()!!.toInt()
    val s = readLine()!!
    val n = s.length
    val table = LongArray(k+n+1){1L}
    val facto = LongArray(n+k+1)
    val front = LongArray(k + n + 1){1L}
    val mod = (1e9+7).toLong()

    table[1] = 26L
    val c = n + k

    for(i in 2..c) {
        table[i] = table[i-1] * 26L
        table[i] %= mod
    }

    front[1] = 25L
    for(i in 2..c) {
        front[i] = front[i-1] * 25L
        front[i] %= mod
    }

    facto[0] = 1L
    facto[1] = 1L

    for(i in 2..c) {
        facto[i] = (facto[i-1] * i) % mod
    }

    fun modInv(a:Long, m:Long = mod): Long {
        fun mInv(a:Long, m:Long): Long {
            if(m == 0L) return 1L
            if(m == 1L) return a
            var result = mInv(a, m / 2) % mod
            result = (result * result) % mod
            if(m % 2 != 0L) {
                result = (result * a) % mod
            }
            return result
        }
        return mInv(a, m - 2)
    }

    fun comb(n:Int, r:Int) : Long {
        val a = facto[n]
        val b = (facto[r] * facto[n-r]) % mod
        val ret = (a*modInv(b)) % mod
        return ret
    }





    // a a -> b a a | a a b -> b a a b , b a a b
    // f(i) : i 번 연산을 수행 했을때 나오는 문자열의 갯수. 각 문자열의 길이는 n + i 가 된다. 길이 n + i - 1 일 때 문자를 추가하는 위치의 수는 n + i 개가 된다.
    // 그 중에서 각 문자열은 이미 위치한 문자열과 같은 알파벳을 앞뒤로 넣는 것은 같은 횟수로 간주가 된다.
    // 주어진 문자열에서 알파벳 추가할때, 나오는 경우의 수는 문자열의 길이가 l 이라고 할때, (l+1) * 26 - l 이다. 25l + 26

    // 존재하지 않는 경우 : 전체 갯수 - (1 개만 존재 + 2개만 존재 + .... (k+s) / s 개)
    // s + k - i * s 에서 s 개를 뽑는다. 남은
    // 0 개만 존재하는 경우
    // 전체 경우 - 존재하지않는 경우 => 답
    // 존재하지 않는 경우 : f(n - 1) 에서 존재하지 않는 경우 f(n) 에서 존재하지 않는 경우 ...
    // f(n - 1) * 25 + 26 - f(n - s)

    // f(1) = f
    // f(k - i) =
    // f(k - 1) = f(k) * k * (26 ^ s - 1 )
    // f(k) = nCs * n - s C s * ... s + k C s * 26 ^ k

    // 1. 주어진 s 에서 부터 알파벳을 붙여나가면서 접근하가.
    //   ---> 중복된 케이스를 제거하면서.
    //      중복 패턴 2 가지
    //       (1) abc* , abc?  - 서로 다른 문자의 위치가 같은 경우 => abc*? , abc?* : 두개가 생김.
    //       (2) a*bc , ab?c  - 서로 다른 문자의 위치가 다른 경우 => a*b?c : 한개가 생김.
    //       abc 에서 나올 수 있는 추가 경우의 수 : 4 * 26 - 3 임. 101 개의 두 개의 경우의 수를 뽑는데.
    //       (101_C_2 - 26_C_2 * 4) * 1
    //       ( 26_C_2 * 4) * 2
    // 2. 길이 s + k 인 모든 알파벳 조합에서 s 가 아예없는 것들을 세서 전체 수에서 빼기.
    //   ---> ㅎㅎ
    //   ===> ㄱㄴㄷㄹ ㅁㅂㅅㅇ ㅈㅊㅋㅌ ㅍㅎ
    //   ===>

    fun solve(idx:Int): Long {
        // cc-[idx]
        val remain = n + k - idx
        val cnt = idx - n
        if(cnt < 0) return 0L
        // Combination(idx - 1, n - 1)
        val b = comb(idx - 1, n - 1)
        val before = front[cnt]
        val after = table[remain]
        val ret = (((b * before) % mod ) * after) % mod
        return ret
    }
    var ans = 0L
    for(i in 1..n+k) {
        ans += solve(i)
        ans %= mod
    }
    print(ans)

}

Measured memory_bytes: 108340
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

li = list(map(int,list(input())))

for flag in itertools.product([0,1], repeat=3):
	tmp = li[0]
	for i,fl in enumerate(flag):
		if fl:
			tmp += li[i+1]
		else:
			tmp -= li[i+1]

	if tmp == 7:
		ans = ''
		for i in range(3):
			ans = ans + str(li[i])
			if flag[i]:
				ans = ans + '+'
			else:
				ans = ans + '-'
		ans = ans + str(li[3]) + '=7'
		break

print(ans)


Measured memory_bytes: 4212
function Main(input) {
  input = input.trim()
  input = input.split("\n");
  var N = input[0].split(" ").map(Number);
  input.shift();
  var arr = Array(N[0]);
  arr.fill(0);
  for(var i=0;i<N[1];i++){
    var mem = input[i].split(" ").map(Number);
    arr[mem[0]-1]++;
    arr[mem[1]-1]++;
  }
  for(var j=0;j<N[0];j++){
    console.log(arr[j])
  }
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;

ll modpow(ll x, ll n, ll m){
    ll res = 1, r = x;
    while(n){
        if(n % 2) res = res * r % m;
        r = r * r % m;
        n /= 2;
    }
    return res;
}

ll primroot(ll m, int inv = 0){
    if(!inv){
        if (m == 2) return 1;
        if (m == 167772161) return 3;
        if (m == 469762049) return 3;
        if (m == 754974721) return 11;
        if (m == 998244353) return 3;
    }
    else{
        if (m == 2) return 1;
        if (m == 167772161) return 55924054;
        if (m == 469762049) return 156587350;
        if (m == 754974721) return 617706590;
        if (m == 998244353) return 332748118;
    }
    return -1;
}

vector<ll> NTT(const vector<ll> &f, int k, const ll &m, int inv){
    vector<ll> Ff = f;
    vector<ll> newFf(1 << k);
    for(int j = 1; j <= k; j++){
        ll z = modpow(primroot(m, inv), m / (1 << j), m);
        ll zz = 1;
        for(int i = 0; i < (1 << j); i++){
            int c = (i << (k - j)), d = (i << (k - j + 1)) & ((1 << k) - 1), e = d + (1 << (k - j));
            for(int l = 0; l < (1 << (k - j)); l++){
                newFf[c] = (Ff[d] + Ff[e] * zz) % m;
                c++; d++; e++;
            }
            zz = zz * z % m;
        }
        swap(Ff, newFf);
    }
    return Ff;
}

vector<ll> Convolution(vector<ll> a, vector<ll> b, const ll m){
    int k = 0;
    while((1 << k) < (int)a.size() + (int)b.size() - 1) k++;
    a.resize(1 << k);
    b.resize(1 << k);
    vector<ll> Fa = NTT(a, k, m, false), Fb = NTT(b, k, m, false);
    vector<ll> Fc(1 << k);
    for(int i = 0; i < (1 << k); i++) Fc[i] = Fa[i] * Fb[i] % m;
    vector<ll> c = NTT(Fc, k, m, true);
    ll r = modpow((1 << k), m - 2, m);
    for(int i = 0; i < (1 << k); i++) c[i] = c[i] * r % m;
    return c;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<ll> a(n), b(m);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < m; i++) cin >> b[i];
    vector<ll> c = Convolution(a, b, 998244353);
    for(int i = 0; i < n + m - 1; i++) cout << c[i] << " ";
    cout << endl;
}


Measured memory_bytes: 68900
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to;
};

signed main()
{
	ll n;

	cin >> n;
	vector<ll> st(n),sa(n-1);
	ll sum = 0, su = (1 + n) * n / 2;
	REP(i, n) {
		scanf("%lld", &st[i]);
		sum += st[i];

		if (i)
			sa[i - 1] = st[i] - st[i - 1];
	}
	if(sum % su) {
		cout << "NO" << endl;
		return 0;
	}
	ll t = sum / su;
	ll rt = t;
	ll cs = 0;
	REP(i, n-1) {
		if ((t - sa[i]) % n) {
			cout << "NO" << endl;
			return 0;
		}
		if((t - sa[i]) / n < 0) {
			cout << "NO" << endl;
			return 0;
		}
		rt -= (t - sa[i]) / n;
	}
	if(rt < 0) {
		cout << "NO" << endl;
		return 0;
	}

	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int,int>> P;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    P.push_back({a, b});
  }
  P.push_back({N, N + 1});
  sort(P.begin(), P.end());

  int nowi = 0;
  int nowto = P[nowi].second;
  int cnt = 0;
  for(int i = 1; i < P.size(); i++) {
    nowto = min(nowto, P[i].second);
    if (nowto <= P[i].first) {
      nowi = i;
      nowto = P[i].second;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1400