akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void dfs(int nbSw, vector<vector<int> >& sw, vector<int>& ps, vector<int> swof, int& cnt, int N, int M) {
	if (nbSw == N - 1) {
		// check if all
		bool isAll = true;
		rep(i, M) {
			int cntSw = 0;
			rep(j, N) {
				cntSw += sw[i][j] * swof[j];
			}
			if (cntSw % 2 != ps[i]) {
				isAll = false;
				break;
			}
		}
		if (isAll) ++cnt;
	}
	else {
		swof[nbSw + 1] = 0;
		dfs(nbSw + 1, sw, ps, swof, cnt, N, M);
		swof[nbSw+1] = 1;
		dfs(nbSw + 1, sw, ps, swof, cnt, N, M);
	}
}

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int N = inputVal<int>(); // nb switches
	const int M = inputVal<int>(); // nb lights

	vector<vector<int> > sw(M, vector<int>(N, 0));

	rep(i, M) {
		int k; cin >> k;
		rep(j, k) {
			int s; cin >> s; --s;
			sw[i][s] = 1;
		}
	}
	vector<int> ps(M, 0);
	rep(i, M) { cin >> ps[i]; }

	vector<int> swof(N, 0);
	int cnt = 0;
	swof[0] = 0;
	dfs(0, sw, ps, swof, cnt, N, M);
	swof[0] = 1;
	dfs(0, sw, ps, swof, cnt, N, M);

	cout << cnt << endl;
}

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

	return 0;
}


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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    string s;
    bool f=false;
    cin >> s;
    if(s=="RRS" || s=="SRR")
    {
        cout << 2 << endl;
    }
    else if(s=="RRR")
    {
        cout << 3 << endl;
    }
    else
    {
        for(int i=0;i<3;i++)
        {
            if(s[i]=='R')
            {
                f=true;
            }
        }
        if(f)
        {
            cout << 1 << endl;
        }
        else
        {
            cout << 0 << endl;
        }
        
    }

    return 0;
}


Measured memory_bytes: 3620
import itertools

n, D = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(n)]
cnt = 0

i1 = [int(i) for i in range(n)]
i2 = itertools.combinations(i1, 2)

for a, b in i2:
    l = 0
    for d in range(D):
        l += (ls[a][d]-ls[b][d])**2
    if l ** 0.5 == int(l ** 0.5):
        cnt += 1

print(cnt)


Measured memory_bytes: 3064
N = gets.to_i
a = gets.split.map(&:to_i)
A = 0
B = 0

for i in 0..N-1
    for j in i..N-1
        if a[i] > a[j]
            b = a[j]
            a[j] = a[i]
            a[i] = b
        end
    end
    # puts a[i]
end

# for k in (N-1)..0
#     if k % 2 == 1
#         c += a[k]
       
#     else
#         d += a[k]
#     end
# end

# for k in 0..N-1
#     if k % 2 == 1
#         B += a[N-k-1]
#     else
#         A += a[N-k-1]
#     end
# end

k = 1
while k < N
    A += a[N-k]
    B += a[N-k-1]
    k += 2
end 
if N % 2 == 1
    A += a[0]
end
print A-B

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



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

	int N;
	cin >> N;
	vector<int>P(N);
	for (int i = 0; i < N; i++)cin >> P[i];
	int ma = 0;
	vector<int>dp(N+1);
	for (int i = 0; i < N; i++) { dp[P[i]] = dp[P[i]-1]+1 ; ma = max(ma,dp[P[i]]); }
	puts(N-ma);
	


	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
   int n,i,n2;
   char s[101];
 
   scanf("%d",&n);
   n2=n/2;
   scanf("%s",s);
   for (i=0;i<n2;i++)
      if (s[i]!=s[i+n2]) break;
   if (n%2==0 && i==n2) puts("Yes");
   else                 puts("No");
   return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
 
#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c)
#define rsort(a,n) sort(a,a+n,greater<>())
 
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100;
 
