akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  string s;
  cin >>s;
  
  if(s=="Sunny") puts("Cloudy");
    if(s=="Cloudy") puts("Rainy");
    if(s=="Rainy") puts("Sunny");
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll table[1005];


int main(){

	ll N;
	scanf("%lld",&N);

	for(ll i = 1; i <= N; i++){

		table[i] = 0;
	}

	for(ll i = 2; i <= N; i++){
		ll tmp = i;
		for(ll k = 2; k*k <= tmp; k++){
			if(tmp%k == 0){
				while(tmp%k == 0){
					table[k]++;
					tmp /= k;
				}
			}
		}
		if(tmp > 1){
			table[tmp]++;
		}
	}

	ll ans = 1;

	for(ll i = 1; i <= N; i++){

		ans *= (table[i]+1);
		ans %= MOD;
	}

	printf("%lld\n",ans);

	return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    cout << (s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0]?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;
using ll = long long;

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

	double odd = 0;
	for (int i = 1; i <= N; ++i) {
		if (i % 2) {
			odd++;
		}
	}

	cout << odd / N << endl;
	return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N ;cin>>N;
	int ans = 0;
	vector<int>A(N);
	rep(i,N)cin>>A[i];
	rep(i,N){
		if(i % 2 == 0 && A[i] % 2 == 1)++ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e7+5;
const ll inf=2e18;
const int mod=998244353;
int n;
bool a[102];
int main(){
    cin>>n;

    for(int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        if(x==y)a[i]=1;
    }
    bool f=0;
    for(int i=1;i<=n-2;i++){
        if(a[i]&&a[i+1]&&a[i+2])f=1;
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3584
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),c=s.nextInt();
		int l=100001;
		int[][]r=new int[c+1][l];
		for(int i=0;i<n;++i) {
			int f=s.nextInt(),t=s.nextInt(),d=s.nextInt();
			r[d][f]++;
			r[d][t]--;
		}
		for(int i=1;i<=c;++i) {
			r[0][0]+=r[i][0];
			for(int j=1;j<l;++j) {
				r[0][j]+=(r[i][j]+=r[i][j-1]);
				if(r[i][j]>0&&r[i][j-1]==0)
					r[0][j-1]++;
			}
		}
		//Arrays.stream(r).map(Arrays::toString).forEach(System.err::println);
		System.out.println(Arrays.stream(r[0]).max().getAsInt());
	}
}


Measured memory_bytes: 109216
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def MS(): return map(str,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

n,k = MI()
a = LI()
ans = [1] * n
memo = [-1] * n
memo[0] = 0
s = 0
for i in range(1,n):
    if memo[a[ans[i-1]-1]-1] == -1:
        ans[i] = a[ans[i-1]-1]
        s += 1
        memo[ans[i] - 1] = s

    else:
        t = memo[a[ans[i-1]-1]-1]
        break
if k <= t:
    print(ans[k])
elif t == 0:
    print(ans[(k - 1) % (s-t +1) +1])
else:
    print(ans[(k-(t-1)-1) % (s-t+1) + t])


Measured memory_bytes: 50860
def s(n):
    ret = 0
    while n > 0:
        ret += n % 10
        n //= 10
    return ret
numbers = [999999999999999999]
while numbers[-1] > 1:
    for d in range(0, 100):
        n = numbers[-1]
        m = n - 10 ** d
        if n * s(m) >= m * s(n):
            numbers.append(m)
            break
numbers = list(reversed(numbers))

n = int(input())
for i in range(n):
    print(numbers[i])


Measured memory_bytes: 40304
#include <iostream>
using namespace std;
int main(){
	int N,v,j=0;
	cin>>N;
	int *p1;
	p1=new int[N];
	for(int a=0;a<N;a++){
		cin>>p1[a];
	}
	for(int a=0;a<N-1;a++){
		cout<<p1[a]<<" ";
	}
	cout<<p1[N-1]<<endl;
	for(int i=1;i<N;i++){
		v=p1[i];
		j=i-1;
		while(j>=0&&p1[j]>v){
			p1[j+1]=p1[j];
			j--;

		}
		p1[j+1]=v;
		for(int a=0;a<N-1;a++){
			cout<<p1[a]<<" ";
		}
		cout<<p1[N-1]<<endl;
	}


}


Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public long[] A;

        public void Run()
        {
            A = Input.ReadLongArray();
            Console.WriteLine(Math.Abs(A[0] - A[1]) >= 2 ? "Alice" : "Brown");
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define all(x) x.begin() , x.end()
#define ll long long 
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , m ; cin>>n>>m;
    int c = 0 , cnt = 1;
    vector<int>v(n);
    for(int& i : v){
        cin>>i;
        c += i;
        if(c <= m){
            cnt++;
        }
    }

    cout<<cnt<<endl;
}

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

#include <iostream>
#include <fstream>

#include <iostream>

class TaskB {
public:
    void solve(std::istream &in, std::ostream &out) {
        long long int n, m, k;
        in >> n >> m >> k;
        for (long long int i = 0; i <= n; ++i) {
            for (long long int j = 0; j <= m; ++j) {
                if (k == ((n - i) * j + (m - j) * i)) {
                    out << "Yes";
                    return;
                }
            }
        }
        out << "No";
    }
};


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


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 400000

vector<int>e[N];
bool used[N];
int s;

void dfs(int k){
used[k]=true;
s++;
f(i,e[k].size()){
if(!used[e[k][i]]){
dfs(e[k][i]);
}
}
return;
}




int main(){
map<int,int>m;
set<int>st;
	vector<int>a;
vector<int>b;
	vector<int>c;
vector<int>d;
	int n, k;
	int x, y, z;
	int ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
y=0;
k=0;
	f(i,n){
		scanf("%d", &x);
if((st.insert(x)).second){
m[x]=k;
k++;
}
y=y^x;
		a.push_back(x);
		c.push_back(x);
	}
if((st.insert(y)).second){
m[y]=k;
k++;
}
		a.push_back(y);
		c.push_back(y);
z=y;
y=0;
	f(i,n){
		scanf("%d", &x);
		b.push_back(x);
		d.push_back(x);
if(a[i]!=b[i])ans++;
y=y^x;
	}
		b.push_back(y);
		d.push_back(y);
sort(a.begin(),a.end());
sort(b.begin(),b.end());

	f(i,n+1){
if(a[i]!=b[i])v=false;
	}
if(!v){
printf("-1\n");
return 0;
}

f(i,n+1){
e[m[c[i]]].push_back(m[d[i]]);
e[m[d[i]]].push_back(m[c[i]]);
}
f(i,k)used[i]=false;


f(i,k){
if(!used[i]){
s=0;
v=used[m[z]];
dfs(i);
if(s>1){
if(v==used[m[z]])ans++;
}
}
}



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


	return 0;
}

Measured memory_bytes: 28528
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;


int main(){
  ll A,V; cin >> A >> V;
  ll B,W; cin >> B >> W;
  ll T; cin >> T;

  if(V<=W){
    cout << "NO" << endl;
    return 0;
  }

  ll d=abs(A-B);
  if(d<=(V-W)*T){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <complex>
#include <cstring>
using namespace std;

#define MAX 999999999
#define EPS (1e-8)

typedef pair<double,double> P;

int n, ans, pos[1000000];
double r;
P p[1000000];
bool rem[1000000];

void solve(){
  ans = 0;
  memset(rem, true, sizeof(rem));

  for(int i = 0; i < n; i++){
    if(!rem[i]) continue;

    int from = lower_bound(p, p + n, P(p[i].first - r - EPS, -MAX)) - p;
    int to = lower_bound(p, p + n, P(p[i].first + r + EPS, MAX)) - p;

    for(int j = from; j < to; j++){
      int y_from = lower_bound(p + j, p + pos[j] + 1,
                               P(p[j].first, p[i].second - r - EPS)) - p;
      int y_to = lower_bound(p + j, p + pos[j] + 1,
                             P(p[j].first, p[i].second + r + EPS)) - p;

      for(int k = y_from ; k < y_to; k++){
        if(pow(p[i].first - p[k].first, 2) +
           pow(p[i].second - p[k].second, 2) < r * r + EPS){
          rem[k] = false;
        }
      }

      j = pos[j];
    }

    ans++;
  }

  cout << ans << endl;
}

int main(){
  while(cin >> n >> r){
    for(int i = 0; i < n; i++){
      cin >> p[i].first >> p[i].second;
    }

    sort(p, p + n);
    pos[n - 1] = n - 1;

    for(int i = n - 2; i >= 0; i--){
      if(p[i].first == p[pos[i + 1]].first){
        pos[i] = pos[i + 1];
      }
      else{
        pos[i] = i;
      }
    }

    solve();
  }
}

Measured memory_bytes: 19676
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
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;
}

vector<vector<int> > g;
bool flag[1010];
int s[1010];
int dfs(int id){
    if(flag[id])return s[id];
    flag[id] = 1;
    set<int> st;
    st.insert(0);
    for(auto x:g[id]){
        st.insert(dfs(x));
    }
    rep(i,1010){
        if(st.count(i)==0){
            s[id] = i;
            return s[id];
        }
    }
}
int res[1010];
int main(){
    int n,m;
    cin >> n >> m;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
        a[i]%=2;
    }
    g.resize(n);
    rep(i,m){
        int c,d;
        cin >> c >> d;
        c--;d--;
        g[c].push_back(d);
    }
    rep(i,n){
        dfs(i);       
    }
    int b = 0;
    rep(i,n){
        if(a[i]){
            res[s[i]]++;
        }
    }
    bool f = 0;
    rep(i,1010){
        if(res[i]%2!=0){
            f = 1;
        }
    }
    if(!f){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,k;
int h[100010],dp[100010];
int main(){
	memset(dp,0x3f,sizeof dp);
	dp[1]=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=2;i<=n;i++)
		for(int j=max(1,i-k);j<i;j++)
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024
//In the name of He
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = true;
#define cerr if(DEBUG)cerr
#define bit(num,i) ((num>>i)&1)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long long maxn = 3e5 + 5 + 1;
const long long INF = 4e18 ;
const long long M = 1e9 + 7;
const int lg = 21;

#pragma GCC Optimize("Ofast")

int n, lq, llq, q;
string ls, s;

bool chk(int a, string A, int b, string B){
    a++;
    a++;
    b++;
    b++;
    if(a%2 == b%2){
        if(A == B) return true;
        return false;
    }
    if(A == B) return false;
    return true;
}

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    cout << 0 << endl;
    cin >> ls;
    if (ls == "Vacant") return 0;
    if(n <= 19){
        for(int i=1;i<n;i++){
            cout << i << endl;
            cin >> ls;
            if (ls == "Vacant") return 0;
        }
    }
    while(n - lq > 2){
        q = (n + lq) / 2;
        cout << q << endl;
        cin >> s;
        if (s == "Vacant") return 0;
        cerr << "llq : " << llq << endl;
        cerr << "ls : " << ls << endl;
        cerr << "q : " << q << endl;
        cerr << "s : " << s << endl;
        if (chk(llq, ls, q, s)){
            if (llq > q){
                n = q;
            }
            else {
                lq = q;
            }
            llq = q;
        }
        else{
            if (llq > q){
                lq = q;
            }
            else {
                n = q;
            }
            llq = q;
        }
        ls = s;
    }
    cout << max(q-2,0) << endl;
    cin >> s;
    if (s == "Vacant") return 0;
    cout << max(q-1,0) << endl;
    cin >> s;
    if (s == "Vacant") return 0;
    cout << min(q+1,n-1) << endl;
    cin >> s;
    if (s == "Vacant") return 0;
    cout << min(q+2,n-1) << endl;
    cin >> s;
    if (s == "Vacant") return 0;
	return 0;
}


Measured memory_bytes: 852
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int K = int.Parse(Console.ReadLine());
        int ans = 1;
        for (int i = 0; i < N; i++) 
        {
            if (ans < K)
                ans *= 2;
            else
                ans += K;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
a, b, x = gets.split.map(&:to_i)
filled_volume = a * a * b
half_volume = filled_volume / 2.0
if x >= half_volume
  bottom = b * ((filled_volume - x) / half_volume)
  angle = Math.atan(bottom / a) * 180 / Math::PI
else
  bottom = a * x / half_volume
  angle = 90 - Math.atan(bottom / b) * 180 / Math::PI
end
puts angle


Measured memory_bytes: 1788
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.math.*;

import static java.util.Comparator.*;


public class Main {
    public static void main(String[] args) throws IOException {
        FastReader s = new FastReader();
        int n=s.nextInt();
        int m=s.nextInt();
        int[] arr=new int[n];
        double sum=0;

        for(int i=0;i<n;i++)
        {
            arr[i]=s.nextInt();
            sum+=arr[i];
        }
//        Arrays.sort(arr);
        sum/=(4*m);
//        System.out.println(sum);
        int count=0;
        for(int i=n-1;i>=0;i--)
        {
            if(arr[i]>=sum)
            {
                count++;
            }
        }
        if(count>=m)
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }

    }

}


class FastReader
{
    BufferedReader br;
    StringTokenizer st;

    public FastReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException  e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 21588
N,X = list(map(int,input().split()))
L = list(map(int,input().split()))

D = []
D.append(0)

for i in range(N):
    din = D[i]+L[i]
    D.append(din)
count = 0
for i in range(N+1):
    if D[i] <= X:
        count = count + 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 2e5+10, mod = 998244353, inv2 = (mod+1)>>1;
int n;
vector<int>e[N];

int mx,pos,s,cnt,p[N],fa[N];
inline void dfs(int u,int fa,int dep){
	if (dep>=mx) mx=dep,pos=u;
	::fa[u]=fa;
	for (auto v:e[u]) if (v!=fa) dfs(v,u,dep+1);
}
inline void Find(){
	dfs(1,0,0),s=pos,dfs(s,0,0);
	for (int u=pos;u!=s;u=fa[u]) p[++cnt]=u;
	p[++cnt]=s;
}

int dp[N][3][3],f[3][3];
inline void Dfs(int u,int fa,int dep){
	if (dep==mx/2) dp[u][1][1]=1;
		else dp[u][0][0]=1;
	for (auto v:e[u]) if (v!=fa){
		Dfs(v,u,dep+1),fil(f,0);
		FOR(i,0,3) FOR(j,0,3) if (dp[u][i][j])
			FOR(_i,0,3) FOR(_j,0,3) if (dp[v][_i][_j])
				FOR(k,0,3){
					int x=min(2,i+(_i)*(k==1)),y=min(2,j+(_j)*(k==2));
					f[x][y]=(f[x][y]+1ll*dp[u][i][j]*dp[v][_i][_j])%mod;
				}
		FOR(i,0,3) FOR(j,0,3) dp[u][i][j]=f[i][j];
	}
}

int main(){
	n=read();
	FOR(i,1,n){
		int x=read(),y=read();
		e[x].pb(y),e[y].pb(x);
	}
	Find();
	if (mx%2==0){
		Dfs(p[cnt+1>>1],0,0);
		printf("%d\n",1ll*dp[p[cnt+1>>1]][1][1]*inv2%mod);
	} else {
		int x=p[cnt/2],y=p[cnt/2+1];
		Dfs(x,y,0),Dfs(y,x,0);
		int ans=(1ll*dp[x][1][0]+dp[x][1][1]+dp[x][1][2])%mod*(1ll*dp[y][1][0]+dp[y][1][1]+dp[y][1][2])%mod;
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 29936
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int ans = 0;
    for(auto &el : cnt) {
        if(el.fi < el.se) {
            ans += el.se - el.fi;
        } else if(el.fi > el.se) {
            ans += el.se;
        }
    }
    cout << ans << "\n";

}

Measured memory_bytes: 7040
M,D=list(map(int, input().split()))

ans = 0
for m in range(1,M+1):
  for d in range(11,D+1):
    a,b=list(map(int, list(str(d))))
    if a>1 and b>1 and a*b==m:
      ans += 1      
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  string s, t;
  cin >> s >> t;
  int ans = INF;
  for(int i = 0; i <= int(s.size()) - int(t.size()); i++){
    int tmp = 0;
    for(int j = 0; j < int(t.size()); j++){
      if(t[j] == s[i + j]) tmp++;
    }
    ans = min(int(t.size()) - tmp, ans);
  }
  cout << ans << endl;
}
    
        




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

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
using namespace std;
const ll mod = 1e9 + 7;



//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}



int main()
{
    MohamedMotaz;
    ll a, b, c;
    cin >> a >> b >> c;
    cout << c << " "  << a << " " << b;
    

   
}








Measured memory_bytes: 256
# 【abc-178】個人的ふりかえり（A〜E）
# https://qiita.com/nyororingo/items/d372d1ff3f690b0d1fe2

S = int(input())
MOD = 10 ** 9 + 7
    
dp = [0] * (S + 1)
dp[0] = 1
for i in range(3, S + 1):
    #print(dp)
    #for j in range((i - 3) + 1):

        #dp[i] += dp[j]
        dp[i] = dp[i-1] +dp[i-3]
        dp[i] %= MOD
print(dp[S] % MOD)

Measured memory_bytes: 9188
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] xArray = new int[num];
        for(int i = 0; i < num; i++){
            xArray[i] = sc.nextInt();
        }
        int[] yArray = new int[num];
        for(int i = 0; i < num; i++){
            yArray[i] = sc.nextInt();
        }
        
        double[] p = new double[4];
        
        for(int i = 0; i < num; i++){
            double dif = Math.abs(xArray[i] - yArray[i]);
            p[0] += dif;
            p[1] += Math.pow(dif, 2);
            p[2] += Math.pow(dif, 3);
            p[3] = Math.max(p[3], dif);
            
        }
        p[1] = Math.sqrt(p[1]);
        p[2] = Math.cbrt(p[2]);
        
        for(double result: p){
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 26580
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if(a <= 5) System.out.println("0");
        else if(a <=12) System.out.println(b/2);
        else System.out.println(b);
    }
}

Measured memory_bytes: 21076
n=int(input())
l=[[]]*n
for i in range(n):
    l[i]=list(map(int,input().split()))
lst=sorted(l,key=lambda x:-x[2])
flag=False

for i in range(0,101):#i=X
    if flag:
        break
    for j in range(0,101):#j=Y
        if flag:
            break
        tmp=lst[0][2]+abs(lst[0][0]-i)+abs(lst[0][1]-j)
        for k in range(n):
            if lst[k][2]!=0:
            #print(k,'ループ目')
                sum=abs(lst[k][0]-i)+abs(lst[k][1]-j)
                H=lst[k][2]+sum
                if tmp!=H :
                    break
                a,b,c=i,j,H
                if k==n-1:
                    flag=True
                    print(i,j,H,)
                    break
            
            else:
                
                if lst[k][2]!=max(c-abs(a-lst[k][0])-abs(b-lst[k][1]),0):
                    #print(c,abs(a-lst[k][0]),abs(b-lst[k][1]))
                    break
                if k==n-1:
                    flag=True
                    print(i,j,H)
                    break
                

Measured memory_bytes: 3064
N, C = map(int, input().split())
X, V = [], []
for i in range(N):
  x, v = map(int, input().split())
  X+=[x]
  V+=[v]

ans = 0
doublepath=[0]
w=0
for i in range(N):
  w+=V[i]
  doublepath+=[-2*X[i]+w]
maxdoublepath=[0]
for i in range(N):
  maxdoublepath+=[max(maxdoublepath[-1],doublepath[i+1])]

ans = 0
w=0
for i in range(N):
  w+= V[N-1-i]
  ans = max(ans,(w-(C-X[N-1-i])) + maxdoublepath[N-1-i])

doublepath=[0]
w=0
for i in range(N):
  w+=V[N-1-i]
  doublepath+=[-2*(C-X[N-1-i])+w]
maxdoublepath=[0]
for i in range(N):
  maxdoublepath+=[max(maxdoublepath[-1],doublepath[i+1])]

w=0
for i in range(N):
  w+= V[i]
  ans = max(ans,(w-X[i]) + maxdoublepath[N-1-i])

print(ans)

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

const int MOD = 1e9 + 7;

long long pow_mod(long long x, long long n) {
    long long res = 1;
    while (n) {
        if (n & 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    int N, K;  cin >> N >> K;
    long long ans = 0;
    vector<long long> memo(K + 1);
    for (long long X = K; X >= 1; --X) {
        memo[X] = pow_mod(K / X, N) % MOD;
        for (int i = 2; i * X <= K; ++i) {
            memo[X] = (memo[X] - memo[i * X] + MOD * 2) % MOD;
        }
        ans = (ans + X * memo[X] % MOD) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4048
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

void input(vi& taro, vi& hana, int n)
{
  REP(i, n) cin >> taro[i];
  sort(taro.begin(), taro.end());
  int j = 0;
  RREP(i, 2 * n){
    if (i != taro[j]){
      hana.pb(i);
      //cout << "push: " << i << endl;
    } else j++;
  }
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n){
    vi taro(n), hana;
    input(taro, hana, n);

    int top;
    top = taro[0];
    taro.erase(taro.begin());
    for (int i = 1; !taro.empty() && !hana.empty(); i++){
      //cout << "|||TOP = " << top << endl;
      if (i % 2 != 0){
        bool check = true;
        REP(j, hana.size()){
          if (top < hana[j]){
            top = hana[j];
            hana.erase(hana.begin() + j);
            check = false;
            break;
          }
        }
        if (check) top = 0;
      } else {
        bool check = true;
        REP(j, taro.size()){
          if (top < taro[j]){
            top = taro[j];
            taro.erase(taro.begin() + j);
            check = false;
            break;
          }
        }
        if (check) top = 0;
      }
    }
    if (taro.size() > hana.size()){
      cout << "0" << endl << taro.size() << endl;
    } else {
      cout << hana.size() << endl << "0" << endl;
    }
  }

  return (0);
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

vector<vector<ll>> G;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;cin>>n>>m;
    G=vector<vector<ll>>(n);
    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    //bfs
    queue<ll> q;
    q.push(0);
    vector<ll> dist(n,-1);
    dist[0]=0;
    while(!q.empty()){
        ll s = q.front();q.pop();
        for(ll to:G[s]){
            if(dist[to]==-1){
                dist[to]=s;
                q.push(to);
            }
        }
    }
    cout<<"Yes\n";
    for(int i=1; i<n; i++){
        cout<<dist[i]+1<<endl;
    }


    return 0;
}

Measured memory_bytes: 12964
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

struct UnionFind {
  vector<int> par; 

  UnionFind(int N) : par(N) {
      for(int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) { 
      if (par[x] == x) return x;
      return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
      int rx = root(x); //xの根をrx
      int ry = root(y); //yの根をry
      if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
      par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
      int rx = root(x);
      int ry = root(y);
      return rx == ry;
  }
};

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

  int32_t N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);
  vector<vector<int>> df(N);
  vector<vector<int>> block(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    uf.unite(a - 1, b - 1);
    df[a-1].push_back(b-1);
    df[b-1].push_back(a-1);
  }

  for (int i = 0; i < K; i++) {
    int c,d;
    cin >> c >> d;
    block[c-1].push_back(d-1);
    block[d-1].push_back(c-1);
  }

  unordered_map<int, int> group_size;
  for (int i = 0; i < N; i++) {
    group_size[uf.root(i)]++;
  }


  for (int i = 0; i < N; i++) {
    int32_t res = group_size[uf.root(i)];
    res -= 1;
    if (!df[i].empty()) {
      res -= (int32_t)df[i].size();
    }
    for (auto it = block[i].begin(); it != block[i].end(); it++) {
      if (uf.root(i) == uf.root(*it)) {
        res--;
      }
    }
    cout << res << " ";
  }
  cout << endl;


  return 0;
}



Measured memory_bytes: 12664
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

int main(){
    string s;cin>>s;
    string t;cin>>t;
    bool ans=false;
    rep(i,26){
        if(s+abc[i]==t)ans=true;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

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

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }


const long long INF = 1LL<<60;
 
int N, M;
vector<long long> a, b;
vector<int> c;
 
 
long long dp[1100][5000];
 
int main() {
    int N, M; cin >> N >> M;
    vector<long long> a(M), b(M), c(M, 0); // c はビットで表す
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
        for (int j = 0; j < b[i]; ++j){
            int t; cin >> t; --t;
            c[i] += (1<<t);
        }
    }
 
    for (int i = 0; i < 1100; ++i) for (int j = 0; j < 5000; ++j) dp[i][j] = INF;
    dp[0][0] = 0;
    
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < (1<<N); ++j) {
            chmin(dp[i+1][j], dp[i][j]);
            
            int nj = j | c[i];
            chmin(dp[i+1][j | c[i]], dp[i][j] + a[i]);
        }
    }
 
    cout << (dp[M][(1<<N)-1] < INF ? dp[M][(1<<N)-1] : -1) << endl;               
}


Measured memory_bytes: 43264
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main { //christmas gifts
    static StringTokenizer st;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args)throws IOException {
        String s = next();
        if(s.equals("SUN")){
            System.out.println(7);
        }
        else if(s.equals("SAT")){
            System.out.println(1);
        }
        else if(s.equals("FRI"))
            System.out.println(2);
        else if(s.equals("THU"))
            System.out.println(3);
        else if(s.equals("WED"))
            System.out.println(4);
        else if(s.equals("TUE"))
            System.out.println(5);
        else if(s.equals("MON"))
            System.out.println(6);
    }
    static class Pair {
        int p , s;
        public Pair(int p, int s){
            this.p = p;
            this.s = s;
        }
    }
    static String next() throws IOException{
        while(st==null||!st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
    static int readInt() throws IOException{
        return Integer.parseInt(next());
    }
}


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

int main() {
    int n, s=0, v=0, w=0, f=1;
    cin >> n;
    for(int i=0;i<n;i++){
        int t, x, y;
        cin >> t >> x >> y;
        if((x+y+t)%2 != (v+w+s)%2){
            f=0;
        }
        if(abs(x-v)+abs(y-w)>t-s){
            f=0;
        }
        v=x;
        w=y;
        s=t;
    }
    if(f==1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include<queue>

const int INF = 1 << 28;
const long long MOD = 1000000007;
using namespace std;
using Graph = vector<vector<int>>;

template<class T> bool chmin(T &a, T &b) { if (a > b) { a = b; return 1; }return 0; }
template<class T> bool chmax(T &a, T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T, class U> using P = pair<T, U>;

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

int counter[200005] = {};
void bfs2(Graph &G,int p,int x) {
	vector<int> dist(G.size() , -1);
	queue<int> que;
	
	dist[p] = 0;
	que.push(p);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
			counter[g] += x;
		}
	}
}
long long int gcd(long long int a, long long int b) {
	long long int c = std::min(a, b);
	a = std::max(a, b);
	b = c;
	while (true) {
		c = a % b;
		a = b;
		b = c;
		if (c == 0)break;
	}
	return a;
}
int main()
{
	int n, k,mx;
	long long d;
	std::cin >> n >> k >> d;
	int a;
	mx = d;
	n--;
	while (n--) {
		std::cin >> a;
		d = gcd(a, d);
		mx = std::max(mx, a);
	}
	printf("%sPOSSIBLE", (k%d || k > mx) ? "IM" : "");

	return 0;
}

Measured memory_bytes: 256
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;

int N;
vc C;

void dfs(int n, string res) {
  if (n >= N) {
    printf("%s\n", res.c_str());
    return;
  }

  char M = 'a';
  for (auto c : res) {
    M = max(M, c);
  }
  
  for (int i = 0; i < C.size(); i++) {
    if (M + 1 < C[i]) continue;
    dfs(n+1, res + C[i]);
  }
}

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

  cin>>N;

  REP(i, N) {
    C.push_back((char)('a'+i));
  }
  dfs(1, "a");
  

  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool ispal(string a)
{
    long long int n=a.length();
    if(n==1)
        return true;
    else{
    int i=0,j;
    j=n-1;
    while(1)
    {
        if(a[i]!=a[j])
        {
            cout<<i<<" "<<j;
           return false;
        }
        i++,j--;
        if(i==j)
         {
        //     cout<<i<<" ";
             break;
        }
    }
    return true;
}}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,x,t;
  cin>>n>>x>>t;
  ll ans=((n/x)*t);
  //cout<<n%x<<" ";
  if((n%x)!=0)
  {
      ans+=t;
  }
  cout<<ans;

  }


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

const int mod = 1e9+7;
char maze[1010][1010];
int dp[1010][1010];
int n,m;
int topdown(int i,int j)
{
    if(i+1==n and j+1==m)
    {
        dp[i][j]=1;
        return 1;
    }
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    int ans=0;
    if(i+1<n and maze[i+1][j]!='#')
    {
        ans+=topdown(i+1,j)%mod;
    }
    if(j+1<m and maze[i][j+1]!='#')
    {
        ans+=topdown(i,j+1)%mod;
    }
    dp[i][j]=ans%mod;
    return dp[i][j];
}

int main()
{
    cin>>n>>m;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>maze[i][j];
        }
    }
    cout<<topdown(0,0)<<endl;
    return 0;
}


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

int n;

int getdiv(int x){
    int cnt = 0;
    int i;
    for(i =1; i*i<x; i++){
        if(x%i==0) cnt+=2;
    }
    if(i*i==x) cnt++;
    return cnt;
}

int main(){
    scanf("%d", &n);
    int cnt=0;
    for(int i=1; i<=n ;i+=2){
        if(getdiv(i)==8) cnt++;
    }
    printf("%d", cnt);
    return 0;
}


Measured memory_bytes: 256
def abc105_c():
    n = int(input())
    # 例外処理
    if n == 0:
        print(0)
        return

    # dを超えない数の商と、余りをとる
    d = n
    bin_arr = []
    while d != 0:
        # dが正の値なら、dを超えない数は、絶対値は小さいほう
        if d > 0:
            _d = d // 2
            bin_arr.append(d % 2)
            d = -1 * _d  # さいごに-1掛ける
        # dが負の値なら、dを超えない数は、絶対値としては大きいほう
        else:
            _d = (abs(d) + 1) // 2
            bin_arr.append(abs(d) % 2)
            d = _d
        #print(d, bin_arr)

    bin_str = ''.join(map(str, reversed(bin_arr)))
    print(bin_str)

abc105_c()

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m;
vector<int> g[100000];

int main() {
	cin >> n >> m;
	inc(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].PB(b);
	}
	
	int ans = 0;
	set<int> se;
	inc(i, n) {
		inc(j, g[i].size()) { se.insert(g[i][j]); }
		if(! se.empty() && *se.begin() == i + 1) {
			ans++;
			se.clear();
		}
		
		// for(auto && e: se) { cout << e << " "; } cout << endl;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 6784
n = int(input())
w_list = []
for i in range(n):
    w_list.append(input())

list = []
result = 'Yes'
for i in range(n):
    if w_list[i] not in list:
        list.append(w_list[i])
    else:
        result = 'No'

for i in range(n-1):
    if w_list[i][-1] != w_list[i+1][0]:
        result = 'No'
        break
print(result)


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	vector<pair<double,double>> pos(n);
	for(int i = 0;i < n;i++){
		double x,y;
		cin >> x >> y;
		pos[i] = make_pair(x,y);
	}
	sort(pos.begin(),pos.end());
	double sum = 0;

	double cnt = 0;
	do{
		ll now = 0;
		for(int i = 0;i < n-1;i++){
			double x1,y1,x2,y2;
			x1 = pos[i].first;
			y1 = pos[i].second;
			x2 = pos[i+1].first;
			y2 = pos[i+1].second;

			sum += sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		}
		cnt++;
	}while(next_permutation(pos.begin(),pos.end()));

	printf("%.14lf\n",sum/cnt);
}


Measured memory_bytes: 256