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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    
    bool is=false;
    repd(i,1,10)repd(k,1,10){
        if(i*k==N)is=true;
    }

    cout << ((is) ? "Yes" : "No") <<endl;
    return (0);
}

Measured memory_bytes: 256
use std::io::Read;

struct Testmony {
    n: usize,
    x: Vec<i32>,
    y: Vec<i32>,
}

fn read(iter: &mut std::str::SplitWhitespace) -> Testmony {
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut t = Testmony {
        n: n,
        x: vec![],
        y: vec![],
    };
    for _ in 0..n {
        let x: i32 = iter.next().unwrap().parse().unwrap();
        let y: i32 = iter.next().unwrap().parse().unwrap();
        t.x.push(x - 1);
        t.y.push(y);
    }
    return t;
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: i32 = iter.next().unwrap().parse().unwrap();
    let v: Vec<Testmony> = (0..n).map(|_| read(&mut iter)).collect();
    let mut ans = 0;
    for b in 0..(1 << n) {
        let mut a = vec![0; n as usize];
        let mut cnt = 0;
        for i in 0..n {
            a[i as usize] = (b >> i) & 1;
            cnt += (b >> i) & 1;
        }
        if ans >= cnt {
            continue;
        }
        let mut satisfy = true;
        for i in 0..n {
            if a[i as usize] == 1 {
                let t = &v[i as usize];
                for j in 0..t.n {
                    if a[t.x[j as usize] as usize] != t.y[j as usize] {
                        satisfy = false;
                        break;
                    }
                }
            }
        }
        if satisfy {
            ans = cnt;
        }
    }

    println!("{}", ans);
}


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

#define ll              long long
#define ull             unsigned long long
#define mx              1000000
#define mod             1000000007

int main()
{
    ios_base::sync_with_stdio(0);
    int a,b,c=0,d;
    int n;
    cin>>n;
    cin>>a>>b;
    int ar[n+2];
    for(int i=0; i<n; i++)
    {
        cin>>ar[i];
        int s=1;
        while(s<=a)
        {
            c++;
            s+=ar[i];
        }
        s=1;
    }
    cout<<c+b<<endl;

}





Measured memory_bytes: 256
/*input 
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
*/


#include <bits/stdc++.h>
using namespace std;
 

 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))

#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
 
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
 
int n,k,i,j,m,c;




void solve() 
{ 
cin>>n>>m;
vector <int> v[n+1];
int par[n+1];
init(par,0);
for(i=0;i<m;i++)
{
    cin>>j>>k;
    v[j].push_back(k);
    v[k].push_back(j);

}  

queue<int> q;
int vis[n+1];
init(vis,0);
q.push(1);
vis[1]=1;
par[1]=1;

while(!q.empty())
{
    k=q.front();
    q.pop();
    for(i=0;i<v[k].size();i++)
    {
        if(vis[v[k][i]]==0)
        {vis[v[k][i]]=1;
            par[v[k][i]]=k;


            q.push(v[k][i]);


        }
    }
}
for(i=2;i<=n;i++)
{if(par[i]==0)
    {
        cout<<"No";
        return;
   // cout<<par[i]<<" ";
    }
}
cout<<"Yes\n";
for(i=2;i<=n;i++)
{
    cout<<par[i]<<"\n";
}

} 
 
 
 
 
signed main()
{
 
    // inputFile;
    fast;
    int T = 1;
//cin >> T;
int h=T;
    while(T--){
//cout<<"Case #"<<(h-T)<<": ";
        solve();
cout<<endl;
     
        
        
 
    }
    
    
    return 0;
 
}

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

int main()
{
    string s;
    cin >> s;
    int t = 0;
    for (int i = 0; i < (int)s.size(); i++)
    {
        if (s[i] == 'R')
            t++;
    }
    if (t == 2 && (s[0] == 'R' && s[2] == 'R'))
        cout << 1 << endl;
    else
        cout << t << endl;
}