int main(void){
    ll a,b;
    str s,op;

    in1(s);
    if (s[0] == 'a') prl("vowel");
    else if (s[0] == 'i') prl("vowel");
    else if (s[0] == 'u') prl("vowel");
    else if (s[0] == 'e') prl("vowel");
    else if (s[0] == 'o') prl("vowel");
    else prl("consonant");

    return 0;
}

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

int main() {

	ll ns, nc; cin >> ns >> nc;
	if (nc % 2 == 1) nc--;
	
	ll ans = 0;

	if (2* ns == nc) {
		ans += ns;
	}
	else if (2 * ns < nc) {
		ans += ns;
		nc -= 2 * ns;
		ans += nc / 4;
	}
	else { // 2 * ns > nc
		ans += nc / 2;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 20, inf = 0x3f3f3f3f;
int n;
int dp[maxn][19][2], a[20][2], pos[maxn][20];
int main() {
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> a[i][0];
	}
	for(int i = 0; i < n; ++i) {
		cin >> a[i][1];
	}
	memset(dp, 0x3f3f, sizeof(dp));
	for(int i = 0; i < n; ++i) {
		dp[1 << i][i][i & 1] = i;
	}
	for(int S = 0; S < 1 << n; ++S) {
		for(int i = 0; i < n; ++i) {
			pos[S][i] = i;
			for(int j = i + 1; j < n; ++j) {
				if(S >> j & 1) {
					++pos[S][i];
				}
			}
		}
	}
	for(int S = 0; S < 1 << n; ++S) {
		int c = __builtin_popcount(S);
		for(int i = 0; i < n; ++i) {
			if(S >> i & 1) {
				for(int j = 0; j < n; ++j) {
					if(!(S >> j & 1)) {
						for(int k = 0; k < 2; ++k) {
							if(a[j][abs(j - c) & 1] >= a[i][k]) {
								dp[S ^ (1 << j)][j][abs(j - c) & 1] = min(dp[S ^ (1 << j)][j][abs(j - c) & 1], dp[S][i][k] + pos[S][j] - c);
							}
						}
					}
				}
			}
		}
	}
	int ans = inf;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < 2; ++j) {
			ans = min(ans, dp[(1 << n) - 1][i][j]);
		}
	}
	cout << (ans == inf ? -1 : ans) << endl;
	/*
		1 2 3 -> 1 -3 -2 -> 3 -1 -2
		1 2 3 -> -2 -1 3 -> -2 -3 1
		dp[S][i][0][1] : 选中了S集合 以i为结尾最少步数
	*/
	return 0;
}

Measured memory_bytes: 178560
INTEGER A,B,C,X,ANS
READ*,A,B,C,X
ANS=0
DO I=0,A
  DO J=0,B
    DO K=0,C
      IF(I*500+J*100+K*50==X)ANS=ANS+1
      IF(I*500+J*100+K*50>X)EXIT
    END DO
    IF(I*500+J*100>X)EXIT
  END DO
  IF(I*500>X)EXIT
END DO
PRINT"(I0)",ANS
END

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#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>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#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 <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main ()
{
	int N , M;
	while( cin >> N >> M , N || M )
	{
		vector<pair<long long int , long long int>>data ( N  );
		for( size_t i = 0; i < N; i++ )
		{
			cin >> data[i].second >> data[i].first;
		}
		sort ( data.rbegin () , data.rend () );
		int i = 0;
		long long int ans = 0;
		while( i < data.size () )
		{
			if( data[i].second > M )
			{
				ans+=( data[i].second - M )*data[i].first;
				M = 0;
			} else
			{
				M -= data[i].second;
			}
			i++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1476
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, m) = scan!(usize, usize);
    let vs = scan!(i64, i64; n);
    let ws = scan!(i64, i64;m);
    for (a, b) in vs {
        let mut no = 0;
        let mut diff = 1 << 60;
        for (i, &(c, d)) in ws.iter().enumerate() {
            let d = (a - c).abs() + (b - d).abs();
            if d < diff {
                diff = d;
                no = i;
            }
        }
        println!("{}", no + 1);
    }
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) { cin >> s[i]; }

    // 処理
    sort(all(s));

    // 出力
    rep(i, n) { cout << s[i]; }

    return 0;
}


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

