akhauriyash/Code-Regression huggingface dataset:
#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;
typedef long long lint;

lint mypow(lint a, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

int main() {

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

	int N, M;
	cin >> N >> M;

	cout << ((N - M) * 100 + 1900 * M) * mypow(2, M) << "\n";

	return 0;
}

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

using namespace std;
 
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pi;

//#define int ll
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007
#define loop(n) for(int i = 0; i < n; i++)
#define rloop(n) for(int i = n-1; i >= 0; i--)

void io() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
void solve() {
    int n; cin>>n;
    vl a(n);
    loop(n) cin>>a[i];
    map <int,int> mk;
    ll ans=0;
    loop(n) {
        
        if (mk[i+1-a[i]]) ans+=mk[i+1-a[i]];
        else mk[i+1-a[i]]=0;

        mk[i+1 + a[i]]++;
    }
    cout<<ans<<"\n";
    return;
}
int32_t main() {
    io();
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 21832
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>
using namespace std;
typedef pair<string, int> P;
typedef pair<P, int> PP;

int main()
{
    int n;
    cin >> n;
    string s[102];
    int p[102];
    P pa[102];
    PP ppa[102];
    for(int i = 0; i < n; i++){
        cin >> s[i] >> p[i];
        p[i] = -p[i];
        pa[i] = P(s[i], p[i]);
        ppa[i] = PP(pa[i], i);
    }
    sort(ppa, ppa + n);
    for(int i = 0; i < n; i++){
        cout << ppa[i].second + 1 << endl;
    }
}


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


int main () {
    int N, Y;
    cin >> N >> Y;
    int ansx = -1, ansy = -1, ansz = -1;
    bool flag = false;
    for ( int x = 0; x <= N; x++) {
        for ( int y = 0; x + y <= N; y++){
            int z = N - x - y;
            int sum = x * 10000 + y * 5000 + z * 1000;
            if ( sum == Y) { 
                ansx = x;
                ansy = y;
                ansz = z;
                flag = true;
                break;
            }
        }
        if ( flag == true ) { break; }
    }
    cout << ansx << " " << ansy << " " << ansz;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

string s, t;
string ta;
bool mu;

signed main() {
	cin >> s >> t;
	ta = s;
	for(int i=s.size()-t.size();i>=0;i--){
		mu = true;
		rep(j, t.size()) {
			if (s[i + j] != '?'&&s[i + j] != t[j])mu = false;
			else if (s[i + j] == '?')ta[i + j] = t[j];
		}
		if (mu) {
			rep(i, s.size()) {
				if (ta[i] == '?')cout << 'a';
				else cout << ta[i];
			}
			cout << endl;
			ggr
		}
		ta = s;
	}
	cout << "UNRESTORABLE" << endl;
	ggr
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
typedef long long ll;
#define SIZE(x) ((int)(x).size())
#define UQ(v) v.erase(unique(v,begin(),v,end()),v.end());
#define INF 11922960 
#define pb push_back 
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
ll mod7 = 1000000007;
ll mod9 = 1000000009;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)




//vector< vector<int> > v (max1, vector<int>(max2) );
int main() {
	using namespace std;
	
	int n,in;
	cin >>n;
	int ans = 0;
	vector<int> a;
	rep(i, n) {
		cin >> in;
		if(in%2 == 0)a.pb(in);
	}
	int c = (int)a.size();
	rep(i, c) {
		while (a[i]) {
			if (a[i] % 2 == 0) {
				ans++;
				a[i] /= 2;
			}
			else {
				break;
			}
		}
	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}

Measured memory_bytes: 384
from itertools import product
ABCD = input()
for op in product('+-',repeat=len(ABCD)-1):
  n = int(ABCD[0])
  for i in range(1,len(ABCD)):
    if op[i-1] == '+':
      n += int(ABCD[i])
    else:
      n -= int(ABCD[i])
  if n == 7:
    print(ABCD[0],end='')
    for i in range(1,len(ABCD)):
      print(op[i-1]+ABCD[i],end='')
    print('=7')
    break

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define forr(i,a,b) for(ll i=(a);i<=(b);i++)
#define ford(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define size(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)



int main(void) {
    long int N,i,j;
    cin >> N;
    long int n[2000000];
    long int m[2000000];
    for(i=0;i<N-1;++i){
       cin >> n[i];
      
    }
     for(i=0;i<N-1;++i){
     
       m[n[i]-1]++;
    }
    for (j=0;j<N;++j){
        
         cout << m[j] << "\n";
    

    }   
    
  return 0;
}

Measured memory_bytes: 6720
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


#隣接リスト 1-order
def make_adjlist_d(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
    return res


#nCr
def cmb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)


def main():
    N = NI()
    S = []
    L = ""
    cnt = 0

    while N > 0:
        S.append(N % 26)

        if N % 26 == 0:
            L = "z" + L
            N = N // 26 - 1
        else:
            L = chr(S[-1] + 96) + L
            N = N // 26

    print(L)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9352
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    int ans = 0; 
    for(int i = 0; i < n; i++) {
        if(a[i] == a[i+1]) {
            while(a[i] == a[i+1] && i < n) {
                i++;
            }
            if(i == n-1) {
                ans++;
                break;
            }
        }
        if(a[i] > a[i+1]) {
            while(a[i] >= a[i+1] && i < n) {
                i++;
            }
            ans++;
        }
        else{
            while(a[i] <= a[i+1] && i < n) {
                i++;
            }
            ans++;
        }
    }
    cout << ans << endl;
}









Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S = sc.next();
      if(S.contains("A") && S.contains("B")){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 35820
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N 100000 + 5

int n, V[N];
LL c, ans, Max_1[N], _Max_1[N], Max_2[N], _Max_2[N], X[N], Sum_1[N], Sum_2[N];

int main()
{
	scanf("%d%lld", &n, &c);
	for (int i = 1; i <= n; i ++)
		scanf("%lld%d", X + i, V + i);
	for (int i = 1; i <= n; i ++)
	{
		Sum_1[i] = Sum_1[i - 1] + V[i] - (X[i] - X[i - 1]);
		Max_1[i] = max(Max_1[i - 1], Sum_1[i]);
		_Max_1[i] = max(_Max_1[i - 1], Sum_1[i] - X[i]);
	}
	X[n + 1] = c;
	for (int i = n; i; i --)
	{
		Sum_2[i] = Sum_2[i + 1] + V[i] - (X[i + 1] - X[i]);
		Max_2[i] = max(Max_2[i + 1], Sum_2[i]);
		_Max_2[i] = max(_Max_2[i + 1], Sum_2[i] - (c - X[i]));
	}
	for (int i = 0; i <= n; i ++)
		ans = max(ans, max(Max_1[i] + _Max_2[i + 1], _Max_1[i] + Max_2[i + 1]));//, printf("%lld %lld, %lld %lld\n", Max_1[i], _Max_1[i], Max_2[n - i + 1], _Max_2[n - i + 1]);
	printf("%lld\n", ans);
	return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;


int k, n;
int a[maxn];

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

    cin>>k;
    n = 1<<k;
    multiset<int> todo;
    for (int i=0; i<n; i++) {
	cin>>a[i];
	todo.insert(a[i]);
    }

    vector<int> have;
    have.push_back(*todo.rbegin());
    todo.erase(--todo.end());


    for (int it=0; it<k; it++) {
	sort(have.begin(), have.end());
	vector<int> nhave;

	while (have.size()) {
	    int at = have.back();
	    have.pop_back();
	    if (*todo.begin() >= at) {
		out("No");
	    }
	    auto iter = std::prev(todo.lower_bound(at));
	    int take = *iter;
	    todo.erase(iter);
	    nhave.push_back(take);
	    nhave.push_back(at);
	}

	swap(have, nhave);
    }


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


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

#define MAX(a , b) (a > b? a : b)
#define MIN(a , b) (a < b? a : b)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

const double pi = 2.0*acos(0.0);

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

    string s;
    cin >> s;
    bool sig = false;
    for (int i=0;i<s.size();i++)
    {
        if (s[i] == '7')
        {
            sig = true;
            break;
        }
    }

    if (sig == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

#define REP(i, n) for (int i=0;i<(n);i++)
#define FOR(i, a, b) for (int i=(a);i<(b);i++)

using namespace std;

int H, W;
char s[51][51];

int main()
{
    scanf("%d %d", &H, &W);
    REP(i, H) {
        REP (j, W) {
            scanf(" %c", &s[i][j]);
        }
    }
    /*
    REP(i, H) {
        REP(j, W) {
            cout << s[i][j];
        }
        cout << endl;
    }
    */

    bool used[51][51];
    REP (i, H) {
        REP (j, W)
            used[i][j] = false;
    }
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, -1, 1};
    bool ans = true;
    REP(i, H) {
        REP (j, W) {
            if(s[i][j]=='.')
                continue;
            if(used[i][j])
                continue;
            bool test = false;
            REP(k, 4) {
                int ni = i + dx[k];
                int nj = j + dy[k];
                if(ni<0 || ni>=H || nj<0 || nj>=W)
                    continue;
                if(s[ni][nj]=='#') {
                    test = true;
                    used[ni][nj] = true;
                    break;
                }
            }
            if(!test) {
                ans = false;
                break;
            }
        }
        if(!ans)
            break;
    }
    printf(ans ? "Yes\n" : "No\n");


    return 0;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<Pii> a(n);
    rep(n){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(all(a));

    vector<int> ans(n);
    int ci = n/2;
    rep(n/2){
        ans[a[i].second] = a[ci].first;
    }
    reppp(i, n/2, n){
        ans[a[i].second] = a[ci-1].first;
    }

    rep(n){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 4608
n=int(input())
i=1


op=[]
while i<=n:
	x=i
	if x%3==0:
		op.append(i)
	else:
		while x>1:
			if x%10==3:
				op.append(i)
				break
			else:
				x//=10
	i+=1

for i in op:
	print(f" {i}",end="")

print()






Measured memory_bytes: 5992
n,m=map(int,input().split())
l=[1]*(n+1)
r=set([1])
for i in range(m):
    x,y=map(int,input().split())
    if x in r:
        r.add(y)
    l[x]-=1
    l[y]+=1
    if l[x]==0 and x in r:
        r.remove(x)
print(len(r))

Measured memory_bytes: 12652
N, Y = map(int, input().split())

flag = 0

for i in range(N+1):
    for j in range(N+1):
        k = N-i-j
        gaku = 10000*i+5000*j+1000*k
        if 0<=k and k<=N and gaku == Y and flag == 0:
            print(i,j,k)
            flag = 1

if flag == 0:
    print(-1,-1,-1)

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

int digit_sum(int a){
  if(a<10) return a;
  else if(a<100){
    int digit_1=(a%10);
    int digit_10=(a-digit_1)/10;
    return digit_10+digit_1;
  }
  else if(a<1000){
    int digit_10_1=a%100;
    int digit_100 = (a-digit_10_1)/100;
    return (digit_100+digit_sum(digit_10_1));
  }
  else if(a<10000){
    int digit_100_10_1=a%1000;
    int digit_1000=(a-a%1000)/1000;
    return (digit_1000 + digit_sum(digit_100_10_1));
  }
  else return 1;
}


int main()
{
  int N,A,B;
  cin>>N>>A>>B;
  int sum=0;
  for(int i=1;i<=N;i++){
    if(digit_sum(i)>=A&&digit_sum(i)<=B){
      sum+=i;
    }
  }
  cout<<sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

int main() {
	long long N;
	cin >> N;
	vector<char> name;

	while (N > 0) {
		decltype(name)::iterator it = name.begin();
		if (N % 26 == 0) {
			name.insert(it, 'z');
			N -= 1;
		}
		else name.insert(it, N % 26 + 96);
		N /= 26;
	}
	string str(name.begin(), name.end());
	cout << str << endl;

	return 0;
}

Measured memory_bytes: 3600
import numpy as np
c1,c2,c3 = map(int,input().split())
c4,c5,c6 = map(int,input().split())
c7,c8,c9 = map(int,input().split())
A = np.array([[1,0,0,1,0,0,c1],[1,0,0,0,1,0,c2],[1,0,0,0,0,1,c3],[0,1,0,1,0,0,c4],[0,1,0,0,1,0,c5],[0,1,0,0,0,1,c6],[0,0,1,1,0,0,c7],[0,0,1,0,1,0,c8],[0,0,1,0,0,1,c9]])
if np.linalg.matrix_rank(A) ==5:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 24824
#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 size=1001001;
    vector<ll> cnt(size,0);
    rep(i,n){
        ll a; cin>>a;
        cnt[a+1]++;
        cnt[a]++;
        if(a>0) cnt[a-1]++;
    }
    ll res=0;
    rep(i,size) chmax(res,cnt[i]);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<cstdio>
#include<cstring>

namespace QiaoMiao
{
	const int N=101000,M=2010;

	int s[M][M],t[M][M];
	int n,m;

	bool out(int x0,int x1,int y0,int y1)
	{
		if(x1<1 || x0>m*2)return 0;
		if(y1<1 || y0>m*2)return 0;
		return 1;
	}

	int asks(int x0,int x1,int y0,int y1)
	{
		return s[x1][y1];
	}
	int cnt=0;

	inline int got(){for(char c;c=getchar(),1;)if(c=='W')return 0;else if(c=='B')return 1;}

	void initialize()
	{
		scanf("%d%d",&n,&m);
		for(int i=1,x,y,c;i<=n;i++)
		{
			scanf("%d%d",&x,&y),c=got();
			
			if(!c)
			{
				if((x/m+y/m)%2==0)cnt++,s[x%m][y%m]++;
				else s[x%m][y%m]--;
			}
			else 
			{
				if((x/m+y/m)%2==1)cnt++,s[x%m][y%m]++;
				else s[x%m][y%m]--;
			}

		}
		for(int i=0;i<=m;i++)
			for(int j=0;j<=m;j++)
			{
				s[i][j]+=(j?s[i][j-1]:0)+(i?s[i-1][j]:0)-(i&&j?s[i-1][j-1]:0);
			}
	}

	int calc(int x,int y)
	{
		int ret=0;
		ret-=s[x][m];
		ret-=s[m][y];
		ret+=2*s[x][y];
		return ret;
	}

	void solve()
	{
		initialize();
		int ans=cnt;
		for(int i=0;i<=m+10;i++)
			for(int j=0;j<=m+10;j++)
			{
				ans=std::max(ans,cnt+calc(i,j));
				ans=std::max(ans,n-(cnt+calc(i,j)));
			}

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

int main()
{
	QiaoMiao::solve();
	return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int N = 2e5 + 4;
int n;
ll k;
ll a[N], f[N];

bool eat(ll m) {
	ll train = k;
	for (int i = 0; i < n; i++) {
		ll x = f[i] * a[n-1-i] - m;
		if (x <= 0) continue;
		train -= (x + f[i] - 1) / f[i];
		if (train < 0) return false;
	}
	return true;
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	scanf("%d%lld", &n, &k);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (int i = 0; i < n; i++) scanf("%lld", &f[i]);
	sort(a, a+n);
	sort(f, f+n);

	if (eat(0)) {
		puts("0");
		return 0;
	}

	ll low = 0, high = 1e12;
	while (low + 1 < high) {
		ll mid = (low + high) / 2;
		if (eat(mid))
			high = mid;
		else
			low = mid;
	}
	printf("%lld\n", high);
}


Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
const int N=200010;
int e[N],nex[N],head[N],ed=0;
void adde(int x,int y){e[++ed]=y;nex[ed]=head[x];head[x]=ed;}
int p[N],isr[N],cnt=0,sum=0,n;
bool dfs(int x,int fa){
    if(x==n){p[++cnt]=x;return true;}
    for(int i=head[x];i;i=nex[i])
        if(e[i]!=fa&&dfs(e[i],x)){
            p[++cnt]=x;
            return true;
        }
    return false;
}
void dfs2(int x,int fa){
    sum++;
    for(int i=head[x];i;i=nex[i])
        if(e[i]!=fa&&!isr[e[i]]) dfs2(e[i],x);
}
int main(){
    int i,x,y;
    scanf("%d",&n);
    for(i=1;i<n;i++){
        scanf("%d %d",&x,&y);
        adde(x,y);
        adde(y,x);
    }
    dfs(1,0);
    for(i=1;i<=cnt;i++) isr[p[i]]=1;
    for(i=1;i<=cnt/2;i++) dfs2(p[i],0);
    if(sum*2<n) printf("Fennec\n");
    else printf("Snuke\n");
    return 0;
}


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

int main(){

  string s;
  string t[4] = {"maerd", "remaerd", "esare", "resare"};

  cin >> s;

  reverse(s.begin(), s.end());
  int idx = 0;
  bool flag = true;

  while(idx < s.size() && flag){
    string tmp1 = s.substr(idx, 5);
    string tmp2 = s.substr(idx, 6);
    string tmp3 = s.substr(idx, 7);
    int cur = idx;
    for(int i = 0; i < 4; i++){
      if(tmp1 == t[i]){
        idx += 5;
        break;
      }
    }
    for(int i = 0; i < 4; i++){
      if(tmp2 == t[i]){
        idx += 6;
        break;
      }
    }
    for(int i = 0; i < 4; i++){
      if(tmp3 == t[i]){
        idx += 7;
        break;
      }
    }
    if(cur == idx) flag = false;
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

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

    Arrays.sort(A);

    int max = A[0] + K - A[N-1];
    for(int i=0; i<N-1; i++) {
      if(max < A[i+1] - A[i]) {
        max = A[i+1] - A[i];
      }
    }
    System.out.println(K - max);
  }
}

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

using namespace std;

int main()
{
  double a, b, c, d;
  cin >> a >> b >> c >> d;
  double ans = sqrt((c - a) * (c - a) + (d - b) * (d - b));
  cout << fixed << setprecision(20) << ans << endl;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
 #define int long long
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

  int n;
  cin >> n;
  P task[n];
  int A, B;
  rep(i, n) {
    cin >> A >> B;
    task[i] = (P(B, A));
  }

  sort(task, task + n);
  int sum = 0;

  rep(i, n) {
    sum += task[i].second;
    if(sum > task[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 3328
def main():
    N = int(input())
    used = set()
    last = ""
    for _ in range(N):
        w = input()
        if w in used or not w.startswith(last):
            print("No")
            return
        last = w[-1]
        used.add(w)
    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,tongac=0,tongwa=0;
ll kt[100001],s[100001];
int main()
{
    cin>>n>>m;
    memset(kt,0,sizeof kt);
    memset(s,0,sizeof s);
    for(int i=1;i<=m;i++)
    {
        int u;string v;
        cin>>u>>v;
        if(v == "AC")
        {
            if(kt[u] == 0){ kt[u] = 1;tongac++;tongwa+=s[u];}
        }
        else
        {
            if(kt[u] == 0) s[u]++;
        }
    }
    cout<<tongac<<" "<<tongwa;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

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

int main(){
    string s; cin >> s;
    if(s=="ABC") out("ARC");
    else out("ABC");

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define ll long long
#define N 100010
using namespace std;

ll n,m,x,y,p[N],dp[N],dp2[N],pre[N],suf[N];
vector<int> g[N];

void dfs(int u,int p)
{
    for(int v: g[u])
    {
        if(v==p) continue;
        dfs(v,u);
        dp[u]=(dp[u]*(dp[v]+1))%m;
    }
}

void dpf(int u,int p)
{
    int l=g[u].size(),k=0;
    pre[0]=1;
    FOR(i,0,l)
    {
        int son=g[u][i];
        if(son==p) continue;
        k++;
        pre[k]=(pre[k-1]*(dp[son]+1))%m;
    }
    suf[k+1]=1;
    for(int i=l-1;i>=0;i--)
    {
        int son=g[u][i];
        if(son==p) continue;
        suf[k]=(suf[k+1]*(dp[son]+1))%m;
        k--;
    }
    k=0;
    FOR(i,0,l)
    {
        int son=g[u][i];
        if(son==p) continue;
        k++;
        dp2[son]=((dp2[u]*pre[k-1])%m*suf[k+1]+1)%m;
    }
    FOR(i,0,l)
    {
        int son=g[u][i];
        if(son==p) continue;
        dpf(son,u);
    }
}

int main()
{
    cin>>n>>m;
    FOR(i,0,N) dp[i]=dp2[i]=1;
    FOR(i,1,n)
    {
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(1,-1);
    dpf(1,-1);
    FOR(i,1,n+1) cout<<(dp[i]*dp2[i])%m<<'\n';

    return 0;
}

Measured memory_bytes: 14976
N, M = list(map(int, input().split(' ')))
AB = []
for i in range(N):
    AB.append(list(map(int, input().split(' '))))

AB = sorted(AB, key=lambda x: x[0])    

cost = 0
for (a, b) in AB:
    if b <= M:
        cost += a * b
        M -= b
    else:
        cost += a * M
        break
        
print(cost)

Measured memory_bytes: 29792
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
const int maxn=1e5+5;
int n,m,tot,sumb,rt,pnt;
int head[maxn],des[maxn<<1],nxt[maxn<<1];
int cntb[maxn],sz[maxn],vis[maxn],dep[maxn],fa[maxn];
void adde(int x,int y){
	des[++tot]=y;nxt[tot]=head[x];head[x]=tot;
}
void dfs(int x){
	vis[x]=1;
	cntb[x]=dep[x]&1;
	sz[x]=1;
	Rep(p,x)if(des[p]!=fa[x]){
		if(des[p]==rt)pnt=x;
		else if(!vis[des[p]]){
			dep[des[p]]=dep[x]+1;
			fa[des[p]]=x;
			dfs(des[p]);
			cntb[x]+=cntb[des[p]];
			sz[x]+=sz[des[p]];
		}
	}
}
void dfs1(int x,int fa){
	vis[x]=1;
	Rep(p,x)if(des[p]!=fa){
		if(vis[des[p]])rt=des[p];
		else dfs1(des[p],x);
	}
}
int main(){
	read(n);read(m);
	if(n&1)return puts("-1"),0;
	rep(i,1,m){
		int x,y;read(x);read(y);
		adde(x,y);adde(y,x);
	}
	if(m==n-1){
		dep[1]=1;
		dfs(1);
		if(cntb[1]*2!=n)puts("-1");
		else{
			ll ans=0;
			rep(i,2,n)ans+=abs(sz[i]-cntb[i]-cntb[i]);
			cout<<ans<<endl;
		}
	}else{
		dfs1(1,0);
		rep(i,1,n)vis[i]=0;
		dep[rt]=1;
		dfs(rt);
		if(!(dep[pnt]&1)){
			if(cntb[rt]*2!=n)puts("-1");
			else{
				ll ans=0;
				vector<int>q;
				q.pb(0);
				rep(i,1,n)vis[i]=0;
				for(int i=pnt;i!=rt;i=fa[i])vis[i]=1,q.pb(2*cntb[i]-sz[i]);
				rep(i,1,n)if(i!=rt&&!vis[i])ans+=abs(sz[i]-2*cntb[i]);
				sort(All(q));
				int tmp=q[SZ(q)/2];
				rep2(i,0,SZ(q))ans+=abs(tmp-q[i]);
				cout<<ans<<endl;
			}
		}else{
			int k=n-2*cntb[rt];
			if(k&1)puts("-1");
			else{
				ll ans=0;
				k>>=1;
				rep(i,1,n)vis[i]=0;
				for(int i=pnt;i!=rt;i=fa[i])vis[i]=1,ans+=abs(sz[i]-2*cntb[i]-k);
				rep(i,1,n)if(i!=rt&&!vis[i])ans+=abs(sz[i]-2*cntb[i]);
				cout<<ans+abs(k)<<endl;
			}
		}
	}
	return 0;
}

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

int main(){
	
	int A, B, C;
	cin >> A >> B >> C;
	if ( A == B ){
		cout << C << endl;
	} else if ( A == C ){
		cout << B << endl;
	} else if ( B == C || A == B == C ){
		cout << A << endl;
	} 
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
int main()
{
    long long int n, i, max=0, cnt=0;
    scanf("%lld", &n);
    long long int a[n];
    for(i=0; i<n; i++)
    {
        scanf("%lld", &a[i]);
    }
    max=a[0];
    for(i=1; i<n; i++)
    {
        if(max>a[i])
        {
            cnt=cnt+max-a[i];
            a[i]=a[i]+max-a[i];
        }
        else if(max<a[i])
        {
            cnt=cnt+0;
            max=a[i];
        }
    }
    printf("%lld\n", cnt);
    return 0;
}

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

using namespace std;

int main()
{
    int n, i, a;
    cin >> n;
    map<long, long> mp;
    for (i = 0; i < n; i++)
    {
        cin >> a;
        if (mp.count(a) == 0)
        {
            mp[a] = 1;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,x) for(int i=0; i<(int) (x); i++)
#define intvec(name, size) vector<int> name;name.resize(size);
#define PI 3.14159265359
#define END "\n"
using namespace std;

int main()
{
	long long int a, b, c, d; cin >> a >> b >> c >> d;
	vector<long long int> x = {a * c, a * d, b * c, b * d};
	sort(x.begin(), x.end());
	cout << x[3] << END;
	//////////////////////////////////
	//--------end--------
	//
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  int cnt=1,ans=n;
  rep(i,n){
    if(cnt==a.at(i)){
      cnt++;
      ans--;
    }
  }
  if(ans==n){
    cout << -1;
    return 0;
  }
  cout << ans;
  
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k;
    cin>>n>>k;
    vector<int> pos, neg;
    int x;
    int zc = 0;
    for(int i=0;i<n;i++) {
        cin>>x;
        if(x<0) {
            neg.pb(x);
        }
        else if(x>0) {
            pos.pb(x);
        }
        else {
            zc++;
        }
    }  
    if(k>n-zc) {
        cout<<0;
        return 0;
    }
    sort(pos.begin(), pos.end(), greater<int>());
    sort(neg.begin(), neg.end());
    int ps = pos.size();
    int ns = neg.size();
    int pp = 0;
    int np = 0;
    int ans = 1;
    if(zc==0 && ps==0 && k%2==1) {
        int ans = 1;
        for(int i=1;i<=k;i++) {
            ans*=abs(neg[(ns-i)]);
            ans%=MOD;
        }
        ans = MOD-ans;
        ans%=MOD;
        // cout<<")";
        cout<<ans;
        return 0;
    }
    if(ps==0 && k%2==1 && zc!=0) {
        cout<<0;
        return 0;
    }

    // if(zc==0 && k>ps && (k-ps)%2 && ((k==n-1 && ps==1) || k==n)) {
    //     int ans =1;
    //     for(int i=1;i<ns;i++) {
    //         ans*=abs(neg[i]);
    //         ans%=MOD;
    //     }
    //     for(int i=0;i<ps-1;i++) {
    //         ans*=pos[i];
    //         ans%=MOD;
    //     }
    //     if(-neg[0]>pos[ps-1]) {
    //         ans*=pos[ps-1];
    //     }
    //     else {
    //         ans*=abs(neg[0]);
    //     }
    //     ans%=MOD;
    //     ans = MOD-ans;
    //     // cout<<")";
    //     cout<<ans;
    //     return 0;
    // }

    if(k==n) {
        int ans = 1;
        for(int i=0;i<ps;i++) {
            ans*=pos[i];
            ans%=MOD;
        }
        for(int i=0;i<ns;i++) {
            ans*=abs(neg[i]);
            ans%=MOD;
        }
        if(ns%2) {
            ans = MOD-ans;
        }
        ans%=MOD;
        cout<<ans;
        return 0;
    }

    while(k>0) {
        if(np>=ns-1) {
            ans*=pos[pp];
            pp++;
            k--;
            ans%=MOD;
            continue;
        }
        if(pp==ps) {
            ans*=abs(neg[np]);
            np++;
            ans%=MOD;
            ans*=abs(neg[np]);
            ans%=MOD;
            np++;
            k-=2;
            continue;
        }
        if(k%2==1) {
            ans*=pos[pp];
            pp++;
            ans%=MOD;
            k--;
            continue;
        }
        int pc = 1;
        pc = pos[pp]*pos[pp+1];
        int nc = neg[np]*neg[np+1];
        if(pc>=nc) {
            ans*=pos[pp];
            pp++;
            ans%=MOD;
            ans*=pos[pp];
            pp++;
            k-=2;
            ans%=MOD;
        }
        else {
            ans*=abs(neg[np]);
            np++;
            ans%=MOD;
            ans*=abs(neg[np]);
            np++;
            ans%=MOD;
            k-=2;
        }
    }
    cout<<ans;
 
    return 0;
}

Measured memory_bytes: 5512
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>

using namespace std;

int main()
{
	double r;
	cin >> r;
	printf("%.6f %.6f\n", r * r * 3.141592653589, 2 * r * 3.141592653589);
	return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,W;cin>>n>>W;
  ll w[n],v[n];
  for(ll i=0;i<n;i++)cin>>w[i]>>v[i];
  ll dp[n+1][W+1];
  for(ll i=0;i<n+1;i++)for(ll j=0;j<W+1;j++)dp[i][j]=-1;
  dp[0][0]=0;
  ll ans=0;
  for(ll i=0;i<n;i++){
    for(ll j=0;j<=W;j++){
      if(dp[i][j]==-1)continue;
      dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
      ans=max(ans,dp[i+1][j]);
      if(j+w[i]<=W){
        dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
        ans=max(ans,dp[i+1][j+w[i]]);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 79104
#include<stdio.h>
int get(int a,int b){
  int r;
  r=a%b;
  if(r==0){
    return b;
  }else{
    return get(b,r);
  }
}
int gcd(int a,int b,int c){
  return get(get(a,b),c);
}
int main(void){
  int K,a,b,c,sum=0;
  scanf("%d",&K);
  for(a=1;a<=K;a++){
    for(b=1;b<=K;b++){
      for(c=1;c<=K;c++){
        sum+=gcd(a,b,c);
      }
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
int memo[51];

int main()
{
    for (int a = 0; a <= 9; a++)
    {
        for (int b = 0; b <= 9; b++)
        {
            for (int c = 0; c <= 9; c++)
            {
                for (int d = 0; d <= 9; d++)
                {
                    memo[a + b + c + d]++;
                }
            }
        }
    }
    int n;
    while (cin >> n)
    {
        cout << memo[n] << endl;
    }
}


Measured memory_bytes: 3076
/* ~created by Pratik~ */

#include <bits/stdc++.h> 
using namespace std; 
int main()
{
	int n,ans=0,i;
    string s;
	cin>>n>>s;
  	for(i=0;i<=n-3;i++)
      if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        ans++;
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a==b&&b==c){
    cout << 1 << endl;
  }else if(a==b||b==c||c==a){
    cout << 2 << endl;
  }else{
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll a,b,ans=0;
  cin >> a >> b;
  if(a==b){
    cout << a << endl;
    return 0;
  }
  if(a%2==1){
    ans ^= a;
    a++;
  }
  if(b%2==0){
    ans ^= b;
    b--;
  }
  if(((b-a+1)/2)%2==1){
    ans ^= 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int N;
    cin >> N;
    vector <int> p(N);
    for(int i=0; i<N; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    p[N-1] = p[N-1]/2;
    cout << accumulate(p.begin(), p.end(),0);
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)

	for i := range a {
		a[i] = nextInt()
	}

	mod := int(1e9) + 7

	sum := a[0]
	ans := 0
	for i := 1; i < n; i++ {
		ans += (sum * a[i])
		ans %= mod
		sum += a[i]
		sum %= mod
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}

Measured memory_bytes: 5860
#include<iostream>
#include<cstdio>
using namespace std;
int n;
int cnt[100010];
int ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		cnt[x]++; 
	}
	for(int i=1;i<=100000;i++)ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[200005];
bool cmp(int a,int b){
    return a>b;
}
int main()
{
	ll n;
cin>>n;
	for(ll i=1;i<=n;i++)cin>>arr[i];
	sort(arr+1,arr+n+1);
	ll sum=0;
	if(n%2==0){
		ll d=n/2;
		for(ll i=n-1;i>d;i--)sum+=arr[i];
		sum*=2;
		sum+=arr[n];
	}
	else{
		ll d=(n+1)/2;
		for(ll i=n-1;i>d;i--)
		sum+=arr[i];
		sum*=2;
		sum+=arr[n];
		sum+=arr[d]; 
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5180
n,m,*a=map(int,open(0).read().split())
dp=[0]*(n+1)
b=[1]*(n+1)
for i in a:
    b[i]=0
dp[0]=1
if b[1]:
    dp[1]=1
for i in range(2,n+1):
    if b[i]:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%(10**9+7))

Measured memory_bytes: 460788
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, k, h[100005], dp[100006];
signed main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		dp[i] = INF;
	}
	dp[1] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[n] << endl;
	endre;
}

Measured memory_bytes: 1792
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

point = [K - Q] * (N+1)
for a in A:
    point[a] += 1
for i in range(1, N+1):
    ans = 'Yes' if point[i]>0 else 'No'
    print(ans)

Measured memory_bytes: 10448
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

void solve() {
	int N, K, A[200020];
	scanf("%d%d", &N, &K);
	for(int i=1;i<=N;i++) scanf("%d", A+i);
	map <int, int> M;
	for(int i=1;i<=N;i++) M[A[i]]++;
	vector <int> v;
	for(auto e : M) v.pb(e.Se);
	sort(all(v)); reverse(all(v));
	int ans = 0;
	for(int i=K;i<szz(v);i++) ans += v[i];
	printf("%d\n", ans);
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}




Measured memory_bytes: 11516
/*
    厳しい 
 */

#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

#define EPS 10e-6
#define PI 3.14159265358979

int N;
int k;
int r[9];
double ans;

bool check(double x) {
    double sum = 0.0;
    double proposed = 0.0;
    double c = cos(x);

    for (int i=0; i<k; i++) {
        double c2 = (double)(r[0] * r[1]) / (r[i] * r[(i+1)%k]) * c;
        sum += acos(c2);
        proposed += sin(acos(c2)) * r[i] * r[(i+1)%k] / 2;
    }

    if (sum > 2 * PI || sum < 0.0) return false;
    return true;
}

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

    sort(r, r+N);
    do {
        for (k=3; k<=N; k++) {
            double low, high;
            double proposed = 0.0;
            double sum = 0.0;

            low = 0.0;
            high = PI;
            for (int i=0; i<100; i++) {
                double mid = (low+high)/2;

                if (check(mid)) low = mid;
                else high = mid;
            }

            for (int i=0; i<k; i++) {
                double c2 = (double)(r[0] * r[1]) / (r[i] * r[(i+1)%k]) * cos(low);
                proposed += sin(acos(c2)) * r[i] * r[(i+1)%k] / 2;
                sum += acos(c2);
            }

            if (abs(sum-2*PI) < EPS) ans = max(ans, proposed);
        }
    } while (next_permutation(r, r+N));

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

Measured memory_bytes: 1200
from collections import deque
import sys
input = sys.stdin.readline
 
k = int(input())
n = 7
ans = -1
 
for i in range(10**6): #注意
  if n % k  == 0:
    ans = i+1
    break
  else:
    n =  (n % k) *10 + 7
    
print(ans)

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



int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int cnt = 0;
	for(int r = 0; r <= 3000; r++){
		for(int g = 0; g <= 3000; g++){
			if(R * r + G * g <= N && (N - R * r - G * g) % B == 0){
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
S = [ord(s)-97 for s in input().strip()]
T = [ord(t)-97 for t in input().strip()]

ls = len(S)

inf = 2*10**9

table = [None]*(2*ls)

ss = S + S
t = [inf]*26
for i in range(2*ls-1, -1, -1):
    z = ss[i]
    t[z] = i
    table[i] = t[:]

if any(table[0][ti] == inf for ti in T):
    print(-1)

else:
    ans = -1
    for ti in T:
       j = ans%ls
       k = table[j+1][ti] % ls
       if j < k:
           ans += k - j
       else:
           ans += ls + k - j
    print(ans + 1)

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M), p(M);
  vector<vector<int>> switches(M, vector<int>(0));
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int tmp;
      cin >> tmp;
      switches[i].push_back(tmp-1);
    }
  }
  for (int i = 0; i < M; i++) cin >> p[i];

  int res = 0;
  for (int bit = 0; bit < (1<<N); bit++) {
    bool can = true;
    for (int i = 0; i < M; i++) {
      int tmp = 0;
      for (int j = 0; j < switches[i].size(); j++) {
        if (bit & (1<<switches[i][j])) tmp++;
      }
      if (tmp % 2 != p[i]) can = false;
    }
    if (can) res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N; cin >> N;
    vector<int> v;
    string ans = "No";
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            if (N == i * j) ans = "Yes";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
const long long mod = 1e9+7; // CHECK
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
#define ll long long
const int INT_INF = 1e9+9;
const ll LL_INF = 2e18;
const int N = 3e5+9;

signed main() {  
    ios_base::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0);
    string s; cin >> s;
    for (char c: s) {
        cout << (c == '?' ? 'D' : c);
    }
    cout << '\n';



    

    return 0;
}



Measured memory_bytes: 3792