Measured memory_bytes: 3600
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
	int a, b, c;
	while(scanf("%d %d", &a, &b) != EOF){
		c = (int)log10(a+b) + 1;
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 1072
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
const lli inf = 1e18;

int main(){
	lli r,d,x;
	cin >> r >> d >> x;
	for(int i=0; i<10; i++){
		x = r*x -d;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 10000000000
#define P pair<int,int>
string s,t;
signed main(){
    cin>>s>>t;
    cout<<t<<s<<endl;
    return 0;
}



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

int main(){
    int n, k;
    cin >> n >> k;
    vector <double> face(n);
    rep(i,n) cin >> face[i];

    vector <double> p(n);
    rep(i,n) p[i] = (face[i] + 1)/2.0;

    vector <double> sum(n-k+1, 0.0);

    double tmp;
    rep(i,k) tmp += p[i];

    for(int i=0; i<n-k+1; i++){
        sum[i] = tmp;
        tmp = tmp - p[i] + p[i + k];
    }

    sort(all(sum));

    cout << fixed << setprecision(10);
    cout << sum[n-k] << endl;
}


Measured memory_bytes: 8032
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define endl "\n"

using namespace std;
using ll = long long;
using ld = long double;
using bnum = int64_t;
string a;
bnum p=0;
int main() {
    cin >> a;
    for(bnum i = 0;i<a.size();++i){
        if(a.at(i) % 3 == 0){
            continue;
        }else{
            p+=a.at(i);
        }
    }if(p % 3 == 0){
        cout << "Yes" << endl;return 0;
    }else{
        cout << "No" << endl;return 0;
    }
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {
	
	static final int INF = Integer.MAX_VALUE/2;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt(), l = sc.nextInt();
		int to[][] = new int[n][n];
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if(i==j)to[i][j] = 0;
				else to[i][j] = INF;
			}
		}
		for(int i=0;i<m;i++) {
			int a = sc.nextInt()-1, b = sc.nextInt()-1, c = sc.nextInt();
			to[a][b] = c; to[b][a] = c;
		}
		for(int k = 0;k<n;k++) {
			for(int i=0;i<n;i++) {
				for(int j=0;j<n;j++) {
					to[i][j] = Math.min(to[i][j], to[i][k] + to[k][j]);
				}
			}
		}
		
		for(int i=0;i<n;i++) for(int j=0;j<n;j++) {
			if(to[i][j]==0)continue;
			if(to[i][j]<=l)to[i][j] = 1;
			else to[i][j] = INF;
		}
		
		for(int k = 0;k<n;k++) {
			for(int i=0;i<n;i++) {
				for(int j=0;j<n;j++) {
					to[i][j] = Math.min(to[i][j], to[i][k] + to[k][j]);
				}
			}
		}
		
		int q = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<q;i++) {
			int s = sc.nextInt()-1, t = sc.nextInt()-1;
			if(to[s][t] == INF) sb.append(-1 + "\n");
			else {
				sb.append((to[s][t] - 1) + "\n");
			}
		}
		System.out.println(sb.toString());
	}
}



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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		A.at(i)=a;
	}

	vector<int> B(N,-1);
	for(int i=0;i<N;i++){
		int xx=A.at(i);
		auto iter=lower_bound(B.begin(),B.end(),xx);
		int yy=iter-B.begin();
		B.at(yy-1)=xx;
	}

	/*
	for(int i=0;i<N;i++){
		cout << B.at(i) << " ";
	}
	cout << endl;
	*/

	for(int i=N-1;i>=0;i--){
		if(B.at(i)==-1){
			cout << N-i-1 << endl;
			return 0;
		}
	}
	cout << N << endl;

	return 0;
}


Measured memory_bytes: 1024
S = input()
T = input()


patan = len(S)-len(T)+1
min_change = 1000
for p in range(patan):
  S_sub = S[p:p+len(T)]
  not_match = len([1 for s,t in zip(S_sub, T) if s!=t])
  if not_match < min_change:
    min_change = not_match

print(min_change)

Measured memory_bytes: 9048
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <tuple>
#include <vector>
using ll = long long;
using namespace std;
#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__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end())
            cout << " ";
    }
    cout << endl;
}

int gcd(int x, int y) {
    int tmp;
    if(x > y)
        return gcd(y, x);
    int r;
    while((r = x % y)) {
        x = y;
        y = r;
    }
    return y;
}

