akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * 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);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			String A = in.next();
			String B = in.next();
			String C = in.next();
			int count = 0;
			for(int i = 0; i < N; i++) {
				if(A.charAt(i) != B.charAt(i) && A.charAt(i) != C.charAt(i) && B.charAt(i) != C.charAt(i)) {
					count += 2;
				}else if((A.charAt(i) != B.charAt(i) && B.charAt(i) == C.charAt(i)) ||( B.charAt(i) != C.charAt(i) && C.charAt(i) == A.charAt(i)) || C.charAt(i) != A.charAt(i) && A.charAt(i) == B.charAt(i)) {
					count++;
				}
			}
			out.println(count);
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

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

	}
}


Measured memory_bytes: 22740
i = 0
while 1:
	arr = list(map(int, input().split()))
	x = arr[0]
	y = arr[1]
	if x == 0 and y == 0:
		break
	if x <= y:
		print(str(x) + ' ' + str(y))
	else:
		print(str(y) + ' ' + str(x))



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

//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("Ofast")

#define F first
#define S second
#define MT make_tuple
#define SZ(a) ((int)(a).size())
#define PB push_back
#define LBS 20
#define MOD ((long long)1e9+7) //1e9+9
#define LEFT(i) (2*(i))
#define RIGHT(i) (2*(i)+1)
#define PAR(i) ((i)/2)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

typedef long long ll;
typedef double rat;
typedef long long bi;
typedef pair<int, int> ii;
typedef std::vector<ii> vii;
typedef std::map<int, int> mii;
typedef bitset<LBS> bis;
typedef std::vector<bis> vbs;

template<class T>
void in(T &a){
  for(auto &x: a)
    cin >> x;
}

template<class T>
void out(T &a, string sep=" "){
  for(auto x: a)
    cout << x<<sep;
  cout << '\n';
}

template<class T>
void err(T &a, string sep=" "){
  for(auto x: a)
    cerr << x <<sep;
  cerr << '\n';
}


int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a,b; cin >> a >> b;
  cout << max(0,a-2*b)<<"\n";
}


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

using namespace std;

#define ll long long 
#define mod 100000007
#define MAX 100000

int main()
{
    double a;
    
    cin >> a;
    double f = a/3;
    double s = a - (f*3);
    cout << fixed << setprecision(12)<< f*f*(f+s) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int N, Y, num, y, z;
	scanf("%d %d", &N, &Y);

	Y /= 1000;
	const int V = Y - N;
	if (Y - N < 0) {
		printf("-1 -1 -1\n");
		return 0;
	}

	for (int x = N; x >= 0; --x) {
		num = V - 9 * x;
		if (num % 4 == 0 && num >= 0) {
			y = num / 4;
			z = N - x - y;
			if (z < 0) continue;
			else {
				printf("%d %d %d\n", x, y, N - x - y);
				return 0;
			}
		}
	}

	printf("-1 -1 -1\n");
	return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

// https://leetcode.com/problems/count-complete-tree-nodes/
#include <bits/stdc++.h>
using namespace std;


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

	int apple, pieces; 
	cin >> apple >> pieces;

	pieces += (apple * 3);

	int res = 0;

	while (pieces >= 2) {
		res++;
		pieces -= 2;
	}

	cout << res;
	

    return 0;
}

Measured memory_bytes: 3644
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
s = input()
s_even = s[1::2]
s_odd = s[::2]

counter = 0
for i in s_odd:
    if i == 'R' or i == 'U' or i == 'D':
        counter +=1
for i in s_even:
    if i == 'L' or i == 'U' or i == 'D':
        counter +=1

