akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		int num = 3;

		if(A % num == 0 || B % num == 0 || (A + B) % num == 0){
			System.out.println("Possible");
		}else{
			System.out.println("Impossible");
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	int N;
	cin >> N;
	vector<LL> L(N), R(N);
	vector<LL> low(N, INF), high(N, 0);
	foreach(i, L)cin>>i;
	foreach(i, R)cin>>i;
	low[0] = high[0] = L[0];
	LL lh = L[0];
	REPA(i, N){
		high[i] = L[i];
		if(lh==L[i]){
			low[i] = 1;
		}else{
			low[i] = L[i];
		}
		chmax(lh, L[i]);
	}
	if(R[N-1] < low[N-1] || high[N-1] < R[N-1]){
		cout << 0 << endl;
		return 0;
	}
	low[N-1] = high[N-1] = R[N-1];
	lh = R[N-1];
	PER(i, N-1){
		LL nlow;
		LL nhigh =R[i];
		if(lh == R[i]){
			nlow = 1;
		}else{
			nlow = nhigh = R[i];
		}
		if(high[i] < nlow || low[i] > nhigh){
			cout << 0 << endl;
			return 0;
		}
		chmax(low[i], nlow);
		chmin(high[i], nhigh);
		chmax(lh, R[i]);
	}
	LL ans = 1;
	REP(i, N){
		ans *= high[i] - low[i] + 1;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
import java.util.*;

public class Main{
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		List<Integer> tree = new ArrayList<>();
		
		// input
		final int NUM = scan.nextInt();
		int light = scan.nextInt();
		for(int i = 0; i < NUM; i++){
			tree.add(scan.nextInt()) ;
		}
		
		// sort
		Collections.sort(tree);
		
		// search
		long answer = Long.MAX_VALUE;
		for(int i = 0; i <= NUM - light; i++){
			if(tree.get(i+light-1) - tree.get(i) < answer){
				answer = tree.get(i+light-1) - tree.get(i);
			}
		}
		
		System.out.println(answer);
	}
}

Measured memory_bytes: 58668
#include <bits/stdc++.h>
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n;cin >> n;
  vector<int> nums(n);
  rep_i(i, n){
    cin >> nums[i];
  }

  // do {
  //   for (vector<int>::iterator i = nums.begin(); i != nums.end(); i++)
  //   {
  //     if(i == nums.begin()){
  //       cout << *i;
  //       continue;
  //     }
  //     cout << " " << *i;
  //   }
  //   cout << endl;
  // }while(next_permutation(nums.begin(), nums.end()));

  if(prev_permutation(nums.begin(), nums.end())){
    for (vector<int>::iterator i = nums.begin(); i != nums.end(); i++)
    {
      if(i == nums.begin()){
        cout << *i;
        continue;
      }
      cout << " " << *i;
    }
    cout << endl;
  }
  next_permutation(nums.begin(), nums.end());
  for (vector<int>::iterator i = nums.begin(); i != nums.end(); i++)
  {
    if(i == nums.begin()){
      cout << *i;
      continue;
    }
    cout << " " << *i;
  }
  cout << endl;
  if(next_permutation(nums.begin(), nums.end())){
    for (vector<int>::iterator i = nums.begin(); i != nums.end(); i++)
    {
      if(i == nums.begin()){
        cout << *i;
        continue;
      }
      cout << " " << *i;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3104
#include<stdio.h>
/*与えられた期間の間のうるう年をすべて出力*/
void leap_year(int year1, int year2);

int main(void)
{
    while (1){
        int a, b; /*a は year1　, b は year2*/
         /*cは一行目の空行をさせないために使う*/
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0){
            break;
        }else {
            leap_year(a, b);
        }
    }
    return 0;
}

void leap_year(int year1, int year2)
{   
    static int c = 0;
    ++c;
    if (c != 1){
        printf("\n");
    }
    int limit = 0; /*もしも、うるう年がなかった時に使う*/
    for (int i = year1; i <= year2; ++i){ /*i は年を表す*/     
        if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0){
            printf("%d\n", i);
        }else{
            ++limit;
        }
    }
    if (limit == (year2 - year1 + 1)){/*うるう年がない場合*/
        printf("NA\n");
    }
} 

Measured memory_bytes: 1044
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int a[100001];
int main()
{
	int N;
	cin >> N;
	a[0] = 0;
	long s = 0;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i <= N-1; i++) s = s + abs(a[i] - a[i+1]);
	s = s + abs(a[N]);
	for (int d = 1; d <= N; d++)
	{
		long s1 = s - abs(a[d-1] - a[d]) - abs(a[d] - a[d+1]) + abs(a[d-1] - a[d+1]);
		cout << s1 << "\n";
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(int i=3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

    int cnt = 0;
    vector<int> v;
    for(int i=2; i<=55555; i++){
        if(IsPrime(i)&&(i%5==1)) {
            v.emplace_back(i); 
            cnt++;
        }
        if(cnt == n) {
            break; 
        }
    }

    rep(i, n){
        cout << v.at(i);
        cout << " ";
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = ni();

		int max = 0;
		int maxi = 1;

		for (int i = 1; i <= n; i++) {
			int d2 = i;
			int count = 0;
			for (;;) {
				if (d2 % 2 == 0) {
					count++;
					d2 /= 2;
				} else {
					break;
				}
			}
			if (max <= count) {
				max = count;
				maxi = i;
			}
		}
		out(maxi);
	}

	/*
	 * 以下メソッド集
	 */

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + 2))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 21972
/* generated by esotope-bfc */
#include <stdio.h>
#include <stdint.h>
#define GETC() (fflush(stdout), fgetc(stdin))
#define PUTC(c) fputc(c, stdout)
#define PUTS(s) fwrite(s, 1, sizeof(s)-1, stdout)
static uint8_t m[30000], *p = m;
int main(void) {
	p[5] = GETC();
	p[5] -= 48;
	p[6] = GETC();
	p[6] -= 10;
	p[7] = 0;
	while (p[6]) {
		p[7] += 6;
		p[6] -= 6*p[7]-10*p[5]+2;
		p[5] = 0;
		p[7] = GETC();
		p[7] -= 10;
		while (p[7]) {
			p[7] = GETC();
			p[7] += 9*p[6];
			p[6] = 0;
			++p;
		}
		++p;
	}
	int loopcnt0;
	for (loopcnt0 = p[5]; loopcnt0 > 0; --loopcnt0) {
		++p[6];
		p[7] += 4;
		int loopcnt1;
		for (loopcnt1 = p[7]; loopcnt1 > 0; --loopcnt1) {
			p[8] += 4;
			p[9] += 8*p[8];
			p[8] = 0;
		}
		p[7] = 0;
	}
	p[5] = 0;
	while (p[9]) {
		p[9] = 0;
		p[11] = 0;
		p += 2;
	}
	while (p[6]) {
		if (p[6]%2) {
			while (1); /* infinite loop */
		}
		p[7] += p[6]/2;
		p[6] = 0;
		while (p[7]) {
			p[8] += p[7]-1;
			p[7] = GETC();
			++p;
		}
		while (p[6] != 0) --p;
		while (p[7]) {
			p[6] = GETC();
			p[6] -= p[7];
			p[7] = 0;
			if (p[6]) {
				++p[5];
				p[6] = 0;
			}
			p[6] = p[5];
			p[5] = 0;
			++p;
		}
		++p;
	}
	p[5] += 10;
	while (p[4]) {
		p[6] += 8*p[5]-2;
		p[7] += 11*p[5]+1;
		p[5] = 0;
		PUTC(p[6]);
		PUTC(p[7]);
		p[7] = 0;
		p += 3;
	}
	while (p[5]) {
		p[6] += 9*p[5]-1;
		p[7] += 10*p[5]+1;
		p[5] = 0;
		PUTC(p[6]);
		PUTC(p[7]);
		p[7] += 14;
		PUTC(p[7]);
		p[7] = 0;
		p += 2;
	}
	PUTS("\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    string s, t;
    cin>>s>>t;
    loop(i,0,s.len()){
        if(s[i] != t[i]){
            print("No");
            ret;
        }
    }
    print("Yes");
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


Measured memory_bytes: 3656
package main

import "fmt"

func calc(d []int, dSum int) []int {
	dp := make([][]int, len(d)+1)
	for i := range dp {
		dp[i] = make([]int, dSum+1)
	}
	dp[0][0] = 1
	for i := 0; i <= dSum; i++ {
		for j := 1; j <= len(d); j++ {
			dp[j][i] = dp[j-1][i]
			if i >= d[j-1] {
				dp[j][i] += dp[j-1][i-d[j-1]]
			}
		}
	}
	return dp[len(d)]
}

func main() {
	var N, A int
	fmt.Scan(&N, &A)
	var aSum, bSum int
	var a, b []int
	var e uint
	for i := 0; i < N; i++ {
		var x int
		fmt.Scan(&x)
		if x > A {
			a = append(a, x-A)
			aSum += x - A
		} else if x < A {
			b = append(b, A-x)
			bSum += A - x
		} else {
			e++
		}
	}
	aComb := calc(a, aSum)
	bComb := calc(b, bSum)
	sum := 0
	for i := 1; i < len(aComb) && i < len(bComb); i++ {
		sum += aComb[i] * bComb[i]
	}
	sum <<= e
	sum += (1 << e) - 1
	fmt.Println(sum)
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e15+4;
const int Nmax=2e5+1;
const int Nd=61;
ll dfs[3003][3003][4];
ll  v[3003][3003];

int main(){
  string n;
  cin>>n;
  int s=n.size();
  ll now=0;
  rep(i,s){
    if(n[i]=='0') continue;
    if(n[i]=='1') now+=1;
    if(n[i]=='2') now+=2;
    if(n[i]=='3') now+=3;
    if(n[i]=='4') now+=4;
    if(n[i]=='5') now+=5;
    if(n[i]=='6') now+=6;
    if(n[i]=='7') now+=7;
    if(n[i]=='8') now+=8;
    if(n[i]=='9') now+=9;
    now=now%9;
  }
  if(now%9==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }




  return 0;
}


Measured memory_bytes: 3724
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() ;
const ll linf = numeric_limits<ll>::max() ;
const ull ulinf = numeric_limits<ull>::max();
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    int n,k;
    cin >> n >>k;
    int a[100005] = {};
    rep(i,0,n){
        cin >> a[i]; 
    }
    rsort(a,a+n,int);
    int g = a[0];
    rep(i,1,n)g = gcd(g,a[i]);

    if(k%g == 0 && k <= a[0])P("POSSIBLE");
    else P("IMPOSSIBLE");
    
	return  0;
}

Measured memory_bytes: 640
n, k = gets.chomp.split.map &:to_i
1.upto(k) do |i|
  if i > n - k + 1
    puts 0
  else
    blue = (1..i + 1).to_a.repeated_combination(n - k + 1 - i).size
    red = (1..i).to_a.repeated_combination(k - i).size
    ans = blue * red % (10 ** 9 + 7)
    puts ans
  end
end

Measured memory_bytes: 2792
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var N int
	fmt.Scan(&N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, N)
	b := make([]int, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		b[i] = a[i]
	}
	sort.Sort(sort.IntSlice(a))
	for i := 0; i < N; i++ {
		if b[i] == a[len(a)-1] {
			fmt.Println(a[len(a)-2])
		} else {
			fmt.Println(a[len(a)-1])
		}
	}
}

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

int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> a(n);
    int i;
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater<int>());

    vector<int64_t> s(a[0]+3);
    for(i = 0; i < n; i++) {
        s[a[i]]++;
        s[a[i]+1]++;
        s[a[i]+2]++;
    }

    sort(s.begin(), s.end(), greater<int64_t>());

    cout << s[0] << endl;
}


