akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void){
	int d,n,hund=1;
    scanf("%d %d", &d,&n);
    for(int i = 1;i <= d;i++){
    	hund *= 100;
    }
    if(n == 100)n += 1;
    printf("%d\n",n * hund);
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <iterator>
#include <algorithm>

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

using namespace std;

vector<map<int, int>> g;
vector<int> depth;

void calc_depth(int x, int k){
	depth[x] = k;
	for(auto it = g[x].begin(), end = g[x].end(); it != end; ++it){
		int t = it->first;
		if(depth[t] == -1){
			calc_depth(t, k + 1);
		}
	}
}

pair<int, int> calc_dp(int x){
	int s = 0, p = 0;
	for(auto it = g[x].begin(), end = g[x].end(); it != end; ++it){
		int t = it->first, c = it->second;
		if(depth[t] < depth[x]){
			continue;
		}
		pair<int, int> v = calc_dp(t);
		int a = v.first, b = v.second;
		s += a ? 3 * c + a : c;
		p = max(p, a ? c + a - b : 0);
	}
	return pair<int, int>(s, s - p);
}

int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0){
			break;
		}
		vector<int> a, b;
		copy_n(istream_iterator<int>(cin), n - 1, back_inserter(a));
		copy_n(istream_iterator<int>(cin), n - 1, back_inserter(b));

		g = vector<map<int, int>>(n, map<int, int>());
		rep(i, n - 1){
			int p = i + 1, q = a[i] - 1, c = b[i];
			g[p][q] = g[q][p] = c;
		}

		vector<int> ans;
		rep(i, n){
			depth = vector<int>(n, -1);
			calc_depth(i, 0);
			ans.push_back(calc_dp(i).second);
		}
		cout << *min_element(ans.begin(), ans.end()) << endl;
	}
	return 0;
}

/*

def calc_depth(x, k):
	global g, depth
	depth[x] = k
	for t in g[x].iterkeys():
		if(depth[t] == -1):
			calc_depth(t, k + 1)

def calc_dp(x):
	global g, depth
	s = 0; p = 0
	for t, c in g[x].iteritems():
		if depth[t] < depth[x]:
			continue		
		a, b = calc_dp(t)
		s += 3 * c + a if a else c
		p = max(p, c + a - b if a else 0)
	return s, s - p

while 1:
	n = input()
	if n == 0:
		break
	a = map(int, raw_input().split())
	b = map(int, raw_input().split())
	
	g = [{} for i in xrange(n)]
	for i in xrange(n - 1):
		p = i + 1; q = a[i] - 1; c = b[i]
		g[p][q] = g[q][p] = c

	ans = []
	for i in xrange(n):
		depth = [-1] * n
		calc_depth(i, 0)
		ans.append(calc_dp(i)[1])
	print min(ans)

*/

Measured memory_bytes: 3256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <map>
#include <cmath>
#include <vector>

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

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

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

    int ans = (n%2 == 0) ? n/2 : n/2 + 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scanner.nextInt();
		int[] b = new int[m];
		for (int i = 0; i < m; i++)
			b[i] = scanner.nextInt();

		int ans = 0;
		for (int i = 0; i < m - ans; i++) {
			int idx = i;
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				if (b[idx] == a[j]) {
					cnt++;
					idx++;
				}
			}
			ans = Math.max(ans, cnt);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36092
#include <cstdio>

using namespace std;

#define YEAR_MAX 3000

bool reap[YEAR_MAX + 1];

int main()
{
	for (int i = 4; i < YEAR_MAX; i++){
		if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0){
			reap[i] = true;
		}
	}
	
	int a[10000], b[10000];
	bool flag;
	int num = 0;
	
	while (scanf("%d %d", &a[num], &b[num]), !(a[num] == 0 && b[num] == 0)){
		num++;
	}
	
	for (int j = 0; j < num; j++){
		flag = true;
		for (int i = a[j]; i <= b[j]; i++){
			if(reap[i]){
				printf("%d\n", i);
				flag = false;
			}
		}
		if (flag) printf("NA\n");
		if (j < num - 1) puts("");
	}
}

Measured memory_bytes: 1052
import java.util.*;
import java.text.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[n];
        Map<Integer, Integer> map = new HashMap<>();
        for (int i=0; i<n; i++) {
            arr[i] = sc.nextInt();
            if (map.containsKey(arr[i])) {
                map.put(arr[i], map.get(arr[i])+1);
            } else {
                map.put(arr[i], 1);
            }
        }
        Arrays.sort(arr);