if counter == len(s):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i64 = read();

    if n == 0 || n == 1 {
        println!("{}", n);
        return;
    }

    if n > 0 {
        let mut cnt = 3;
        let mut tmp = 4;
        let mut sum = 5;

        while sum <= n - 1 {
            cnt += 2;
            tmp *= 4;
            sum += tmp;
        }
        let mut magic = n - (sum / 4) - 1;
        let mut ans = "1".to_string();
        let mut a: Vec<&str> = vec![];
        while a.len() * 2 < cnt - 1 {
            let amari = magic % 4;
            magic /= 4;
            a.push(match amari {
                0 => "10",
                1 => "11",
                2 => "00",
                3 => "01",
                _ => "",
            });
        }
        a.reverse();
        for i in (0..a.len()) {
            ans += a[i];
        }
        println!("{}", ans);
    } else {
        if n == -1 {
            println!("11");
            return;
        }
        if n == -2 {
            println!("10");
            return;
        }

        let rn = -n;
        let mut keta = 2;
        let mut sum = 2;
        let mut tmp = 2;
        let mut prev = 0;

        while sum < rn {
            keta += 2;
            tmp *= 4;
            prev = sum;
            sum += tmp;
        }
        // println!("keta:{}", keta);
        // println!("magic:{}", rn - prev);
        let mut magic = rn - prev - 1;
        let mut a: Vec<&str> = vec![];
        let mut ans = "1".to_string();

        while a.len() < keta - 1 {
            let amari = magic % 2;
            magic /= 2;
            if a.len() % 2 == 0 {
                a.push(match amari {
                    1 => "0",
                    0 => "1",
                    _ => "",
                })
            } else {
                a.push(match amari {
                    1 => "1",
                    0 => "0",
                    _ => "",
                })
            }
        }
        a.reverse();
        for i in (0..a.len()) {
            ans += a[i];
        }
        println!("{}", ans);
   }
}


Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int n,m; cin>>n>>m;
    if (abs(n-m)>1) {
        cout<<0<<endl;
        return 0;
    }
    i64 ans = 1;
    REP(i,n) ans *= n-i,ans %= INF;
    REP(i,m) ans *= m-i,ans %= INF;
    if (n==m) ans *= 2,ans%=INF;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import math

N, D = map(int, input().split())

x  = []
cnt = 0

def calc_dis(dis1, dis2):
    sum = 0
    for i in range(D):
        sum += (dis1[i] - dis2[i]) ** 2
    return math.sqrt(sum)


for i in range(N):
    row = input().split()
    for i in range(len(row)):
        row[i] = int(row[i])
    x.append(row)

for i in range(N):
    for j in range(i + 1, N):
        dis = calc_dis(x[i], x[j])
        if int(dis) == dis:
            cnt += 1


print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000


int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++)C[i]=0;
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
    printf("\n");
 


  return 0;
}



Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int N = 2e5 + 5, MOD = 1e9 + 7;
int dp[2005][2005];
int a[2005], b[2005], n, m;
int solve(int i1, int i2){
  if(i1 == n || i2 == m)
    return 1;
  int &ret = dp[i1][i2];
  if(~ret)
    return ret;
  ret = solve(i1+1,i2) + solve(i1, i2 + 1);
  if(ret >= MOD)ret -= MOD;
  if(a[i1] != b[i2]){
    ret -= solve(i1+1,i2+1);
    if(ret<0)ret+=MOD;
  }
  return ret;
}

int main(){

  cin >> n >> m;

  for(int i = 0; i < n; i++)
    cin >> a[i];
  for(int i = 0; i < m; i++)
    cin >> b[i];

  memset(dp,-1,sizeof dp);

  cout << solve(0,0) << '\n';


  return 0;
}


Measured memory_bytes: 16384
#include <iostream>
#include <vector>
using namespace std;
int main(){
  long long N,V;
  V=0;
  vector<int> A,B,C;
  cin>>N;
  for(int i=0;i<N;i++){
    int t;
    cin>>t;
    A.push_back(t);
  }
  for(int i=0;i<N;i++){
    int t;
    cin>>t;
    B.push_back(t);
  }
  for(int i=0;i<N-1;i++){
    int t;
    cin>>t;
    C.push_back(t);
  }
  for(int i=0;i<N;i++){
    V+=B[A[i]-1];
    if(i+1!=N){
      if(A[i]+1==A[i+1]){
        V+=C[A[i]-1];
      }
    }
  }
  cout<<V<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
    
signed main(){
    string s;
    int n = 0;
    cin >> s;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'x')n++;
    }
    if(n >= 8)cout << "NO" << endl;
    else cout << "YES" << endl;
    
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://m-solutions2019.contest.atcoder.jp/tasks/m_solutions2019_a

Measured memory_bytes: 256
import itertools
a,b,c=map(int,input().split())
li=list(range(1,b+1))

i=0
list2=[]
list1=[list(map(int,input().split())) for i in range(c)]
max=0
for v in  itertools.combinations_with_replacement(li,a):
    lv=list(v)
    sum1=0


    for i in list1:

        if lv[i[1]-1]-lv[i[0]-1]==i[2]:
            #print(lv)
            #print(i)
            sum1+=i[3]


    if max<=sum1:
        max=sum1


