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

// APG4b-G
int main() {
  int N;
  cin >> N;
  string ans = "No";

  for(int j = 1; j < 10; j++) {
    int a = j*1000;
    for (int i = 0; i < 10; i++) { // x000 ~ x999
      int b = a + i*111;
      if (N==b) {
        ans = "Yes";
        break;
      }
      
    }
    if(ans=="Yes") break; // eco

    a = j*111*10;
    for (int i = 0; i < 10; i++) { // xxx0 ~ xxx9
      if (N==(a+i)) {
        ans = "Yes";
        break;
      }
    }
    if(ans=="Yes") break; // eco
    
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
n= int(input())
s_list= list(input())
count=0
rr,bb,gg=0,0,0
for i in range(0,n):
    if s_list[i]=="R":
        rr=rr+1
    elif s_list[i]=="G":
        gg=gg+1
    else:
        bb=bb+1
sum=rr*gg*bb

for p in range(0,n-2):
    for q in range(p+1,n-1):
        if s_list[p] == s_list[q]:
            continue
        elif 2*q-p<n and s_list[2*q-p]!=s_list[p] and s_list[2*q-p]!=s_list[q]:
            count= count+1
print(sum-count)


Measured memory_bytes: 9124
#include<cstdio>
#include<map>
typedef __int128 i128;
std::map<i128,int>M[101];
const int mod=998244353;
int dfs(int n,i128 S){
	if(!n)return 1;
	if(M[n].count(S))return M[n][S];
	int sum=dfs(n-1,S>>1)*(S&1?2:1)%mod;
	i128 st=0;
	for(int k=1;k<=n;k++){
		st=st<<1|1;
		i128 T=S&st;
		for(int w=k;w<=n;w+=k){
			if(w>k)sum=(sum+1ll*dfs(k,T)*dfs(n-w,S>>w))%mod;
			T&=S>>w;
		}
	}
	return M[n][S]=sum;
}
char str[110];
int main(){
	scanf("%s",str);
	int n=0;while(str[n])n++;
	i128 S=0;
	for(int i=n;i--;)S=S<<1|(str[i]=='1');
	printf("%d\n",dfs(n,S));
}

Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int n;
int main(void){
    // Your code here!
    cin >> n;
    bool go = true;
    int tim = 0, X = 0, Y = 0;
    for (int i = 0; i < n; i++) {
        int t, x, y, p, q, r;
        cin >> t >> x >> y;
        p = t - tim, q = x - X, r = y - Y;
        tim = t, X = x, Y = y;
        if ((p - q - r) % 2 == 1 || p < q + r) go = false;
    }
    if (go) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
def Sieve_of_Eratosthenes(N):
    if N<2:
        prime = [False for i in range(N+1)]
        return prime
 
    prime = [True for i in range(N+1)]
    prime[0] = False
    prime[1] = False
 
    for i in range(2, int(N**0.5)+1):
        if prime[i]:
            for j in range(i*2, N+1, i):
                prime[j] = False
 
    return prime

n,p=map(int,input().split())


if n>50: print(1)
elif n==1: print(p)
else:
    prime=Sieve_of_Eratosthenes(int(p**(1/n)))
    ans=1
    for i in range(2,len(prime)):
        tmp=0
        while p%i==0:
            p//=i
            tmp+=1
        if tmp>=n:
            for _ in range(tmp//n):
                ans*=i
    print(ans)

Measured memory_bytes: 10008
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;

typedef pair<int, P> PP;

int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};

int main()
{
    int h, w, sy, sx, gy, gx;
    cin >> h >> w >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    vector<string> field(h);
    rep(i,h) cin >> field[i];

    auto dist = make_vec(h, w, INF);
    vector<queue<P>> que(2); 
    dist[sy][sx] = 0;
    que[0].emplace(sy, sx);
    while(!que[0].empty())
    {
        auto [y, x] = que[0].front();
        que[0].pop();
        rep2(dy,-2,3) rep2(dx,-2,3)
        {
            int ny = y + dy;
            int nx = x + dx;
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(field[ny][nx] == '#') continue;
            if(abs(dy) + abs(dx) <= 1) //移動1を使う
            {
                if(chmin(dist[ny][nx], dist[y][x]))
                    que[0].emplace(ny, nx);
            }
            else //移動2を使う
            {
                if(chmin(dist[ny][nx], dist[y][x] + 1))
                    que[1].emplace(ny, nx);
            }
        }
        if(que[0].empty()) swap(que[0], que[1]);
    }

    int ans = dist[gy][gx];
    if(ans == INF) ans = -1;
    cout << ans << endl;
    // cout << dist << endl;

    return 0;
}

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

struct comp2{
    bool operator()(const pair<int,int> &p1,const pair<int,int> &p2) const {
        if (p1.second == p2.second) {
            return p1.first < p2.first;
        } else {
            return p1.second < p2.second;
        }
    }
};

int main(void)
{
    int n,m;
    cin >> n >> m;
    priority_queue<pair<int,int>,
                   vector<pair<int,int>>,
                   greater<pair<int,int>>> pq1;
    priority_queue<pair<int,int>,
                   vector<pair<int,int>>,
                   comp2> pq2;

    for(int i = 0; i < n; i++) {
        int a,b;
        cin >> a >> b;
        pq1.push(make_pair(a,b));
    }

    int ans = 0;
    for(int i = 1;i <= m ; i++) {
        while(!pq1.empty() && pq1.top().first <= i) {
            pq2.push(pq1.top());
            pq1.pop();
        }
        if (!pq2.empty()) {
            ans += pq2.top().second;
            pq2.pop();
        }
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
const int maxn=2e5+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int a[maxn],b[maxn],c1[maxn],c2[maxn],p[maxn];
vector<pii> v;

int32_t main()
{
    IOS
    int n;
    cin>>n;
    int ans1=0,ans2=0;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
        ans1+=a[i];
        ans2+=b[i];
        v.pb(mkp(a[i],i));
        v.pb(mkp(b[i],-i));
    }
    int ans=inff;
    sort(all(v));
    for (int i=1;i<=2*n;i++)
    {
        if (v[i-1].S>0) c1[v[i-1].S]=i;
        if (v[i-1].S<0) c2[-v[i-1].S]=i;
        p[i]=p[i-1]+v[i-1].F;
    }
    for (int i=1;i<=n;i++)
    {
        for (int j=n-2;j<=n;j++)
            if (j+(c1[i]>j)+(c2[i]>j)==n)
            {
                ans=min(ans,p[j]+(c1[i]>j ? a[i] : 0)+(c2[i]>j ? b[i] : 0));
                break;
            }

    }
    cout<<min({ans,ans1,ans2})<<endl;
}



Measured memory_bytes: 11008
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100010;

int n, k;
int t[N], a[N];

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%d", &t[i]);
    int ans = t[n] - t[1] + 1;
    for (int i = 1; i < n; ++i) a[i] = t[i + 1] - t[i] - 1;
    nth_element(a + 1, a + k, a + n, greater<int>());
    ans -= accumulate(a + 1, a + k, 0);
    printf("%d\n", ans);
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<long> prime, sieve(31622, 1);
    for(long i = 2; i < 31622; ++i)
        if(sieve[i]){
            prime.push_back(i);
            for(auto j = i * i; j < 31622; j += i)sieve[j] = 0;
        }

    vector<long> a(N);
    long C;
    for(auto& i : a)cin >> i;
    cin >> C;
    long u{C};
    for(const auto i : a)u = __gcd(u, abs(i));

    vector<long> ans;
    for(const auto p : prime)
        if(u % p == 0){
            ans.push_back(p);
            while(u % p == 0)u /= p;
        }else if(p <= N && C % p == 0){
            vector<long> v(p);
            for(unsigned long j = 0, k = 0; j < N; ++j){
                v[k] += a[j];
                if(++k == p - 1)k = 0;
            }
            [&]{
                for(auto j : v)if(j % p)return;
                ans.push_back(p);
            }();
        }
    for(const auto i : ans)cout << i << endl;
    if(u != 1)cout << u << endl;
}

Measured memory_bytes: 768
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        Solver s = new Solver();
        for (int i = 1; i <= t; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

}

class Solver {
    void solve(int test, InputReader in, PrintWriter out) throws IOException {
        int x = in.nextInt();
        x = 24 - x + 24;
        out.println(x);
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
    }

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

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

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

    public String nextLine() throws IOException {
        return br.readLine();
    }

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

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

int main() {
  int N, N1;
  int d = 1;
  int cnt = 0;
  int fx = 0;
  cin >> N;
  N1 = N;

  while (N / d) {
    d *= 10;
    cnt += 1;
  }
  d /= 10;
  for (int i = 0; i < cnt; i++) {
    fx += N / d;
    N %= d;
    d /= 10;
  }
  if (N1 % fx) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
ll c[10][10]={},d[10][10]={};

int main() {

	ll n;
	cin>>n;
	ll t=10,ans=0;
	for(int i=1; i<n+1; i++){
		if(i>=t)t*=10;
		c[i/(t/10)][i%10]++;
		d[i%10][i/(t/10)]++;
	}
	rep(i,10){
		rep(j,10){
			ans+=c[j][i]*d[j][i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

typedef pair<long, char> pii;

bool compare(pii x, pii y){
  return x.first < y.first;
}

int main(){
  long X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<pii> a,b,c,d;
  for(int i = 0; i < A; i++){
    long x;
    cin >> x;
    a.push_back(make_pair(x, 'A'));
    d.push_back(make_pair(x, 'A'));
  }
  for(int i = 0; i < B; i++){
    long x;
    cin >> x;
    b.push_back(make_pair(x, 'B'));
    d.push_back(make_pair(x, 'B'));
  }
  for(int i = 0; i < C; i++){
    long x;
    cin >> x;
    c.push_back(make_pair(x,'C'));
    d.push_back(make_pair(x,'C'));
  }
  
  sort(d.begin(), d.end(), compare);
  cerr << d[d.size() -1].first << endl;
  
  long ans = 0;
  long a_cnt = 0;
  long b_cnt = 0;
  long c_cnt = 0;
  int index = d.size()-1;
  while(true){
    if(a_cnt + b_cnt + c_cnt == X + Y) break;
    pii x = d[index];
    if(x.second == 'A' && a_cnt < X){
      a_cnt++;
      ans += x.first;
    }
    if(x.second == 'B' && b_cnt < Y){
      b_cnt++;
      ans += x.first;
    }
    if(x.second == 'C'){
      ans += x.first;
      c_cnt++;
    }
    index--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 15584
#include <stdio.h>

int main(void)
{
	int N,a=0;
	scanf("%d",&N);
	if(65<=N&&N<=90){
		a+=1;
	}else if(97<=N&&N<=122){
		a+=2;
	}else{
		a=0;
	}
	printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    while (1) {
        int dice;
        cin >> dice;
        if (dice == 0)break;

        int n;
        cin >> n;
        n += 2;
        VI d(n, 0);
        FOR(i, 1, n - 1)cin >> d[i];

        vector<vector<bool>> g(n, vector<bool>(n, false));
        FOR(i, 0, n)g[i][i] = true;
        FOR(i, 0, n) {
            eFOR(j, 1, dice) {
                int next = i + j + d[min(i + j, n - 1) ];
                chmax(next, 0), chmin(next, n - 1);
                g[i][next] = true;
            }
        }
        FOR(k, 0, n)FOR(i, 0, n)FOR(j, 0, n) {
            if (g[i][k] && g[k][j])g[i][j] = true;
        }
        string ans = "OK\n";
        FOR(i, 0, n)if (g[0][i]) {
            if (!g[i][n - 1])ans = "NG\n";
        }
        cout << ans;
    }
    
}


Measured memory_bytes: 3176
module Color
  WHITE = 0
  GRAY = 1
  BLACK = 2
end

class MyNode
  attr_reader :v, :c
  def initialize(v, c)
    @v = v
    @c = c
  end
end

class PriorityQueue

  def initialize
    @arr = []
    @h = 0
  end

  def insert(node)
    @h += 1
    @arr[@h] = - 1.0/0
    heap_increase_key(@h, node)
    # puts "h : #{@h}"
  end

  def heap_increase_key(i, node)
    @arr[i] = node
    while i > 1 && @arr[parent(i)].c < @arr[i].c do
      @arr[i], @arr[parent(i)] = @arr[parent(i)], @arr[i]
      i = parent(i)
    end
  end

  def heap_extract_max()
    # puts "h : #{@h} extract"
    # puts "arr : #{@arr}"
    # puts "empty? : #{empty?}"
    if @h < 1
      raise "HEAP_UNDERFLOW"
    end
    max = @arr[1]
    @arr[1] = @arr.pop
    @h -= 1
    max_heapify(1)
    # puts "arr : #{@arr}"
    max
  end

  def parent(i)
    ( i / 2 ).ceil
  end

  def right(i)
    2 * i + 1
  end

  def left(i)
    2 * i
  end

  def max_heapify(i)
    l = left(i)
    r = right(i)
    h = @arr.size - 1

    # puts "i : #{i}, l : #{l}, r : #{r}, h : #{h} arr[r] : #{arr[r]}, arr : #{arr}"

    largest = nil
    if l <= h && @arr[l].c > @arr[i].c
      largest = l
    else
      largest = i
    end
    if r <= h && @arr[r].c > @arr[largest].c
      largest = r
    end

    if largest != i
      @arr[i], @arr[largest] = @arr[largest], @arr[i]
      max_heapify(largest)
    end
  end

  def empty?
    @h == 0
  end
end

def dijkstra(s)
  d = Array.new($n, Float::INFINITY)
  color = Array.new($n, Color::WHITE)
  d[s] = 0

  pq = PriorityQueue.new
  pq.insert(MyNode.new(0, 0))
  

  while !pq.empty?
    # puts d.join(' ')
    # puts pq
    
    node = pq.heap_extract_max
    u = node.v
    cost = node.c

    # puts $adj[u].join(' ')
    # puts "====="

    color[u] = Color::BLACK

    if d[u] < cost * -1
      next
    end

    $adj[u].each do | vc |
      v = vc[0]
      c = vc[1]
      # puts "vc: #{vc}, v: #{v}, c: #{c}"
      if color[v] == Color::BLACK
        next
      end
      if d[u] + c < d[v]
        d[v] = d[u] + c
        color[v] = Color::GRAY
        pq.insert(MyNode.new(v, d[v] * -1))
      end
    end
  end
  d
end

$n = gets.to_i
$adj = Array.new($n) { [] }
$n.times do |i|
  u, k, *arr = gets.split.map(&:to_i)
  arr.each_slice(2) do |v, c|
    $adj[u] << [v, c]
  end
end
# puts "====="
# $m.each do |k|
#   puts k.join(' ')
# end
# puts "====="

d = dijkstra(0)
d.each_with_index do | v, i |
  puts "#{i} #{v}"
end



Measured memory_bytes: 46084
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int count = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt() - 1;
			if (a[i] < i && a[a[i]] == i) count++;
		}

		System.out.println(count);
	}
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c, d, n;
	cin >> a >> b >> c >> d >> n;

	ll tmp = min(4 * a, min(2 * b, c));

	ll ans = tmp*n;

	if (n % 2) {
		ans = min(ans, tmp + n / 2 * d);
	}
	else {
		ans = min(ans, (n + 1) / 2 * d);
	}

	cout << ans << endl;


}


Measured memory_bytes: 256
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const N = parseInt(input[0].split(" ")[0]);
    const M = parseInt(input[0].split(" ")[1]);
    let s = {}
    for(let i = 1; i<=M; i++){
        let digit = parseInt(input[i].split(" ")[0])
        let num = parseInt(input[i].split(" ")[1])
        if(s[digit] && s[digit] !== num){
            console.log('-1')
            return
        } else if (N >= 2 && digit === 1 && num == 0){
            console.log('-1')
            return
        } else {
            s[digit] = num
        }
    }
    let ans = new Array(N).fill(0)
    if(N==1){
        console.log(s[1] || 0)
        return
    }
    ans[0] = 1
    for(let key of Object.keys(s)){
        ans[key-1] = s[key]
    }
    console.log(Number(ans.join("")))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 7624
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  while(1){
    getline(cin,s);
    if(s=="END OF INPUT")break;
    int ans=0;
    s=s+" ";
    rep(i,s.size()){
      if(s[i]==' '){
	cout<<ans;
	ans=0;
      }else{
	ans++;
      }
    }
    cout<<endl;
  }
}

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

int a[500], b[500];
string S, T;

int main(){
    cin >> S >> T;
    auto j = T.begin();
    for(auto i : S){
        if(a[i] > 0 || b[*j] > 0){
            if(a[i] != *j || b[*j] != i)return 0 & puts("No");
        }else{
            a[i] = *j;
            b[*j] = i;
        }
        ++j;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  ll ans = 0;
  if(n % 2 == 0) {
    ll nn = n;
    ll sum = 0;
    while(nn >= 5) {
      nn /= 5;
      sum += nn / 2;
    }
    ans = sum;
  }

  cout << ans << endl;
}


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

int main(){
	int n;
	while(cin>>n){
		vector<bool> a(n+1,true);
		for(int i=2;i<=n+1;i++){
			if(a[i]){
				for(int j=i*2;j<n+1;j+=i){
					a[j]=false;
				}
			}
		}
		int ans=0;
		for(int i=2;i<n+1;i++){
			if(a[i])ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3196
n = int(input())
lista = list(map(int, input().split()))
count = 0

while True:
    temp = 0
    for i in range(n):
        if lista[i] % 2 == 0:
            lista[i] //= 2
            temp += 1

    if temp == n:
        count += 1
    else:
        break

print(count)


Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<int> a;

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i){ int n; scanf("%d", &n); a.push_back(n); }
    sort(a.begin(), a.end());
    
    int n = a[N - 1];
    
    int ans = 0;
    if(n % 2 == 0){
        int cmx = (n - 1) / 2 + 1;
        auto itr = lower_bound(a.begin(), a.end(), cmx);
        int high = *min_element(itr, a.end());
        int low = *max_element(a.begin(), itr);
        ans = (abs(cmx - high) < abs(cmx - low)) ? high : low;
    }
    else{
        int cmx1 = (n - 1) / 2 + 1, cmx2 = n - cmx1;
        auto itr1 = lower_bound(a.begin(), a.end(), cmx1);
        auto itr2 = lower_bound(a.begin(), a.end(), cmx2);
        if(itr1 != a.end() && cmx1 == *itr1) ans = cmx1;
        else if(itr2 != a.end() && cmx2 == *itr2) ans = cmx2;
        else{
            int high = *min_element(itr2, a.end());
            int low = *max_element(a.begin(), itr1);
            ans = (abs(cmx1 - low) < abs(cmx2 - high)) ? low : high;
        }
    }
    printf("%d %d\n", n, ans);
    
    return 0;
}

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

using namespace std ; 

const int N = 2e5 + 7 ; 

int pre[N] ; 
int n , m , k ; 
string s ; 
vector<int> ans ; 

int dp[N] ; 

int solve(int i){
    if(i>=n)return 0 ; 
    if(dp[i]!=-1)return dp[i] ; 
    if(s[i]=='o'){
        return dp[i] = 1 + solve(i + k + 1) ; 
    }
    return dp[i]  = solve(i+1) ; 
}


int main(){ 
    memset(dp , -1 , sizeof dp ) ; 
    ios_base::sync_with_stdio(0) ; 
    cin.tie(0) ; 
   // freopen("in.in" , "r" , stdin) ; 

    cin>>n>>m>>k ;
    cin>>s ; 

    for(int i =0 ; i < n;i++){
        solve(i)  ;
    }

    int l =-1 , sum = 0 ; 
    for(int i = 0 ; i < n;i++){
        pre[i] = sum ; 
        if(i<=l)continue ; 
        if(s[i]=='o'){
            sum++ ; 
            l = i + k ; 
        }
        pre[i] = sum ; 
    }
    int r= n+ N ; 
    for(int i = n-1 ; i >=0;i--){
        if(s[i]=='o'){
            int leftix = min(i-1 , r - k -1  );
            int right = solve(i+1) ; 
            int left = (leftix<0 ?0 : pre[leftix]) ; 
            if(right + left < m){
                ans.push_back(i+1) ; 
            }
            if(solve(i) > solve(r))
               r = i ; 
        }
    }
    reverse(ans.begin() , ans.end()) ; 
    for(auto u : ans){
        cout<<u<<"\n" ; 
    }
    return 0 ; 
}

Measured memory_bytes: 10380
/**
*    created: 13.06.2020 20:59:29
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}

Measured memory_bytes: 3596
# coding=utf-8


class Dice(object):

    def __init__(self, label):
        self.label = label

    def rotateS(self):
        s1, s2, s3, s4, s5, s6 = self.label
        self.label = [s5, s1, s3, s4, s6, s2]

    def rotateN(self):
        s1, s2, s3, s4, s5, s6 = self.label
        self.label = [s2, s6, s3, s4, s1, s5]

    def rotateE(self):
        s1, s2, s3, s4, s5, s6 = self.label
        self.label = [s4, s2, s1, s6, s5, s3]

    def rotateW(self):
        s1, s2, s3, s4, s5, s6 = self.label
        self.label = [s3, s2, s6, s1, s5, s4]

    def rotate(self, r):
        if r == 'S':
            self.rotateS()
        elif r == 'N':
            self.rotateN()
        elif r == 'E':
            self.rotateE()
        elif r == 'W':
            self.rotateW()
        else:
            print 'Cannot rotate into ' + r + 'direction.'

    def getTopLabel(self):
        return self.label[0]


if __name__ == '__main__':
    d = Dice(map(int, raw_input().split()))
    rotations = raw_input()
    for r in rotations:
        d.rotate(r)
    print d.getTopLabel()

Measured memory_bytes: 4276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,K;
struct perm{
	int a[N];
	int &operator[](int k){return a[k];}
}p,q,A,ans;
perm inv(perm a){
	static perm b;
	for (int i=1;i<=n;i++) b[a[i]]=i;
	return b;
}
perm operator*(perm a,perm b){
	static perm c;
	for (int i=1;i<=n;i++) c[i]=a[b[i]];
	return c;
}
perm operator^(perm a,int k){
	static perm c;
	static int b[N],h[N],cnt;
	for (int i=1;i<=n;i++) h[i]=0;
	for (int i=1;i<=n;i++)
	if (!h[i]){
		int x=i;cnt=0;
		while (!h[x]){h[x]=1;x=a[x];b[cnt++]=x;}
		for (int j=0;j<cnt;j++) c[b[j]]=b[(j+k)%cnt];
	}
	return c;
}
int main(){
	n=read();K=read()-1;
	for (int i=1;i<=n;i++) p[i]=read();
	for (int i=1;i<=n;i++) q[i]=read();
	A=q*inv(p)*inv(q)*p;
	A=A^(K/6);
	int r=K%6;
	for (int i=1;i<=r;i++){
		ans=q*inv(p);
		p=q;q=ans;
	}
	ans=A*p*inv(A);
	for (int i=1;i<=n;i++) printf("%d ",ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 15232
#include<bits/stdc++.h>
using namespace std;
const int maxn=20010;
int p[maxn],n;
int a[maxn],b[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]);


	for(int i=1;i<=n;i++){
		a[i]=i*maxn;
		b[i]=(n-i+1)*maxn;
	}
	for(int i=1;i<=n;i++){
		a[p[i]]+=i;
	}

	for(int i=1;i<=n;i++)
		printf("%d%c",a[i]," \n"[i==n]);
	for(int i=1;i<=n;i++)
		printf("%d%c",b[i]," \n"[i==n]);



	return 0;
}

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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}
int main(){
	int n;cin>>n;call(n);
	}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
 
int main()
{
	int n, m;
	cin >> n >> m;
	vector<string> grid(n);
	for (int i=0; i<n; i++) {
		cin >> grid[i];
	}
	vector< vector<int> > dp(n, vector<int>(m, 0));
	
	for(int i=0; i<n; i++) {
		if (grid[0][i]=='#')
			break;
		dp[0][i]=1;
	}
	
	for(int i=0; i<n; i++) {
		if (grid[i][0]=='#')
			break;
		dp[i][0]=1;
	}
	
	for(int i=1; i<n; i++) {
		for (int j=1; j<m; j++) {
			if (grid[i][j]=='.')
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
		}
	}
	
	cout << dp[n-1][m-1] << endl;
  	return 0;
}

Measured memory_bytes: 9468
#include<stdio.h>
#define NIL -200000

int main(){

  int sumnode;
  int i,parent,left,right;
  int heap[400];

  for(i = 0; i < 400; i++){

    heap[i] = NIL;

  }

  scanf("%d",&sumnode);

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

    scanf("%d",&heap[i]);

  }

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

    parent = i /2;
    left = i * 2;
    right = i * 2 + 1;

    printf("node %d: key = %d, ",i,heap[i]);
    

    if(parent != 0){

      printf("parent key = %d, ",heap[parent]);

    }

    if(heap[left] != NIL && left <= sumnode +1){

      printf("left key = %d, ",heap[left]);

    }

    if(heap[right] != NIL && right <= sumnode + 1){

      printf("right key = %d, ",heap[right]);

    }

    printf("\n");

  }

  return 0;

}

Measured memory_bytes: 600
// template version 1.8

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
#define INF 1e18
// #define INF 2147483647
#define MOD 998244353
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int dp[300][90005];
int dp2[300][90005];

int solve(){
  int n;
  cin>>n;
  vi a(n); rep(i, n) {cin>>a[i];}
  sort(all(a));
  int S = accumulate(all(a), 0LL);

  int r = (S%2==0 ? S/2 : S/2+1);
  dump(S, r);

  dp[0][a[0]]=1;
  dp[0][0]=2;
  rep(i, 1, n){
    rep(j, S+5){
      dp[i][j+a[i]] += dp[i-1][j];
      dp[i][j+a[i]] %= MOD;
      dp[i][j] += 2*dp[i-1][j];
      dp[i][j] %= MOD;
    }
  }
  int x = 0;
  rep(i, r, S+5){
    x+=dp[n-1][i];
    x%=MOD;
  }

  int A = 1;
  rep(i, n){
    A *= 3;
    A %= MOD;
  }

  int res;
  if (S%2!=0){
    res = A - 3*x;
    res %=MOD;
  }
  else{
    dp2[0][a[0]]=1;
    dp2[0][0]=1;
    rep(i, 1, n){
      rep(j, S+5){
        dp2[i][j+a[i]] += dp2[i-1][j];
        dp2[i][j+a[i]] %= MOD;
        dp2[i][j] += dp2[i-1][j];
        dp2[i][j] %= MOD;
      }
    }
    res = A - (3*x-dp2[n-1][S/2]*3);
    res %=MOD;
  }
  cout << (res<0 ? res+MOD : res) << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 421504
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

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

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = MAP()
uf = UnionFind(n) # 初期化

for i in range(m):
    x, y = MAP1()
    uf.union(x, y) # グループを併合

ans = 0
for i in range(n):
    ans = max(ans, uf.size(i))

print(ans)


Measured memory_bytes: 15928
#include<bits/stdc++.h>
#define reg register
#define int long long
#define maxn 300010
#define max(a,b) ((a)>(b)?(a):(b))
#define getchar() (S==T&&(T=(S=B)+fread(B,1,1<<15,stdin),S==T)?EOF:*S++)
char B[1<<15],*S=B,*T=B;
int read()
{
	reg int s=0,f=1; reg char ch;
	for(;(ch=getchar())<'0'||ch>'9';ch=='-'?f=-f:0);
	for(;ch>='0'&&ch<='9';s=s*10+ch-'0',ch=getchar());
	return s*f;
}
void write(reg int x) {x<0?x=-x,putchar('-'):0,x>9?write(x/10):void(),putchar(x%10+'0');}
int n,t[maxn],sum[maxn],f[maxn],b[maxn],k[maxn],q[maxn];
struct DP
{
	int tail=1,sum[maxn],f[maxn],b[maxn],k[maxn],q[maxn];
	int y(reg int i,reg int j) {return k[j]*i+b[j];}
	double check(reg int i,reg int j) {return (b[j]-b[i])/(double)(k[i]-k[j]);}
	void dp()
	{
		for(reg int i=1;i<=n;i++) sum[i]=sum[i-1]+t[i];
		for(reg int i=1;i<=n;i++)
		{
			while(tail>1&&y(i,q[tail-1])>=y(i,q[tail])) tail--;
			f[i]=max(y(i,q[tail])+(i*i+i)/2-sum[i],f[i-1]),k[i]=-i,b[i]=f[i]+(i*i-i)/2+sum[i];
			while(tail>1&&check(i,q[tail-1])>=check(q[tail],q[tail-1])) tail--;
			q[++tail]=i;
		}
	}
}f1,f2;
int y(reg int i,reg int j) {return k[j]*i+b[j];}
double check(reg int i,reg int j) {return (b[j]-b[i])/(double)(k[i]-k[j]);}
void solve(reg int l,reg int r)
{
	if(l==r) return void(f[l]=1ll-t[l]);
	reg int mid=l+r>>1,head=1,tail=0,mx=-1<<30;
	solve(l,mid),solve(mid+1,r);
	for(reg int i=l-1;i<mid;i++)
	{
		k[i]=-i,b[i]=f1.f[i]+(i*i-i)/2+sum[i];
		while(head<tail&&check(i,q[tail-1])>=check(q[tail],q[tail-1])) tail--;
		q[++tail]=i;
	}
	for(reg int i=r;i>mid;i--)
	{
		while(head<tail&&y(i,q[head+1])>=y(i,q[head])) head++;
		mx=max(mx,y(i,q[head])+(i*i+i)/2-sum[i]+f2.f[i+1]),f[i]=max(f[i],mx);
		
	}
	tail=0,mx=-1<<30;
	for(reg int i=mid+1;i<=r;i++)
	{
		k[i]=-i,b[i]=f2.f[i+1]+(i*i+i)/2-sum[i];
		while(tail>1&&check(i,q[tail-1])>=check(q[tail],q[tail-1])) tail--;
		q[++tail]=i;
	}
	for(reg int i=l-1;i<mid;i++)
	{
		while(tail>1&&y(i,q[tail-1])>=y(i,q[tail])) tail--;
		mx=max(mx,y(i,q[tail])+(i*i-i)/2+sum[i]+f1.f[i]),f[i+1]=max(f[i+1],mx);
	}
}
signed main()
{
	n=read();
	for(reg int i=1;i<=n;i++) t[i]=read();
	f1.dp(),std::reverse(t+1,t+n+1),f2.dp(),std::reverse(t+1,t+n+1),std::reverse(f2.f+1,f2.f+n+1);
	for(reg int i=1;i<=n;i++) sum[i]=sum[i-1]+t[i];
	solve(1,n);
	for(reg int m=read(),p,x;m--;) p=read(),x=read(),write(max(f1.f[p-1]+f2.f[p+1],f[p]+t[p]-x)),puts("");
	return 0;
}

Measured memory_bytes: 40064
n,k = map(int,input().split())
mod,ans = 1000000007,0
a = list(map(int,input().split()))
for i in range(len(a)):
    tmps,tmpt = 0,0
    for j in range(i):
        if a[i] > a[j]:
            tmpt+=1
    for j in range(i+1,len(a)):
        if a[i] > a[j]:
            tmps+=1
    ans = (ans%mod + k*tmps%mod + (k-1)*(k)%mod * (tmpt+tmps)%mod*500000004%mod)%mod
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
using namespace std;
char s[101][101];
int main()
{
	int i,j,k,n,m,d,q,ans=0;
	bool lyes,tyes;
	cin>>n>>m>>d;
	q=m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)cin>>s[i][j];
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(s[i][j]=='.')
			{
				for(k=1;k<d;k++)
				{
					if(s[i][j+k]!='.')break;
				}
				if(k==d)ans++;
				for(k=1;k<d;k++)
				{
					if(s[i+k][j]!='.')break;
				}
				if(k==d)ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  

int main() {
	int min=99999999,x,n, ans = 0;
	cin >> n;
	//vector<int> a(n,0);
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (min >= x) {
			ans++;
			min = x;
		}
	}
	cout << ans << endl;
}

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

int main()
{
    int n; cin>>n;
    map<int, int> f;
    for(int i=2; i<=n; ++i) {
        int m=i;
        for(int j=2; j*j<=m; ++j) {
            while (m%j==0) { ++f[j]; m/=j; }
        }
        if (m>1) ++f[m];
    }

    vector<int> a;
    for(auto& e: f) a.push_back(e.second+1);
    int m=a.size();

    int res=0;
    for(int i=0; i<m; ++i) if (a[i]>=75) ++res;
    for(int i=0; i<m; ++i) if (a[i]>=3)
        for(int j=i+1; j<m; ++j) if (a[j]>=25) ++res;
    for(int i=0; i<m; ++i) if (a[i]>=5)
        for(int j=i+1; j<m; ++j) if (a[j]>=15) ++res;
    for(int i=0; i<m; ++i) if (a[i]>=15)
        for(int j=i+1; j<m; ++j) if (a[j]>=5) ++res;
    for(int i=0; i<m; ++i) if (a[i]>=25)
        for(int j=i+1; j<m; ++j) if (a[j]>=3) ++res;
    for(int i=0; i<m; ++i) if (a[i]>=3)
        for(int j=i+1; j<m; ++j) if (a[j]>=5)
            for(int k=j+1; k<m; ++k) if (a[k]>=5) ++res;
    for(int i=0; i<m; ++i) if (a[i]>=5)
        for(int j=i+1; j<m; ++j) if (a[j]>=3)
            for(int k=j+1; k<m; ++k) if (a[k]>=5) ++res;
    for(int i=0; i<m; ++i) if (a[i]>=5)
        for(int j=i+1; j<m; ++j) if (a[j]>=5)
            for(int k=j+1; k<m; ++k) if (a[k]>=3) ++res;
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <utility>
#include <map>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 1 << 29;	// 十分大きい値にする, INT_MAX にしないのはオーバーフロー対策


void solve()
{
	LL r, D, x2000;
	cin >> r >> D >> x2000;

	LL prev = x2000;
	FOR(i, 1, 11) {
		prev = r * prev - D;
		cout << prev << endl;
	}
}

int main(void)
{
	solve();
	return 0;
}


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

// Union-Find, 0-indexed
struct UnionFind {
    int size; // 木の数
    UnionFind(int N) : par(N), scale1(N,1), size(N){
        iota(par.begin(), par.end(), 0);
    }

    // xの木とyの木を併合
    void unite(int x, int y){
        int rx = root(x), ry = root(y);
        if (rx == ry) return;
        par[ry] = rx;
        scale1[rx] += scale1[ry];
        size--;
    }

    // 2つのデータx, yが属する木が同じならtrueを返す関数
    bool same(int x, int y){ return root(x) == root(y);}
    // xの属する木の要素の数を返す関数
    int scale(int x){ return scale1[root(x)];}

private:
    vector<int> par, scale1;
    int root(int x){
        if (par[x] == x) return x;
        par[x] = root(par[x]);
        return par[x];
    }
};


int main() {
    int N,M;
    cin >> N >> M;
    vector<int>A(M);
    vector<int>B(M);
    for (int i = 0; i < M; ++i) {
      cin >> A[i] >> B[i];
    }

    UnionFind tree(N);
    vector<ll>ans(M);
    ll temp = N;
    temp = (temp * (temp-1)) / 2;
    for(int i = M - 1; i >= 0; --i){
        ans[i] = temp;
        if(! tree.same(A[i]-1, B[i]-1)){
            ll aS = tree.scale(A[i]-1);
            ll bS = tree.scale(B[i]-1);
            temp = temp - aS * bS;
            tree.unite(A[i]-1, B[i]-1);
        }
    }

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


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
#include <functional>	
using namespace std;

int main() {
	int a, b, k, A[110];
	cin >> a >> b >> k;
	if (b - a +1 > k*2) {
		for (int i = 0; i < k; i++) {
			cout << a + i << endl;
		}
		for (int i = k; i != 0; i--) {
			cout << b - i+1 << endl;
		}
	} else {
		for (int i = 0; i < b - a + 1; i++) {
			cout << a + i << endl;
		}
	}



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

using ll = long long;

int main() {
	ll a, b, n; cin >> a >> b >> n;
	if (n / b > 0) 
		cout << (ll)floor((long double)(b-1) * (long double)(a) / (long double)(b)) << endl;
	else 
		cout << (ll)floor((long double)(n % b) * (long double)(a) / (long double)(b)) << endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;

class A{
	public static void Main(){


		string[] input = Console.ReadLine ().Split (' ');
		int W = int.Parse(input[0]);
		int H = int.Parse(input[1]);
		int x = int.Parse(input[2]);
		int y = int.Parse(input[3]);
		int r = int.Parse(input[4]);

		if (W >= (x + r) && 0 <= (x - r)&& H >= (y + r) && 0 <= (y - r)) {
			Console.WriteLine ("Yes");
		} else {
			Console.WriteLine ("No");
		}
	}
}

Measured memory_bytes: 8876
#include<cstdio>

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

using namespace std;

int main(){
	for(int a,b,n;~scanf("%d%d%d",&a,&b,&n);){
		a%=b;
		int sum=0;
		rep(i,n){
			a*=10;
			sum+=a/b;
			a%=b;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
    int n, i, j, k, v;
    int N = 100;
    int a[N];
    scanf("%d", &n);
    for(i = 0;i < n;i++){
        scanf("%d", &a[i]);
    }
    for(i = 0;i < n;i++){
        printf("%d", a[i]);
        if(i < n-1){
            printf(" ");
        }
    }
    printf("\n");
    for(i = 1;i < n;i++){
        v = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
            a[j+1] = v;
        }
        for(k = 0;k < n;k++){
            printf("%d", a[k]);
            if(k < n-1){
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
    
}

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

_input.sort(key=lambda x: x[1])

removed = []

for a,b in _input:
    flag = False
    for i in removed:
        if a <= i < b:
            flag = True
            break
    if not flag:
        removed.append(b-1)

print(len(removed))

Measured memory_bytes: 64856
# -*- coding: utf-8 -*-

# 入力値受け取り
A, B, K = map(int, input().split())

for i in range(K):
    if i % 2 == 0:
        # A を操作
        if A % 2 != 0:
            A -= 1
        A //= 2
        B += A
    else:
        # B を操作
        if B % 2 != 0:
            B -= 1
        B //= 2
        A += B

# 結果出力
print("{} {}".format(A, B))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

struct team {
    int id;
    int ac_cnt;
    int penalty;
    vector<bool> ac;
    vector<int> wa;
};
bool cmp(const team &a, const team &b) {
    if(a.ac_cnt == b.ac_cnt) {
        if(a.penalty == b.penalty) {
            return a.id < b.id;
        }
        else return a.penalty < b.penalty;
    }
    else return a.ac_cnt > b.ac_cnt;
}
void solve(int T,int P,int R) {
    vector<team> t(T);
    REP(i,T) {
        t[i].id=i;
        t[i].ac=vector<bool>(P,false);
        t[i].wa=vector<int>(P,0);
    }
    REP(r,R) {
        int tid,pid,tm;
        string msg;
        cin>>tid>>pid>>tm>>msg;
        tid--;
        pid--;
        if(t[tid].ac[pid]) continue;
        if(msg=="CORRECT") {
            t[tid].penalty+=t[tid].wa[pid]*1200+tm;
            t[tid].ac[pid]=true;
            t[tid].ac_cnt++;
        }
        else {
            t[tid].wa[pid]++;
        }
    }
    sort(ALL(t),cmp);
    REP(i,T) {
        cout<<t[i].id+1<<" "<<t[i].ac_cnt<<" "<<t[i].penalty<<endl;
    }
}
signed main() {
    while(1) {
        int T,P,R;
        cin>>T>>P>>R;
        if((T+P+R)==0) break;
        solve(T,P,R);
    }
    return 0;
}

Measured memory_bytes: 3180