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

public class Main {

    private static Scanner sc;

    public Main() {
    }

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

    private void solve() {
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        
        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans += Math.min(arr[i] * 2, (K - arr[i]) * 2);
        }
        
        System.out.println(ans);
    }

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
	int N;
	string S;
	cin >> N;
	vector<vector<long long>>U(10, vector<long long>(10));
	for (int i = 1; i <= N; i++)
	{
		S = to_string(i);
		U.at(S.at(0) - '0').at(S.at(S.size() - 1) - '0')++;
	}
	long long int ans=0;
	for (size_t i = 0; i < 10; i++)
	{
		for (size_t j = 0; j < 10; j++)
		{
			ans += U.at(i).at(j) * U.at(j).at(i);
		}
		
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;
const lli mod = 998244353;
const int inf = 1e9;

int main(){
	int n,x,y;
	cin >> n >> x >> y;
	x--; y--;
	vector<int> ans(n, 0);
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			ans[min(j-i, abs(i-x) +1 +abs(j-y))]++;
		}
	}
	for(int i=1; i<n; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  cout << min(N % K, abs((N % K) - K)) << endl;
   
}

Measured memory_bytes: 3520
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var n = Console.ReadLine().ToCharArray();
        foreach (var i in n)
        {
            if (i == '7')
            {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}

Measured memory_bytes: 25892
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, W, dp[105][10005];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> W;
	for (int i = 1; i <= n; i++) {
		int v, w;
		cin >> v >> w;
		for (int j = 0; j <= W; j++) {
			if (j-w >= 0) dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v);
			else dp[i][j] = dp[i-1][j];
		}
	}
	int ans = 0;
	for (int i = 0; i <= W; i++) ans = max(ans, dp[n][i]);
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n,a,b;
    cin>>n;
    if (n==1) {
        cout<<"Hello World"<<endl;
    } else {
        cin>>a>>b;
        cout<<a+b<<endl;
    }
}


Measured memory_bytes: 256
using System;
class Program
 {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            int H = int.Parse(input[0]);  //数値で受け取りたい場合は変換する
            int W = int.Parse(input[1]);
            string[] mapStr = new string[H];
            for(int i = 0; i < H; i++){
                mapStr[i] = Console.ReadLine();
            }
            int[,] shortRouteMap = new int[H , W];
            int blackNum = 0;
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    shortRouteMap[i , j] = -1;
                    if(mapStr[i].Substring(j, 1) == "#"){
                        blackNum++;
                    }
                }
            }
            shortRouteMap[0 , 0] = 0;
            for(int i = 0; i < H * W; i++){
                for(int j = 0; j < H; j++){
                    for(int h = 0; h < W; h++){
                        int num = shortRouteMap[j , h];
                        if(num < 0 && mapStr[j].Substring(h , 1) == "."){
                            int mawariMin = 100000;
                            if(j > 0){
                                if(shortRouteMap[j - 1 , h] >= 0 && shortRouteMap[j - 1 , h] < mawariMin){
                                    mawariMin = shortRouteMap[j - 1 , h];
                                }
                            }
                            if(j < H - 1){
                                if(shortRouteMap[j + 1 , h] >= 0 && shortRouteMap[j + 1 , h] < mawariMin){
                                    mawariMin = shortRouteMap[j + 1 , h];
                                }
                            }
                            if(h > 0){
                                if(shortRouteMap[j , h - 1] >= 0 && shortRouteMap[j , h - 1] < mawariMin){
                                    mawariMin = shortRouteMap[j, h - 1];
                                }
                            }
                            if(h < W - 1){
                                if(shortRouteMap[j, h + 1] >= 0 && shortRouteMap[j, h + 1] < mawariMin){
                                    mawariMin = shortRouteMap[j, h + 1];
                                }
                            }
                            if(mawariMin != 100000){
                                shortRouteMap[j, h] = mawariMin + 1;
                            }
                        }
                    }
                }
            }
            int answer = -1;
            if(shortRouteMap[H - 1, W - 1] > 0){
                answer = H * W - (shortRouteMap[H - 1, W - 1] + 1) - blackNum;
            }
            // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
            Console.WriteLine(answer.ToString());
        }
 }

Measured memory_bytes: 15276
L,R=map(int,input().split())
if R-L>=2019:
    minimum=0
else:
    left,right=L%2019,R%2019
    minimum=2018**2
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)

Measured memory_bytes: 3064
n = gets.strip.to_i
array = gets.split.map(&:to_i)
puts array.join(' ') 

for i in 1..n-1 do
  key = array[i]
  j = i
  while j > 0 && array[j-1] > key do
    array[j] = array[j-1]
    j -= 1
  end
  array[j] = key
  puts array.join(' ')
