akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18+7;

class CompareDist
{
public:
    bool operator()(pair<int,int> n1,pair<int,int> n2) {
        return n1.second>n2.second;
    }
};

class Dijkstra{ //O((N+M)logN)
    private:
        static const int INF = 1e9+7;
        vector<vector<pair<long long,int>>> graph; //pair<cost,next_path>
        vector<long long> total_cost;
        vector<vector<int>>  shortest_path;
    
    public:
        Dijkstra(vector<vector<pair<long long,int>>> graph,int start,int size,bool path_check = false){
            priority_queue<
                pair<long long,int>,
                vector<pair<long long,int>>,
               // greater<pair<long long,int>>> q;
               CompareDist> q;
            vector<long long> cost(size,1e18+7);
            vector<vector<int>> path(size);
            if(path_check) for(int i=0;i<size;i++) path[i].push_back(i);//自分は必ず通る
            cost[start] = 0;
            q.push(make_pair(0ll,start));
            while (!q.empty()){
                auto now = q.top();
                q.pop();
                int prev = now.second;
                if( cost[prev] < now.first) continue;
                for (auto next : graph[prev]){
                    if (cost[next.second] <= cost[now.second] + next.first) continue;
                    cost[next.second] = cost[now.second] + next.first;
                    //先頭からpathを追加
                    //if(path_check) path[next.second].insert(path[next.second].begin(),path[now.second].begin(),path[now.second].end()); 
                    q.push(next);
                }
            }
            total_cost = cost;
            if(path_check) shortest_path = path;
        }
        vector<long long> get_cost(){ return total_cost; }
        vector<vector<int>> get_path(){ return shortest_path; }
};
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    //長さ、次の場所のペア
    vector<vector<pair<ll,int>>> graph(n);
    rep(i,0,m){
        int l,r,c;
        cin >> l>>r>>c;
        l--;
        r--;
        graph[l].push_back(make_pair(c,r));
    }
    rep(i,1,n) graph[i].push_back(make_pair(0,i-1));

    Dijkstra g(graph,0,n);
    if(g.get_cost()[n-1] == inf) cout << -1 << endl;
    else cout << g.get_cost()[n-1] << endl;
    /*
    vector<ll> ans = Dijk(graph,0,n);
    if(ans[n-1] == inf) cout << -1 << endl;
    else cout << ans[n-1] << endl;
    */
}

Measured memory_bytes: 25836
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static io;
public class CompetitiveProgramming
{
  public void Solve()
  {
    var n = Int1;
    var x = seive(1000000);
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
      var y = Int1;
      if (isPrime(y))
        ++ans;
    }
    Write(ans);
  }
  List<int> seive(int n)
  {
    var ret = new List<int>();
    bool[] isPrime = new bool[n + 1];
    for (int i = 1; i <= n; ++i) isPrime[i] = true;
    isPrime[1] = false;
    for (int i = 1; i <= n; ++i)
    {
      int j = i;
      if (isPrime[i]) ret.Add(i);
      else continue;
      while (j <= n)
      {
        j += i;
        if (j > n) continue;
        isPrime[j] = false;
      }
    }
    return ret;
  }
  bool isPrime(long n)
  {
    for (int i = 2; i * i <= n; ++i)
    {
      if (n % i == 0) return false;
    }
    return true;
  }

}



class Program
{
  static void Main(string[] args)
  {
    var CompetitiveProgramming = new CompetitiveProgramming();
    CompetitiveProgramming.Solve();
  }
}
public static class io
{
  public static string Str => Console.ReadLine();
  public static string[] Strs => Str.Split(' ');
  public static long[] Longs => Strs.Select(long.Parse).ToArray();
  public static int[] Ints => Strs.Select(int.Parse).ToArray();
  public static char[] Chars => Str.ToArray();
  public static double[] Doubles => Strs.Select(double.Parse).ToArray();
  public static long Long1 => Longs[0];
  public static int Int1 => Ints[0];
  public static char Char1 => Chars[0];
  public static double Double1 => Doubles[0];
  public static long[] VerticalRead(int N) { long[] A = new long[N]; for (int i = 0; i < N; ++i) A[i] = Long1; return A; }
  public static void Write(string a) => Console.WriteLine(a);
  public static void Write(params object[] i) => Write(string.Join(" ", i));
  public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
  public static void Verticalwrite<T>(IEnumerable<T> a) { foreach (var z in a) Write(z); }
  public static void YN(bool i) { if (i) Write("Yes"); else Write("No"); }
}



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

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

  int ans_i = 0;
  int ans = 0;

  for(int j=0; j<n; j++){
    while(a[j]%2==0){
      a[j] /= 2;
      ans++;
    }
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

calc :: String -> String
calc [] = "No"
calc (c:s)
  | c == '7' = "Yes"
  | otherwise = calc s

main = do
  [s] <- getString
  putStrLn $ calc s

Measured memory_bytes: 3660
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;



void main() {
    immutable EPS = 1.0e-12;
    string[] input = new string[](8);

    while ((input = readln.chomp.split(" ")).length != 0) {
        auto points = input.map!(to!double);
        auto innerProduct = fabs((points[2] - points[0])*(points[6] - points[4]) + (points[3] - points[1])*(points[7] - points[5]));

        if (innerProduct < EPS) {
            writeln("YES");
        } else {
            writeln("NO");
        }
    }
}

Measured memory_bytes: 1076
arr = Array.new(5) { gets.to_i }
all = arr.inject(:+)
x = 0
min = 99
for i in 0..4 do
    if arr[i]%10 != 0
        if arr[i]%10 < min
            x += (10 - min)
            min = arr[i]%10
        elsif
            x += 10 - arr[i]%10
        end
    end
end

if min == 99
    puts all
elsif
    puts all + x - (10 - 99)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int dp[102][100005],n;
int a[102],k;
signed main()
{
    cin>>n>>k;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j)
                dp[i][j]+=dp[i][j-1];
                dp[i][j]%=mod;
            if(j-a[i]-1>=0)
            dp[i][j]=(dp[i][j]+mod-dp[i-1][j-a[i]-1])%mod;
            dp[i][j]%=mod;
        }
    }
    cout<<dp[n][k]<<endl;
	return 0;
}