Measured memory_bytes: 4804
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int i,j,k,ii,jj,n,rr[10][3],r,temp,flg;
	char t[11],ctm,tcopy[11];
	while(1){
		cin>>n;
		if(n==0)break;
		for(i=0;i<n;i++){
			cin>>t[i];
			tcopy[i]=t[i];
			rr[i][0]=0; rr[i][1]=0; rr[i][2]=0;
			for(j=0;j<n-1;j++){
				cin>>r;
				rr[i][r]++;
			}
		}
//		for(i=0;i<n;i++)printf("%c ??????%d?????????%d\n",t[i],rr[i][0],rr[i][1]);
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(rr[i][0]<rr[j][0]){
					temp=rr[i][0];
					rr[i][0]=rr[j][0];
					rr[j][0]=temp;
					
					temp=rr[i][1];
					rr[i][1]=rr[j][1];
					rr[j][1]=temp;
					
					ctm=t[i];
					t[i]=t[j];
					t[j]=ctm;
				}
			}
		}
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(rr[i][1]>rr[j][1]&&rr[i][0]==rr[j][0]){
					temp=rr[i][0];
					rr[i][0]=rr[j][0];
					rr[j][0]=temp;
					
					temp=rr[i][1];
					rr[i][1]=rr[j][1];
					rr[j][1]=temp;
					
					ctm=t[i];
					t[i]=t[j];
					t[j]=ctm;
				}
			}
		}
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(rr[i][1]==rr[j][1]&&rr[i][0]==rr[j][0]){
					flg=0;
					for(k=0;k<n;k++){
						if(t[i]==tcopy[k])flg=1;
						if(t[j]==tcopy[k]&&flg==0){
							temp=rr[i][0];
							rr[i][0]=rr[j][0];
							rr[j][0]=temp;
							
							temp=rr[i][1];
							rr[i][1]=rr[j][1];
							rr[j][1]=temp;
							
							ctm=t[i];
							t[i]=t[j];
							t[j]=ctm;
							break;
						}
					}
				}
			}
		}
		for(i=0;i<n;i++) cout<<t[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n;
	cin >> n;
	n *= 2;
	vector<vector<int>> a(n, vector<int>(n));
	for (int z = 1; z <= 2; z++) {
		int d;
		cin >> d;
		int sz = 1;
		while (d % 4 == 0) {
			d >>= 2; sz <<= 1;
		}
		if (d % 4 == 1) rep(i, n) rep(j, n) if (i % (2 * sz) < sz && j % (2 * sz) < sz || i % (2 * sz) >= sz && j % (2 * sz) >= sz) a[i][j] += z;
		if (d % 4 == 2) rep(i, n) rep(j, n) if (i % (2 * sz) < sz) a[i][j] += z;
	}
	vector<int> cnt(4);
	rep(i, n) rep(j, n) cnt[a[i][j]]++;
	int tmp = 0; int use = 0;
	rep(i, 4) if (chmax(tmp, cnt[i])) use = i;
	int q = n * n / 4;
	rep(i, n) {
		rep(j, n) {
			if (q == 0) break;
			if (a[i][j] == use) {
				cout << i << ' ' << j << '\n';
				q--;
			}
		}
	}
}

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