end

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

using namespace std;

const int MX_BIT = 25;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    long long h, w;
    cin >> h >> w;
    auto ans = h == 1 || w == 1 ? 1 : ((h+1)/2) * ((w+1)/2) + (h/2) * (w/2);
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
vector<bool>a(8,false);
int che = 0;
int n;
cin >> n;
for(int i=0;i<n;i++){
    int z;
    cin >> z;
    if(z>=3200)che++;
    else if(z>=2800)a.at(0)=1;
    else if(z>=2400)a.at(1)=1;
    else if(z>=2000)a.at(2)=1;
    else if(z>=1600)a.at(3)=1;
    else if(z>=1200)a.at(4)=1;
    else if(z>=800)a.at(5)=1;
    else if(z>=400)a.at(6)=1;
    else a.at(7)=1;
}
int chem =0;
for(int i=0;i<8;i++){
    if(a.at(i))chem++;
}
ll ans = chem+che;
cout << max(chem,1) <<" "<<ans<<endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n - 1);

  for (int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++){
    cin >> b.at(i);
  }
  for (int i = 0; i < n - 1; i++){
    cin >> c.at(i);
  }
  // cout << 10 << endl;

  int sum = 0;
  int pre_num = 50;
  for (int i = 0; i < n; i++){
    sum += b[a[i] - 1];
    if (pre_num == a[i] - 1){
      sum += c[a[i] - 2];
    }
    pre_num = a[i];
    // cout << sum << endl;
    // cout << "aa" << endl;
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	long long cnt = 0;
	cin >> a >> b;
	for(int i = 0; i < a.size(); i++){
		if(a[i] != b[i]){
			cnt++;
		}
	}
	cout << cnt;
}

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

int n;
bool adj[22][22];
vector<int> m[22];
const int MOD = 1e9+7;
int dp[22][(1<<21)];
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>adj[i][j];
		}
	}
	
	for(int i=0;i < (1<<n);i++){
		m[__builtin_popcountll(i)].push_back(i);
	}
	//dp[0][0] = 1;
	
	for(int j=0;j<n;j++){
		if(adj[0][j]) dp[0][(1<<j)] = 1;
	}
	
	for(int i=1;i<n;i++){
		for(int mask: m[i]){
			for(int j=0;j<n;j++){
				if(mask&(1<<j) || adj[i][j] == 0) continue;
				int hnhn = mask|(1<<j);
				dp[i][hnhn] += dp[i-1][mask];
				if(dp[i][hnhn] >= MOD) dp[i][hnhn]-=MOD;
			}
		}
	}
	
	//for(int i=0;i<=n;i++){
	//	for(int j=0;j<(1<<n);j++){
	//		cout<<dp[i][j]<<" ";
	//	}cout<<endl;
	//}
	
	cout<<dp[n-1][(1<<n)-1];
	
	return 0;
}


Measured memory_bytes: 171452
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    ll m;cin>>m;
    ll a[m],b[m];
    vector<ll> v[m];
    rep(i,0,m){
        cin>>a[i]>>b[i];
        rep(j,0,b[i]){
            ll c;cin>>c;
            v[i].push_back(c-1);
        }
    }
    ll r=(1<<n);
    ll dp[m+1][r];
    rep(i,0,m+1){
        rep(j,0,r)dp[i][j]=inf;
    }
    dp[0][0]=0;
    rep(i,0,m){
      // rep(j,0,v[i].size())cout<<v[i][j]<<" ";
      //  cout<<endl;
    }
    rep(i,0,m){
        rep(j,0,r){
            if(dp[i][j]==inf)continue;
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            ll t=0;
            rep(k,0,v[i].size())t+=(1<<v[i][k]);
            //cout<<t<<" ";
            t|=j;
            //cout<<t<<endl;
            dp[i+1][t]=min(dp[i+1][t],dp[i][j]+a[i]);
           // cout<<dp[i+1][t]<<endl;
        }
    }
    if(dp[m][r-1]==inf)cout<<-1<<endl;
    else cout<<dp[m][r-1]<<endl;
    rep(i,0,m+1){
       //rep(j,0,(1<<n))cout<<dp[i][j]<<" ";
       //cout<<endl;
    }
}


Measured memory_bytes: 32512
#include<iostream>
using namespace std;
int m=1e9+7;
int main(){
	int N,M;cin>>N>>M;
	long d[N+1],a=M-N+1;d[0]=1,d[1]=M-N;
	for(int i=2;i<=N;i++){d[i]=((M-N+i-1)*d[i-1]+(i-1)*d[i-2])%m;a=a*(M-i+2)%m;}
	cout<<a*d[N]%m;
	return 0;
}


