akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

long long arr[1000005];

void findMax(long long n){
  long long left = 0;
  long long right = 3*n - 2; 

  long long ans = 0; 

  while(left<right){
    ans += arr[right];
    left++;
    right = right - 2; 
  }
  
  cout << ans << endl; 
}

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

  for(long long i = 0; i < 3*n; i++){
    cin >> arr[i];
  }
  sort(arr , arr + 3*n);

  if(n == 1){
    cout << arr[1] << endl; 
    exit(0);
  }

  findMax(n);
}
  

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<int> A(N + 1);
  for (int i = 0; i < N; i++)
    cin >> A[i + 1];
  vector<ll> arrive(N + 1, -1);
  int cur = 1;
  ll t = 0;
  while (K > 0) {
    if (arrive[cur] != -1) {
      ll cycle = t - arrive[cur];
      if (cycle != 0)
        K %= cycle;
    } else {
      arrive[cur] = t;
    }
    if (K > 0) {
      t++;
      K--;
      cur = A[cur];
    }
  }
  cout << cur << endl;
  return 0;
}

Measured memory_bytes: 5636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct Tree{
  int key;
  struct Tree *parent;
  struct Tree *left;
  struct Tree *right;
}Tree;

Tree *t;
void Print1(Tree*);
void Print2(Tree*);
void Insert(int);  

int main(){
  int m,i,key;
  char comma[7];
  scanf("%d",&m);
  t=(Tree*)malloc(sizeof(Tree)*1);
  t->parent=t->left=t->right=NULL;
  t->key=2000000001;
  for(i=0;i<m;i++){
    scanf("%s",&comma);
    if(strcmp(comma,"insert")==0){
      scanf("%d",&key);
      Insert(key);
     }
    else if(strcmp(comma,"print")==0){
      Print1(t);
      printf("\n");
      Print2(t);
      printf("\n");
    }
  }
  free(t);
  return 0;
}

void Insert(int key){
  Tree *y;
  Tree *x;
  Tree *hoge;
  if(t->key==2000000001){
    t->key=key;
    return;
  }
  x=t;
  y=NULL;
  hoge=(Tree*)malloc(sizeof(Tree)*1);
  hoge->key=key;
  hoge->parent=hoge->left=hoge->right=NULL;
  while(x!=NULL){
    y=x;
    if(key<x->key)
      x=x->left;
    else
      x=x->right;
    hoge->parent=y;
  }
  if(hoge->key<y->key)
    y->left=hoge;
  else
    y->right=hoge;
}

void Print1(Tree *x){
  if(x==NULL)
    return;
  else{
    Print1(x->left);
    printf(" %d",x->key);
    Print1(x->right);
  }
}

void Print2(Tree *x){
  if(x==NULL)
    return;
  else{
    printf(" %d",x->key);
    Print2(x->left);
    Print2(x->right);
  }
}