int main()
{ //freopen("in.txt","r",stdin);
 //freopen("out.txt","w",stdout);
 string s;
 cin>>s;
 int f=0,ss=0;
 int n=s.length();
 for(int i=0;i<n;i+=2)
 {  if(s[i]=='1')
      f++;
    	
 }
 for(int i=1;i<n;i+=2)
 {  if(s[i]=='1')
      ss++;
    	
 }
 int m=max(f,ss);
 int x=min(f,ss);
  if(s.length()%2==0)
   cout<<s.length()/2-m+x;
  else if(f>0||ss>0){
  	if(f>=ss) 
  	cout<<s.length()/2+1-f+ss;
  	else if(ss>f)
  	cout<<s.length()/2-ss+f;
  
  	 
  }
  else
   cout<<s.length()/2; 
  
}


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

struct str
{
    int a,b;
};
bool operator<(str a,str b)
{
    return a.a<b.a;
}
int main()
{

    int i,j,c=0,c1=0,ans,pre_a,pre_b,a,b,n,m;
    vector<str>v;
    cin >> n >> m;
    for(i=0; i<m; i++)
    {
        cin >> a >> b;
        v.push_back({a,b-1});
    }
    sort(v.begin(),v.end());
    for(i=0; i<v.size(); i++)
    {
        a=v[i].a,b=v[i].b;
        if(i==0)
            pre_a=a,pre_b=b;
        else
        {
            if(a>pre_b)
                c++,pre_a=a,pre_b=b;
            else
            {
                pre_a=max(pre_a,a);
                pre_b=min(pre_b,b);
            }
        }
    }
    c++;
    cout << c << "\n";



    return 0;
}


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