typedef long long ll;

int main(){
	ll s;
	cin>>s;
	
	const ll mod=1000000000;
	
	ll x=(mod-s%mod)%mod;
	ll y=(s+x)/mod;
	
	cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int[] a  = new int[n];
        for(int i=0;i<n;i++){
            a[i] = Integer.parseInt(sc.next());
        }
        for(int i=k;i<n;i++){
            if(a[i-k]<a[i]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 61740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int su = 0; 
    rep(i,n) su ^= a[i];
    rep(i,n) {
        cout<<(su^a[i])<<" ";
    }
    cout<<endl;
    return 0;
}

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

using lint = long long int;
using pii = std::pair<int, int>;

using std::vector;
using std::priority_queue;

vector<pii> ve;
vector<int> ve2;
priority_queue<int, vector<int>, std::greater<int> > pq;

int main(void) {
	int N, M;
	scanf("%d %d", &N, &M);
	for (int i = 1; i <= N; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		ve.push_back(pii(t1, t2));
	}

	sort(ve.begin(), ve.end());

	int cou = 0;
	for (int i = 0; i < N; i++) {
		pq.push(ve[i].second);
		if (ve[i].first <= cou) {
			ve2.push_back(pq.top());
			pq.pop();
		}
		else {
			cou++;
		}
	}

	sort(ve2.begin(), ve2.end(), std::greater<int>());

	int cou2 = cou;
	cou = 0;
	int ans = 0;
	for (int i = 0; i < ve2.size(); i++) {
		if (M - cou == cou2) {
			ans++;
		}
		else if (M + 1 - ve2[i] <= cou) {
			ans++;
		}
		else {
			cou++;
		}
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 3952
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
    char a[3];
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    int sum=0;
    for(int i=0;i<3;i++){
        if(a[i]=='1')sum++;
    }
   cout<<sum<<endl;
    
    return 0;
}

Measured memory_bytes: 256
// {{{ Headers
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <cassert>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <fstream>
#include <iostream>
#include <sstream>

using namespace std;
// }}}

typedef long long int64;
const int INF = 0x3f3f3f3f;
template <class T> inline int len (const T &a) { return a.size (); }
#define ALL(x) (x).begin(), (x).end()

const int MX = 100 * 1000 + 5;
int a [MX];
int dp [MX];

int
main () {
    int N;
    scanf ("%d", &N);
    for (int i = 0; i < N; i++) scanf ("%d", a + i);
    memset (dp, INF, sizeof (dp));
    dp [0] = 0;
    for (int i = 0; i < N; i++)
        for (int j = 1; j <= 2; j++)
            if (i >= j)
                dp [i] = min (dp [i], dp [i - j] + abs (a [i] - a [i - j]));
    printf ("%d\n", dp [N - 1]);

#ifdef LOCALHOST
	cerr << "time: " << (int64) clock () * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
    return 0;
}



Measured memory_bytes: 1024
import heapq

n,m=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for i in range(n):
    heapq.heappush(q,-a[i])

for i in range(m):
    b=heapq.heappop(q)
    b=-b
    b=b//2
    b=-b
    heapq.heappush(q,b)
    
print(-sum(q))

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

//vector<vector<int>> vec(縦,vector<int>(横));
/*deque<型> 配列の先頭にも用がある時はvectorの代わりに。
入力はstringでもらってからpush_back()*/
//printf("%書式指定" ,出力したい物);\nで改行



int main(){
  int K,A,B;
  cin>>K>>A>>B;
  
  for(int i=A;i<=B;i++)
  {
    if(i%K==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
    
    
  
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#define N 110
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,GMatrices[N][N]={0};
int color[N],d[N],f[N],tt;

void dfs_visit(int u)
{
	int v;
	color[u]=GRAY;
	d[u]=tt+1;
	tt++;
	for(v=0;v<n;v++)
	{
		if(GMatrices[u+1][v+1]==0)
			continue;
		if(color[v]==WHITE)
			dfs_visit(v);
	}
	color[u]=BLACK;
	f[u]=tt+1;
	tt++;
	return;
}
void dfs()
{
	int u;
	for(u=0;u<n;u++)
		color[u]=WHITE;
	tt=0;

	for(u=0;u<n;u++)
		if(color[u]==WHITE)
			dfs_visit(u);

	for(u=0;u<n;u++)
		printf("%d %d %d\n",u+1,d[u],f[u]);
	return;
}
int main()
{
	int u,k,v;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&u,&k);
		for(int j=1;j<=k;j++)
		{
			scanf("%d",&v);
			GMatrices[u][v]=1;
		}
	}
	
	dfs();

	return 0;
}


Measured memory_bytes: 2148
#include<cstdio>
using namespace std;
long long n,m,i,ans;
int main()
{
  scanf("%lld%lld",&n,&m);
  ans=m*1900+(n-m)*100;
  for (i=1;i<=m;i++) ans=ans*2;
  printf("%lld\n",ans);
}


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

int n,x,a[222],b[222],na,nb,c,ans,G[222][222],pre[222],used[222];
map<int,int>mp;

bool pri(int x){
	if (x==1) return 0;
	for (int i=3;i*i<=x;++i) if (x%i==0) return 0;
	return 1;
}

int dfs(int x){
	for (int i=1;i<=nb;++i) if (!used[i]&&G[x][i]){
		used[i]=1;
		if (!pre[i]||dfs(pre[i])){
			pre[i]=x;
			return 1;
		}
	}
	return 0;
}

int main(){
	for (cin>>n;n--;)
		cin>>x, mp[x]^=1, mp[x+1]^=1;
	for (auto o:mp) if (o.second)
		(o.first&1? a[++na]: b[++nb])=o.first;
	for (int i=1;i<=na;++i)
		for (int j=1;j<=nb;++j) if (pri(abs(a[i]-b[j])))
			G[i][j]=1;
	for (int i=1;i<=na;++i){
		memset(used,0,sizeof used);
		c+=dfs(i);
	}
	ans=c+((na-c)/2+(nb-c)/2)*2+(na-c)%2*3;
	cout<<ans;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;



int main() {
	int k,a=0,b=0;
	cin >> k;
	for (int i = 1; i <= k; i++) {
		if (i % 2 == 0) a++;
		else b++;
	}
	cout << a * b << endl;

	return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const ll inf = (1LL<<32);
const int mod = 1e9 + 7;
const int N = 100005;

int v[N], p[N];

int main(){
	fastio;
    int n,k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> p[i];
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    ll ans = -inf;
    for(int i = 1; i <= n; i++){
        int pos = p[i], cnt = 1;
        ll sum = 0;
        vector<ll> f;
        while(cnt <= k){
            sum += v[pos]; // soma do ciclo
            ans = max(ans, sum);
            f.pb(sum);
            if(pos == i)
                break;
            pos = p[pos];
            cnt++; // tamanho do ciclo
        }
        if(k > cnt and sum > 0){
            ll temp = 0;
            for(int j = 0; j < (k%cnt != 0 ? k%cnt : sz(f)); j++) // pego o maior subciclo
                temp = max(temp, f[j]);
            ans = max(ans, temp + sum*(k/cnt - (k%cnt == 0)));
        }
    }
    cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
#define ll long long
int h, w;
ll dp[1010][1010];
bool a[1010][1010];
const int MOD = 1e9 + 7;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> h >> w;
	for(int i = 1; i <= h; ++i)
		for(int j = 1; j <= w; ++j) {
			char x;
			cin >> x;
			a[i][j] = (x == '#');
		}
	dp[1][1] = 1;
	for(int i = 1; i <= h; ++i) {
		for(int j = 1; j <= w; ++j) {
			if(i == j && i == 1) continue;
			if(!a[i][j - 1]) dp[i][j] = 1ll * (dp[i][j] + dp[i][j - 1]) % MOD;
			if(!a[i - 1][j]) dp[i][j] = 1ll * (dp[i][j] + dp[i - 1][j]) % MOD;
		}
	}
	cout << dp[h][w];
	return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            CWalkingTakahashi solver = new CWalkingTakahashi();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class CWalkingTakahashi {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            long x = Math.abs(s.nextLong()), k = s.nextLong(), d = s.nextLong();
            if (k >= x / d + 1) {
                long y = x / d + 1, dif = k - y;
                w.println(dif % 2 == 0 ? d * y - x : x - d * (y - 1));
            } else {
                w.println(x - d * k);
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

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

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public long nextLong() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }

            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

const int MAX_N = 3003;

double p[MAX_N], dp[MAX_N][MAX_N];

int main() {
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> p[i];
    for (int i = 1; i <= N; i++) dp[0][i] = 0;
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            dp[i][j] = dp[i - 1][j] * (1 - p[i]);
            if (j - 1 >= 0) dp[i][j] += dp[i - 1][j - 1] * p[i];
        }
    }
    double ans = 0;
    for (int i = (N + 1) / 2; i <= N; i++) ans += dp[N][i];
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k;
	cin >> n >> k;
	ll dp[n + 2];
	dp[n + 1] = 1;
	for (ll i = n; i >= 1; i--) {
		dp[i] = dp[i + 1] + n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2 - i * (i - 1) / 2 + 1;
		dp[i] %= mod;
	}
	cout << dp[k] << "\n";
 	return 0;
}

Measured memory_bytes: 5144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (Math.abs(x - a) < Math.abs(x - b)) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}

		sc.close();

	}

}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    string s = "abcdefghijklmnopqrstuvwxyz";
    string ss;
    cin >> ss;
    bool flag = false;
    rep(i, s.size())
    {
        if (ss.find(s[i]) == string::npos)
        {
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) {
		ll a;
		cin >> a;
		A.at(a)++;
	}
	ll an = 1;
	if (N % 2 == 0) {
		rep(i, N / 2) {
			if (A.at(2 * i + 1) != 2) {
				cout << 0 << endl;
				return 0;
			}
			an *= 2;
			an %= 1000000007;
		}
	}
	else {
		rep(i, N / 2) {
			if (A.at(2 * i+2) != 2) {
				cout << 0 << endl;
				return 0;
			}
			an *= 2;
			an %= 1000000007;
		}
		if(A.at(0)!=1) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << an << endl;
}




Measured memory_bytes: 1024
line_num = int(raw_input())
for n in range(line_num):
	a = raw_input()
	b = raw_input()
	if len(a) > 80 or len(b) > 80:
		print 'overflow'
	else:
		filled_a, filled_b = a.zfill(80), b.zfill(80)
		rlist_a = map(int,list(filled_a)[::-1])
		rlist_b = map(int,list(filled_b)[::-1])
		rlist_sum = []
		for n in range(80):
			rlist_sum.append(rlist_a[n]+rlist_b[n])
		for n in range(79):
			if rlist_sum[n] > 9:
				rlist_sum[n] -= 10
				rlist_sum[n+1] += 1
		if rlist_sum[79] > 9:
			print 'overflow'
		else:
			list_sum = []
			f = 0
			for n in rlist_sum[::-1]:
				if f > 0:
					list_sum.append(n)
				else:
					if n > 0:
						f = 1
						list_sum.append(n)
			ans = ''.join(map(str,list_sum))
			if len(ans) < 1:
				print '0'
			else:
				print ans

Measured memory_bytes: 4284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll sum[200009];
map<ll,ll>mp;

int main(){
  ll n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    a--;
    sum[i+1]=sum[i]+a;
    sum[i+1]%=k;
  }
  ll ans=0;
  for(int i=0;i<=n;i++){
    if(i-k>=0){
      mp[sum[i-k]]--;
    }
    ans+=mp[sum[i]];
    mp[sum[i]]++;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    string s;
    cin >> s;
    string ans ="No";
    if(s=="abc" || s=="acb" || s=="cba" || s=="cab" ||s=="bac" || s=="bca"){
        ans = "Yes";
    }
    cout << ans << endl;
}



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

using namespace std;

int main(){
    long long int H,W,ans=0;
    cin >> H >> W;
    long long int d[10][10];

    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> d[i][j];
        }
    }

    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int A;
            cin >> A;
            if(A!=-1){
                ans += d[A][1];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
def _resulting(ab):
    a, b = 0, 0
    for itr in ab:
        if itr[0] > itr[1]:
            a = a + (itr[0] + itr[1])
        elif itr[0] < itr[1]:
            b = b + (itr[0] + itr[1])
        else:
            a = a + itr[0]
            b = b + itr[1]
    return a, b


if __name__ == '__main__':
    while True:
        N = int(input())
        if N != 0:
            ab = []

            for itr in range(0, N):
                ab.append(list(map(int, input().split())))

            a, b = _resulting(ab)

            print(a, b)
        else:
            break

Measured memory_bytes: 9208
#include <cstdio>
#include <cstdlib>

void func(int **D, bool **pass, int V){
    int i,j,k;
    for(i=0;i<V;i++){
        for(j=0;j<V;j++){
            for(k=0;k<V;k++){
                if(pass[j][i] && pass[i][k]){
                    if(!pass[j][k]){
                        D[j][k] = D[j][i] + D[i][k];
                        pass[j][k] = true;
                    }else{
                        if(D[j][i] + D[i][k] < D[j][k]){
                            D[j][k] = D[j][i] + D[i][k];
                        }
                    }
                }
            }
        }
    }
}

int main(){
    int i,j,s,t,d,V,E;
    scanf("%d %d",&V,&E);

    int **D = (int **)malloc(sizeof(int *)*V);
    bool **pass = (bool **)malloc(sizeof(bool *)*V);
    for(i=0;i<V;i++){
        D[i] = (int *)malloc(sizeof(int)*V);
        pass[i] = (bool *)malloc(sizeof(bool)*V);
        for(j=0;j<V;j++){
            D[i][j] = 0;
            if(i==j) pass[i][j] = true;
            else pass[i][j] = false;
        }
    }

    for(i=0;i<E;i++){
        scanf("%d %d %d",&s,&t,&d);
        D[s][t] = d;
        pass[s][t] = true;
    }

    func(D,pass,V);

    for(i=0;i<V;i++){
        if(D[i][i]<0){
            printf("NEGATIVE CYCLE\n");
            return 0;
        }
    }

    for(i=0;i<V;i++){
        for(j=0;j<V;j++){
            if(pass[i][j])printf("%d",D[i][j]);
            else printf("INF");
            if(j<V-1)printf(" ");
            else printf("\n");
        }
    }

    return 0;
}



Measured memory_bytes: 2796
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
    char n[4];
    scanf("%s", n);
    for(int i = 0; i < 3; i++){
        if (n[i] == '1') {
            n[i] = '9';
        }else if (n[i] == '9'){
            n[i] = '1'; 
        }
    }
    cout << n << '\n';
}

Measured memory_bytes: 256
// なぜかREになるが意味不明

package main

import "fmt"

func main() {
	var N, Q int
	fmt.Scan(&N, &Q)
	var S string
	fmt.Scan(&S)
	SS := make([]string, len(S))
	for i, c := range []rune(S) {
		SS[i] = string(c)
	}
	ruiseki := make([]int, N+1)
	for i := 0; i < len(SS)-1; i++ {
		if SS[i] == "A" && SS[i+1] == "C" {
			ruiseki[i+1]++
		}
	}
	//             ↓ ????????????????????????
	for i := 1; i <= N; i++ {
		ruiseki[i] += ruiseki[i-1]
	}
	for i := 0; i < Q; i++ {
		var L, R int
		fmt.Scan(&L, &R)
		L, R = L-1, R-1
		fmt.Println(ruiseki[R] - ruiseki[L])
	}
}


Measured memory_bytes: 5632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String L = sc.next();
    long MOD = (long)Math.pow(10, 9) + 7;
    int n = L.length();
    long[][] dp = new long[n + 1][2];
    dp[0][0] = 1;
    dp[0][1] = 0;
    for(int i = 1; i < n + 1; i++) {
      if(L.charAt(i - 1) == '0') {
        dp[i][0] = dp[i - 1][0];
        dp[i][1] = (3 * dp[i - 1][1]) % MOD;
      } else {
        dp[i][0] = (2 * dp[i - 1][0]) % MOD;
        dp[i][1] = (3 * dp[i - 1][1]) % MOD;
        dp[i][1] = (dp[i][1] + dp[i - 1][0]) % MOD; 
      }
    }
    long ans = (dp[n][0] + dp[n][1]) % MOD;
    System.out.println(ans);
  }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define SZ(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
using namespace std;

typedef long long ll;
typedef pair<int,int> PI;
typedef unsigned long long ull;

#define PR(...) do{cerr << "line : " << __LINE__ << endl; pr(#__VA_ARGS__, __VA_ARGS__);}while(0);
template<class T>
void pr(const string& name, T t){
  cerr << name << ": " << t << endl;
}

template<typename T, typename ... Types>
void pr(const string& names, T t, Types ... rest) {
  auto comma_pos = names.find(',');
  cerr << names.substr(0, comma_pos) << ": " << t << ", ";
  
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest ...);
}

template<class T,class U> ostream& operator<< (ostream& o, const pair<T,U>& v){return o << "(" << v.F << ", " << v.S << ")";}
template<class T> ostream& operator<< (ostream& o, const vector<T>& v){o << "{";rep(i,SZ(v)) o << (i?", ":"") << v[i];return o << "}";}
template<class T> ostream& operator<< (ostream& o, const set<T> &v){o << "{";for(auto e : v) o << e << ", ";return o << "}";}
template<class T, class U> ostream& operator<< (ostream& o, const map<T,U> &v){o << "{";for(auto e : v) o << e.F << ": " << e.S << ", ";return o << "}";}

//                < v > ^
const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};
#define endl '\n'

vector<PI> G[1000];

ll dfs(int v, int p){
  ll ret = 0;
  for(auto e : G[v]){
    if(e.F == p) continue;
    if(SZ(G[e.F]) == 1) continue;
    ret = max(ret, dfs(e.F, v) + e.S);
  }
  
  return ret;
}

int main(int argc, char *argv[])
{
  int n;
  while(cin >> n && n){
    rep(i, n) G[i].clear();
    ll sum = 0;
    vector<int> pv(n-1), dv(n-1);
    rep(i, n - 1) cin >> pv[i];
    rep(i, n - 1) cin >> dv[i];
    
    rep(i, n - 1){
      int p = pv[i];
      int d = dv[i];
      --p;
      G[i + 1].pb(mp(p, d));
      G[p].pb(mp(i + 1, d));
    }
    
    ll ans = 0;
    rep(i, n){
      if(SZ(G[i]) == 1) continue;
      ans = max(ans, dfs(i, -1));
    }
    
    rep(i, n - 1){
      int a = i + 1;
      int b = pv[i] - 1;
      if(SZ(G[a]) == 1 ||
	 SZ(G[b]) == 1) sum += dv[i];
      else sum += dv[i] * 3;
    }
    //cout << sum << " " << ans << endl;
    cout << sum  - ans << endl;
  }
  
}

Measured memory_bytes: 1336
import copy

def main():
  N=int(input())
  A=[int(input()) for _ in range(N)]

  a=max(A)
  k=A.count(a)#リストの最大数の個数をカウント
  if k>=2:
    for i in range(N):
      print(a)
  else:
    b=A.index(a)
    for i in range(N):
      if i != b:
        print(a)
      else:
        s=sorted(A)
        print(s[N-2])

if __name__ == "__main__":
    main()

Measured memory_bytes: 14672
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())

    X = [1]
    for i in range(1, 101):
        if 6**i > N:
            break
        X.append(6**i)
    for i in range(1, 101):
        if 9**i > N:
            break
        X.append(9**i)
    dp = [N+1] * (N+1)
    dp[0] = 0
    for i in range(N):
        for x in X:
            if i+x <= N:
                dp[i+x] = min(dp[i+x], dp[i] + 1)
    print(dp[N])