print(max)


Measured memory_bytes: 73736
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<int, int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int, int>
#define mii         map<pii, int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
int mult(int a,int b, int p=MOD){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p=MOD){return (a + b + p)%p;}
int fpow(int n, int k, int p = MOD) {int r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
void solve(){
    int n;
    cin>>n;
    int a[n];
    rep(i, 0, n) {
        cin>>a[i];
    }
    int g = a[0];
    rep(i, 0, n) 
        g = gcd(g, a[i]);
    cout<<g<<endl;
}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 4008
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

// boost
//#define USE_BOOST_IN_CODE
#ifdef USE_BOOST_IN_CODE
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/strided.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/format.hpp>
#endif


using ll = long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vv = vec<vec<T>>;

//namespace std
//{
//    template<>
//    class hash<Key>
//    {
//    public:
//        size_t operator() (const Key& key) const
//        {
//            size_t seed = 0;
//            auto i_hash = hash<int>()(key.i_th);
//            auto w_hash = hash<int>()(key.W);
//
//            seed ^= i_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
//            seed ^= w_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
//
//            return seed;
//        }
//    };
//}

void solve()
{
    using namespace std;
    int n;

    while (cin >> n)
    {
        if (n == 0)
            break;

        int r;
        cin >> r;
        vec<int> deck;
        for (int i = 0; i <= n; ++i)
            deck.push_back(i);

        while (r-- != 0)
        {
            vec<int> newDeck {};
            int p, c;
            cin >> p >> c; 

            auto binserter = back_inserter(newDeck);

            copy(deck.cbegin(), deck.cend() - p + 1 - c, binserter);
            copy(deck.cend() - p + 1, deck.cend(), binserter);
            copy(deck.cend() - p + 1 - c, deck.cend() - p + 1, binserter);

            deck = newDeck;
        }

        cout << deck[deck.size() - 1] << endl;
    }

}

int main()
{
    solve();
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> b(n, 0);

	for(ll i = 0; i < n; ++i)
	{
		ll in;
		cin >> in;
		a[i] = in - 1;
	}

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

	// 循環を見つけて mod
	ll now = 0;
	ll loop_cnt = 1;
	ll loop_start_cnt = 0;
	bool conti = true;
	b[0] = 1;

	while(conti)
	{
		loop_cnt++;

		//cout << "move " << now+1 << " -> ";

		now = a[now];

		//cout << now+1 << endl;

		if (b[now] > 0)
		{
			conti = false;
			loop_start_cnt = b[now];
			break;
		}

		b[now] = loop_cnt;
	}

	/*
	cout << "now   " << now+1 << endl;
	cout << "loop  " << loop_cnt << endl;
	cout << "start " << loop_start_cnt << endl;
	//*/

	ll dest = 1;
	dest = (k - loop_start_cnt + 1) % (loop_cnt - loop_start_cnt);

	//cout << dest << endl;

	ll ans = 0;
	for(ll i = 0; i < min(k, loop_start_cnt + dest - 1); ++i)
	{
		ans = a[ans];
	}
	cout << ans + 1 << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<typename T> using VVVV = std::vector<std::vector<std::vector<std::vector<T>>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


void solve(int N, int A, int B) {

    vector<int> dp(N + 10, 0);
    dp[0] = 1;
    vector<int> v = {A, B};
    FOR(i, 0, v.size()) {
        FOR(j, 0, dp.size()) {
            if (dp[j] == 1 and j + v[i] < dp.size()) {
                dp[j + v[i]] = 1;
            }
        }
    }

    int ans = 0;
    FOR(i, 1, N + 1) {
        ans += (dp[i] == 0);
    }

    print(ans);
}

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

    while (true) {
        int N, A, B;
        cin >> N >> A >> B;
        if (N == 0 and A == 0 and B == 0) {
            break;
        }
        solve(N, A, B);
    }

    return 0;
}


Measured memory_bytes: 7084
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Thu Jan 24 15:48:11 2019
//
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	fmt.Println((N - 1 + K - 2) / (K - 1))
}


Measured memory_bytes: 5504
import math