//        List<Integer> list = new ArrayList<>();
//        for (int i=0; i<n; i++) list.add(sc.nextInt());
//        Collections.sort(list);

        int cnt = 0;

        int max = arr[n-1]+1;
        boolean[] flag = new boolean[max+1];
        for (int i=0; i<n; i++) flag[arr[i]] = true;
        int sqrt = (int)Math.sqrt(max+1);

        for (int i=0; i<n; i++) {
            int tmp = arr[i];
            if (flag[tmp]) {
                for (int j=tmp*2; j<=max; j+=tmp) {
                    flag[j] = false;
                }
            }
            if (map.get(tmp)!=1) flag[tmp] = false;
        }

        for (int i=0; i<flag.length; i++) {
//            System.out.println(flag[i] + " ");
            if (flag[i]) cnt++;
        }

        System.out.println(cnt);
    }


}


Measured memory_bytes: 72056
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt(), k = sc.nextInt();
		int[] d = new int[k];
		for (int i = 0; i < k; i++) {
			d[i] = sc.nextInt();
		}

		while (true) {
			boolean match = false;
			for (int i = 0; i < k; i++) {
				if (String.valueOf(n).contains(String.valueOf(d[i]))) {
					n++;
					match = true;
					break;
				}
			}
			if (!match) {
				System.out.println(n);
				return;
			}
		}
	}
}