if __name__ == '__main__':
    main()


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

using namespace std;

int n;
double t, a, diff = 1e9, an;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> t >> a;
    for (int i = 0; i < n; ++i) {
        double h;
        cin >> h;
        double v = t - h * 0.006;
        if (abs(v-a) < diff) {
            diff = abs(v-a);
            an = i+1;
        }
    }
    cout << an << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
		public static void main(String args[]) {
			Scanner sc = new Scanner(System.in);
			int h, m, cnt = 0;
			String array[] = new String[10];
			String temp;
			String str;
			
			for(int i = 0; i < 10; i++) {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				array[i] = str;
				m = sc.nextInt();
				for(int j = 0; j < m; j++) {
					h = sc.nextInt();
					temp = array[i].substring(0, h);
					array[i] = array[i].substring(h);
					array[i] = array[i].concat(temp);
				}
				cnt++;
			}
			sc.close();
			
			for(int i = 0; i < cnt; i++) {
				System.out.println(array[i]);
			}
		}
}


Measured memory_bytes: 26448
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
int N, M;
int P[100005], par[100005], tree_rank[100005]; //木の深さ

void init(int n){
  rep(i, n){
    par[i] = i;
    tree_rank[i] = 0;
  }
}

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

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

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

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

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

  cin >> N >> M;
  init(N);
  rep(i, N) cin >> P[i];
  int a,b;
  rep(i, M){
    cin >> a >> b;
    unite(a, b);
  }

  int cnt = 0;
  rep(i, N){
    if(P[i]==i+1){
      cnt++;
      continue;
    }
    if(same(P[i], i+1)){
      cnt++;
      continue;
    }
  }

  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------