int main(){
  
  int result = 1;
  char S[12], T[12];
  scanf("%s\n", S);
  scanf("%s\n", T);
  int l = strlen(S);
  
  for(int i=0;i<l;i++){
  	if(S[i]!=T[i]){
      result = 0;
      break;
    }
  }
  
  if(result==1){
  	printf("Yes\n");
  }
  else{
  	printf("No\n");
  }
  
  return 0;
  
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N;
    cin >> N;

    int s=0;
    vector<int> a(N);
    rep(i,0,N){
        cin >> a[i];
        s+=a[i];
    }

    int d=inf,ans;
    rep(i,0,N){
        if(d>abs(s-N*a[i])){
            d=abs(s-N*a[i]);
            ans=i;
        }
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	ll n, m;
	cin >> n >> m;
	pair<ll, ll> a[n];
	REP(i, n) cin >> a[i].first >> a[i].second;
	sort(a, a+n);
	ll ans = 0;
	ll cnt = 0;

	REP(i, n){
		cnt += a[i].second;
		ans += a[i].first * a[i].second;
		if (cnt >= m){
			cout << ans - (cnt - m) * a[i].first << endl;
			return 0;
		}
	}




}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(1000000)

N, K = map(int, input().split())
D = input().split()
decimal = set(["0","1", "2", "3", "4", "5", "6", "7", "8", "9"]) - set(D)
candidate = []
def dfs(s):
    if len(s) == 0:
        sub_d = decimal - set("0")
        for d in sub_d:
            dfs(s + d)    
    elif len(s) < len(str(N)) + 1:
        if int(s) >= N:
            candidate.append(int(s))
        for d in decimal:
            dfs(s + d)
    else:
        candidate.append(int(s))
        return
dfs("")
print(sorted(candidate)[0])


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

// #define int long long

signed main(void) {
  int num; // num
  // num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  num = numeric_limits<int>::max(); // min
  int n;

  cin >> n;

  if (n == 3 || n == 5 || n == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    long long bal = 1000;
    for(int i = 0; i < n - 1; ++i){
        long long stocks = 0;
        if(a[i] < a[i + 1]) stocks = bal/a[i];
        bal += (a[i + 1] - a[i]) * stocks;
    }
    cout << bal << endl;
    return 0;
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(){
    int n, k;
    double kitai_max, kitai_tmp, kitai_prev;
    kitai_max = 0;
    cin >> n >> k;
    vector<double> v(n);
    for(int i=0; i<n; i++){
        int p;
        cin >> p;
        v.at(i) = (double)(p+1)/(double)2;
    }
    for(int i=0; i<k; i++){
        kitai_max += v.at(i);
    }
    kitai_prev = kitai_max;
    for(int i=1; i+k<=n; i++){
        kitai_tmp = kitai_prev - v.at(i-1) + v.at(i+k-1);
        kitai_prev = kitai_tmp;
        if(kitai_tmp > kitai_max) kitai_max = kitai_tmp;
    }

    cout << fixed << kitai_max << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m, X; cin >> n >> m >> X;
    vi a(m); for(auto& e : a) cin >> e;
    int resl = 0, resr = 0;
    for(auto& e : a){
        if(e < X) resl++;
        else resr++;
    }

    cout << min(resl, resr) << endl;

    return 0;
}


Measured memory_bytes: 256
A_B_C = list(map(int,input().split()))
A = A_B_C[0]
B = A_B_C[1]
C = A_B_C[2]
ans = "No"
if A_B_C.count(A)==2:
    ans = "Yes"
elif A_B_C.count(B)==2:
    ans = "Yes"
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int N; cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end(), greater<long long>());

    if (N % 2 == 0) {
        long long res = 0;
        for (int i = 0; i < N/2 - 1; ++i) res += A[i] * 2;
        res += A[N/2 - 1];
        res -= A[N/2];
        for (int i = N/2 + 1; i < N; ++i) res -= A[i] * 2;
        cout << res << endl;
    }
    else {
        long long res1 = 0;
        for (int i = 0; i < N/2 - 1; ++i) res1 += A[i] * 2;
        res1 += A[N/2 - 1] + A[N/2];
        for (int i = N/2 + 1; i < N; ++i) res1 -= A[i] * 2;
        
        long long res2 = 0;
        for (int i = 0; i < N/2; ++i) res2 += A[i] * 2;
        res2 -= A[N/2] + A[N/2 + 1];
        for (int i = N/2 + 2; i < N; ++i) res2 -= A[i] * 2;
        cout << max(res1, res2) << endl;
    }
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt(), k = in.nextInt();
            boolean dislike[] = new boolean[10];
            int i;
            for (i = 0; i < k; i++) {
                dislike[in.nextInt()] = true;
            }
            int rem;
            boolean flag;
            for (i = n; ; i++) {
                int p = i;
                flag = true;
                while (p > 0) {
                    rem = p % 10;
                    if (dislike[rem]) {
                        flag = false;
                        break;
                    }
                    p /= 10;
                }
                if (flag) {
                    out.printLine(i);
                    return;
                }
            }
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tokenizer = null;

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
        }

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

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

    }
}