bool isPrime(int n) {
    if(n < 2)
        return false;
    else if(n == 2)
        return true;
    else if(n % 2 == 0)
        return false;
    double sq = sqrt(n);
    for(int i = 3; i <= sq; i += 2) {
        if(n % i == 0)
            return false;
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    int r, m, M = -1e9, d;
    cin >> m;
    rep(i, 1, N) {
        cin >> r;
        M = M > r - m ? M : r - m;
        m = m < r ? m : r;
    }
    cout << M << endl;
}



Measured memory_bytes: 3108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>


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


int main( ){
    
    int n, div;
    
    scanf("%d", &n);
    
    
    if (isPrime(n) == 1) {
        printf("%d: %d\n", n, n);
        return 0;
    }
    
    printf("%d:", n);
    div = 2;
    
    while (1) {
        while(n % div == 0){
            n = n/div;
            printf(" %d", div);
        }
        if (n == 1) {
            break;
        }
        div = div + 1;
    }
    printf("\n");
    return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def dfs(nodes, src):
    """ DFS(木、スタック、重みなし) """

    N = len(nodes)
    stack = [(src, -1, 0)]
    dist = [-1] * N
    while stack:
        u, prev, c = stack.pop()
        dist[u] = c
        for v in nodes[u]:
            if v != prev:
                # 0,1を交互に入れて二部グラフを塗り分け
                stack.append((v, u, 1-c))
    return dist

N = INT()
nodes = [[] for i in range(N)]
for _ in range(N-1):
    a, b = MAP()
    a -= 1; b-= 1
    nodes[a].append(b)
    nodes[b].append(a)

res = dfs(nodes, 0)
cnt0 = res.count(0)
cnt1 = res.count(1)

ans = [0] * N
# グラフの偏りによって場合分け
if cnt0 <= N // 3 or cnt1 <= N // 3:
    if cnt0 > cnt1:
        cnt0, cnt1 = cnt1, cnt0
        res = [1-c for c in res]
    # 少ない方に全部0mod3入れて、多い方は残りを適当に入れる
    p12 = 1
    p3 = 3
    for i in range(N):
        if res[i] == 0:
            ans[i] = p3
            p3 += 3
    for i in range(N):
        if res[i] == 1:
            if p12 <= N:
                ans[i] = p12
                p12 += 1
                if p12 % 3 == 0:
                    p12 += 1
            else:
                ans[i] = p3
                p3 += 3

else:
    # それぞれに1mod3と2mod3を優先して入れて、なくなったら残りには0mod3を入れる
    p1 = 1
    p2 = 2
    p3 = 3
    for i in range(N):
        if res[i] == 0:
            if p1 <= N:
                ans[i] = p1
                p1 += 3
            else:
                ans[i] = p3
                p3 += 3
        else:
            if p2 <= N:
                ans[i] = p2
                p2 += 3
            else:
                ans[i] = p3
                p3 += 3
print(*ans)


Measured memory_bytes: 108212
from collections import Counter
n = int(input())
s = input()
cnt = Counter(s)
ans = cnt["R"]*cnt["G"]*cnt["B"]
for i in range(n):
    for j in range(i+1,n):
        k = 2*j-i
        if k >= n: continue
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]: ans -= 1
print(ans)

Measured memory_bytes: 9420
N,M=map(int,input().split())
Islands=[[10**9]*N for i in range(N)]
Edge=[]
S=0
for i in range(M):
  a,b,c=map(int,input().split())
  Islands[a-1][b-1]=c
  Islands[b-1][a-1]=c
  Edge.append([a-1,b-1,c])
for k in range(N):
  for i in range(N):
    for j in range(N):
      Islands[i][j]=min(Islands[i][j],Islands[i][k]+Islands[k][j])

ans=0
for a,b,c in Edge:
  if Islands[a][b]!=c:
    ans+=1
print(ans)
    
  

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

void Main() {
  int N;
  cin >> N;
  int p[N + 1];
  for (int i = 1; i <= N; i++) {
    cin >> p[i];
  }

  int ans = 0;
  for (int i = 1; i < N; i++) {
    if (p[i] == i) {
      p[i] = p[i + 1];
      p[i + 1] = i;
      ans++;
    }
  }
  if (p[N] == N) ans++;

  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 640
#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;
typedef long long ll;

string makes(int p, int x) {
	string pref = to_string(p), id = to_string(x);
	return string(6 - pref.size(), '0') + pref + string(6 - id.size(), '0') + id;
}

int main() {
	int n, m; cin >> n >> m;
	vector<pair<pair<int, int>, int>> v;
	for (int i = 0; i < m; i++) {
		int p, y; cin >> p >> y;
		v.push_back({ {p, y}, i });
	}
	sort(v.begin(), v.end());
	vector<string> ans(m);
	int cnt = 1;
	ans[v[0].second] = makes(v[0].first.first, 1);
	for (int i = 1; i < m; i++) {
		int id = v[i].second;
		if (v[i].first.first == v[i - 1].first.first) cnt++;
		else cnt = 1;
		ans[id] = makes(v[i].first.first, cnt);
	}
	for (string s : ans) cout << s << endl;
	return 0;
}


Measured memory_bytes: 9716
#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// pair 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const pair<T,S>& p){
  cout << "(" << p.first << "," << p.second << ")";
  return os;
}

// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << " ";
  }
  return os;
}

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