Measured memory_bytes: 24036
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e6+10;
const int mod=1e9+7;
int dp[N];
int main()
{
    memset(dp,inf,sizeof(dp));
    dp[0]=0;
    for(ll i=0; i<=N; i++)
    {
        dp[i+1]=min(dp[i+1],dp[i]+1);
        for(ll j=6; i+j<=N; j*=6)
        {
            dp[i+j]=min(dp[i+j],dp[i]+1);
        }
        for(ll j=9; i+j<=N; j*=9)
        {
            dp[i+j]=min(dp[i+j],dp[i]+1);
        }
    }
    int n;
    cin>>n;
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 7496
package main

import (
	"fmt"
)

func main() {
	var s, t string
	_, _ = fmt.Scan(&s, &t)
	m1, m2 := make(map[string]int), make(map[string]int)
	for i := 0; i < len(s); i++ {
		str1, str2 := string(s[i]), string(t[i])
		if m1[str1] != m2[str2] {
			fmt.Println("No")
			return
		}
		m1[str1], m2[str2] = i + 1, i + 1
	}
	fmt.Println("Yes")
}

Measured memory_bytes: 3840
const Main = input => {
  const input2 = input.split('\n');
  const Asinfo = input2[0].split(' ');
  const Bsinfo = input2[1].split(' ');
  let diff;
  const asspeed = Number(Asinfo[1]);
  const bsspeed = Number(Bsinfo[1]);
  const farDiff = Math.abs(Number(Asinfo[0] - Bsinfo[0]));
  if(Math.sign(asspeed - bsspeed) != 1) return console.log('NO');
  const sec = farDiff / (asspeed - bsspeed);
  if(sec <= Number(input2[2])){
    return console.log("YES")
   }
  console.log("NO")
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29632
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#define INF 0x3f3f3f3f
#define NO 200005
#define MO 100005
typedef long long ll;
using namespace std;
inline ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

ll n, a[NO], MIN, sum, cnt;
//variable

void init()
{
	MIN = INF;
	n = read();
	for (int i = 1; i <= n; i++)
		a[i] = read(), sum += abs(a[i]), MIN = min(MIN, abs(a[i])), cnt += (a[i] <= 0);
}
//functions

int main()
{
	init();
	cout << sum - MIN * 2 * (cnt % 2) << endl;
	return 0;
}
//main

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <map>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

#define repn( i , a , b ) for( int i = ( int ) a ; i < ( int ) b ; i ++ )
#define rep( i , n ) repn( i , 0 , n ) 
#define all( x )  x.begin() , x.end()
#define rall( x ) x.rbegin() , x.rend()
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long int64;
typedef long double ldouble;
typedef pair< int , int > pii;

const int MAXN = 100005;

int N;
int V[MAXN];
int inv[MAXN];
int p[MAXN];

inline int find_set(const int &x){
	return p[x] == x? x:( p[x] = find_set(p[x]) );
}

int main(){
	int u, v;
	int M;

	scanf("%d %d", &N, &M);
	for ( int i=0; i < N; ++i ){ 
		scanf("%d", V + i);
		V[i]--;
		inv[ V[i] ] = i;
		p[i] = i;
	}
	while ( M-- ){
		scanf("%d %d", &u, &v);
		u--, v--;
		u = find_set(u), v = find_set(v);
		if ( u != v ){
			p[v] = u;
		}
	}
	
	int res = 0;
	for ( int i=0; i < N; ++i )
		if ( find_set( i ) == find_set( inv[i] ) ) res++;

	printf("%d\n", res);

	return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int a1, a2, a3, ans;
    cin >> a1 >> a2 >> a3;
    ans = a1 + a2 + a3;
    if(ans >= 22){
        cout << "bust";
        return 0;
    }else{
        cout << "win";
        return 0;
    }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * https://abc052.contest.atcoder.jp/tasks/arc067_a
 */
public class Main {

	static final int MOD = 1000000007;
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		long[] factors = new long[N+1];
		List<Integer> primes = new ArrayList<>();
		for(int i=2; i<=N; i++){
			if(isPrime(i)) primes.add(i);
		}
		
		for(int n=2; n<=N; n++){
			int a = n;
			for(int p:primes){
				while(a%p==0 && a>1){
					factors[p]++;
					a=a/p;
				}
			}
		}
		
		long ans = 1;
		for(long f:factors){
			ans = (ans*(f+1))%MOD;
		}
		System.out.println(ans);

	}
	
	static boolean isPrime(long num) {
		if(num==2) return true;
		if(num<2 || num%2==0) return false;
		for(int i=3; i*i<=num; i+=2){
			if(num%i==0) return false;
		}
		return true;
	}

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  string s, t;
  cin >> s >> t;
  vector<vector<int>> v(26);
  rep(i,t.size())
    v[t[i] - 'a'].push_back(i);
  rep(i,26)
    if (v[i].size() > 0) {
      char c = s[v[i][0]];
      rep(j,v[i].size())
        if (c != s[v[i][j]]) {
          cout << "No";
          return 0;
        }
    }
  vector<vector<int>> v2(26);
  rep(i,s.size())
    v2[s[i] - 'a'].push_back(i);
  rep(i,26)
    if (v2[i].size() > 0) {
      char c = t[v2[i][0]];
      rep(j,v2[i].size())
        if (c != t[v2[i][j]]) {
          cout << "No";
          return 0;
        }
    }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 2952
#include <iostream>
#include <vector>

int CountPrime(int n){
	
	if ((n == 0) || (n == 1)){
		return 0;
	}else{
		std::vector<bool> data(n - 1, 1);
		int count = 0;

		for (int i = 2; i <= n; i++){
			if (data[i - 2] == 1){
				for (int j = i * 2; j <= n; j += i){
					data[j - 2] = 0;
				}
			}
		}
		for (int i = 0; i < n - 1; i++){
			if (data[i] == 1){
				count++;
			}
		}

		return count;

	}
}


int main(){
	int n;

	while (std::cin >> n){
		std::cout << CountPrime(n) << "\n";
	}

	return 0;
}

Measured memory_bytes: 1316
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val x = sc.nextLong()

  println(abc165b(x))
}

private fun abc165b(x: Long): Long {
  var bank = 100L
  var ans = 0L
  while (bank < x) {
    bank = bank + bank / 100
    ans++
  }
  return ans
}


Measured memory_bytes: 36380
#include<stdio.h>
#pragma warning (disable:4996)
int main()
{
	int n;
	while (~scanf("%d", &n))
	{
		long long int arr[100] = { 0 };
		arr[0] = 2; arr[1] = 1;
		for (int i = 2; i <= n; i++)
			arr[i] = arr[i - 1] + arr[i - 2];
		printf("%lld\n", arr[n]);
	}
}

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

//string lines = q"[
//abcdeffg]";

long INF = pow(10, 9);
long[] H = [0L];

long cost(int i, int j)
{
    return abs(H[i]-H[j]).to!long;
}

void main()
{
  string lines;
  string buf;

  while (!stdin.eof) {
    buf = stdin.readln();
    lines ~= buf;
  }

  string[] array = splitLines(lines);
    
  int N = array[0].split(" ")[0].to!int;
  int K = array[0].split(" ")[1].to!int;
  array[1].split(" ").each!(a => H ~= a.to!long);
  
  long[] dp = new long[](N+1);
  foreach (ref long e; dp) {
    e = INF;
  }
  dp[1] = 0L;
  
  for (int i = 1; i <= N; i++) {
    for (int j = i+1; j <= i+K; j++) {
      if (j>N) continue;
      dp[j] = min( cost(i, j) + dp[i], dp[j] );
    }
  }
  writeln(dp[N]);
}

Measured memory_bytes: 6820
# Bを一回使えると考えると
# - Ai>BiであるBiを使う意味はない(Aiで殴ればいいので)
# - Ai>AjであるAjを使う意味はない（Aiで殴ればいいので）
# つまりA中最強のAiより上（i=j自身を含む）のBjを1度使い、あとはAiで殴る
n, h = map(int, input().split())
power = [list(map(int, input().split())) for _ in range(n)]
maxa = sorted(power, key=lambda x : x[0], reverse=True)[0][0]
muscleb = sorted(list(filter(lambda x : x[1] >=  maxa, power)), key = lambda x : x[1], reverse=True)
ans = 0
for m in muscleb:
    ans += 1
    h -= m[1]
    if h <= 0:
        print(ans)
        exit()
additionala = h // maxa
if h % maxa != 0:
    additionala += 1
print(additionala + ans)

Measured memory_bytes: 30044
n, m, C = map(int, input().split())
B = list(map(int, input().split()))
source = []
score  = 0
for i in range(n):
    source.append([int(x) for x in input().split()])

for j in range(n):
    pre = 0
    for k in range(m):
        pre += source[j][k]*B[k]
    else:
        if pre + C > 0:
            score += 1
print(score)



Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);

		int n = sc.nextInt();
		int[] ar = new int[n];

		for (int i = 0; i < n; i++)
			ar[i] = sc.nextInt();

		Arrays.parallelSort(ar);
		
		long sum = ar[n - 1];
		int count = 0;
		int idx = n - 2;
		
		while(count < (n - 1) / 2) {
			
			sum += (2L * ar[idx--]);
			count++;
		}
		
		if((n & 1) == 1)
			sum -= ar[++idx];
		pr.println(sum);
		pr.close();
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			InputStreamReader inputreader = new InputStreamReader(System.in);
			br = new BufferedReader(inputreader);
		}

		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: 56852
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;
const int N = 1e5;