Measured memory_bytes: 8148
s=input()
t=len(s)-1
sl=[s[i] for i in range(len(s))]
answers=[]

for i in range(2**t):
  tmp=[]
  for j in range(t):
    if (i>>j)&1:
      tmp.append(j)
  ll=['*'] * len(s)
  for k in tmp:
    ll[k]="+"
  ans=[]
  
  for k,_ in zip(sl,ll):
    ans.append(k)
    ans.append(_)
  ans=[_ for _ in ans if _ != "*"]
  ans=''.join(ans)
  ans=ans.split('+')
  ans=[int(k) for k in ans if k != '+']
  ans=sum(ans)
  answers.append(ans)
  
print(sum(answers))

    
    
  

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

int main(){
	int count;
	std::cin >> count;
	
	std::vector<int> seq_number;
	seq_number.resize(count);
	for(int i=0; i<count; ++i){
		std::cin >> seq_number[i];
	}
	
	std::vector<std::vector<long int>> table(count, std::vector<long int>(21,0));
	table[0][seq_number[0]] = 1;
	
	for(int i=1; i<count-1; ++i){
		for(int j=0; j<21; ++j){
			if(j + seq_number[i] <= 20){
				table[i][j+seq_number[i]] += table[i-1][j]; 
			}
			if(j - seq_number[i] >= 0){
				table[i][j-seq_number[i]] += table[i-1][j];
			}
		}
	}
	
	std::cout << table[count-2][seq_number.back()] << std::endl;
	
	
	return 0;
}

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