Measured memory_bytes: 42588
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
 
static const int tx[] = {+0,+1,+0,-1};
static const int ty[] = {-1,+0,+1,+0};
 
static const double EPS = 1e-8;


map<vector<int>,int> dp;

int dfs(vector<int>& buns,int sum,int comb_i,vector<vector<int> >& all_combinations){
  if(comb_i >= all_combinations.size()) return sum;
  if(dp.find(buns) != dp.end()) return dp[buns];

  vector<int> prev = buns;
  bool isok = true;
  for(int weight = 1; weight <= 9; weight++){
    int use_count = all_combinations[comb_i][weight];
    buns[weight] -= use_count;
    if(buns[weight] < 0){
      isok = false;
      break;
    }
  }

  int res = 0;
  if(isok){
    res = max(sum + 1,dfs(buns,sum + 1,comb_i,all_combinations));
  }
  buns = prev;
  res = max(res,dfs(buns,sum,comb_i + 1,all_combinations));

  return (dp[buns] = max(res,dp[buns]));
}

void make_combinations(int weight,int sum,vector<int>& current,vector<vector<int> >& all_combinations){
  if(sum >= 10){
    if(sum == 10) all_combinations.push_back(current);
    return;
  }
  if(weight >= 10) return;

  for(int use_count = 0; use_count <= 10; use_count++){
    current[weight] = use_count;
    make_combinations(weight + 1,sum + weight * use_count,current,all_combinations);
    current[weight] = 0;
  }
}

int main(){
  int total_buns;
  
  vector<vector<int> > all_combinations;
  vector<int> current(11);
  make_combinations(1,0,current,all_combinations);
  sort(all_combinations.begin(),all_combinations.end());

  while(~scanf("%d",&total_buns)){
    if(total_buns == 0) break;
    vector<int> buns(11);
    dp.clear();

    for(int i = 0; i < total_buns; i++){
      int weight;
      scanf("%d",&weight);
      buns[weight]++;
    }

    int greedy_sum = 0;
    for(int weight = 1; weight <= 5; weight++){
      if(weight == 5){
        int use_count = (buns[weight] / 2) * 2;
        greedy_sum += use_count / 2;
        buns[weight] -= use_count;
      }
      else{
        int use_count = min(buns[weight],buns[10 - weight]);
        greedy_sum += use_count;
        buns[weight] -= use_count;
        buns[10 - weight] -= use_count;
      }
    }

    printf("%d\n",greedy_sum + dfs(buns,0,0,all_combinations));
  }
}

Measured memory_bytes: 8572
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i =>int.Parse(i)).ToArray();
        if (input.Sum()>= 10)
        {
            Console.WriteLine("error");
        }
        else
        {
Console.WriteLine(input.Sum());
        }
        

        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法

        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();
        
    }
}

Measured memory_bytes: 13396
n,m=map(int,input().split())
INF=10**9
dp=[INF for i in range(2**n)]
dp[0]=0
for i in range(m):
    a,b=map(int,input().split())
    tmp=0
    for j in list(map(int,input().split())):
        tmp+=2**(j-1)
    dp[tmp]=min(dp[tmp],a)
for i in range(2**n):
    for j in range(2**n):
        dp[i|j]=min(dp[i]+dp[j],dp[i|j])
if dp[-1]==INF:
    print(-1)
else:
    print(dp[-1])

Measured memory_bytes: 46296
def f(n):
    if n%2==0:
        return int(n/2)
    else:
        return 3*n+1

s = int(input())
if s==1 or s==2:
    print(4)
    exit()
cnt = 1
while s>1:
    s = f(s)
    cnt += 1
print(cnt+1)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

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

using namespace std;