ll N;
vector<ll> H(MAX_N);

int main() {

  cin >> N;
  rep(i, N) cin >> H[i];

  rep(i, N-1) {
    if(H[i]<=H[i+1]||H[i]<=H[i+1]+1) {
      if(!(H[i]<=H[i+1])) {
        ++H[i+1];
      }
    }else {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

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

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

    int64 ans = 0;
    for (int64 i=1; i<=n; i++) {
        int64 m = n/i;
        ans += i * m*(m+1)/2;
    }
    cout << ans << endl;
}

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

class piza{
    public:
    int num;
    int price;
};

int main(){
    piza A, B, C, more, less;
    cin >> A.price >> B.price >> C.price >> A.num >> B.num;
    if(A.num > B.num){
        more = A;
        less = B;
    }
    else{
        less = A;
        more = B;
    }

    //ABピザ割高
    if(A.price+B.price <= 2*C.price) cout << A.price*A.num + B.price*B.num << endl;

    //ABピザ割安
    else{
        //ABピザ破格
        if(more.price >= 2*C.price){
            cout << 2*C.price*more.num << endl;;
        }
        //ABピザ普通
        if(more.price < 2*C.price){
            cout << 2*less.num * C.price + (more.num-less.num) * more.price << endl;
        }
    }
}

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

public class Main {
	private static final long MOD = (long)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		long res = 0;
		int abh = 2 * c; // a + b
		
		// buy a + b
		int buyab = Math.min(x, y);
		res += buyab * Math.min(a+b, abh);
		
		x -= buyab;
		y -= buyab;
		
		// buy a
		if (x > 0) { res += (x * Math.min(a, abh)); }
		
		// buy b
		if (y > 0) { res += (y * Math.min(b, abh)); }
		
		System.out.println(res);
	}
	
	private static int findNiconicoLevel(String s) {
		int res = 0;
		String prev = "";
		int pos = 1;
		int level = 0;
		while (pos < s.length()) {
			String curr = "" + s.charAt(pos - 1) + s.charAt(pos);
			if (curr.equals("25")) {
				if (prev.equals("25")) {
					level += 2;
				} else {
					prev = "25";
					level = 2;
				}
				res = Math.max(res, level);
				pos += 2;
			} else {
				level = 0;
				prev = "";
				pos++;
			}
		}
		
		return res;
	}
	
	private static String nTimesChar(char c, int t) {
		String res = "";
		for (int i = 0; i < t; i++) {
			res += c;
		}
		return res;
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21332