long n, m, a, b;

vector<int> node[100005];
long color[100005];
long cnt[3] = {};

void dfs(int s, int c){
  color[s] = c;
  cnt[c]++;
  for(int i = 0; i < node[s].size(); i++){
    if(color[node[s][i]] == c){
      cout << n * (n - 1) / 2 - m << endl;
      exit(0);
    }
    if(color[node[s][i]] == 0){
      dfs(node[s][i], 3 - c);
    }
  }
}

int main(){
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> a >> b;
    node[a].push_back(b);
    node[b].push_back(a);
  }
  dfs(1, 1);
  cout << cnt[1] * cnt[2] - m << endl;
      
  return 0;
}


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

int main() {
  int N,A,hantei=0,hantei2 = 1;
  cin >> N ;

  for(int i=0; i<N; i++){
    cin >> A;
    if(A%2==0){
      if(A%3==0 || A%5==0){
          hantei = 1;
      }else{
        hantei2 = 0;
      }
    }
  }
  if(hantei2!=0){
    cout << "APPROVED";
  }else{
     cout << "DENIED";
  }
  return 0;
}


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

int main() {
	int N;
	double A[1000];
	cin >> N;
	for (int i = 0; i < N; i++)cin >> A[i];

	long double reciprocal_sum = 0.0;
	for (int i = 0; i < N; i++) {
		reciprocal_sum += 1 / A[i];
	}
	cout << fixed << setprecision(6) << 1 / reciprocal_sum << endl;

	return 0;
}