typedef long long int lli;
typedef unsigned long long int ulli;

int main() {
    lli N;
    cin >> N;
    vector<ulli> L(90, 0);
    L[0] = 2;
    L[1] = 1;
    REP (i, 2, N + 1) {
        L[i] = L[i - 1] + L[i - 2];
    }
    cout << L[N] << endl;
    return 0;
}

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

ll n;

int dfs(ll x, int c1, int c2, int c3) {
  int ret=0;
  ll nx=x*10+7;
  if (nx<=n&&c2&&c3) ret+=1+dfs(nx,c1+1,c2,c3);
  else if (nx<=n) ret+=dfs(nx,c1+1,c2,c3);
  nx=x*10+5;
  if (nx<=n&&c1&&c3) ret+=1+dfs(nx,c1,c2+1,c3);
  else if (nx<=n) ret+=dfs(nx,c1,c2+1,c3);
  nx=x*10+3;
  if (nx<=n&&c1&&c2) ret+=1+dfs(nx,c1,c2,c3+1);
  else if (nx<=n) ret+=dfs(nx,c1,c2,c3+1);
  return ret;
}

int main() {
  cin>>n;
    
  cout<<dfs(0,0,0,0)<<endl;
  return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
map1 = [list(input()) for _ in range(h)]
check_board = [[9e9]*w for _ in range(h)]
for x in range(h):
	for y in range(w):
		map1[x][y] = 1 if map1[x][y] =="#" else 0
check_board[0][0] = map1[0][0]
def cal_ans(a,b,x,y):
	return ((map1[a][b]^map1[x][y])&map1[a][b])+check_board[x][y]
for x in range(h):
	for y in range(w):
		if x < h-1:
			check_board[x+1][y] = min(check_board[x+1][y],cal_ans(x+1,y,x,y))
		if y < w-1:
			check_board[x][y+1] = min(check_board[x][y+1],cal_ans(x,y+1,x,y))
print(check_board[-1][-1])


Measured memory_bytes: 3188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFerrisWheel solver = new AFerrisWheel();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFerrisWheel {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a <= 5) {
                out.println(0);
            } else if (a <= 12) {
                out.println(b / 2);
            } else {
                out.println(b);
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <queue>
#include <cstring>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 400+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a[N];
pair<ll, ll> dp[N][N];
pair<ll, ll> f(int l, int r) {
    if (l == r) return {a[l], 0};
    if (dp[l][r].first != -1) return dp[l][r];
    pair<ll, ll> ans = {numeric_limits<ll>::max(), numeric_limits<ll>::max()};
    for (int i = l; i < r; ++i) {
        auto L = f(l, i);
        auto R = f(i + 1, r);
        if (ans.second > L.first+R.first+L.second+R.second) {
            ans = {L.first+R.first, L.first+R.first+L.second+R.second};
        }
    }
    return dp[l][r] = ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    rep (i, 0, n) cin >> a[i];
    rep (i, 0, n) rep (j, 0, n) dp[i][j] = {-1, -1};
    auto ans = f(0, n-1);
    cout << ans.second << endl;
    return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 105

int n , h;
bool used[MAXX];

int main()
{
    _FastIO;
    memset(used , true , sizeof(used));
    cin >> n;
    vector<pair<int , int> > v;
    for(int i = 0; i < n; i++){
        cin >> h;
        v.push_back({h , i});
    }
    sort(v.begin() , v.end());
    int ans = 0;
    while(!v.empty()){
        int x = v[0].first;
        int y = v[0].second;
        v.erase(v.begin());
        int s = 0;
        for(int i = 0; i < v.size(); i++){
            v[i].first -= x;
        }
        for(int i = 0; i < n; i++){
            if(used[i])
                s++;
            if(i && used[i] && used[i - 1])
                s--;
        }
        used[y] = false;
        ans += s * x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;



class UnionFind {
public:
	vector<int> par, ran;

public:
	UnionFind(int n) {
		par = decltype(par)(n + 4, -1);
		ran = decltype(ran)(n + 4, 0);
	}

private:
	int find(int x) {
		if (par[x] < 0) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

public:
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;

		if (ran[x] < ran[y]) {
			par[find(y)] += par[find(x)];
			par[x] = y;
		}
		else {
			par[find(x)] += par[find(y)];
			par[y] = x;
			if (ran[x] == ran[y]) ran[x]++;
		}
	}

	int size(int x) {
		return -par[find(x)];
	}

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


int main() {
	int n, m; cin >> n >> m;
	UnionFind uf(n);
	for (int i = 0; i < m; i++) {
		int x, y, z; cin >> x >> y >> z;
		x--, y--;
		uf.unite(x, y);
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) cnt += uf.par[i] < 0;
	cout << cnt << endl;
	return 0;
} 

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

int main(){
	int n,q;scanf("%d%d",&n,&q);
	rep(i,q){
		int u,v;scanf("%d%d",&u,&v);
		if(n==1){
			cout<<u<<endl;
			continue;
		}
		set<int>a;
		while(u){
			a.insert(u);
			u=(u+n-2)/n;
		}
		while(v){
			if(a.count(v)){
				cout<<v<<endl;
				break;
			}
			v=(v+n-2)/n;
		}
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
const int MOD=1000000007;//1e9+7
//const int MOD=998244353;
const int INTMAX=2147483647;//2e9
const ll LLMAX=9223372036854775807;//9e17


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll A,B;
    cin>>A>>B;
    cout<<A*B<<endl;
    
    return 0;
}


Measured memory_bytes: 3636
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    xc = collections.Counter(LI())

    c = collections.defaultdict(int)
    d = collections.defaultdict(int)
    for x,v in xc.items():
        if v % 2 == 1:
            c[x % m] += 1
        d[x % m] += v

    r = d[0] // 2
    if m % 2 == 0:
        r += d[m // 2] // 2

    for i in range(1, (m+1)//2):
        t = min(d[i], d[m-i])
        r += t
        r += (d[i] - max(c[i], t)) // 2
        r += (d[m-i] - max(c[m-i], t)) // 2

    return r

print(main())





Measured memory_bytes: 31596
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   int d,t,s;
   cin>>d>>t>>s;
   if(s*t>=d){
    cout<<"Yes"<<"\n";
   }else{
    cout<<"No"<<"\n";
   }


}

Measured memory_bytes: 3660
N,K,Q=map(int,input().split())
a=[]
p=[0]*(N+1)
for i in range(Q):
    a.append(int(input()))

for i in range(Q):
    p[a[i]]+=1


for j in range(1,N+1):
    if K-(Q-p[j])>0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 8632
#include"stdio.h"

int main(void)
{
    int num;    /*入力する数字の数*/
    int normal[100],reverse[100];    /*入力用、反転用配列*/

    scanf("%d",&num);

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

    for(int j=num;j!=0;j--)
    {
        printf("%d",normal[j-1]);
        if(j!=1)
        {
            printf(" ");
        }
        if(j==1)printf("\n");
    }
}


Measured memory_bytes: 2732
//#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)

#define MAXN 100000
int main() {
  int n;
  int a[MAXN];
  int h[MAXN];
  cin >> n;
  forr(i,0,n-1)
    cin >> h[i];
  a[0] = 0;
  a[1] = abs(h[1] - h[0]);
  forr(i,2,n-1) {
    a[i] =
     min(a[i-1] + abs(h[i] - h[i-1]), a[i-2] + abs(h[i] - h[i-2]));
  }
  cout << a[n-1];

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int f,g=0,h;
  cin>>f;
  h=f;
  while(f){
  g+=f%10;
  f=(f-g)/10;
  }
  if(h%g==0){
  cout<<"Yes"<<endl;
  }
  else {
  cout<<"No"<<endl;
  }
}

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

int DP[4][32768];

int main(){
    for(int n=1;n*n<32768;n++){
        int N=n*n;
        DP[0][N]++;
        for(int i=1;i<4;i++){
            for(int j=N;j<32768;j++) DP[i][j]+=DP[i-1][j-N];
        }
    }
    int n;
    while(cin>>n,n){
        cout<<DP[0][n]+DP[1][n]+DP[2][n]+DP[3][n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3596
import scipy.sparse as s,numpy as n
f=n.loadtxt(open(0),skiprows=1)
g=s.csgraph.dijkstra(f)
h=n.where(g,g,1)
print(int(sum(t[j]*all(t[j]<t+h[j])for i,t in enumerate(h)for j in range(i)))*(f==g).all()or-1)

Measured memory_bytes: 18628
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	int n,k;
	scanf("%d%d",&n,&k);
	if(k==0){
		printf("%d\n",n*(n-1)/2);
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				printf("%d %d\n",i+1,j+1);
			}
		}
	}else{
		if(k>(n-1)*(n-2)/2){
			printf("-1\n");
		}else{
			vector<P> ans;
			for(int i=1;i<n;i++){
				ans.push_back(P(1,i+1));
			}
			int diff=(n-1)*(n-2)/2-k;
			for(int i=2;i<=n;i++){
				for(int j=i+1;j<=n;j++){
					if(diff==0)break;
					diff--;
					ans.push_back(P(i,j));
				}
			}
			printf("%d\n",(int)ans.size());
			for(int i=0;i<ans.size();i++){
				printf("%d %d\n",ans[i].first,ans[i].second);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll x;
  cin >> x;
  x -= 400;
  cout << 8 - x / 200 << endl;
}

Measured memory_bytes: 3672
#include<stdio.h>

int main(){
    
    int a,b;

    -1000<=a<=1000;
    -1000<=b<=1000;

    scanf("%d %d",&a,&b);

    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");    
    }

    return 0;
}

Measured memory_bytes: 1808
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,x=0;
    cin>>n;
    for(int i=0; i<100; i++){
            for(int j=0; j<100; j++){
                    if(n == i*7 + j*4){
                            x++;
                    }
                    
            }
    }
    if(x>0){
            cout<< "Yes" <<endl;
    }
    else{
            cout<< "No" <<endl;
    }
}


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

const int MAX_N = 100005;
int par[MAX_N];
int rank_[MAX_N];

// n要素で初期化
void init(int n) {
    rep(i,n) {
        par[i] = i;
        rank_[i] = 0;
    }
}

// 木の根を求める
int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]);
    // if (par[x] == x) return x;
    // else return par[x] = root(par[x]);
}

// xとyが同じ根に属するかどうか
bool same(int x, int y) {
    return root(x) == root(y);
}

// xとyが属する集合を併合
void unit(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    
    if (rank_[x] < rank_[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rank_[x] == rank_[y]) rank_[x]++;
    }
}


int main() {
    int n, m, k;
    cin >> n >> m >> k;

    init(n);

    vector<P> fbNum(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (!same(a, b)) unit(a, b);
        fbNum[a].first++;
        fbNum[b].first++;
    }

    rep(i,k) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (same(a, b)) {
            fbNum[a].second++;
            fbNum[b].second++;
        }
    }
    vector<int> gNum(n);
    rep(i,n) gNum[root(i)]++;
    rep(i,n) {
        int ans = gNum[root(i)] - 1 - fbNum[i].second - fbNum[i].first;
        cout << ans << " ";
    }

    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    if (abs(n - m) >= 2) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    ll np = 1, mp = 1;
    ll mod = 1e9 + 7;
    for (int i = n; i >= 1; i--) {
        np *= i;
        np = np % mod;
    }
    for (int i = m; i >= 1; i--) {
        mp *= i;
        mp = mp % mod;
    }

    ans = np * mp % mod;

    if (n == m) {
        ans *= 2;
        ans = ans % mod;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int N = 1000;
vector<int> G[N];

bool found = false;
vector<int> buf,cycle;
int vis[N] = {};

void dfs(int x){
    vis[x] = 2;
    buf.pb(x);

    for(int nx:G[x]){
        if(vis[nx]==2 && !found){
            int idx = 0;
            while(buf[idx]!=nx) ++idx;

            vector<int> t;
            int sz = buf.size();
            for(int i=idx; i<sz; ++i) cycle.pb(buf[i]);

            found = true;
        }

        if(!vis[nx]) dfs(nx);
    }

    vis[x] = 1;
    buf.pop_back();
}

int main(){
    int n,m;
    cin >>n >>m;
    vector<pi> e(m);
    rep(i,m){
        int a,b;
        cin >>a >>b;
        --a;
        --b;

        e[i] = {a,b};
        G[a].pb(b);
    }

    rep(i,n)if(!vis[i] && !found) dfs(i);
    if(!found){
        cout << -1 << "\n";
        return 0;
    }

    rep(loop,n){
        bool upd = false;

        int C = cycle.size();
        vector<int> idx(n,-1);
        rep(i,C) idx[cycle[i]] = i;

        for(const pi &p:e){
            int a = p.fi, b = p.se;
            if(idx[a]!=-1 && idx[b]!=-1 && (idx[a]+1)%C != idx[b]){
                vector<bool> next(C);
                if(idx[a] < idx[b]){
                    fill(all(next), true);
                    for(int i=idx[a]+1; i<idx[b]; ++i) next[i] = false;
                }
                else{
                    fill(all(next), false);
                    for(int i=idx[b]; i<=idx[a]; ++i) next[i] = true;
                }

                vector<int> t;
                rep(i,C)if(next[i]) t.pb(cycle[i]);

                cycle = t;
                upd = true;
                break;
            }
        }
        if(!upd) break;
    }

    cout << cycle.size() << "\n";
    for(int i:cycle) cout << i+1 << "\n";
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int i,a,p,m,n;
  char s[20];
  for(i=0;i<9;i++){
    scanf("%s %d %d",s,&a,&p);
    m=a*200+p*300;
    n=a+p;
    printf("%s %d %d\n",s,n,m);
  }
  return 0;
}

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

using namespace std;
const int maxn = 5005;
typedef long long ll;
int dp[2][maxn],sum[maxn];
int main() {
	int n,mod,rt = 0;
	cin>>n>>mod;
	dp[rt][0] = 1;
	for(int i = 1;i < n;++i) {
		rt ^= 1;
		int s = i;
		if(n%2 == 1&& s > n/2 + 1) s = (n-i+1);
		if(n%2 == 0 && s > n/2) s = (n-i+1);
		memset(dp[rt],0,(n+1)<<2);
	//	cout<<s<<'\n';
		for(int j = 0;j < n; ++j) {
			for(int k = 0;k < n&&j-k*s>=0; ++k) {
				dp[rt][j] += dp[rt^1][j-k*s];
				if(dp[rt][j] >= mod) dp[rt][j] -= mod;
			}
		}
	}
	ll ans = 0;
	for(int i = 0;i < n; ++i) {
		int j = n-i-1;
		ans += 1ll*(j+1)* dp[rt][i];
		ans %= mod;
	}
	cout<<ans<<'\n';
	return 0;
}



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

bool comp(const pair<int, int> &x, const pair<int, int> &y){
	return x.second * (y.first  - 1) < y.second * (x.first - 1);
}

signed main(){
	int N, T, i, j;
	int M = 30;
	scanf("%lld%lld", &N, &T);
	vector<pair<int, int>> AB(N);
	for(i = 0; i < N; i++){
		int a, b;
		scanf("%lld%lld", &a, &b);
		AB[i].first = a + 1;
		AB[i].second = a + b + 1;
	}
	sort(AB.begin(), AB.end(), comp);
//	printf("test2\n");
	int N1, N2;
	for(i = 0; i < N; i++){
		if(AB[i].first == 1){
			break;
		}
	}
	N1 = i;
	N2 = N - N1;
//	printf("(N1, N2) = (%lld, %lld)\n", N1, N2);
	vector<int> rest(N2);
	for(i = N1; i < N; i++){
		rest[i - N1] = AB[i].second;
	}
	sort(rest.begin(), rest.end());
	vector<vector<int>> dp(N1 + 1, vector<int>(M + 1, T + 1));
	dp[0][0] = 0;
	for(i = 1; i <= N1; i++){
		dp[i][0] = dp[i - 1][0];
		for(j = 1; j <= M; j++){
			dp[i][j] = min(dp[i - 1][j], AB[i - 1].first * dp[i - 1][j - 1] + AB[i - 1].second);
			dp[i][j] = min(dp[i][j], T + 1);
		}
	}
/*	for(i = 0; i <= N1; i++){
		for(j = 0; j <= M; j++){
			printf("dp[%lld][%lld] = %lld\n", i, j, dp[i][j]);
		}
	}
*/	vector<int> s(N2 + 1, 0);
	for(i = 1; i <= N2; i++){
		s[i] = s[i - 1] + rest[i - 1];
	}
	int ans = 0;
	for(i = 0; i <= N1; i++){
		for(j = 0; j <= M; j++){
			if(dp[i][j] <= T){
				int now = j + upper_bound(s.begin(), s.end(), T - dp[i][j]) - s.begin() - 1;
				ans = max(ans, now);
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 58112
a, op, b = gets.split
while op != '?'
    a, b = a.to_i, b.to_i
    case op
    when '+'
        puts a + b
    when '-'
        puts a - b
    when '*'
        puts a * b
    when '/'
        puts a / b
    end
    a, op, b = gets.split
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define int long long
//#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//#define mod 1000000007

using namespace std;

int32_t main()
{
    int num;
    cin >> num;
    if(num==0)
    cout<<"1"<<endl;
    else
    {
        cout<<"0";
    }
    
    
    
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

struct UnionFind {
	vector<int> par; // 親ノード
	vector<int> rank; // ランク

	UnionFind(int n = 1) {
		init(n);
	}

	void init(int n = 1) {
		par.resize(n); rank.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
	}

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

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

	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y);
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		return true;
	}
};

signed main() {
	ll n, m, k, l;

	cin >> n >> m;

	UnionFind uf(n + m);

	REP(i, n) {
		cin >> k;

		REP(j, k) {
			cin >> l;
			uf.unite(l - 1, m + i);
		}
	}

	REP(i, n - 1) {
		if (!uf.same(m + i, m + i + 1)) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
vector<int> a;
int in;
for(int i=0;i<3;i++)
{
cin>>in;
a.push_back(in);
}
sort(a.begin(),a.end());
for(int i=0;i<3;i++)
{
if(i)cout<<" ";
cout<<a[i];
}
cout<<endl;
return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <map>
#include <set>
#define ll long long


using namespace std;

ll H, W, N;

int main(){
	cin >> H >> W >> N;
	int a, b;
	map<pair<int, int>, int> mp;

	for (int i = 0; i < N; ++i)
	{
		pair<int, int> p;
		cin >> a >> b;
		mp[pair<int, int>(a-1, b-1) ]++;
		mp[pair<int, int>(a-1, b) ]++;
		mp[pair<int, int>(a, b-1) ]++;
		mp[pair<int, int>(a, b) ]++;
		mp[pair<int, int>(a+1, b+1) ]++;
		mp[pair<int, int>(a+1, b) ]++;
		mp[pair<int, int>(a, b+1) ]++;
		mp[pair<int, int>(a+1, b-1) ]++;
		mp[pair<int, int>(a-1, b+1) ]++;
		// cout << "pair "<< p.first << " "<< p.second <<"count後" << mp[p]  << endl;
	}
	ll ans[10] = {0};
	ll size = 0;
	for (auto itr = mp.begin(); itr != mp.end(); ++itr)
	{
		if(itr->first.first > 1 && itr->first.second > 1 && itr->first.first < H && itr->first.second < W ){
			ans[itr->second]++;
			size++;
			// cout << itr->first.first <<itr->first.second<<" "<< itr->second<<endl;
		}
	}
	// cout << "size:"<<size << endl;
	ans[0] = (W - 2) * (H - 2) - size;

	for (int i = 0; i < 10; ++i)
	{
		 cout << ans[i] << endl;
	}


}

Measured memory_bytes: 56448
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 h, w;
vector<string> s;
vector<vector<i64>> dp[4];

i64 di[] = { 1, 0, -1, 0 },
    dj[] = { 0, 1, 0, -1 };

i64 f(i64 i, i64 j, i64 k) {
  if (0 <= i && i < h && 0 <= j && j < w && s[i][j] == '.') {
    if (dp[k][i][j] >= 0) return dp[k][i][j];
    return dp[k][i][j] = 1 + f(i + di[k], j + dj[k], k);
  }
  return 0;
}

int main() {
  cin >> h >> w;
  read_n(s, h);
  
  for (i64 k = 0; k < 4; ++k) init_n(dp[k], h, vector<i64>(w, -1));

  i64 ans = 0;
  for (i64 i = 0; i < h; ++i) {
    for (i64 j = 0; j < w; ++j) {
      if (s[i][j] == '#') continue;
      i64 s = 1 - 4;
      for (i64 k = 0; k < 4; ++k) {
        s += f(i, j, k);
      }
      ans = max(ans, s);
    }
  }
  cout << ans << '\n';
  return 0;
}



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

int A,B,N;
string ans;
vector<int> V;

int main()
{
    scanf("%d%d",&A,&B);
    N = A + B;

    if(A <= B)
    {
        printf("Impossible\n");
        return 0;
    }

    for(int i = 0; i < N; i++)
    {
        if(V.size() == 0)V.push_back(i),i++;
        if(V.size() > B)break;
        printf("? %d %d\n",V.back(),i);
        fflush(stdout);
        char res;
        scanf(" %c",&res);
        if(res == 'Y')V.push_back(i);
        else V.pop_back(),B--;
    }

    for(int i = 0; i < N; i++)
    {
        printf("? %d %d\n",V.back(),i);
        fflush(stdout);
        char res;
        scanf(" %c",&res);
        if(res == 'Y')ans += '1';
        else ans += '0';
    }
    printf("! ");
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  string s;
  cin >> s;
  int    len = s.size();
  bool   ret = true;
  string s01(s), s02(s);
  reverse(all(s02));
  string s11(s.begin(), s.begin() + len / 2), s12(s11);
  reverse(all(s12));
  string s21(s.begin() + (len + 3) / 2 - 1, s.end()), s22(s21);
  reverse(all(s22));
  cout << (s01 == s02 && s11 == s12 && s21 == s22 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

R = [i for i in range(N) if S[i] == "R"]
G = [i for i in range(N) if S[i] == "G"]
B = [i for i in range(N) if S[i] == "B"]

ans = len(R) * len(G) * len(B)
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = 2 * j - i
        if k < N and S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
             ans -= 1

print(ans)

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

const int N = 1e6+7, KK = 12, RT = 6;
int f[N], p3[N];

void pre() {
    p3[0] = 1;
    for (int i=1; i<=KK; i++)    p3[i] = p3[i-1]*3;

    for (int i=0; i<N; i++) {
        for (int k=0; k<KK; k++) {
            int d = (i/p3[k])%3;
            if (d == 1)      f[i] += p3[k]*2;
            else if (d == 2) f[i] += p3[k];
        }
    }

}

int aa[N], bb[N];
vector<int> v[N];
int asol[N];
int temp[N];

int vid[N];

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

    pre();

    int n;
    string s;
    cin>>n>>s;


    int mx = p3[max(0, n-RT)];
    int my = p3[min(RT, n)];
    int all = p3[n];


    for (int i=0; i<mx; i++)
        for (int j=0; j<my; j++)
            v[i].push_back(my*i + j);

    for (int j=0; j<my; j++)    asol[j] = j;
    for (int i=0; i<mx; i++)    vid[i] = i;

    for (char c: s) {
        if (c == 'R')  {
            for (int i=0; i<mx; i++)    temp[i] = v[vid[i]][asol[my-1]];

            int st = asol[my-1];
            for (int i=my-1; i>0; i--)    asol[i] = asol[i-1];
            asol[0] = st;

            for (int i=1; i<mx; i++)    v[vid[i]][asol[0]] = temp[i-1];
            v[vid[0]][asol[0]] = temp[mx-1];
        }
        else {
            for (int i=0; i<my; i++)
                if (f[i] > i)
                    swap(asol[i], asol[f[i]]);

            for (int i=0; i<mx; i++)
                if (f[i] > i)
                    swap(vid[i], vid[f[i]]);
        }

//        for (int i=0; i<my; i++)    cout<<asol[i]<<" "; cout<<":::"<<endl;
//        for (int i=0; i<my; i++)    cout<<v[0][i]<<" "; cout<<"---"<<endl;
    }

    for (int i=0; i<mx; i++)
        for (int j=0; j<my; j++)
            aa[i*my+j] = v[vid[i]][asol[j]];


    for (int i=0; i<all; i++) bb[aa[i]] = i;
    for (int i=0; i<all; i++) cout<<bb[i]<<" ";
    cout<<endl;
}


Measured memory_bytes: 38708
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
     int n,k,p[5005],c[5005];
     cin>>n>>k;
     for(int i=0;i<n;i++)
     cin>>p[i],p[i]--;
     for(int i=0;i<n;i++)
     cin>>c[i];
     ll ans=-INT_MAX;
     for(int i=0;i<n;i++)
     {
         int now=i;
         ll c_sum=0,c_cnt=0;
         while(true)
         {
             c_cnt++;
             c_sum+=c[now];
             now=p[now];
             if(now==i)
             break;
         }
         ll sum=0,cnt=0;
         while(true)
         {
             cnt++;
             sum+=c[now];
             if(cnt>k)
             break;
             ll temp=(k-cnt)/c_cnt;
             temp=sum+max(0ll,c_sum)*temp;
             ans=max(ans,temp);
             now=p[now];
             if(now==i)
            break;
         }
     }
     cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
   int N,M,sum=0,i;
   cin >> N >> M;
   int A[M];
   for(i=0;i<M;i++){
       cin >> A[i];
       sum+=A[i];
   }
   if(sum>N) cout << "-1";
   else cout << N-sum;
   
   return 0;
}

Measured memory_bytes: 3664
li = [0]*26
alpha2num = lambda c: ord(c) - ord('A')
w = input().upper()
for i in range(len(w)):
  k = alpha2num(w[i])
  li[k] += 1
for j in li:
  if j % 2:
    print("No")
    break
else:
  print("Yes")

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

struct f {
    string l;
    int  p, a, b, c, d, e, f, s, m;
    double rate;
    void input() {
        cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
    }
    void calc() {
        double k = 0;
        rep(i, m) {
            if (i == 0) k += a+b+c+d+e;
            else k += d+e;
        }
        double kk = (f*m*s)-p;
        rate = kk/k;
    }
    void print() {
        cout << l << endl;
    }
};

int main() {
    int n;
    int count = 0;
    while (cin >> n) {
        if (n == 0) break;
        vector<f> a(n);
        rep(i, n) {
            a[i].input();
            a[i].calc();
        }
        sort(a.begin(), a.end(), [](const f& a, const f& b) {
            if (a.rate == b.rate) {
                return a.l < b.l;
            }
            return a.rate > b.rate;
        });
        rep(i, n) {
            a[i].print();
        }
        cout << "#" << endl;
    }
    return 0;
}



Measured memory_bytes: 3136
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int W, A, B; scanf("%d%d%d", &W, &A, &B);
	if (A > B) swap(A, B);

	if (B <= A + W) return !printf("0\n");
	printf("%d\n", B - A - W);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
// n = mk + k = k(m+1) k<m
int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i*i <= n; ++i){
        if(n%i==0){
            ll x = n/i;
            x--;
            if(x > i) ans += x;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
long x[200001];
using namespace std;
void buildheap(int index,int n) {
	int j, maxi, tmp;
	j = index;
	tmp = x[index];
	while ((j << 1) <= n) {
		maxi = (j << 1);
		if (maxi + 1 <= n && x[maxi] < x[maxi + 1])
			maxi++;
		if (x[maxi] <= tmp)
			break;
		x[j] = x[maxi];
		j = maxi;
	}
	x[j] = tmp;
}

int main()
{
	int n,k;
	cin >> n>>k;
	long long sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	for (int i = n; i >=1; i--) {
		buildheap(i, n);
	}
	for (int i = 1; i <= k; i++) {
		if (x[1] == 0)
			break;
		x[1] /=2;
		buildheap(1, n);
	}
	for (int i = 1; i <= n; i++) {
		sum+= x[i];
	}
	cout << sum;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
past = 0

for i in range(n):
    ryouri = a[i]-1
    ans += b[ryouri]
    if i >= 1:
      if (ryouri) == past+1:
        ans += c[ryouri-1]
    past = ryouri
print(ans)
      

Measured memory_bytes: 3064
while True:
    h,w = map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        str = ''
        for j in range(w):
            if (i+j) % 2 == 0:
                str += '#'
            else:
                str += '.'
        print(str)
    print("")


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

#define REP(i, n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 1e9

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

typedef long long ll;

using namespace std;

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    vector<int> L(100001);
    vector<int> R(100001);

    fill(ALL(L), INF);
    fill(ALL(R), INF);

    REP(i, M) cin >> L[i] >> R[i];
    
    sort(ALL(L));
    sort(ALL(R));

    int ans;

    if (R[0] - L[M-1] < 0)
    {
        ans = 0;
    }
    else if(R[0] - L[M-1] > N)
    {
        ans = N;
    }
    else
    {
        ans = (R[0] - L[M-1]) + 1; 
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1024