int a[N], b[N], c[N];

int main()
{

    //freopen("input.txt", "r", stdin);

    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; ++i)
        scanf("%d", a + i);

    ll S = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", b + i);
        if (a[i] < b[i])
        {
            S += b[i] - a[i];
            ++ans;
        }
        c[i] = b[i] - a[i];
    }

    sort(c, c + n);
    for (int i = 0; i < n; ++i, ++ans)
    {
        if (S <= 0) break;
        S += c[i];
    }

    if (S > 0)
        printf("-1");
    else
        printf("%d", ans);

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	ll n; cin>>n;
	ll sum=0LL;
	for(ll i=1;i<=n;i++){
		sum+=i;
		if(sum>=n){
			if(sum==n){
				reps(j,i) cout<<j<<endl;
			}else{
				reps(j,i) if(j!=sum-n) cout<<j<<endl;
			}
			return 0;
		}
	}
	return 0;
}


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

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

  vector<string> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  set<string> Set;
  for (int i = 0; i < N; i++) Set.insert(A.at(i));
  cout << Set.size() << endl;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fst first
#define snd second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template<typename T>
std::vector<T> divisor(T n) {
  std::vector<T> div;
  for(int i = 1; i * i <= n; ++i) {
    if(n % (T)i == 0) {
      div.push_back(i);
      if(i * i != n) div.push_back(n / i);
    }
  }
  sort(begin(div), end(div));
  return div;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  ll k;
  ll sum = 0;
  cin >> n >> k;
  VI a(n);
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  VL ret = divisor<ll>(sum);
  ll ans = 0;
  for(auto re : ret){
    ll d = re;
    VL r(n, 0);
    rep(i, n) r[i] = a[i] % d;
    sort(all(r));
    VL pos(n, 0);
    VL neg(n, 0);
    neg[0] = r[0];
    pos[n-1] = d - r[n-1];
    rep(i, n-1) {
      neg[i+1] = neg[i] + r[i+1];
      pos[n-i-2] = pos[n-i-1] + d - r[n-i-2];
    }
    rep(i, n-1){
      if((neg[i] - pos[i+1] + d) % d == 0 && k >= max(neg[i], pos[i+1])){
        ans = max(ans, d);
        break;
      }
    }
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
	int n = 0, s = 0, e = 0, w = 0;
	string str;
	cin >> str;
	for(int i = 0; i < str.size(); i++){
		switch(str[i])
		{
			case 'N':
				n++;
				break;
			case 'S':
				s++;
				break;
			case 'E':
				e++;
				break;
			case 'W':
				w++;
		}
	}
	if(((n == 0 && s == 0) || (n > 0 && s > 0) )&& ((e == 0 && w == 0) || (e > 0 && w > 0) )){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
	int a;
	char di[100];
	cin >> a;
	while (a != 0){
		int  d, g = 1, i, dice[6] = {1, 2, 3, 4, 5, 6};
		for (i = 0; i < a; i++){
			cin >> di;
			if (di[0] == 'N'){
				d = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = d;
			}
			if (di[0] == 'E'){
				d = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = d;
			}
			if (di[0] == 'W'){
				d = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = d;
			}
			if (di[0] == 'S'){
				d = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = d;
			}
			if (di[0] == 'R'){
				d = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[3];
				dice[3] = d;
			}
			if (di[0] == 'L'){
				d = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[4];
				dice[4] = dice[2];
				dice[2] = d;
			}
			g = g + dice[0];
		}
		cout << g << endl;
		cin >> a;
	}
}

Measured memory_bytes: 3028
/************
* 	@Just Another Source code by: ankit.sangwan1999
*	@created on: 22 May 2020
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) //;cout.tie(NULL)
#define ll long long
const int mod = 1e9+7;
#define endl '\n'

const int N = 3000;
double arr[N];


signed main(){

    fastio;

    int n;
    cin>>n;

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

    double dp[n+1][n+1];

    for(int i=0;i<=n;i++){ // ith toss
    	for(int j=0;j<=n;j++){ 
    		if(i==0 and j==0){
    			dp[i][j] = 1;
    		}
    		else if(j==0){
    			dp[i][j] = dp[i-1][j] * (1-arr[i-1]);
    		}
    		else if(i==0){
    			dp[i][j] = 0;
    		}
    		else{
    			dp[i][j] = dp[i-1][j]*(1-arr[i-1]) + dp[i-1][j-1]*arr[i-1];
    		}
    	}
    }

    double ans = 0;

    for(int i=n-n/2;i<=n;i++){ // ith toss
    	ans += dp[n][i];
    }

    cout<<setprecision(10)<<ans;


    return 0;
}

Measured memory_bytes: 70656
#include<stdio.h>
static const int N = 500;
static const int INFTY = (1<<21);

#define NIL -1

int p[100],key[100],n;

int main(){
  int a,b,c,sum,i,j;
  int M[100][100];
  int l[100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a);
      M[i][j]=(a==-1)?INFTY:a;

    }
  }

  for(c=0;c<n;c++){
    key[c]=100000000;
    p[c]=NIL;
    l[c]=NIL;
  }
  
  key[0]=0;

  while(1){
    int c=NIL;
    int b=100000000;

    for(i=0;i<n;i++){
     
      if(key[i]<b && l[i]==NIL){
	b=key[i];
	c=i;
      }
    }
	
      if(c==NIL){
      break;
    }

    for(b=0;b<n;b++){
      if(M[c][b]<key[b] && l[b]==NIL){
	key[b]=M[c][b];
	p[b]=c;
      }
    }
    l[c]=0;
  }
  
  sum = 0;
  
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }
  
  printf("%d\n",sum);
  
  return 0;
}

Measured memory_bytes: 640
n = gets.to_i
hist = Hash.new
("a".."z").each do |c|
  hist[c] = 50
end
n.times do |i|
  s = gets.chomp
  h = Hash.new
  ("a".."z").each do |c|
    h[c] = 0
  end
  s.each_char do |c|
    h[c] += 1
  end
  ("a".."z").each do |c|
    hist[c] = h[c] if h[c] < hist[c]
  end
end
t = ""
("a".."z").each do |c|
  t += c * hist[c]
end
puts t


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	long long *nodes = new long long[n+1];
	for (int i = 1; i <= n; ++i)
		cin >> nodes[i];
	for (int i = 1; i <= n; ++i) {
		printf("node %d: key = %lld, ", i, nodes[i]);
		int p = i / 2;
		if (1 <= p && p <= n)
			printf("parent key = %lld, ", nodes[p]);
		int l = i * 2;
		if (1 <= l && l <= n)
			printf("left key = %lld, ", nodes[l]);
		int r = i * 2 + 1;
		if (1 <= r && r <= n)
			printf("right key = %lld, ", nodes[r]);
		cout << endl;
	}

	delete[] nodes;
	return 0;
}

Measured memory_bytes: 1220
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        char[] N = new char[100];
        int M = in.read(N, 0, N.length);
        int K = in.i();
        out.println(solve(0, K, N, M));
    }

    static int solve(int i, int k, char[] N, int M) {
        if (M < i + k) return 0;
        if (k == 0) return 1;
        if (N[i] == '0') return solve(i + 1, k, N, M);
        else return (N[i] - '1') * solve2(i + 1, k - 1, N, M) + solve2(i + 1, k, N, M) + solve(i + 1, k - 1, N, M);
    }

    static int solve2(int i, int k, char[] N, int M) {
        if (M < i + k) return 0;
        if (k == 0) return 1;
        return 9 * solve2(i + 1, k - 1, N, M) + solve2(i + 1, k, N, M);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int l[n];
  for(int i = 0; i < n; i++) {
    cin >> l[i];
  }
  sort(l, l + n, greater<int>());
  int ans = 0;
  for(int i = 0; i < k; i++) {
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(10**5+1):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return


def combination_mod(n, k, mod):
    # power_funcを用いて(nCk) mod p を求める 
    # nCk = n!/((n-k)!k!)を使用

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % mod
    b = factorial(k) % mod
    c = factorial(n - k) % mod
    return (a * power_func(b, mod - 2, mod) * power_func(c, mod - 2, mod)) % mod
    
def power_func(a, b, mod):
    # a^b mod p を求める
    # bを2進数分解して高速累乗

    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod

#D
def D():
    n, k = LI()
    ans = 0
    for i in range(1,k+1):
        a = combination_mod(n - k + 1, i, mod)
        b = combination_mod(k - 1, i - 1, mod)
        print((a*b)%mod)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 80092
fun main(args: Array<String>) = IO().exec {
    val n = int()
    val m = int()
    val K = int()
    var isOk = false
    for (k in n+1) for (l in m+1) if (k*(m-l)+(n-k)*l==K) isOk = true
    println(if (isOk) "Yes" else "No")
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 31396
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto N = readln.chomp.to!long;
    int[] A = iota(1, 101).array;
    int[] B;
    long ans = 0;

    for (int i = 1; ans < N; ++i) {
        int p = 0;
        long tmp = 1;
        while (p < B.length && ans + tmp * 2 <= N) {
            p += 1;
            tmp *= 2;
        }
        B.insertInPlace(p, i);
        ans += tmp;
    }

    writeln(A.length + B.length);
    (A ~ B).map!(to!string).join(" ").writeln;
}


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

int main() {
  int x, y;
  while (1) {
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    if (x > y) swap(x, y);
    cout << x << " " << y << endl;
  }
}

Measured memory_bytes: 2964
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line1 = sc.nextLine();
        
        String[] array1 = line1.split(" ");
        int a = Integer.parseInt(array1[0]);
        int b = Integer.parseInt(array1[1]);
        
        int min = 0;
        int max = 10;
        if(a < b)
        {
            min = a;
            max = b;
        }
        else
        {
            min = b;
            max = a;
        }
        
        String result = "";
        
        for(int i = 0; i < max; i++)
        {
            String buf = String.valueOf(min);
            result = result + buf;
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 21076
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	while (k--)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		--x; --y;
		if (x > n / 2)
			x = n-1 - x;
		if (y > n / 2)
			y = n-1 - y;
		printf("%d\n", min(x, y) % 3 + 1);
	}
}

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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

ll pow_f(ll b, ll e) {
    ll ans = 1;
    b = b % M;
    while (e) {
        if (e&1) {
            ans = (ans * b) % M;
        }
        b = (b * b) % M;
        e >>= 1;
    }
    return ans;
}

ll nCr(ll n, ll r) {
    if (r > n || n < 0 || r < 0) { return 0; }
    if (n == r || r == 0) { return 1; }
    r = min(r, n-r);
    ll ans = 1;
    for (ll i = 1; i <= r; ++i) {
        ans = (ans * (n-i+1))/(i); 
    }
    return ans;
}

ll nCr(tuple<ll,ll> t) {
    auto n = get<0>(t);
    auto k = get<1>(t);
    return nCr(n+k-1, k);
}

template<typename T>
void print(T v) {
    cout << v << " ";
}

template<typename T>
void print(vector<T> v) {
    for (auto &i : v) {
        print(i);
    }
    cout << endl;
}

void solve() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    while (k) {
        ans += min(a, k);
        k -= min(a, k);
        break;
    }
    while (k) {
        ans += 0;
        k -= min(b, k);
        break;
    }
    while (k) {
        ans += -min(c, k);
        k -= min(c, k);
        break;
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 3612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,a,n) for(ll i=a;i<(ll)(n);i++)

int main(){
    long N,M;
    cin>>N>>M;
    vector<vector<long>> list(N);

    rep(i, M){
        long a,b;
        cin>>a>>b;
        list[a-1].push_back(b-1);
        list[b-1].push_back(a-1);
    }

    queue<long> que;
    vector<long> dis(N, -1);
    que.push(0);
    dis[0] = 0;
    while(!que.empty()){
        long v = que.front();
        que.pop();

        if(v == N-1 && dis[v] == 2){
            cout << "POSSIBLE" << endl;
            return 0;
        }

        for(long t : list[v]){
            if(dis[t] != -1) continue;
            que.push(t);
            dis[t] = dis[v]+1;
        }
    }

    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 24304
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    
    map<int,int> mp;
    rep(i,0,N)mp[V[i]]++;
    rep(i,0,N){
        int x = V[i];
        auto itr = mp.end();
        
        itr--;
        //cout << itr->first << " " << itr->second << " " << x << endl;

        if(itr->first == x && mp[x] == 1){
            itr--;
        }
        cout << itr->first << endl;
        
    }
}

Measured memory_bytes: 7936
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <limits>

int main() {

    int64_t N;
    std::cin >> N;

    std::vector<int64_t> employees(N);

    for (int64_t i = 1; i < N; ++i) {
        int64_t A;
        std::cin >> A;
        employees.at(A-1)++;
    }

    for (auto employee : employees) {
        std::cout << employee << std::endl;
    }

    return 0;
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b,min,max;
  cin>>N>>a>>b;
  //最大
  if( a > b ){
    max = b;
  }
  if( a < b ){
    max = a;
  }
  //最少
  if( N >= a+b ){
    min = 0;
  }
  if( N < a+b ){
    min = ( a + b ) - N;
  }
  cout << max << " " << min << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;
static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	int ans = N % 1000;
	if(ans != 0){
		ans = 1000 - ans;
	}
	printf("%d\n", ans);
	return 0;

}

Measured memory_bytes: 3816
N, A, B, C, D = map(int, input().split())

#右端がでかくしても一般性を失わない
if A > B:
    A, B = B, A

for k in range(N):
    if k * C - (N - 1 - k) * D <= B - A <= k * D - (N - 1 - k) * C:
        print ('YES')
        exit()
print ('NO')

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

using namespace std;

#define ll long long
#define vi vector<int>
#define pb push_back
#define loop(i,n) for(int i=0; i<n; i++)
#define pii pair<int, int>

int main() {
    ios_base::sync_with_stdio(false);
    ll x;
    cin>>x;
    ll res = (x / 11) * 2;
    ll rem = x % 11;
    if (rem == 0) {} 
    else if (rem <= 6) res++;
    else res += 2;
    cout<<res<<endl;
    return 0;
} 

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $N, $M, $K);
$uf = new UnionFind(1, $N);
$friend = $block = $parent = [];
$parent = array_pad(array(), $N + 1, 0);
for ($i = 0; $i < $M; $i++) {
    fscanf(STDIN, "%d %d", $A, $B);
    $uf->Union($A, $B);
    $friend[$A][$B] = 1;
    $friend[$B][$A] = 1;
}
for ($i = 1; $i <= $N; $i++) {
    $root = $uf->Find($i);
    $parent[$root]++;
}
for ($i = 0; $i < $K; $i++) {
    fscanf(STDIN, "%d %d", $C, $D);
    if ($uf->Find($C) === $uf->Find($D)) {
        $block[$C][$D] = 1;
        $block[$D][$C] = 1;
    }
}
$ans = [];
for ($i = 1; $i <= $N; $i++) {
    $group = $parent[$uf->Find($i)] - 1;
    $count_friend = isset($friend[$i]) ? count($friend[$i]) : 0;
    $count_block = isset($block[$i]) ? count($block[$i]) :  0;
    $ans[] = $group - $count_friend - $count_block;
}
echo implode(' ', $ans);

class UnionFind {
    var $e;
    
    function __construct($st, $en) {
        for ($i = $st; $i <= $en; $i++) {
            $this->MakeSet($i);
        }
    }
    
    function MakeSet($x) {
         $this->e[$x]['parent'] = $x;
         $this->e[$x]['rank']   = 0;
    }
     
    function Union($x, $y) {
        $xRoot = $this->Find($x);
        $yRoot = $this->Find($y);
        if ($this->e[$xRoot]['rank'] > $this->e[$yRoot]['rank']) {
            $this->e[$yRoot]['parent'] = $xRoot;
        } else if ($this->e[$xRoot]['rank'] < $this->e[$yRoot]['rank']) {
            $this->e[$xRoot]['parent'] = $yRoot;
        } else if ($xRoot != $yRoot) {
            $this->e[$yRoot]['parent'] = $this->e[$xRoot]['parent'];
            $this->e[$xRoot]['rank'] = $this->e[$xRoot]['rank'] + 1;
        }
    }
    
    function Find($x) {
        if ($this->e[$x]['parent'] == $x) {
           return $this->e[$x]['parent'];
        } else {
           $this->e[$x]['parent'] = $this->Find($this->e[$x]['parent']);
           return $this->e[$x]['parent'];
        }
    }
}


Measured memory_bytes: 136820
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i;
    int	count;
    int	max;
	char s[4];
    
    s[3] = '\n';
    scanf("%s", &s);
    i = 0;
    count = 0;
	max = 0;
    while (s[i])
    {
    	if (s[i++] == 'R')
        {
        	count++;
            if (max < count)
            	max = count;
        }
        else
        	count = 0;
    }
	printf("%d\n", max);
	return (0);
}

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

int main(void){
  int i,j,k; 
  int n,r,c=0,k2=1;
  cin>>n>>k;
  rep(i,n){
  
  if(n<k2)break;
  c++;
  k2*=k;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		long x = scan.nextLong();
		long k = scan.nextLong();
		long d = scan.nextLong();
		
		long oppai = Math.abs(x/d); 
		long ans_a = Math.abs(x%d);
		long ans_b = Math.abs(Math.min(ans_a+d, ans_a-d));
		
		if(oppai >= k){
			System.out.println(Math.min(Math.abs(x-d*k), Math.abs(x+d*k)));
		}else {
			if((k-oppai)%2 == 0) {
				System.out.println(ans_a);
			}else {
				System.out.println(ans_b);
			}
		}
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
}
 





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

int w,h;
int islID;
int mp[52][52], island[52][52];
void dfs(int x, int y){
  if (mp[x][y]==0 || island[x][y]) return;
  island[x][y] = islID;
  for (int dx = -1; dx<=1; dx++){
    for (int dy= -1; dy<=1; dy++){
      if (dx==0 && dy==0) continue;
      dfs(x+dx, y+dy);
    }
  }
}

int main(void){  
  while (cin >> w >> h){
    if (w==0 && h==0) break;
    for (int i=0; i<h; i++){
      for (int j=0; j<w; j++){
        cin >> mp[j+1][i+1];
        island[j+1][i+1] = 0;
      }
    }
    islID = 0;
    for (int i=1; i<=h; i++){
      for (int j=1; j<=w; j++){
        if (mp[j][i] && !island[j][i]){
          islID++; 
          dfs(j, i);
        }
//        cout << island[j][i] << " ";
      }
//      cout << endl;
    }
    cout << islID << endl;
  }
  return 0;
}


Measured memory_bytes: 3232
n = int(input())
f = []
p = []
for _ in range(n):
    f.append(list(map(int, input().split())))

for _ in range(n):
    p.append(list(map(int, input().split())))

result = -float('inf')
for i in range(1,1024):
    working = [0 for _ in range(n)]
    for j in range(10):
        if i>>j&1:
            for shop in range(n):
                if f[shop][j]:
                    working[shop] += 1
    benefit = 0
    for shop in range(n):
        benefit += p[shop][working[shop]]

    result = max([result, benefit])

print(result)

Measured memory_bytes: 3064
#![allow(unused)]

use std::{cell, cmp, collections, convert, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let s = read_line();

    let sn = s.chars()
        .map(|c| c.to_digit(10).unwrap() as i32)
        .sum::<i32>();
    let n = s.parse::<i32>().unwrap();

    debugln!("{}, {}, {}", s, sn, n);

    if n % sn == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn next_prime(x: i32) -> i32 {
    for i in (x + 1).. {
        if is_prime(i) {
            return i;
        }
    }

    panic!("attempt to add with overflow");
}

fn is_prime(x: i32) -> bool {
    let ceil = f64::from(x).sqrt().ceil() as i32;
    x == 2 || (2..(ceil + 1)).all(|i| x % i != 0)
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

ModInt mod_pow(ModInt x, ModInt n) {
	ModInt ret = 1;
	while (n.a > 0) {
		if (n.a & 1) (ret *= x);
		(x *= x);
		n.a >>= 1;
	}
	return ret;
}

ModInt func[200000];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
ModInt comb(ModInt n, ModInt r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}

lint N, K;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> K;
	ModInt sum = 0;
	FOR(k, K, N + 2) {
		sum += (N + 1 - k) * k + 1;
	}
	cout << sum.a << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long N, i, dp[200001] = {0}, a[200001] = {0};
	cin >> N;
	for(i = 0; i < N; i++)
		cin >> a[i];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for(i = 2; i < N; i++)
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	cout << dp[N - 1];
	return 0;
}

Measured memory_bytes: 3328