Measured memory_bytes: 7392
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define root sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : ' ');
  }
  // os << '}';
  return os;
}

int main()
{
  int r;
  cin >> r;
  double ans = 3.141592648777698869248;
  printf("%.10lf\n", r * 2 * ans);
}


Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
 
using namespace std;
 
#define MAX_RANGE 2000000
 
void Sol4()
{
	int N;
	cin >> N;
	vector<int> A;
	int numOfNonDivisibles=0;
	int max_val = 0;
	vector<int> hsh_map(MAX_RANGE+1);
	vector<int> isDivisible(MAX_RANGE+1);
	

	for (int i = 0; i < N; i++)
	{
		int num;
		cin >> num;
		hsh_map[num]++;		// sort of count sort. going in sequence will be in ascending order
		max_val = max(max_val, num);
	}

	

	for (int i = 0 ; i <= max_val; i++)
	{
		if (!hsh_map[i] || isDivisible[i])		// if number does not exists in the list (hshmap is 0) or if exists, then we are not checking divisble for the same number.
			continue;							// example 16 is in list, and divisible was made 1 due to second loop starting i = 8, then we skip
		if (hsh_map[i] == 1 && !isDivisible[i])		// if number existed and isdivisible is not set so far, then count.
			numOfNonDivisibles++;					// moreover if there are duplicates, say 5 appear 2 times, so hshmap = 2. should not  count as one 5 is divisble by another 
		for (int j = i; j <= max_val; j += i)	// set all numtiple of i's to 1. say control reaches here for existed values only example 3.
			isDivisible[j] = 1;					// then 3 6 9  .. so on all indexes set to 1
	}
	
	cout << numOfNonDivisibles << endl;
}
int main()
{
    #define endl '\n'
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(0);
    {
        //freopen("handmade09", "r", stdin);
        //freopen("out.txt", "w", stdout);
        //Sol1();
        //Sol2();
        //Sol3();
        Sol4();
        //Sol5();
        //Sol6();
    }
    //cin.get();
}

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

template<class T> inline bool isPrime(T n) {
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    long double sqrtN = sqrt(n);
    for (T i = 3; i <= sqrtN; i += 2)
        if (n % i == 0) return false;
    return true;
}

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

    ll n; cin >> n;

    if (isPrime(n)) cout << n - 1 << '\n';
    else {
        ll mini = 1LL << 60;
        ll num = 0;
        for (ll i = 2; i <= sqrt(n); i++) {
            if (n % i == 0) {
                if (i + n / i < mini) {
                    mini = min(mini, i + n / i);
                    num = i;
                }
            }
        }
        cout << num + n / num - 2 << '\n';
    }
    return 0;
}


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

int w,h;
int b[20][20];
int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

int rec(int y, int x, int d);

int main(){
  while(cin >> w >> h,w){

    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> b[i][j];

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(b[i][j] == 2){
	  int res = rec(i,j,0);
	  if(res == 11)cout << -1 << endl;
	  else cout << res << endl;
	}
      }
    }
  }
}

int rec(int y, int x, int d){
  if(d==10)return 11;

  int res = 11;
  for(int i=0;i<4;i++){
    int ny = y+dy[i], nx = x+dx[i];
    if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
    if(b[ny][nx] == 1)continue;

    while(true){
      if(ny<0 || nx<0 || ny>=h || nx>=w)break;
      if(b[ny][nx] == 3)return d+1;

      if(b[ny][nx] == 1){
	b[ny][nx] = 0;
	res = min(res, rec(ny-dy[i],nx-dx[i],d+1) );
	b[ny][nx] = 1;
	break;
      }
      ny += dy[i]; nx += dx[i];
    }
  }
  return res;
}

Measured memory_bytes: 1160
A, B, C = list(map(int, input().split()))
eat_good_cookie_count = 0
if C > A + B:
    eat_good_cookie_count = C - (C - A - B) + B + 1
elif C == A + B:
    eat_good_cookie_count = C - (C - A - B) + B
else:
    eat_good_cookie_count = C + B