def make_divisors(n):
    divisors = []
    for k in range(2, math.floor(math.sqrt(n))+1):
        if n % k == 0:
            divisors.append(k)
            divisors.append(n // k)

    divisors.append(n)

    return sorted(divisors)

def main():
    n = int(input())
    original_n = n

    factors = []
    divisors = make_divisors(n)

    i = 0
    while True:
        if n == 1:
            break

        if n % divisors[i] == 0:
            n //= divisors[i]
            factors.append(divisors[i])
        else:
            i += 1

    print("{}: {}".format(
        original_n,
        " ".join(list(map(str, factors)))
    ))

main()



Measured memory_bytes: 5680
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = n / 500;
        int tmp = n - a * 500;
        int b = tmp / 5;
        System.out.println(a * 1000 + b * 5);
    }
}


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

int main()
{
  int n;
  int k;
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ans += min(x, abs(x - k)) * 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	string str;cin >> str;
	int ans = 0;
	REP(i,str.size())
	{
		if(str[i] == '1')ans++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
tl = [[int(x) for x in input().split()] for _ in range(N)]
ans = 0

for i in range(N):
  for j in range(N):
    ans += ((tl[i][0]-tl[j][0])**2 + (tl[i][1]-tl[j][1])**2)**0.5
    
print(ans/N)

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

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

    int a, b;
    char op;
    cin >> a >> op >> b;
    if (op == '+') {
        cout << a + b << endl;
    }
    else {
        cout << a - b << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int xy[16][16]; int a,b;
int dp(const int x,const int y)
{
	if(x>a || y>b) return (0);
	if(x==a && y==b) return (1);
	if(xy[x-1][y-1]==0) return (0);
	if(xy[x-1][y-1]==-1) return (dp(x+1,y)+dp(x,y+1)) ;
	return (0);
}
int main()
{
	while(1)
	{
		cin >> a >> b ; if(a==0 && b==0) break;
		int n; cin >> n ;
		for(int i=0;i<16;i++) for(int j=0;j<16;j++) xy[i][j]=-1;
		int koji[40][2];
		for(int i=0;i<n;i++) cin >> koji[i][0] >> koji[i][1] ;
		for(int i=0;i<n;i++) xy[koji[i][0]-1][koji[i][1]-1]=0;
		cout << dp(1,1) << '\n' ;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
const int MAX_V = 100000;
int main(){
        int prime[MAX_V+1];
        int i, j, v, n;
        for(i = 2; i <= MAX_V; i++){
                prime[i] = 1;
        }
        for(i = 2; i * i <= MAX_V; i++){
                if(prime[i]){
                        for(j = 2 * i; j <= MAX_V; j += i){
                                prime[j] = 0;
                        }
                }
        }
        for(;;){
                scanf("%d", &n);
                if(n == 0) break;
                for(i = n - 2; i >= 2; i--){
                        if(prime[i] == 1 && prime[i + 2] == 1){
                                printf("%d %d\n", i, i + 2);
                                break;
                        }
                }
        }
        return 0;
}

Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
main(){
  
  int n;
   cin>>n;
  int a[n+1][4];
  
 
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=3;j++){
      cin>>a[i][j];
    }
  }
  int dp[n+1][4];
  dp[1][1]=a[1][1];
  dp[1][2]=a[1][2];
  dp[1][3]=a[1][3];
  
  for(int i=2;i<=n;i++)
  {
   dp[i][1]=a[i][1]+max(dp[i-1][2],dp[i-1][3]); 
   dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][3]); 
   dp[i][3]=a[i][3]+max(dp[i-1][1],dp[i-1][2]); 
    
  }
   cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
                
                
                
                
  
  
  
  
  
  
  
}

Measured memory_bytes: 3328
//Feet don't fail me now
//Take me to the finish line
//Oh, my heart, it breaks every step that I take
//But I'm hoping at the gates, they'll tell me
//that IOI gold is mine
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer {cout << "NO"; exit(0);}
#define vectors vector<vector<llong> >
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)

const long long MXN = 2e5 + 10;
const long long MNN = 1e4 + 520;
const long long MOD = 10007;
const long long INF = 1e18;
const long long OO = 1e9;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int n, ans, b[MXN];
map<int, int> mp;

int main(){
    ios;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        mp[b[i]]++;
    }
    sort(b + 1, b + n + 1);
    reverse(b + 1, b + n + 1);
    for(int i = 1; i <= n; i++){
        if(mp[b[i]] == 0) continue;
        mp[b[i]]--;
        for(int j = 30; j >= 0; j--){
            if((1 << j) < b[i]) break;
            if(mp[(1 << j) - b[i]] > 0){
                ans++;
                mp[(1 << j) - b[i]]--;
                break;
            }
        }
    }
    cout << ans;
}