Measured memory_bytes: 36860
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int A, B, K;
    cin >> A >> B >> K;

    int max;
    for(int i=0;i<K;i++){
        cout << A+i << endl;
        max = A+i;
        if(A+i == B)
            break;
    }
    
    for(int i=1;i<=K;i++){
        if(B - (K-i) > max)
            cout << B - (K-i) <<endl;
    }

    return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    ($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; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($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(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(usize);
    let (mut t, mut a) = get!(usize, usize);
    for _ in 0..n-1 {
        let (nt, na) = get!(usize, usize);
        let x = (t + nt - 1) / nt;
        let y = (a + na - 1) / na;
        if x > y {
            t = nt * x;
            a = na * x;
        } else {
            t = nt * y;
            a = na * y;
        }
    }
    println!("{}", t + a);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
string s;
int a=-1;
int main()
{
    getline(cin,s);
    for(int i=0;i<s.size();i++)
    	if(s[i]=='C'){a=i;break;}
    if(a==-1){cout<<"No"<<endl;return 0;}
    for(int i=a;i<s.size();i++)
    	if(s[i]=='F'){cout<<"Yes"<<endl;return 0;}
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = (int)1e5 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int h, w, k;
    cin >> h >> w >> k;
    vector <vector <char> > grid(h + 1, vector <char>(w + 1));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> grid[i][j];
        }
    }
    int ans = 0;
    int mask_row = 1 << h, mask_col = 1 << w;
    for (int mask_i = 0; mask_i < mask_row; ++mask_i) {
        for (int mask_j = 0; mask_j < mask_col; ++mask_j) {
            vector <vector <char> > grid_temp(h + 1, vector <char>(w + 1));
            grid_temp = grid;
            for (int i = 0; i < h; ++i) {
                if (mask_i & (1 << i)) {
                    for (int j = 0; j < w; ++j) {
                        grid_temp[i][j] = 'R';
                    }
                }
            }
            for (int i = 0; i < w; ++i) {
                if (mask_j & (1 << i)) {
                    for (int j = 0; j < h; ++j) {
                        grid_temp[j][i] = 'R';
                    }
                }
            }
            int black = 0;
            for (int i = 0; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    
                    if (grid_temp[i][j] == '#') ++black;
                }
            }
            if (black == k) {
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if(a==7&&b==5&&c==5){
        cout<<"YES"<<endl;
        return 0;
    }
     else if(a==5&&b==7&&c==5){
        cout<<"YES"<<endl;
        return 0;
    }
    else if(a==5&&b==5&&c==7){
        cout<<"YES"<<endl;
        return 0;
    }
    else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Array.ST
import Control.Monad.ST

type IA s = STArray s Int Int

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- getInt
  let (ns, cnt) = solve as
  putStrLn $ init $ concatMap (\i -> show i ++ " ") ns
  print cnt

getInt :: IO [Int]
getInt = map read . words <$> getLine

solve :: [Int] -> ([Int], Int)
solve as = runST $ do
  as' <- newListArray (0, n) as :: ST s (IA s)
  cnt <- bsort as' 0
  ans <- getElems as'
  return (ans, cnt)
  where
    n = length as - 1
    swap arr i j = do
      tmp <- readArray arr i
      readArray arr j >>= writeArray arr i 
      writeArray arr j tmp
    bsort :: IA s -> Int -> ST s Int
    bsort arr cnt = do
      fs <- forM [1..n] $ \i -> do
        x <- readArray arr i
        y <- readArray arr (i - 1)
        if x < y then do
          swap arr i (i - 1)
          return 1
          else
          return 0
      let cnt' = sum fs
      if cnt' == 0 then return cnt
        else bsort arr (cnt+cnt')

Measured memory_bytes: 4068
#include <stdio.h>


void printstate(int N, int* mons){
    for(int i=0; i < N; i++){
        printf("%d, ", mons[i]);
    }
    printf("\n");
}

bool check_killable(long hit, int N, int A, int B, int* mons){
    int remA = hit;
    for(int i=0; i < N; i++){
        long remains = (mons[i] - B*hit);
        if(remains > 0){
            long center = remains / (A-B); // need to hit by center
            if(remains % (A-B) != 0){
                center++;
            }
            remA -= center;
        }
        if(remA < 0){
            return false;
        }
    }
    return true;
}

int test(int N, int A, int B, int* mons){
    for(int i=0; i < 5; i++){
        if(check_killable(i, N, A, B, mons)){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
}

int main(){
    int N = 0;
    int A = 0;
    int B = 0;
    int mons[100001] = {};
    scanf("%d %d %d", &N, &A, &B);
    for(int i=0; i < N; i++){
        scanf("%d", &(mons[i]));
    }

    //test(N, A, B, mons);
    /* main */
    long lower = 0;
    long upper = 1000000001;

    while(upper - lower > 1){
        long mid = (lower + upper)/2;
        if(check_killable(mid, N, A, B, mons)){
            upper = mid;
        }else{
            lower = mid;
        }
    }
    

    printf("%ld\n", upper);
  
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define llong long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
4
5 6 8 10
)");
#define cin input
#endif

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

	int min = INF;
	REP (i, 6)
	{
		int a;
		cin >> a;
		int count = 0;
		while (a%2==0)
		{
			a /= 2;
			count++;
		}
		if (count < min)
			min=count;
	}
	cout << min << endl;
}

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

using namespace std;

int main(){
	while(true){
		int m,n; cin >> m >> n;
		if(m == 0)break;
		bitset<7368792> t;
		int ans;
		for( int i = m; i < t.size(); i++){
			if(!t[i]){
				n--;
				if(n < 0){
					ans = i;
					break;
				}
				for(int j = 1; i*j < t.size(); j++){
					t.set(i*j);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}




Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n, k; cin >> n >> k;
    vector<ll> V(n);
    rep(i, n) cin >> V[i];

    ll res = 0;
    // 左から s 個、 右から t 個取る (s + t <= n && s + t <= k)
    // k - s - t 個まで戻せる -> マイナスの分だけ戻す
    rep(s, k + 1) rep(t, k + 1){
        if(s + t > n or s + t > k) continue;
        vector<ll> jewel;
        rep(i, s) jewel.push_back(V[i]);
        rep(i, n - t, n) jewel.push_back(V[i]);

        sort(jewel.begin(), jewel.end(), greater<ll>());
        rep(_, k - s - t){
            if(!jewel.empty() and jewel.back() < 0) jewel.pop_back();
        }
        chmax(res, accumulate(jewel.begin(), jewel.end(), (ll)0));
    }

    cout << res << endl;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 MOD = 998244353;


template<typename T> T mod_pow(T x, T n, T mod) {
  T res = 1;
  while (n > 0) {
    if (n & 1) (res *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return res;
}

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

  int n; cin >> n;
  vector<int64> d(n);
  int64 cnt[101010] = {};
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
    ++cnt[d[i]];
  }

  if (d[0] != 0) {
    cout << 0 << endl;
    return 0;
  }

  if (cnt[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  int64 ans = 1;

  for (int i = 1; i < n; ++i) {
    if (cnt[i + 1] != 0) {
      ans *= mod_pow(cnt[i], cnt[i + 1], MOD);
      ans %= MOD;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int f[100100][20],n,ans;
vector<int> e[101000];
void dfs(int x,int dad){
	int lim[20],now=0;memset(lim,0,sizeof(lim));
	for(int v:e[x]) if(v!=dad){
		dfs(v,x);
		for(int j=0;j<20;j++){
			if(lim[j]&&f[v][j]) now=max(now,j+1);
			lim[j]|=f[v][j];
		}
	}
	while(lim[now]) now++;
	ans=max(ans,now);
	for(int i=0;i<now;i++) lim[i]=0;
	lim[now]=1;
	memcpy(f[x],lim,sizeof(lim));
}
int main(){
	read(n);
	for(int i=1;i<n;i++){
		int x,y;read(x);read(y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs(1,0);
	cout<<ans<<'\n';
	return 0;
}


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

signed main(){
  int N,M;cin>>N>>M;
  std::vector<int> v(M);
  for(int i=0;i<M;i++)cin>>v[i];
  sort(v.rbegin(),v.rend());
  int ans=0;
  std::vector<int> dp(50001);
  for(int i=0;i<50001;i++)dp[i]=1e9+7;
  dp[0]=0;
  for(int i=0;i<M;i++){
    for(int j=v[i];j<50001;j++){
      dp[j]=min(dp[j],dp[j-v[i]]+1);
    }
  }
  cout<<dp[N]<<endl;
}



Measured memory_bytes: 3112
function main(input){
  var line1 = parseInt(input[0]);
 
  var ans = false;
  for (var i=1; i<input.length; i++){
    var n = parseInt(input[i]);
    
    if (n%2 ===1)
      ans = true;;
  }

  console.log(ans ? 'first' : 'second');
}


function parse(line){
  var ret = [];
  var arr = line.split(' ');
  for (var i = 0; i < arr.length; i++) {
    ret.push(parseInt(arr[i]));
  }
  return ret;
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


Measured memory_bytes: 27596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  int A[3][3];
  rep(i,3) rep(j,3) cin>>A[i][j];
  int N; cin>>N;
  rep(i,N){
    int B; cin>>B;
    rep(i,3) rep(j,3){
      if(A[i][j]==B) A[i][j]=0;
    }
  }
  rep(i,3){
    int cnt[2]={};
    rep(j,3){
      cnt[0]+=A[i][j];
      cnt[1]+=A[j][i];
    }
    if(cnt[0]==0||cnt[1]==0){
      cout<<"Yes\n";
      return 0;
    }
  }
  int cnt[2]={};
  rep(i,3){
    cnt[0]+=A[i][i];
    cnt[1]+=A[i][2-i];
  }
  if(cnt[0]==0||cnt[1]==0){
    cout<<"Yes\n";
    return 0;
  }
  cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    S = [rl().rstrip() for _ in range(N)]
    
    counter = defaultdict(int)
    for si in S:
        counter[si] += 1
    
    print('AC x ' + str(counter['AC']))
    print('WA x ' + str(counter['WA']))
    print('TLE x ' + str(counter['TLE']))
    print('RE x ' + str(counter['RE']))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 74912
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
n=int(input())
l=factorization(n)
ans=[]
for item in l:
    a=item[0]
    b=item[1]
    for i in range(b):
        ans.append(str(a))
print(str(n)+": "+" ".join(ans))


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<pair<int, ll>> ab(n);
    for (int i=0; i<n; ++i) cin >> ab.at(i).first >> ab.at(i).second;

    ll res = 0;
    vector<bool> ok(30, true);
    for (int i=29; i>=0; --i) {
        ok.at(i) = false;
        if (k & (1<<i)) {
            ll tmp = 0;
            for (auto p : ab) {
                int a = p.first;
                ll b = p.second;
                bool flag = true;
                for (int j=0; j<30; ++j) {
                    if ((a & (1<<j)) && !ok.at(j)) {
                        flag = false;
                        break;
                    }
                }
                if (flag) tmp += b;
            }
            chmax(res, tmp);
            ok.at(i) = true;
        }
    }
    ll tmp = 0;
    for (auto p : ab) {
        int a = p.first;
        ll b = p.second;
        bool flag = true;
        for (int i=0; i<30; ++i) {
            if ((a & (1<<i)) && !ok.at(i)) {
                flag = false;
                break;
            }
        }
        if (flag) tmp += b;
    }
    chmax(res, tmp);
    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1792
import math

N = int(input())

ans = 0

for a in range(1, N):
    cnt = 0
    for b in range(a, N):
        if a * b < N:
            if a < b:
                cnt += 2
            elif a == b:
                cnt += 1
        else:
            break
    ans += cnt

print (ans)


Measured memory_bytes: 9172
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;

#define rep(i,n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

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

const int mod = 1000000007;
const int INF = 1001001001;

ll n;
ll ans = 0;

void dfs(ll i, int use) {
    if(i > n) return;
    if(use == 0b111) ans += 1;

    dfs(i*10+3, use | 0b001);
    dfs(i*10+5, use | 0b010);
    dfs(i*10+7, use | 0b100);
}
int main() {
    cin >> n;
    dfs(0, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int MOD = 1'000'000'007;

char a[4] = {'A', 'C', 'G', 'T'};
map<pair<string, int>, int> dp;

bool ok(string s, char c){
	s += c;
	for (int i = 0; i < 4; i++){
		if (i >= 1){
			char temp = s[i];
			s[i] = s[i - 1]; s[i - 1] = temp;
		}
		
		if (s.substr(0, 3) == "AGC" or s.substr(1, 3) == "AGC"){
			return false;
		}
		if (i >= 1){
			char temp = s[i];
			s[i] = s[i - 1]; s[i - 1] = temp;
		}

	}
	return true;
}

int solve(string k, int n)
{
	if (dp.count(make_pair(k, n)) == 0){
		if (n == 0){
			dp[{k, n}] = 1;
		} else {
			int ans = 0;
			for (int i = 0; i < 4; i++){
				if (ok(k, a[i])){
					ans = (ans + solve(k.substr(1, 2) + a[i], n - 1)) % MOD;
				}
			}
			dp[{k,n}] = ans;
		}
	}
	return dp[{k,n}];
}

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


Measured memory_bytes: 896
a,b,k = map(int, input().split())
ans = []
for i in range(a, min(a+k,b+1)):
    ans.append(i)
for i in range(max(a,b-k+1), b+1):
    ans.append(i)

ans = sorted(list(set(ans)))
for i in ans:
    print(i)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long llint;

llint q,h,s,d;
llint n;
llint a[100005];
void solve(){
  cin >> q >> h >> s >> d;
  cin >> n;
  s = min(s,min(4 * q, 2 * h));
  d = min(d,2*s);
  llint ans=d*(n/2)+s*(n%2);
  cout << ans << endl;

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

// Counter ...
type Counter struct {
	s   string
	cnt int
}

var counters []Counter

func main() {
	var a, b, h int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&h)
	// fmt.Printf("a = %d, b = %d, h = %d\n", a, b, h)

	result := (a + b) * h / 2
	fmt.Println(result)
}


Measured memory_bytes: 512
#include<stdio.h>
#define MAX 21000000
 
int main()
{
  int n,i,j,k;
  scanf("%d",&n);
  int row[n],col[n];
  int dp[n][n];
  
  for(i=0;i<n;i++) scanf("%d %d",&row[i],&col[i]);
    
  for(i=0;i<n;i++){
      for(j=0;j<n;j++)
    {
      dp[i][j]=MAX;
    }
    }
    
  for(i=0;i<n;i++){
      dp[i][i]=0;
    }
   
  for(j=0;j<n;j++){
      for(i=0;i<n-j;i++){
    
      for(k=i+1;k<=i+j;k++){
        if(dp[i][i+j]<dp[i][k-1]+dp[k][i+j]+row[i]*col[k-1]*col[i+j]) dp[i][i+j]=dp[i][i+j];
        else dp[i][i+j]=dp[i][k-1]+dp[k][i+j]+row[i]*col[k-1]*col[i+j];
        }
    }
}
  printf("%d\n",dp[0][n-1]);
   
  return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  if (a[0] == 0) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  ll ansb = 1;
  rep(i, n) {
    ansb = ans;
    ans *= a[i];
    if (ansb > ans) {
      cout << -1 << endl;
      return 0;
    }
    if (ans > 1000000000000000000) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3996
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	Int len = S.size();

	Int flag = 0;
	for (Int i = 0; i < len; i++) {
		if (i % 2) {//偶数番目
			if (S[i] == 'R') {
				flag = 1;
				break;
			}
		}
		else {
			if (S[i] == 'L') {
				flag = 1;
				break;
			}
		}
	}

	cout << (flag ? "No" : "Yes") << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
signed main() {
	string s, t; cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++)ans += (s[i] == t[i]);
	cout << ans << endl;
}

Measured memory_bytes: 256
def main(n,q,a,x):
  a.reverse()
  keys=[]
  sums1=[0]
  sums2=[0]
  tmp1=0
  tmp2=0
  for i in range(n):
    if i%2==0:tmp1+=a[i]
    tmp2+=a[i]
    sums1.append(tmp1)
    sums2.append(tmp2)
  sums=[]
  for i in range((n-1)//2):
    k=a[i+1]+a[i+1+(i+1)]
    keys.append(k//2+1)
    # 
    s=sums2[i+1]+sums1[-1]-sums1[i+1+(i+1)]
    sums.append(s)
  sums.append(sums2[(n+2-1)//2])
  keys.append(0)
  sums.reverse()
  keys.reverse()
  from bisect import bisect_right
  #print(sums)
  #print(keys)
  for xx in x:
    idx=bisect_right(keys,xx)-1
    print(sums[idx])



n,q=map(int,input().split())
a=list(map(int,input().split()))
x=[int(input()) for _ in range(q)]
main(n,q,a,x)


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


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;cin>>n>>m;
	ll sum=0;
	ll i,j;
	for(i=0;i<m;i++)
	{
		ll a;cin>>a;
		sum+=a;
	}

	if(sum>n)
		cout<<-1;
	else cout<<n-sum;
	return 0;
} 

Measured memory_bytes: 3624
import copy
n,m=map(int,input().split())
temp=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  a=a-1
  b=b-1
  temp[a].append(b)
  temp[b].append(a)
count=0
a=[]
c=True
while c:
  c=False
  for i in range(n):
    if len(temp[i])==1 and i not in a:
      temp[temp[i][0]].remove(i)
      a.append(i)
      count=count+1
      c=True
print(count)

Measured memory_bytes: 3444
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;




public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e18;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 32;
    public static int[] Bit;
    public static long[] dp;
    public static long[] fac,inv;
	public static void main(String[] args) {
	
	FastReader sc = new FastReader();
	
	int a = sc.nextInt();
	int b = sc.nextInt();
	String sa = "";
	String sb = "";
	for(int i=0;i<a;++i) sa+=b;
	for(int i=0;i<b;++i) sb+=a;
	if(sa.compareTo(sb) < 0) out.print(sa);
	else out.print(sb);
	out.close();
}
}

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

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

using namespace std;

typedef long long ll;

#define pf(n) printf("%d\n",n)
#define sf(n) scanf("%d",&n)
#define in(n) for(int i=0;i<n;i++)
#define vi vector<int>
#define vs vector<string>
#define sort(a) sort(a.begin(),a.end())

int main()
{
    ll r,d,x;
    cin>>r>>d>>x;
    in(10)
    {
        x=(r*x)-d;
        pf(x);
    }
}


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

int main(){
  int N,max=0,k,value;
  cin>>N;
  vector<int> p(N);
  
  for(int i=0;i<N;i++){
    cin>>p.at(i);
    if(max<p.at(i)){
      k=i;
      max = p.at(i);
    }
  }
  
  for(int i=0;i<N;i++){
    if(i==k)
      value += p.at(i)/2;
    else
      value += p.at(i);
  }
  
  cout<<value<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
using namespace std;


int main()
{
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int ans = 0;
	for(int i=0;i<=3000;i++)
		for (int j = 0; j <= 3000; j++) {
			if ((N - R * i - G * j) >= 0 && (N - R * i - G * j) % B == 0)
				ans++;
		}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <array>
#include <queue>

using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " ";
    int ans;
    if(a + b <= n){
        cout << 0 << endl;
    }
    else {
        cout << (a + b - n) << endl;
    }
    return 0;
}


Measured memory_bytes: 888
N=int(input())
h=list(map(int,input().split()))
dp=[0]*(N+1)
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
  dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(abs(h[i]-h[i-2])+dp[i-2]))
print(dp[N-1])

Measured memory_bytes: 13928
from itertools import product
H, W, K = map(int, input().split())
mod = 10 ** 9 + 7

# dp[i][j]:= 上からi番目, 左からj番目にいる通り数
dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1


def calc(x):
    if x < 0:
        return 1
    ret = 0
    for p in product(['0', '1'], repeat=x):
        p = ''.join(p)
        if '11' not in p:
            ret += 1
    return ret


for i in range(1, H + 1):
    for j in range(W):
        tmp = 0
        if j > 0:  # 左から
            tmp += dp[i - 1][j - 1] * calc(j - 2) * calc(W - j - 2) % mod

        # 上から
        tmp += dp[i - 1][j] * calc(j - 1) * calc(W - j - 2) % mod

        if j + 1 < W:  # 右から
            tmp += dp[i - 1][j + 1] * calc(j - 1) * calc(W - j - 3) % mod

        dp[i][j] = tmp

print(dp[H][K - 1] % mod)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll dp[1005][1005];
char a[1005][1005];
ll n,m;
int main(){FAST;
cin>>n>>m;
for(ll i=1;i<=n;++i){
  for(ll j=1;j<=m;++j){
    cin>>a[i][j];
  }
}
dp[1][1] = 1;
for(ll i=2;i<=m;++i){
  dp[1][i] = dp[1][i-1];
  if(a[1][i] == '#')dp[1][i] = 0;
}
for(ll i=2;i<=n;++i){
  dp[i][1] = dp[i-1][1];
  if(a[i][1] == '#')dp[i][1] = 0;
}
for(ll i=2;i<=n;++i){
  for(ll j=2;j<=m;++j){
    if(a[i][j] == '#')continue;
    dp[i][j] = dp[i-1][j]+dp[i][j-1];
    dp[i][j]%=MOD;
  }
}
cout<<dp[n][m];
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


Measured memory_bytes: 12412
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n, a, b = sc.nextInt

    println(
      (1 to n)
      .filter { i =>
        val sum = i.toString.map(_.toString.toInt).sum
        a <= sum && sum <= b
      }
      .sum
    )
  }
}


Measured memory_bytes: 37056
#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++)

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

Measured memory_bytes: 5200
n = int(input())
v = list(map(int,input().split()))
v1 = v[0::2]
v2 = v[1::2]
v1.sort()
v2.sort()
v1_hind = dict()
v2_hind = dict()
v1_hind[v1[0]] = 1
v2_hind[v2[0]] = 1
for i in range(1, len(v1)):
    if v1[i] != v1[i-1]:
        v1_hind[v1[i]] = 0
    if v2[i] != v2[i-1]:
        v2_hind[v2[i]] = 0
    v1_hind[v1[i]] += 1
    v2_hind[v2[i]] += 1
v1_it = list(v1_hind.items())
v2_it = list(v2_hind.items())
v1_it.sort(key=lambda x: x[1], reverse=True)
v2_it.sort(key=lambda x: x[1], reverse=True)
if v1_it[0][0] != v2_it[0][0]:
    print(len(v1)-v1_it[0][1] + len(v2)-v2_it[0][1])
elif v1_it[0][0] == v2_it[0][0] and len(v2_it) == 1:
    print(len(v2))
else:
    print(min(len(v1) - v1_it[0][1] + len(v2) - v2_it[1][1],
          len(v1) - v1_it[1][1] + len(v2) - v2_it[0][1]))
















Measured memory_bytes: 21480
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>
#include <regex>
#include <locale>
#include <fstream>
#include <stdlib.h>
#include <cctype>

//#include <map>

using namespace std;

class cDise
{

	vector<int> X;
	vector<int> Y;
	vector<int> vLabel;

	void rotateDice(char d)
	{
		int t;

		switch (d)
		{
			case 'N':
				t = X[0];
				X[0] = Y[0] = Y[1];
				Y[1] = 7 - t;
				break;
			case 'S':
				t = Y[1];
				Y[1] = Y[0];
				X[0] = Y[0] = 7 - t;
				break;
			case 'W':
				t = X[0];
				X[0] = Y[0] = X[1];
				X[1] = 7 - t;
				break;
			case 'E':
				t = X[1];
				X[1] = X[0];
				X[0] = Y[0] = 7 - t;
				break;
			default:break;
		}
	}

public:

	cDise(string l)
	{
		X = { 1, 3 };
		Y = { 1, 2 };

		istringstream iss(l);
		while (!iss.eof())
		{
			int t;
			iss >> t;
			vLabel.push_back(t);
			iss.ignore();
		}
	}

	void rotateByStr(string dir)
	{
		istringstream iss(dir);
		vector<char> vc;
		int char_size = 1;

		for (string::iterator it = dir.begin(); it != dir.end(); it += char_size)
		{
			int t;
			rotateDice(*it);
		}
	}

	void rotateAndFindTop(string dir,int t)
	{
		istringstream iss(dir);
		vector<char> vc;
		int char_size = 1;

		for (string::iterator it = dir.begin(); it != dir.end(); it += char_size)
		{
			rotateDice(*it);
			if (getCurrentTop() == t)break;
		}
	}


	int getCurrentTop()
	{
		if (X[0] == Y[0])
		{
			return vLabel.at(X[0] - 1);
		}
		return -1;
	}
	
	int getCurrentFront()
	{
		if (X[0] == Y[0])
		{
			return vLabel.at(Y[1] - 1);
		}
		return -1;
	}
	
	int getCurrentRight()
	{
		if (X[0] == Y[0])
		{
			return vLabel.at(X[1] - 1);
		}
		return -1;
	}
};

int main()
{
	string lb;
	int q;
	getline(cin, lb);

	cDise cd(lb);
	cin >> q;
	cin.ignore();

	for (int i = 0; i < q; i++)
	{
		string qstr;
		int top, front;

		getline(cin, qstr);
		istringstream iss(qstr);
		iss >> top;
		iss.ignore();
		iss >> front;
		iss.ignore();
	
		while (cd.getCurrentTop() != top)
		{
			cd.rotateAndFindTop("NNNNENNN",top);
		}

		while (cd.getCurrentFront() != front)
		{
			cd.rotateByStr("NES");
		}
		cout << cd.getCurrentRight() << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
while True:
    cnt=0
    n,x = map(int,input().split())
    if n!=0:
        for i in range(1,n-1):
            for j in range(i+1,n):
                for k in range(j+1,n+1):
                    if i+j+k==x:
                        cnt += 1
        print(cnt)
    else:
        break



Measured memory_bytes: 5592
#include <stdio.h>
#include <string.h>
#include <math.h>
#define rep(i,l,n) for(i=l;i<n;i++)

int main(void){
	char str[25];
	int len,i;
	
	scanf("%s",str);
	len=strlen(str);

	for(i=len-1;i>=0;i--){
		printf("%c",str[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 520
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define nl '\n'

#define PI 3.14159265

using namespace std;

int n, a;

int main(){
    cin >> n;
    multiset<pair<int, int>> m;
    for(int i = 0; i < n; i++){
        cin >> a;
        m.insert(make_pair(a, i));
    }
    multiset<pair<int, int>>:: iterator it = m.end();
    --it;

    for(int i = 0; i < n; i++){
        if(it->second != i){
            cout << it->first << nl;
        } else{
            --it;
            cout << it->first << nl;
        }
        it = m.end();
        --it;
    }


}

//g++ -std=c++14 comp.cpp -o b; ./b.exe


Measured memory_bytes: 11008
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>0) puts("Positive");
    else if(b>=0) puts("Zero");
    else if((a&1)^(b&1)) puts("Positive");
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 128
while True:
    H, W = list(map(int, input().split()))
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if i == 0 or i == H-1 or j == 0 or j == W-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7004
void main(){
	int n=_scan();
	int d, ans;
	int[int] dic;
	foreach(i; 0..n){
		d = _scan();
		if(dic.get(d, 0)==0){
			ans++;
		}
		dic[d]++;
	}
	ans.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;

int main()
{
    FIO
    ll n, x, t;
    cin>>n>>x>>t;
    cout<<(n + x-1) / x * t <<endl;
    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		string S = Console.ReadLine();
		int c0 = 0;
		int c1 = 0;
		
        for(var i = 0; i < S.Length; i++)
		{
			if (S[i] == '0') { c0++; }
			else { c1++; }
		}
		int ans = 2 * c1;
		if (c0 < c1) { ans = 2 * c0; }

		Console.WriteLine(ans);
	}
	
}

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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n; cin >> n;
    vector<int> ans;
    while(n >= 26) {
        if((n%26) == 0) {
            ans.push_back(26);
            n -= 26;
        }
        else {
            ans.push_back(n%26);
        }
        n /= 26;
    }
    if(n != 0) {
        ans.push_back(n);
    }
    rrep(i, ans.size()) {
        cout << char('a'-1+ans[i]);
    }
    cout << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    bool s[h][w];
    int i, j;
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {
            s[i][j] = true;
        }
    }

    for(i = 0; i < n; i++) {
        int x, y, a;
        cin >> x >> y >> a;

        if (a == 1) {
            int k;
            for(j = 0; j < h; j++) {
                for(k = 0; k < x; k++) {
                    s[j][k] = false;
                }
            }
        }
        else if (a == 2) {
            int k;
            for(j = 0; j < h; j++) {
                for(k = x; k < w; k++) {
                    s[j][k] = false;
                }
            }
        }
        else if (a == 3) {
            int k;
            for(j = 0; j < y; j++) {
                for(k = 0; k < w; k++) {
                    s[j][k] = false;
                }
            }
        }
        else if (a == 4) {
            int k;
            for(j = y; j < h; j++) {
                for(k = 0; k < w; k++) {
                    s[j][k] = false;
                }
            }
        }
    }

    int ans = 0;
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {
            if (s[i][j]) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256