int main(){
  int n; li k; cin >>n >>k;
  vector<int> v(n);
  vector<pair<int,int>> post(n);
  map<int,int> mp;
  rep(i,n){
    post[i]={1,i};
    int a; cin >>a;
    if(mp.find(a)!=mp.end()){
      post[mp[a]]={0,i};
    }
    mp[a]=i;
    v[i]=a;
  }
  if(df)print(v);
  rep(i,n){
    if(mp[v[i]]>i){
      post[mp[v[i]]]={1,i};
      mp[v[i]]=i;
    }
  }
  if(df){
    print(mp);
    print(post);
  }
  
  int ord=1,i=0;
  while(1){
    pair<int,int> p=post[i];
    i=p.second; ord+=p.first;
    if(i==n-1) break;
    i++;
    if(i==n){
      i=0; ord++;
    }
  }
  if(df)print("ord:",ord);

  k%=ord;
  i=0;
  vector<int> ans;
  while(k){
    if(df)print(k,i);
    pair<int,int> p=post[i];
    if(k>1 or p.first==0){
      i=p.second; k-=p.first;
    }else{
      ans.push_back(v[i]);
    }
    i++;
    if(i==n){
      i=0; k--;
    }
  }
  print(ans);
}


Measured memory_bytes: 14072
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N, K;
    i64 S;
    cin >> N >> K >> S;
    i64 p = 1;
    if (S < 1000000000) {
        p = S + 1;
    }
    for (i32 i = 0; i < N; i++) {
        if (i < K) {
            cout << S;
        } else {
            cout << p;
        }
        if (i != N - 1) {
            cout << " ";
        }
    }
    cout << endl;
    return;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(int argc,char* argv[]){
  char str[11];
  int i;
  
  while(scanf("%s",&str) != EOF){
    int sum = 
      (str[0] - '0') + 
      (str[1] - '0')*9 + 
      (str[2] - '0')*36 +
      (str[3] - '0')*84 + 
      (str[4] - '0')*126 + 
      (str[5] - '0')*126 + 
      (str[6] - '0')*84 + 
      (str[7] - '0')*36 + 
      (str[8] - '0')*9 + 
      (str[9] - '0');
      
    printf("%d\n",sum%10);
    
    
  }
  
  
  return 0;
  
}

Measured memory_bytes: 0
#define _ijps 0
#define _ALLOW_RTCc_IN_STL
#define _CRT_SECURE_NO_DEPRECATE
//#pragma comment(linker, "/STACK:667772160")
#include <iostream>
#include <cmath>
#include <time.h>
#include <map>
#include <set>
#include <deque>
#include <cstdio>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <string>
#include <fstream>
#include <assert.h>
#include <list>
#include <cstring>
#include <queue>

using namespace std;

#define name "pail"

typedef long long ll;

struct __isoff {
	__isoff() {
		if (_ijps)
			freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);//, freopen("test.txt", "w", stderr);
		//else freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);
		//ios_base::sync_with_stdio(0);
		//srand(time(0));
		srand('C' + 'T' + 'A' + 'C' + 'Y' + 'M' + 'B' + 'A');
	}

	~__isoff() {
		//if(_ijps) cout<<times<<'\n';
	}
} __osafwf;
vector<ll> A, B;
void add_line(int l, int r, int a, int b) {
	A[l] += a;
	A[r + 1] -= a;
	B[l] += b;
	B[r + 1] -= b;
}