Measured memory_bytes: 29824
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int[] count = new int[4];
		for(int i=0; i<4; i++){
			if(s.charAt(i) == s.charAt(0)){
				count[0]++;
			}else if(s.charAt(i) == s.charAt(1)){
				count[1]++;
			}else if(s.charAt(i) == s.charAt(2)){
				count[2]++;
			}else if(s.charAt(i) == s.charAt(3)){
				count[3]++;
			}
		}
		Arrays.sort(count);
		System.out.println(count[0] == 0 && count[1] == 0 && count[2] == 2 && count[3] == 2 ? "Yes" : "No");
	}
}


Measured memory_bytes: 35620
#include <stdio.h>

int main()
{
    int a, b, c;
    
    scanf("%d%d%d", &a, &b, &c);
    
    if (a==b && a==c || a!=b && a!=c && b!=c)
    {
        printf("No");
    }    
    else 
    {
        printf("Yes");
    }
    return 0;
}


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

using namespace std;

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


ll M=1e9+9;
ll dp[100][100][100];


int main(){
  ll w,h,n;
  ll T=1;

  while(cin>>w>>h>>n,w){

    vector<P> v;
    for(ll x,y,i=0;i<n;i++){

      cin>>x>>y;
      v.push_back(P(y-1,x-1));
      
    }
    
    sort(v.begin(),v.end());
    ll bt=0;

    memset(dp,0,sizeof(dp));
    
    for(ll i=0;i<w;i++)
      for(ll j=max(0LL,i-1);j<=min(w-1,i+1);j++)
	dp[0][i][j]=1;
  
    h--;

    while((1LL<<bt)<=h){
 
      for(ll i=0;i<w;i++)
	for(ll j=0;j<w;j++)
	  for(ll k=0;k<w;k++)
	    dp[bt+1][j][k]=(dp[bt][j][i]*dp[bt][i][k]+dp[bt+1][j][k])%M;
      
      bt++;
    }

    ll pr=0;

    v.push_back(P(h,-1));

    ll ans[100]={};

    ans[0]=1;
    
    for(ll p=0;p<=n;p++){
      bt=0;
      ll nh=v[p].first-pr;
      pr=v[p].first;
      while((1LL<<bt)<=nh){
	if((1LL<<bt)&nh){
	  ll tmp[100]={};
	  
	  for(ll i=0;i<w;i++)
	    for(ll j=0;j<w;j++)
	      tmp[j]=(tmp[j]+ans[i]*dp[bt][i][j])%M;
	  
	  for(ll i=0;i<w;i++)ans[i]=tmp[i];
	  
	}
	bt++;
      }

      ll yy=v[p].first;

      while(p<=n&&v[p].first==yy){
	if(v[p].second!=-1)ans[v[p].second]=0;
	p++;
      }
      
      p--;
      
    }
    cout<<"Case "<<T++<<": ";
    cout<<ans[w-1]<<endl;

  }



  return 0;
}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0; i<n; i++)
const ll INF= 1LL << 60;
int main(){
    ll n;
    cin >> n;
    cout << ((n%2==0)?(n/2-1):n/2) << endl;
}