print(eat_good_cookie_count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char b;
    cin>>b;
    if(b=='a'||b=='e'||b=='i'||b=='o'||b=='u')
        {cout<<"vowel";}
    else
    {
        cout<<"consonant";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string str;
    int q;
    cin >> str;
    cin >> q;
    while(q--){
        string s;
        cin >> s;
        if(s == "print"){
            int a, b;
            cin >> a >> b;
            cout << str.substr( a, b - a + 1) << endl;
        } else if(s == "reverse"){
            int a, b;
            cin >> a >> b;
            reverse( str.begin() + a, str.begin() + b + 1);
        } else {
            int a, b;
            string p;
            cin >> a >> b >> p;
            str.replace( a, b - a + 1, p);
        }
    }
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[m],b[m];
    vector<vector<int>>c(m,vector<int>(0));
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        c[i].resize(b[i]);
        for(int j=0;j<b[i];j++){
            cin>>c[i][j];
        }
    }
    int box=1;
    for(int i=0;i<n;i++)box*=2;
    vector<vector<int>>dp(m+1,vector<int>(box,1000000000));
    //dp[i][j]:i(1～m)番目の鍵まで見てj(どの箱が空いたかを2進数で表し、10進数展開したもの)のコストの最小値
    dp[0][0]=0;
    int mi=1000000000;
    for(int i=0;i<m;i++){
        for(int j=0;j<box;j++){
            //i+1番目の鍵を使う
            int J=j,x=0,p=0,pow=1;
            for(int k=1;k<=n;k++){
                if(k==c[i][p] && p<b[i]){
                    p++;
                    if(J%2==0/*未開封*/)x+=pow;
                }
                J/=2;
                pow*=2;
            }
            dp[i+1][j+x]=min(dp[i][j]+a[i],dp[i+1][j+x]);
            //i+1番目の鍵を使わない
            dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
        }
        mi=min(mi,dp[i+1][box-1]);
    }
    if(mi==1000000000)mi=-1;
    cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 16384
use proconio::input;
fn main() {
    input!(a: usize, b: usize);
    match (a, b) {
        (x, y) if x == y => draw!(),
        (1, _) => win_alice!(),
        (_, 1) => win_bob!(),
        (x, y) if x > y => win_alice!(),
        _ => win_bob!(),
    }
}

#[macro_export]
macro_rules! win_alice {
    () => {
        println!("Alice")
    };
}

#[macro_export]
macro_rules! win_bob {
    () => {
        println!("Bob")
    };
}

#[macro_export]
macro_rules! draw {
    () => {
        println!("Draw")
    };
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define sz(x) (int)(x).size()
using vi = vector<int>;
using ll = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int INFTY = 1e9;
    vector<vector<int>> dist(n,vector<int>(n,INFTY));
    rep(i,0,n) {
        string s;
        cin >> s;
        dist[i][i] = 0;
        rep(j,0,n) if(s[j]=='1') dist[i][j] = 1;
    }
    queue<int> q;
    q.push(0);
    vector<int> col(n,-1);
    col[0] = 0;
    bool good = true;
    while(!q.empty()) {
        int u = q.front();
        q.pop();
        rep(v,0,n) if(dist[u][v]==1) {
            if(col[v]==col[u]) good = false;
            else if(col[v]==-1) {
                col[v] = col[u]^1;
                q.push(v);
            }
        }
    }
    if(good) {
        rep(k,0,n) rep(i,0,n) rep(j,0,n) {
            dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
        }
        int most = 0;
        rep(i,0,n) rep(j,0,n) most = max(most,dist[i][j]);
        cout << most+1 << endl;
    }
    else cout << "-1\n";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long M  = 1e9+7;
 
 
signed main(){
    fast;
    int n; cin >> n;
    vector <int> a(n);
    for(int i=0 ; i<n ; i++)
        cin >> a[i];
    map <int,int> mp;
    for(int i=0 ; i<n ; i++){
        
        if(mp[a[i]]){
            cout << "NO" << endl;
            return 0;
        }
        mp[a[i]]++;
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 14336
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace D_ABC172
{
    class MainClass
    {

        static long[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);
            long ans = 0;
            long n = s[0];
            for (long i = 1; i <= s[0]; i++)
            {
                long tmp = n / i;
                ans += i * (tmp)*(tmp+1) /2;

            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27952
#include <bits/stdc++.h>
#include <queue>
#include <string.h>
#include <stdint.h>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define ull unsigned long long
#define ut uint64_t

#define pb push_back
#define ins insert
#define er erase

#define fi(i, b) for (int i=0;i<b;i++)
#define fll(i, b) for (ll i=0;i<b;i++)
#define fla(i,a,b) for (ll i=a;i<b;i++)

#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define vst vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define vv(n,m) vector<vector<ll> > vec( n , vector<ll> (m, 0))


#define all(v) v.begin(), v.end()
#define lb lower_bound
#define ub upper_bound
#define mxe max_element
#define mne min_element

#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(), v.rend())

#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second

#define mii map<int, int>
#define mll map<ll, ll>
#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>

#define si set<int>
#define sll set<ll>
#define usi unordered_set<int>
#define usll unordered_set<ll>
#define spii set<pii>
#define spll set<pll>

#define pqi priority_queue<int>
#define pqll priority_queue<ll>

 #define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)

#define nl "\n"
using namespace std;


ll md = 1000000007;
ll ma = 998244353;

ll pw(ll a, ll b)
{
    ll c = 1, m = a;
    while (b){
        if (b & 1)c = (c * m);
        m = (m * m);
        b /= 2;
    }
    return c;
}

ll pwmd(ll a, ll b){
    ll c = 1, m = a;
    while (b){
        if (b & 1)
            c = ((c * m)) % md;
        m = (m * m) % md;
        b /= 2;
    }
    return c;
}


ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll min(ll a,ll b){
    if(a>=b)return b;
    return a;
    
//vst vect={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    
    
    
}
void solve(){
    ll a,b;
    cin>>a>>b;
    if(a>=1&&b>=1&&a<=9&&b<=9)cout<<a*b;
    else cout<<-1;
    
}

// AB DEKHO JAADU...

int main(){

    fast;
    ll tests=1;
    //cin>>tests;
    while(tests--){
        solve();
    }

    return 0;
    }

// KHATAM HO GAYA:)...






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, p, A=0, W=0;
  string S;
  
  cin >> N >> M;
  vector<int> cA(N);
  vector<int> cW(N);
  
  for(int i=0; i<M; i++){
    
    cin >> p >> S;
    
    if(S=="AC" && cA.at(p-1)==0){
      A++;
      W += cW.at(p-1);
      cA.at(p-1) = 1;
    }else if(cA.at(p-1)==0)
      cW.at(p-1)++;

  }
  
  cout << A << " " << W << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int Inf = 1e9;
const double EPS = 1e-9;



int main()
{
  int n, k ;
  cin >> n >> k ;
  ll ans = k ;
  
  REP(i,n-1){
    ans = ans*(k-1) ;
  }
  
  cout << ans <<endl ;

  return 0 ;
}



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

using namespace std;

bool judge (const string& K){
	int n = K.size();
	char tmp_a = K[0];
	
	for(int i = 1; i < n; i++){
		if (K[i] == tmp_a) return true;
		tmp_a = K[i];	
	}
	
	return false;
}

int main() {
	string K;
	cin >> K;
	
	bool result = judge(K);
	
	if(result == true) cout << "Bad" << endl;
	else cout << "Good" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N, ans;
  ans = 0;
  cin >> N;
  vector<int> mochi(110);
  for(int i = 0; i < N; i++){
    cin >> mochi.at(i);
  }
  vector<int> backets(110);
  for(int i = 0; i < N; i++){
   backets.at(mochi.at(i))++; 
  }
  for(int i = 0; i < 110; i++){
   if(backets.at(i) > 0){
    ans++; 
   }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int n;cin >> n;
    cout << (n-2)*180 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  int n;
  cin >> n;
  int cnt = 0;
  int p_n;
  int q_n;
  vector<int>order(n);
  for(int i=0;i<n;i++) order[i]=i+1;
  vector<int>p(n);
  vector<int>q(n);
  for(int i=0;i<n;i++) cin >> p[i];
  for(int i=0;i<n;i++) cin >> q[i];

  do {
    cnt++;
    if(order==p) p_n=cnt;
    if(order==q) q_n=cnt;
  } while(next_permutation(All(order)));
  cout<< abs(p_n-q_n) <<endl;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int n, m;
map<int, int> es[100];

void dfs(int n, vector<bool>& used) {
    if (used[n]) return;
    used[n] = true;
    for(auto v: es[n]) if (v.second > 0) dfs(v.first, used);
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    cin >> n >> m;

    vi a(m), b(m);
    rep(i, m) {
        int _a, _b;
        cin >> _a >> _b;
        _a--, _b--;
        a[i] = _a;
        b[i] = _b;
        es[_a][_b] = 1;
        es[_b][_a] = 1;
    }

    int ans = 0;
    rep(i, m) {
        es[a[i]][b[i]] = 0;
        es[b[i]][a[i]] = 0;
        vector<bool> us(n, false);
        dfs(0, us);
        es[a[i]][b[i]] = 1;
        es[b[i]][a[i]] = 1;

        rep(j, n) if (!us[j]) {ans++; break;}
    }

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


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

using namespace std;


#define MAXN 100001
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  pair<int, int> a[MAXN];
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a[i].second >> a[i].first;
  }
  sort(a, a+m);
  int ans = 0;

  for (int i = 0; i < m;) {
    int cut = a[i].first-1;
    ++ans;
    while(a[i].second<=cut && i<m) ++i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int N,X,L[100],D=0,a=0,i;
	scanf("%d",&N);
	scanf("%d",&X);
	for(i=0;i<N;i++)
	{
		scanf("%d",&L[i]);
		D=D+L[i];
		if (D<X || D==X)
		{
		a++;
	    }	
	}
	a=a+1;
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

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

    int count = 0;
    int head = 0;
    int last = 0;
    int mul = 0;
    string s;
    for(int i = 0; i < n; i++){
        cin >> s;
        for(int j = 0; j < s.size()-1; j++){
            if(s[j]=='A'&&s[j+1]=='B'){
                count++;
            }
        }
        if(s[0] == 'B'){
            head++;
        }
        if(s[s.size()-1] == 'A'){
            last++;
        }
        if(s[0] == 'B' && s[s.size()-1] == 'A'){
            mul++;
        }
    }
//    cerr << count << " " << head << " " << last << endl;

    if(mul == head && mul == last){
        int a = count+min(head, last)-1;
        if(mul == 0){
            cout << count << endl;
        }else {
            cout << count + min(head, last) - 1 << endl;
        }
    }else{
        cout << count+min(head, last) << endl;
    }

    return 0;
}


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

int main() {
  string b;
    cin >> b;
  if(b=="A"){
    cout<<"T"<<endl;
  }
  if(b=="T"){
    cout<<"A"<<endl;
  }
  if(b=="C"){
    cout<<"G"<<endl;
  }
  if(b=="G"){
    cout<<"C"<<endl;
  }
  
}

Measured memory_bytes: 256
N, L = [int(x) for x in input().split()]

pie = 0
minimum = [0, float('inf')]
for i in range(1, N + 1):
	pie += L + i - 1
	if abs(L + i - 1) < minimum[1]:
		minimum[0] = i
		minimum[1] = abs(L + i - 1)

print(pie - (L + minimum[0] - 1))

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

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	long long XOR = 0;
	for (int i = 2; i < N; i++) XOR ^= A[i];
	if ((A[0] + A[1]) % 2 != XOR % 2) {
		cout << -1 << endl;
		return 0;
	}
	long long AND = (A[0] + A[1] - XOR) / 2;
	if (AND < 0) {
		cout << -1 << endl;
		return 0;
	}
	if ((AND & XOR) != 0) {
		cout << -1 << endl;
		return 0;
	}
	vector<int> Xor(40);
	for (int i = 0; i < 40; i++) Xor[i] = XOR % 2, XOR /= 2;
	for (int i = 39; i >= 0; i--) {
		if (Xor[i] == 1) {
			if (AND + (1LL << i) <= A[0]) AND += (1LL << i);
		}
	}
	if (AND == 0 || AND > A[0]) {
		cout << -1 << endl;
		return 0;
	}
	cout << A[0] - AND << endl;
}

Measured memory_bytes: 3592
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s;
int a = Integer.parseInt(sc.next());
int b = Integer.parseInt(sc.next());
if(a%2==0||b%2==0){
s = "Even";
}else{
s = "Odd";
}
System.out.println(s);

}
}

Measured memory_bytes: 23764
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

#include <iostream>
using namespace std;
typedef long long ll;

#define MUTABLE

#ifdef MUTABLE
int mod;
#else
template<int mod>
#endif
struct ModInt {
  int val;
  ModInt inv() const{
    int tmp,a=val,b=mod,x=1,y=0;
    while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
    return ModInt(x);
  }
  ModInt():val(0){}
  ModInt(ll x){if((val=x%mod)<0)val+=mod;}
  ModInt pow(ll t){ModInt res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
  ModInt& operator+=(const ModInt& x){if((val+=x.val)>=mod)val-=mod;return *this;}
  ModInt& operator-=(const ModInt& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
  ModInt& operator*=(const ModInt& x){val=(ll)val*x.val%mod; return *this;}
  ModInt& operator/=(const ModInt& x){return *this*=x.inv();}
  bool operator==(const ModInt& x) const{return val==x.val;}
  bool operator!=(const ModInt& x) const{return val!=x.val;}
  bool operator<(const ModInt& x) const{return val<x.val;}
  bool operator<=(const ModInt& x) const{return val<=x.val;}
  bool operator>(const ModInt& x) const{return val>x.val;}
  bool operator>=(const ModInt& x) const{return val>=x.val;}
  ModInt operator+(const ModInt& x) const{return ModInt(*this)+=x;}
  ModInt operator-(const ModInt& x) const{return ModInt(*this)-=x;}
  ModInt operator*(const ModInt& x) const{return ModInt(*this)*=x;}
  ModInt operator/(const ModInt& x) const{return ModInt(*this)/=x;}
  static int get_mod() { return mod; }
};

#ifndef MUTABLE
using modint = ModInt<1000000007>;
#endif

typedef long long ll;
int main() {
  int n, p; cin >> n >> p;
  string s; cin >> s;
  vector<ll> r(p);
  ll ans = 0;
  int cur = 0;
  vector<int> fact(n+1);
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = fact[i-1]*10;
    fact[i] %= p;
  }

  if (p == 2 || p == 5) {
    int ok = 0;
    for (int i = n-1; i >= 0; --i) {
      int d = s[i]-'0';
      if (d % p == 0) ok += 1;
      ans += ok;
    }
    cout << ans << endl;
    return 0;
  }
  // if (p == 5) {
  //   int ok = 0;
  //   for (int i = n-1; i >= 0; --i) {
  //     int d = s[i]-'0';
  //     if (d % 5 == 0) ok += 1;
  //     ans += ok;
  //   }
  //   cout << ans 

  // }
  for (int i = n-1; i >= 0; --i) {
    int d = s[i]-'0';
    cur = cur+d*fact[n-1-i];
    cur %= p;
    // cerr << d  << " " << cur << endl;
    ans += r[cur];
    r[cur] += 1;
    if (cur == 0) ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1412
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

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

    cin >> n >> m;

    vl a(n);
    rep(i, n) cin >> a[i];

    vvl b(m, vl(2));
    rep(i, m) rep(j, 2) cin >> b[i][j];

    sort(all(a));
    sort(all(b), [](vl a, vl b) {return a[1] > b[1];});

    if(a[0] >= b[0][1]) return cout << accumulate(all(a), 0LL) << endl, 0;

    ll sum = 0, idx = 0, che = 0;
    rep(i, n) {
        if(a[i] < b[idx][1]) {
            sum += b[idx][1];
        } else {
            for(; i < n; i++) sum += a[i];
            break;
        }

        che++;
        if(che == b[idx][0]) {
            idx++;
            if(idx == m) {
                for(i++; i < n; i++) sum += a[i];
                break;
            }
            che = 0;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 9496
import math, sys

def loadable(w, n, k, p, wsum):
    wait = 0
    for i in range(n):
        wait += w[i]
        wsum -= w[i]
        if wait > p:
            k -= 1
            wait = w[i]
            if k == 0 or p < wsum / k:
                return False
    return True

n, k = map(int, sys.stdin.readline().split())
w = [int(sys.stdin.readline()) for _ in range(n)]

wsum = sum(w)

p = max(int(math.ceil(wsum / k)), max(w))
pre_f = p -1
pre_s = None

while True:
    if loadable(w, n, k, p, wsum):
        pre_s = p
    else:
        pre_f = p

    if pre_s != None and pre_s - pre_f == 1:
            break
    
    if pre_s:
        p = int((pre_s + pre_f) / 2)
    else:
        p = math.ceil(p * 1.01)
    
print(pre_s)

Measured memory_bytes: 11232
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int c[8] = { 1 ,4 ,1, 4, 1, 2, 1, 2 };
	int p[8];
	for (; cin >> p[0];) {
		string ans = "";
		rep(i, 1, 8)cin >> p[i];
		int M = -INF;
		rep(i, 0, 8) {//?????¢
			int temp = 0;
			string temps = "";
			rep(j, 0, 8) {
				int add = p[j];
				if (p[j] > c[(j + i) % 8])add = c[(j + i) % 8];
				temp += add;
				temps += char(c[(j + i) % 8] + '0');
			}
			if (temp == M) {
				ans = min(ans, temps);
			}
			else if (temp > M) {
				ans = temps;
				M = temp;
			}
		}
		cout << ans[0];
		rep(i, 1, 8)cout << " " << ans[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int m,na,ni,ans;
	while(cin>>m>>ni>>na,(m||ni)||na){
		int p[m];
		rep(i,m)cin>>p[i];
		sort(p,p+m);
		int gap=0;
		loop(i,ni,na+1){
			if(gap<=p[m-i]-p[m-i-1]){
				ans=i;
				gap=p[m-i]-p[m-i-1];
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;
  s[k-1] = s[k-1] + 32;

  for(int i = 0;i < n;i++){
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())
flg = 0
if n%2 == 1:
	flg = 1
else:
	for i in range(len(s)//2):
		if s[i] != s[i+len(s)//2]:
			flg = 1
			break
if flg == 1:
	print('No')
else:
	print('Yes')
	




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

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    bool flag = false;

    for (int i = 1; i <= 1000; i++) {
        if (K*i >= A && K*i <=B) {
            flag = true;
            cout << "OK" << endl;
            break;
        }
        if (K*i > B) {
            break;
        }
    }
    if (!flag) {
        cout << "NG" << endl;
    }

}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  int i=1;
  for(;i<=n;i++){
    if(i*(i+1)/2>=n) break;
  }
  for(int j=1;j<=i;j++){
    if(j!=i*(i+1)/2-n) cout << j << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        
        int res=0;
        int count=0;
        for(int i=0; i<3; i++){
            if(S[i]=='R'){
                res++;
                count = res;
            }else{
                res = 0;
            }
        }
        
        System.out.println(count);
                
            
        
        
        
        
        
        }
    }

Measured memory_bytes: 35504
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int d;
      cin >> d;
      if(d==25)cout << "Christmas" << endl;
      else if(d==24)cout << "Christmas Eve" << endl;
      else if(d==23)cout << "Christmas Eve Eve" << endl;
      else if(d==22)cout << "Christmas Eve Eve Eve" << endl;
      return 0;}

Measured memory_bytes: 256
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;int a[1010];

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int k;
	int n;cin>>n>>k;for(int i=0;i<n;i++)cin>>a[i];ll sum=0;sort(a,a+n);for(int i=0;i<k;i++)sum+=a[i];cout<<sum;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3648
#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;
 
int main() {
    int n;cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll aaa = 1000000000000000000;
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        if (aaa < a[i]) {
            cout << -1 << endl;
            return 0;
        }
        aaa /= a[i];
        ans *= a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4060
#include <stdio.h>
int main(void){
    int k,n,a[1000000],ans,x=0;
    // 入力
    scanf("%d%d",&k,&n);
    for (int i=1; i<=n ;i++){
        scanf("%d",&a[i]);
    }
    // 家の間の最長距離xを求める
    for (int j=1; j<=n-1 ;j++){
        if (x < a[j+1] - a[j]){
            x = a[j+1] - a[j];
        }
    }
    if (x < a[1] + k - a[n]){
        x = a[1] + k - a[n];
    }
    // 解
    ans = k - x;
    printf("%d",ans);
}


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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int a, b;
  cin >> a >> b;

  int ans = 1;
  rep(i, 10000){
    if(ans * a - (ans-1) >= b) break;
    ans ++;
  }
  if(b == 1) cout << 0 << endl;
  else cout << ans << endl;
}


/*





















*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<map>
#include<iterator>
#include<algorithm>
#include<set>
using namespace std;
typedef long long int lli;

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

    lli n, t, i, j, x, y, flag, cnt, z, a = 0, b = 0, c = 0, d = 0;
    string s;
    cin >> t;
    while(t--){
        cin >> s;
        if(s[0]=='A') a++;
        else if(s[0]=='W') b++;
        else if(s[0]=='T') c++;
        else if(s[0]=='R') d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    return 0;
}


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

using namespace std;

const int N = 100010;

int main() {
    string a, b;
    cin >> a >> b;
    int res = b.size();
    int lena = a.size(), lenb = b.size();
    for (int i = 0; i + lenb - 1 < lena; ++i) {
        int t = 0;
        for (int j = 0; j < lenb; ++j) {
            if (a[i + j] != b[j]) ++t;
        }
        res = min(res, t);
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long
#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)
using namespace std;

int main() {
  int n, a;
  cin >> n >> a;
  cout << n*n-a << "\n";
}


Measured memory_bytes: 3580
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, K; cin >> N >> K;
    int digit = 0;
    while (N > 0)
    {
        N /= K;
        ++digit;
    }
    cout << digit << endl;
}

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

using namespace std;

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

	if (n == 0) {
		cin;
		cout << x << endl;
		return 0;
	}

	int p[110];
	bool exist = false;
	bool existA, existB;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	//sort(p, p + n);

	for (int i = 0; i < n; i++) {
		if (x == p[i]) {
			exist = true;
		}
	}
	if (!exist) {
		cout << x << endl;
		return 0;
	}

	int m_min, p_min;

	for (int i = 1;; i++) {
		m_min = 110;
		p_min = 110;

		existA = false;
		for (int j = 0; j < n; j++) {
			if (p[j] == x - i) {
				existA = true;
				break;
			}
		}
		if (!existA) {
			m_min = x - i;
		}

		existB = false;
		for (int j = 0; j < n; j++) {
			if (p[j] == x + i) {
				existB = true;
				break;
			}
		}
		if (!existB) {
			p_min = x + i;
		}
		if (!(existA && existB)) {
			cout << min(m_min, p_min) << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3164