int main() {
	int n, m;
	cin >> n >> m;
	A.resize(m + 5);
	B.resize(m + 5);
	vector<int> P(n);
	for (int i = 0; i < n; i++) {
		cin >> P[i];
	}
	ll res = 0;
	for (int i = 1; i < n; i++) {
		int a = P[i - 1] - 1;
		int b = P[i] - 1;
		if (a < b) {
			int c = b - a;
			res += c;
			add_line(
				a + 1, 
				b,
				-c + (a + 1) + (c),
				-1
			);
		}
		else if (a > b) {
			int c = m - a + b;
			res += c;
			add_line(
				a + 1,
				m,
				-c + (a + 1) + (c),
				-1
			);
			add_line(
				0,
				b,
				-c + (c - (m - a) + 1),
				-1
			);
		}
	}
	ll a = 0;
	ll b = 0;
	ll ans = 1e18;
	for (int i = 0; i < m; i++) {
		a += A[i];
		b += B[i];
		ll x = b * i + a;
		ll y = x + res;
		ans = min(ans, y);
	}
	cout << ans;
}


Measured memory_bytes: 2176
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;

    int res = n * (n + 1) / 2;

    cout << res << '\n';


    return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll A,B;
cin >> A >> B;
if(A%B!=0) cout << A/B+1;
else cout << A/B;
}

Measured memory_bytes: 3648
/*input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
*/
/**
    Author: Kristopher Paul
    Date Created: 11-01-2020
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

//Uncomment for File I/O
/*
#define cin fin
#define cout fout

ifstream fin("input.in");
ofstream fout("input.out");
*/

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    string s[n];
    int t[n];
    FOR(i,0,n){
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    FOR(i,0,n){
        if(s[i] == x){
            int c = 0;
            FOR(j,i+1,n){
                c += t[j];
            }
            cout << c << endl;
            return;
        }
    }
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}



Measured memory_bytes: 256
H, W = map(int, input().split())
A = [[int(_) for _ in input().split()] for _ in range(H)]
N = 0
move = []
for i in range(H):
    for j in range(W):
        if A[i][j] % 2 == 1 and j <= W-2:
            A[i][j+1] += 1
            N += 1
            move.append([i+1, j+1, i+1, j+2])
        elif A[i][j]%2 == 1 and j == W-1 and i!=H-1:
            A[i+1][j] += 1
            N += 1
            move.append([i+1, j+1, i+2, j+1])

print(N)
for i in range(N):
    print(move[i][0], move[i][1], move[i][2], move[i][3])

Measured memory_bytes: 30792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

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

    long sum = 0;
    long square_sum = 0;
    vector<long> d(N);
    rep(i, N) {
        cin >> d[i];
        sum += d[i];
        square_sum += d[i] * d[i];
    }

    long ans;
    ans = (sum * sum - square_sum) / 2;

    cout << ans << 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;