Measured memory_bytes: 256
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int x = 0;
    int ans = 0;

    for (auto &&i : s) {
        if (i == 'I')
            x++;
        else
            x--;

        ans = max(x, ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3648
//17:30
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abss(ll a){return(a<0)?-a:a;}

int x[53];
int main(){
	int N,A;
	scanf("%d %d",&N,&A); 
	
	memset(x,0,sizeof(x));
	for(int i = 0; i < N; i++){
		scanf("%d",x+i);
	}
	for(int i = 0; i < 53; i++){
		x[i] -= A;
	}

	ll ans = 0;
	if(N == 1){
		if(x[0] == 0) ans++;
	}else if(N == 2){
		if(x[0] == 0) ans++;
		if(x[1] == 0) ans++;

		if(x[0] + x[1]== 0) ans++;
	}else if(N == 3){
		if(x[0] == 0) ans++;
		if(x[1] == 0) ans++;
		if(x[2] == 0) ans++;

		if(x[0] + x[1]== 0) ans++;
		if(x[1] + x[2]== 0) ans++;
		if(x[2] + x[0]== 0) ans++;

		if(x[0] + x[1] + x[2] == 0) ans++;
	}else{
		map<int,ll> m1,m2,m3,m4;

		int sub = N/4+1;
		if(N % 4 == 0) sub = N/4;
		for(int a = 0; a < (1 << sub); a++){
			int ans1 = 0;
			int ans2 = 0;
			int ans3 = 0;
			for(int i = 0; i < sub; i++){
				if(a&(1<<i)){
					 ans1 += x[0*sub+i];
					 ans2 += x[1*sub+i];
					 ans3 += x[2*sub+i];
				}
			}
			m1[ans1]++;
			m2[ans2]++;
			m3[ans3]++;
		}
		for(int a = 0; a < (1 << (N-3*sub)); a++){
			int ans4 = 0;
			for(int i = 0; i < N-3*sub; i++){
				if(a&(1<<i)){
					 ans4 += x[3*sub+i];
				}
			}
			m4[ans4]++;
		}
		map<int,ll>::iterator it1,it2,it3,it4;
		/*
		puts("1---");
		it1 = m1.begin();
		while(it1 != m1.end()){
			printf("%d %d\n",it1->first,it1->second);
			it1++;
		}
		puts("4---");
		it4 = m4.begin();
		while(it4 != m4.end()){
			printf("%d %d\n",it4->first,it4->second);
			it4++;
		}*/
		map<int,ll> m12,m34;
		it1 = m1.begin();
		it2 = m2.begin();
		while(it1 != m1.end()){
			it2 = m2.begin();
			while(it2 != m2.end()){
				m12[it1->first+it2->first] += it1->second*it2->second;
				it2++;
			}
			it1++;
		}
		it3 = m3.begin();
		it4 = m4.begin();
		while(it3 != m3.end()){
			it4 = m4.begin();
			while(it4 != m4.end()){
				m34[it3->first+it4->first] += it3->second*it4->second;
				it4++;
			}
			it3++;
		}

		map<int,ll>::iterator it12 = m12.begin();
		it12 = m12.begin();
		while(it12 != m12.end()){
			ans += it12->second * m34[ - it12->first];
			it12++;
		}

		ans--;//all 0
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	int ans = 0;
	for(string s; getline(cin, s);) {
		string rev = s;
		reverse(all(rev));
		if(s == rev) ans ++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{

    int m, f, r, sum;

    while(1){
        scanf("%d %d %d", &m, &f, &r);

        if(m+f+r == -3){break;}

        sum = m + f;    
    
        if(m == -1 || f == -1 || sum < 30){
            printf("F\n");
        }
        else if(sum >= 80){
            printf("A\n");
        }
        else if(sum >= 65 && sum < 80){
            printf("B\n");
        }
        else if(sum >= 50 && sum < 65){
            printf("C\n");
        }
        else if(sum >= 30 && sum < 50){
            if(r >= 50){
                printf("C\n");
            }
            else{
                printf("D\n");
            }
        }
    }
    return 0;
}
        

         

Measured memory_bytes: 584
n = int(input())
A = list(map(int, input().split()))
kisu = 0
if n == 1:
    print("YES")
    exit()


for a in A:
    if a % 2 == 1:
        kisu += 1
if kisu % 2 == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 14108
#include<iostream>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
    char c;
    int a,b;
    scanf("%d %c %d",&a,&c,&b);
    if(c=='+') printf("%d\n",a+b);
    if(c=='-') printf("%d\n",a-b);
    return 0;
}

Measured memory_bytes: 256
import math

a,b = map(int,input().split())

ans = []
for i in range(10000):
    a_shouhizei = math.floor(i * 8/100)
    b_shouhizei = math.floor(i * 10/100)
    if a_shouhizei == a and b_shouhizei == b:
        ans.append(i)
if ans == []:
    print('-1')
else:
    print(min(ans))

Measured memory_bytes: 3188
use std;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn c_tsundoku() {
    let nmk = read_vec::<i64>();
    let n = nmk[0];
    let m = nmk[1];
    let k = nmk[2];
    let a_books = read_vec::<i64>();
    let b_books = read_vec::<i64>();

    let a_times: Vec<i64> = a_books.iter().fold(vec![0], |mut acc, a| {
        acc.push(acc.last().unwrap() + a);
        acc
    });
    let b_times: Vec<i64> = b_books.iter().fold(vec![0], |mut acc, b| {
        acc.push(acc.last().unwrap() + b);
        acc
    });

    let mut ans = 0;
    let mut j = m;
    for i in 0..n+1 {
        if a_times[i as usize] > k { break; }
        while b_times[j as usize] > k - a_times[i as usize] { j -= 1}
        ans = *vec![ans, i + j].iter().max().unwrap();
    }
    println!("{}", ans);
}

fn main() {
    c_tsundoku();
}


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

int main() {
	int h, w;
	cin>>h>>w;
	char a[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
			cout<<a[i][j];
			
		}
		cout<<endl;
		for(int j=0;j<w;j++){
			cout<<a[i][j];
		}
		cout<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 384
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,ans;
int x[55],y[55];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n;
  for(int i=1;i<=n;i++)cin>>x[i];
  for(int i=1;i<=n;i++)cin>>y[i];
  for(int i=1;i<=n;i++){
    int a=x[i];
    int b=y[i];
    ans+= max(0LL,a-b);
  }
  cout<<ans<<endl;

return 0;
}
///....


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int m, d;
    cin >> m >> d;
    int ans = 0;
    Rep(i, 1, m + 1)
    {
        Rep(j, 1, d + 1)
        {
            if (j < 10)
                continue;
            int d1 = j % 10;
            int d2 = j / 10;
            if (d1 < 2 || d2 < 2)
                continue;
            if (d1 * d2 == i)
                ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n;
char a[1005],s[10000005];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	a['q']='p';
	a['b']='d';
	a['p']='q';
	a['d']='b';
	for (int i=1;i<=n;i++)
		if (s[i]!=a[s[n-i+1]]){
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define V vector
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

int main(){
    ins(N);ins(C);
    V< V <int> > d(C);
    rep(i,C){
        rep(j,C){
            d.at(i).PB(0);
        }
    }
    V<ll> csum0(C),csum1(C),csum2(C);
    int c;
    rep(i,C){
        rep(j,C){
            ins(p);
            d.at(i).at(j)=p;
        }
    }
    rep(i,N){
        rep(j,N){
            ins(p);
            rep(k,C){
                if((i+j)%3==0){
                    csum0.at(k)+=d.at(p-1).at(k);
                }else if((i+j)%3==1){    
                    csum1.at(k)+=d.at(p-1).at(k);
                }else{
                    csum2.at(k)+=d.at(p-1).at(k);
                }
            }
        }
    }
    ll ans=LINF;
    rep(i,C){
        rep(j,C){
            rep(k,C){
                if(i!=j&&j!=k&&k!=i){
                    ans=min(ans,csum0.at(i)+csum1.at(j)+csum2.at(k));
                }
            }
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
x, n = map(int, input().split())
P = list(map(int, input().split()))
INF = 10**18
ans = INF
if x not in P:
    print(x)
    exit()
for i in range(-100, 200):
    if i in P:
        continue
    if ans > abs(x-i):
        ans = abs(x-i)
        cnt = i
print(cnt)


Measured memory_bytes: 9184
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>

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

using namespace std;
using p = pair<int, int>;
using ll = long long;



int main() {
	string s, t;
	cin >> s;
	cin >> t;
	string ans = "Yes";
	rep(i, s.size()) {
		if (s[i] != t[i]) {
			ans = "No";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  vector<long long> va;
  long long a;
  cin>>n;
  for (long long i=0;i<n;i++){
    cin>>a;
    va.push_back(a);
  }
  sort(va.begin(),va.end());
  long long amax=va.back();
  long long al,ar;
  auto ci=lower_bound(va.begin(),va.end(),((double)amax)/2);
  //al=*ci;
  ar=*ci;
  if (ci==va.begin()){
    al=ar;
  }
  else{
    al=*(ci-1);
  }

  //ar=*(ci+1);

  //cout<<"al"<<al<<endl;
  if (ar==amax||amax-2*al<2*ar-amax){
    cout<<amax<<" "<<al<<endl;
  }
  else {
    cout<<amax<<" "<<ar<<endl;
  }
  
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define pqdef priority_queue
#define ii pair<int,int>
#define st first
#define nd second
#define ll long long 
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define INF 0xFFFFFF
#define endl '\n'
#define bitctr(n) __builtin_popcount(n)//2 tabainindaki basasmak toplami
#define bitctrll(n) __builtin_popcountll(n)//long long 2 tabainindaki basasmak toplami
const double PI = acos(-1);//2*acos(0.0);
const int MAXX=1000005;
const int maxInt = 2147483647;
using namespace std;
int vis[MAXX],dis[MAXX];
int main(){
	string s;
	ll int cnt = 0;
	int flag = 0; 
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>s;
	int a = s.length(); 
	rep(i,a){
		if(flag == 1){
			flag = 0;
			cnt++;
		}
		else{
			if(s[i] != s[i+1]){
				flag = 0;
				cnt++;
			}
			else if(s[i] == s[i+1]){
				i++;
				cnt++;
				flag = 1;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;	
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define ull unsigned long long
# define lli long long int
# define ulli unsigned long long int
#define ll long long
#define db double
#define ldb long double
#define vi vector<int>
#define vull vector<ull>
#define vll vector<ll>
#define pb push_back
#define eb emplace_back
#define si set<int>
#define sll set<ll>
#define ins insert
#define rep(i,n) for(int i=0;i<n;i++)
#define vpp vector<pair<int,int>>
#define mp make_pair
#define ft first
#define sc second
#define MAX 9999999
#define MOD 1000000007
using namespace std;
//ll prime[9999999];
// //Modular Exponentiation
// ll fastExpo(ll x, ll n) {
//   if (n == 0) return 1;
//   if ((n & 1) == 0) return fastExpo((x * x) % MOD, n / 2) % MOD;
//   return ((x % MOD) * fastExpo((x * x) % MOD, (n - 1) / 2)) % MOD;
// }
//   //Euclidean Algorithm
// ll gcd(ll a, ll b) {
//   return (b == 0) ? a : gcd(b, a % b);
// }
//  // Extended Euclidean Algorithm
//   ll exgcd(ll a,ll b,ll &x, ll &y){
//   if(b==0){
//     x=1,y=0;
//     return a;
//   }
//    ll x1,y1;
//     ll d=exgcd(b,a%b,x1,y1);
//    x=y1;
//    y=x1-y1*(a/b);
//    return d;
//  }

// void sieve() {
//   prime[0] = 0;
//   prime[1] = 0;
//   for (int i = 2; i < 9999999; i++) {
//     prime[i] = 1;
//   }
//   for (int i = 2; i * i < 9999999; i++) {
//     if (prime[i] == 1) {
//       for (int j = i * i; j < 9999999; j += i) {
//         prime[j] = 0;
//       }
//     }
//   }
// }
// int fi[10009];
// void fun(){
//   for(int i=0;i<10009;i++)fi[i]=i;
//   for(int i=2;i<10009;i++)
//   {   if(fi[i]==i)
//       {
//         for(int j=i;j vt<10009;j+=i)
//         fi[j]=fi[j]*(i-1)/i;
//       }
//   }
//

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  //  cout << fixed;
  // cout.precision(2);

  string n;
  cin >> n;
  ll sum = 0;
  for (int i = 0; i < n.size(); i++) {
    sum += (n[i] - '0');
  }
  if (sum % 9 == 0)
    cout << "Yes" << "\n";
  else
    cout << "No" << "\n";
  return 0;
}







Measured memory_bytes: 3780
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
ll mod=1e18;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}
long modInverse(long a) {return powmod(a, mod-2);}
ll my_rand(){ll a=rand();ll b=rand();return (a*RAND_MAX+1)+b;}
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()


int main(){
    ios::sync_with_stdio(false);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<"safe"<<endl;
    }
    else cout<<"unsafe"<<endl;
    return 0;
    }


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

int main() {
  string S,T;
  cin >> S >> T;
  string s;
  bool t=false;
  for(int i=0;i<S.size();i++){
    s=S.at(S.size()-1);
    S.pop_back();
    S=s+S;
    //cout << S << endl;
    if(S==T) t=true;
  }
  if(t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            char[] s = sc.next().toCharArray();
            Arrays.sort(s);
            if ( s[0] == 'a' && s[1] == 'b' && s[2] == 'c' ) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 21332
@$_=$p[$_]=$_ for@N=1..<>;map{unshift@a,@N*$#N/2-$%;$%+=@$A*@$B,@$A>@$B&&($A^=$B^=$A^=$B),map$p[$$B[@$B]=$_]=$B,@$A if($B=$p[$'*/ /])-($A=$p[$`])}reverse<>;print"@a"

Measured memory_bytes: 118272
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    ll a, b;
    cin >> a >> b;
    put(a * b);
}

Measured memory_bytes: 3672