Measured memory_bytes: 256
import collections


N = int(input())
if N <=9:
    print(0)
    exit()

np = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53]
a = []
for i in range(2,N+1):
    for num in np:
        l = i
        if i % num ==0:
            q=0
            while(l%num ==0):
                l = l//num
                a.append(str(num))
count_a = collections.Counter(a)
sorted_c = count_a.most_common()
count_75 = 0
count_25 = 0
count_15 = 0
count_5 = 0
count_3 = 0
#print(sorted_c)
for i in range(len(sorted_c)):
    if sorted_c[i][1] >=74:
        count_75 +=1
    if sorted_c[i][1] >=24:
        count_25 +=1
    if sorted_c[i][1] >=14:
        count_15 +=1
    if sorted_c[i][1] >=4:
        count_5+=1
    if sorted_c[i][1] >=2:
        count_3+=1
#print(count_25)
ans = (count_75+ count_25*(count_3-1) + count_15*(count_5-1) 
      + count_5*(count_5-1)*(count_3-2)//2)
print(ans)

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

const int MAXN = 121;
int best[2][MAXN];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	for(int z = 0; z < 2; z++){
		for(int i = 0; i < n; i++){
			int a;
			cin >> a;
			int maxv = 0;
			if(z > 0){
				maxv = max(maxv, best[z-1][i]);
			}
			if(i > 0){
				maxv = max(maxv, best[z][i-1]);
			}
			best[z][i] = maxv + a;
		}
	}
	cout << best[1][n-1] << '\n';
}


Measured memory_bytes: 3644
import heapq
import itertools

def solve():
    N, M, _ = list(map(int, input().split()))
    R = list(map(int, input().split()))
    R = map(lambda x: x-1, R)
    G = [[] for i in range(N)]

    for i in range(M):
        A, B, C = list(map(int, input().split()))
        A -= 1
        B -= 1
        G[A].append((C, B))
        G[B].append((C, A))


    def dijkstra(d):
        que = []

        tar = -1
        count = set()
        for i in range(len(d)):
            if d[i] == 1e+16:
                break
            if d[i] == 0:
                tar = i
            heapq.heappush(que, (d[i], i))
            count.add(i)

        checked = [False for i in range(N)]

        while len(que) != 0:
            dist, node = heapq.heappop(que)
            if checked[node]:
                continue
            count.add(node)
            if len(count) == N:
                break

            for (cost, to) in G[node]:
                if d[to] > d[node] + cost:
                    d[to] = d[node] + cost
                    heapq.heappush(que, (dist + cost, to))

            checked[node] = True

        return d


    ds = [[1e16 for i in range(N)] for j in range(N)]

    for i in range(N):
        ds[i][i] = 0

    for i in range(N):
        ds[i] = dijkstra(ds[i])
        for j in range(N):
            ds[j][i] = ds[i][j]

    res = 1e16
    for r in list(itertools.permutations(R)):
        d = 0
        for i in range(len(r)-1):
            d += ds[r[i]][r[i+1]]
        res = min(res, d)

    return res

print(solve())