using ll = long long;
using P = pair<int, int>;

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

  ll result = 1;
  while (n / k > 0) {
    result++;
    n /= k;
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> v(100000);
int main() {
	int n; cin >> n; long long int max, min, sum = 0; max = -10000010; min = 100000100;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		if (max < v[i])
			max = v[i];
		if (min > v[i])
			min = v[i];
		sum += v[i];
	}
	cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;
vector<int> c[1010];

int x[1010];
int d[1010];
const int inf = 1e9;

bitset<5010> dp, tmp, msk;

void dfs(int v){
	for(int i:c[v]){
		dfs(i);
	}
	dp.reset(); msk.reset();
	dp.set(0);
	for(int i=0; i<=x[v]; ++i) msk.set(i);
	
	int as = 0, ms = 0;
	for(int i:c[v]){
		int D=d[i], X=x[i];
		
		tmp = (dp<<D) | (dp<<X);
		dp = tmp & msk;
		
		as += D+X;
		ms += min(D, X);
	}
	if(x[v] < ms){
		puts("IMPOSSIBLE");
		exit(0);
	}
	for(int i=x[v]; ms<=i; --i) if(dp[i]){
		d[v] = as - i;
		break;
	}
}

int main()
{
	read(n);
	for(int x, i=2; i<=n; ++i){ read(x); c[x].pb(i); }
	for(int i=1; i<=n; ++i) read(x[i]);
	dfs(1);
	puts("POSSIBLE");
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1<<30
const int mod = 1e9+7;


int main(){
    string s; cin >> s;
    ll x,y; cin >> x >> y;
    bool f = true;
    bool first = true;
    ll n = s.size();
    ll cnt = 0;
    vl tate;
    vl yoko;
    ll ini = 0;
    rep(i,n){
        if(s[i]=='T'){
            if(first){
                ini = cnt;
                first = false;
                f = !f;
                cnt = 0;
                continue;
            }
            if(f) yoko.push_back(cnt);
            else tate.push_back(cnt);
            f = !f;
            cnt = 0;
        }else{
            cnt++;
        }
    }
    if(first) ini = cnt;
    else{
        if(f) yoko.push_back(cnt);
        else tate.push_back(cnt);
    }
    ll yy = tate.size();
    ll xx = yoko.size();
    vector<vector<bool>> X(xx+1,vector<bool>(16002,0)), Y(yy+1,vector<bool>(16002,0));
    X[0][8000+ini]=1; Y[0][8000]=1;
    rep(i,xx){
        rep(j,16001){
            if(X[i][j]){
                X[i+1][j-yoko[i]]=1;
                X[i+1][j+yoko[i]]=1;
            }
        }
    }
    rep(i,yy){
        rep(j,16001){
            if(Y[i][j]){
                Y[i+1][j-tate[i]]=1;
                Y[i+1][j+tate[i]]=1;
            }
        }
    }
    if(X[xx][8000+x]&&Y[yy][8000+y]) puts("Yes");
    else puts("No");
}


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

void solve()
{
    string s, t;
    cin >> s >> t;
    int m = s.size(), n = t.size();
    int maxi = 0;
    for (int i = 0; i < m - n+1; i++)
    {
        int diff = 0;
        for (int j = i; j <i+n; j++)
        {
            if (s[j] == t[j - i])
                diff++;
        }
        maxi = max(diff, maxi);
    }
    cout << t.size() - maxi << "\n";
}

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


    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll A,B,T;
    cin>>A>>B>>T;
    ll ans=0,sum=0;
    while(sum<=T){
        sum+=A;
        if(sum<=T)ans+=B;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

int main() {
	int a = 0, b = 0, x;
	rep(i, 4) {
		cin >> x;
		a += x;
	}

	rep(i, 4) {
		cin >> x;
		b += x;
	}

	if(a >= b) cout << a << endl;
	else cout << b << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

int main(void) {
	int i, ans;
	string s;
	cin >> s;
	ans = s.size();
	for(i = 1; i < s.size(); i++) {
		if (s[i - 1] != s[i])
			chmin(ans, max(i, (int)s.size() - i));
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;
int SAdx[4]={1,-1,0,0};
int SAdy[4]={0,0,-1,1};
int SAw,SAh;
char SAmap[51][51];
void SArec(int x,int y,char c){
	for(int i=0;i<4;i++){
		int nextx=x+SAdx[i],nexty=y+SAdy[i];
		if(nextx>=0 && nextx<SAw && nexty>=0 &&nexty<SAh){
			if(SAmap[nexty][nextx]=='.'){
				SAmap[nexty][nextx]=(c == 'B' ? 'b' : 'w');
				SArec(nextx,nexty,c);
			}else if( (SAmap[nexty][nextx]=='b'&&c=='W')||(SAmap[nexty][nextx]=='w'&&c=='B')){
				SAmap[nexty][nextx]='e';
				SArec(nextx,nexty,c);
			}
		}
	}
}

int main(){
	while(cin>>SAw>>SAh,SAw){
		int b=0,w=0;
		REP(i,0,SAh){
			REP(j,0,SAw){
				cin>>SAmap[i][j];
			}
		}
		REP(i,0,SAh){
			REP(j,0,SAw){
				if(SAmap[i][j]=='B'||SAmap[i][j]=='W'){
					SArec(j,i,SAmap[i][j]);
				}
			}
		}
		REP(i,0,SAh){
			REP(j,0,SAw){
				if(SAmap[i][j]=='b'){
					b++;
				}else if(SAmap[i][j]=='w'){
					w++;
				}
			}
		}
		cout<<b<<" "<<w<<endl;
	}
	return 0;
}

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

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int N = 1e5+7;

int32_t main() {
    IOS;
	string a[N];
	a[2] = "hon";
	a[4] = "hon";
	a[5] = "hon";
	a[7] = "hon";
	a[9] = "hon";
	a[0] = "pon";
	a[1] = "pon";
	a[6] = "pon";
	a[8] = "pon";
	a[3] = "bon";
	int n;
	cin >> n;
	cout << a[n%10] << endl;
    return 0;
}


Measured memory_bytes: 6768
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	LL n;
	cin >> n;

	LL ans = 1;
	REP2(i, 1, n + 1) {
		ans = (ans * i) % 1000000007;
	}

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

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    string s,t;
    cin>>s;
    cin>>t;

    REP(i,s.size()){
        string tmp;
        tmp=s.substr(s.size()-i,i)+s.substr(0,s.size()-i);
        //DEBUG(tmp);
        if(tmp==t){
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from operator import itemgetter

MOD = 998244353

N,*A = map(int,read().split())

T = A.count(1)
if T == 0:
    print(0)
    exit()
if T == 1:
    answer = 1 if len(set(A)) == N else 0
    print(answer)
    exit()
if T == N:
    answer = 1
    for n in range(1,N+1):
        answer *= n
        answer %= MOD
    print(answer)
    exit()

n = A.index(1)
while A[n-1] == 1:
    n -= 1
A = A[n:] + A[:n]

# assert len(A) == N and A[0] == 1 and A[-1] != 1

L = [0] * (N+1)
R = [-1] * (N+1)
ctr = [0] * (N+1)
nums = []
prev = 0
for i,x in enumerate(A):
    ctr[x] += 1
    R[x] = i
    if prev != x:
        nums.append(x)
        L[x] = i
        prev = x

if any(y - x + 1 != z for x,y,z in zip(L,R,ctr)):
    print(0)
    exit()
if any(x > T for x in ctr[2:]):
    print(0)
    exit()

free = [0] * (N+1) # ある数値を書き込んだ時点で、死亡確定になってるマス数
answer = 1
for x,y,z in zip(nums,nums[1:],nums[2:]+[1]):
    if x > y < z:
        if ctr[y] != T:
            answer = 0
            break
    elif x < y < z:
        free[y] += ctr[y] - 1
    elif x > y > z:
        free[y] += ctr[y] - 1
    else:
        # x < y > z
        answer *= (T + 1 - ctr[y])
        answer %= MOD
        free[y] += ctr[y] + T - 2

f = 0
for n in range(1,N+1):
    if ctr[n] >= 1:
        f += free[n]
        continue
    answer *= f
    answer %= MOD
    f -= 1

print(answer)

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

int main(){
	int n;
	cin >> n;
	vector<vector<int> > to(n);
	rep(i,n){
		int u;
		cin >> u;
		u--;
		int k;
		cin >> k;
		rep(j,k){
			int v;
			cin >> v;
			v--;
			to[u].push_back(v);
		}
	}
	
	int dist[105];
	rep(i,n){
		dist[i] = -1;
	}
	
	queue<int> que;
	dist[0] = 0;
	que.push(0);
	while(!que.empty()){
		int p = que.front();
		que.pop();
		for (int i = 0; i < to[p].size(); ++i) {
			int nextv = to[p][i];
			if(dist[nextv] != -1) continue;
			dist[nextv] = dist[p] + 1;
			que.push(nextv);
		}
	}
	
	rep(i,n){
		cout << i+1 << " " << dist[i] << endl;
	}
    return 0;
}




Measured memory_bytes: 3160
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String strB = "";

		String strA = sc.nextLine();
	//	System.out.println("??\?????????????????? : "+strA);
	//	System.out.println("");


		for(int i = 0; i < strA.length(); i++) {
			strB = strA.substring(i,i+1);

		//	System.out.println("strB.charAt(0) : "+strB.charAt(0));

			//??§????????????true
			if(Character.isUpperCase(strB.charAt(0))) {
				Character.toLowerCase(strB.charAt(0));
				System.out.print(Character.toLowerCase(strB.charAt(0)));
			}
			//?°???????????????§???????????????
			else {
				if(strB == " " || strB == "," || strB == ".") {
					System.out.println(strB);
				}
				else {
					Character.toUpperCase(strB.charAt(0));
					System.out.print(Character.toUpperCase(strB.charAt(0)));
				}
			}

		}
		System.out.println("");
	}
}

Measured memory_bytes: 26632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	ll k;
	cin>>s>>k;
	for(int i=0;i<s.size();i++){
		ll now=('z' - s[i] + 1) % 26;
		if(k>=now){
			s[i]='a';
			k-=now;
		}
	}
	if(k>0){
		k%=26;
		s[s.size()-1]=s[s.size()-1]+k;
	}
	cout << s;
	// your code goes here
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  vector<int> v(3);
  for (int i = 0; i < 3; i++) cin >> v[i];
  sort(v.begin(), v.end());
  int ans = v[2] - v[1];
  v[0] += ans;
  v[1] = v[2];
  if ((v[2] - v[0]) % 2 == 1)
    ans += (v[2] - v[0]) / 2 + 2;
  else
    ans += (v[2] - v[0]) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
char a[50],b[50],c[50];
int main()
{
	int l1,l2,l3;
	scanf("%s%s%s",a,b,c);
	l1=strlen(a);
	l2=strlen(b);
	l3=strlen(c);
	if(a[l1-1]==b[0]&&b[l2-1]==c[0]) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector <vector<int>> vec;
vector <int> dp;
vector <int> vis;

void dfs(int i){
    //cout<<i<<endl;
    if(vec[i].size()==0){dp[i]=0;vis[i]=2;}
    vis[i]=1;
    for(auto v:vec[i]){
        if(vis[v]==0)dfs(v);
        dp[i]=max(dp[v]+1,dp[i]);
    }
    vis[i]=2;
}

int main() {
    int n,m;
    cin>>n>>m;
    vec.assign(n,vector <int>(0));
    dp.assign(n,-1);
    vis.assign(n,0);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        vec[a].pb(b);
    }
    int mx=-1;
    for(int i=0;i<n;i++){
    if(vis[i]==0)dfs(i);
    mx=max(mx,dp[i]);}
    cout<<mx<<endl;
    
    
}

Measured memory_bytes: 8576
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int MOD = 1e9 + 7, N = 1e5 + 10;

int fac[N], inv[N];

int fpow(int a, int b) {
  int ans = 1;
  for(; b > 0; a = 1ll * a * a % MOD, b >>= 1) {
    if(b & 1) {
      ans = 1ll * ans * a % MOD;
    }
  }
  return ans;
}

void init() {
  fac[0] = 1;
  for(int i = 1; i < N; i++) {
    fac[i] = 1ll * fac[i - 1] * i % MOD;
  }
  inv[N - 1] = fpow(fac[N - 1], MOD - 2);
  for(int i = N - 2; i >= 0; i--) {
    inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
  }
}
 
int a[N], b[N];

void Main() {
  init();
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < n - 1; i++) {
    a[i] = a[i + 1] - a[i];
    // debug(a[i]);
  }
  b[0] = 1;
  for(int i = 1; i < N; i++) {
    b[i] = (1ll * b[i - 1] * (i + 1) % MOD + fac[i]) % MOD;
  }
  int ans = 0;
  for(int i = 0; i < n - 1; i++) {
    ans += 1ll * a[i] * b[i] % MOD * fac[n - 1] % MOD * inv[i + 1] % MOD;
    if(ans >= MOD) ans -= MOD;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;
#include <string>

int main() {
    string n;    cin >> n;
    bool can = true;
    for (int i = 1; i < n.length(); i++) {
        if (n[i] != '9')
            can = false;
    }

    if (can)
        cout << 9 * (n.length() - 1)  + (n[0] - '0')<< endl; 
    else 
        cout << 9 * (n.length() - 1) + (n[0] - '1') << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int n,m;

bool binarySearch(int x[], int y){
    int left = 0;
    int right = n;
    
    while(left<right){
        int mid = (right-left)/2 + left;
        if(x[mid] == y) return 1;
        
        if(x[mid]<y) left = mid+1;
        else right = mid;
    }
    
    return 0;
}




int main(){
    cin >> n;
    int a[n];
    
    rep(i,n) cin >> a[i];
    
    cin >> m;
    int b[m];
    
    rep(i,m) cin >> b[i];
    
    int ans = 0;
    rep(i,m){
        ans += binarySearch(a,b[i]);
    }
    
    cout << ans << endl;
    
}














Measured memory_bytes: 3688
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	if(n == 1) System.out.println("Hello World");
      	else{
        	int a = sc.nextInt();
          	int b = sc.nextInt();
          	System.out.println(a+b);
        }
    }
}

Measured memory_bytes: 35656
ans_list = []

while True:
    n = int(input())
    if n == 0:
        break
    S = input().split()
    cnt = 0
    dq = []
    for s in S:
        if not dq:
            dq.append(s)
        if [dq[-1], s] in [["lu","ru"],["ru","lu"],["ld","rd"],["rd","ld"]]:
            cnt += 1
            dq.append("@")
        else:
            dq.append(s)
    ans_list.append(cnt)

for ans in ans_list:
    print(ans)


Measured memory_bytes: 5628