Measured memory_bytes: 74968
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;
int main()
{
    unsigned long long h = 0u;
    cin >> h;
    unsigned long long w = 0u;
    cin >> w;

    unsigned long long result = 0u;
    if ((w == 1) || (h == 1))
    {
        result = 1u;
    }
    else if (w % 2 == 0)
    {
        result = (w / 2) * h;
    }
    else
    {
        if (h % 2 == 0)
        {
            result = (w / 2) * (h / 2) + (w / 2 + 1) * (h / 2);
        }
        else
        {
            result = (w / 2) * (h / 2) + (w / 2 + 1) * (h / 2 + 1);
        }
    }

    cout << result << endl;

    return 0;
}



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

using namespace std;

class Solution {
public:
	void solve() {
		long long n, k;
		cin >> n >> k;
		cout << min(n % k, k - n % k) << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const int maxn=200000+10;
int t[maxn];
int n,T;
int main()
{
    scanf("%d%d",&n,&T);
    for(int i=1;i<=n;i++)
        scanf("%d",&t[i]);
    ll sum=T;
    ll pre=T;
    for(int i=2;i<=n;i++)
    {
        if(pre<t[i])
        {
            sum+=T;
            pre=t[i]+T;
        }
        else
        {
            sum+=t[i]+T-pre;
            pre=t[i]+T;
        }
    }
    printf("%lld\n",sum);
}


Measured memory_bytes: 1024
N = int(input())
A = [int(input()) for i in range(N)]
A_max = max(A)
A_max_count = A.count(A_max)
if A_max_count != N:
  a_ = A[:]
  a_ = sorted(a_,reverse = True)
  A_next_max = a_[A_max_count]
else:
  A_next_max = A_max_count

for i in range(N):
  tmp = A[i]
  if tmp != A_max:
    print(A_max)
  else:
    if A_max_count == 1:
      print(A_next_max)
    else:
      print(A_max)

Measured memory_bytes: 14876
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	if (s.size()<=n)
		cout<<s<<endl;
	else{
		string res=s.substr(0,n);
		cout<<res<<"..."<<endl;
	}
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
string str;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> str;
	print1(str[5]=='1'||str[6]>='5'?"TBD":"Heisei");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<int> g[200005];
int main() {
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(int u:g[1])for(int v:g[u]){
    if(v==n){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 12016
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n)
        cin >> a[i];

    vector<bool> num(n+1, false);
    num[0] = true;

    int ans = -1;
    REP(i, n){
        int x = a[i];
        if(num[x-1] && !num[x]){
            num[x] = true;
            ans = x;
        }
    }
    if(ans == -1)
        cout << -1 << endl;
    else
        cout << n - ans << endl;
    return 0;
}

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

using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define N 2000001
#define M 1000000007
#define INF 1000000000000000


int main()
{
  int x;
  cin>>x;
  if(x>=30)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 3628
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vll a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for (int i = 0; i < n; i++) ans ^= a[i];
    for (int i = 0; i < 60; i++) {
        if ((ans >> i) & 1) {
            for (int j = 0; j < n; j++) {
                a[j] &= ((1LL << 61) - 1) ^ (1LL << i);
            }
        }
    }

    int rank = 0;
    V<int> rankb;
    for (int i = 60; i >= 0; i--) {
        int j = rank;
        for (; j < n; j++) {
            if ((a[j] >> i) & 1) {
                swap(a[j], a[rank]);
                break;
            }
        }
        if (j == n) continue;
        for (j = 0; j < n; j++) {
            if (j == rank) continue;
            if ((a[j] >> i) & 1) a[j] ^= a[rank];
        }
        rankb.emplace_back(i);
        rank++;
    }

    ll ab = 0;
    for (int i = 60; i >= 0; i--) {
        // i bit 目を 0 に出来るか？
        ll tmpab = ab | (1LL << i);
        for (int j = 0; j < rank; j++) {
            if ((tmpab >> rankb[j]) & 1) tmpab ^= a[j];
        }
        if (((ab | (1LL << i)) & tmpab) == 0) ab |= (1LL << i);
    }
    cout << ans + ab * 2 << '\n';
    return 0;
}


Measured memory_bytes: 3920