akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
    
x = Base_10_to_n(n, k)
print(len(x))







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

int main() {
  int N;
  cin >>N;
  vector<int> mochi(N);
  for(int i=0;i<N;i++){
    cin >> mochi.at(i);
  }
  sort(mochi.begin(),mochi.end());
  reverse(mochi.begin(),mochi.end());
  int X=1;
  int r=mochi.at(0);
  for(int i=0;i<N;i++){
    if(!(r==mochi.at(i))){
      X++;
    }
    r=mochi.at(i);
  }
  cout << X <<endl;
}
 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int sa[2005][2005];
int main(){
	int n,t;
	int x,y;
	char ca;
	int a,b,c;
	int s=0;
	int i,j,k;
	cin>>n>>t;
	for(i=0;i<n;i++){
		cin>>x>>y>>ca;
		a=(ca=='B')?0:1;
		b=x/t;
		x-=b*t,a=(a+b)%2;
		b=y/t;
		y-=b*t,a=(a+b)%2;
		x++,y++;
		if(a==0)sa[x][y]++,sa[x+t][y+t]++;
		else sa[x+t][y]++,sa[x][y+t]++;
	}
	
	for(i=1;i<=2*t;i++){
		for(j=1;j<=2*t;j++){
			sa[i][j]+=sa[i-1][j]+sa[i][j-1]-sa[i-1][j-1];
		}
	}
	for(i=0;i<t;i++){
		for(j=0;j<t;j++){
			a=sa[i+t][j+t]-sa[i][j+t]-sa[i+t][j]+sa[i][j];
			if(s<a)s=a;
			a=n-a;
			if(s<a)s=a;
		}
	}
	cout<<s<<endl;
	return 0;
}
		
	
	


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	int pref[n], suf[n];
	pref[0] = a[0];
	suf[n - 1] = a[n - 1];
	for(int i = 1; i < n; ++i){
		pref[i] = max(pref[i - 1], a[i]);
	}
	for(itn i = n - 2; i >= 0; --i){
		suf[i] = max(suf[i + 1], a[i]);
	}
	if(n == 1) cout << a[0];
	else{
		for(int i = 0; i < n; ++i){
			if(!i) cout << suf[i + 1];
			else if(i == n - 1) cout << pref[i - 1];
			else cout << max(suf[i + 1], pref[i - 1]);
			cout << endl; 
		}
	}
}	
int main()
{
	Red;
	solve();
	return 0;
}

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

int main(void)
{
    int N,ans = 0,tmp;
    cin >> N;
    map<int,int> mp;

    rep(i,N){
        cin >> tmp;
        mp[tmp]++;
    }

    

    for(auto i:mp){
        if(i.second%2 == 1) ans++;
    }

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

Measured memory_bytes: 8164
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  string str;
  vector<string> strList;
  long num,loop,ii,jj,prevPos = 0;
  long sum = 0;
  cin >> str;
  num = str.length();
  loop = pow(2,num-1);
  long powRet[11];

  for(jj=0;jj<=10;jj++){
	powRet[jj] = (long)pow(2,jj);
  }
  
  for(ii=0;ii<loop;ii++){
	//cout << "ii" << ii << endl;
	strList.resize(0);
	prevPos = 0;
	for(jj=0;jj<=10;jj++){

	  //cout << str << endl;
  if(ii & powRet[jj]){
		strList.push_back(str.substr(prevPos,jj-prevPos+1));
		prevPos = jj+1;
	  }
	}
	strList.push_back(str.substr(prevPos,num-prevPos));
	for(string s : strList){
	  sum += atol(s.c_str());
	  //cout << s << endl;
	}
	
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in);){
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for(int i = 0; i < length;i++){
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch) == true){
                    ch = Character.toUpperCase(ch);
                }else{
                    ch = Character.toLowerCase(ch);
                }
                answer += ch;
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 31348
#include <bits/stdc++.h>
using namespace std;
string s[100];
int n;
map<char,int>q;
string s1;
int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>s[i];
    for(char i='a';i<='z';i++){
        int flag=0;
        for(int j=0; j<n; j++) if(s[j].find(i)==-1) flag=1; 
        if(flag==0){
            int minn=100;
            for(int j=0; j<n; j++){
                int cnt=0;
                for(int z=0;z<s[j].size();z++) if(s[j][z]==i) cnt++;
                minn=min(minn,cnt);
            }
            for(int j=0;j<minn;j++) s1+=i;
        }
    }
    cout<<s1<<endl;
    return 0;
}

Measured memory_bytes: 256
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    let ans = a * b - a - b + 1;
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner (System.in)){
			int n = sc.nextInt();
			int b,f,r,v;
			int[][][] table = new int[4][3][10];
			for (int i=0; i < 4; i++) {
				for (int j=0; j < 3; j++) {
					for (int k=0; k < 10; k++) {
						table[i][j][k] = 0;  //初期化
					}
				}
			}

			//読み取って処理
			for (int i = 0; i<n; i++) {
				b = sc.nextInt();
				f = sc.nextInt();
				r = sc.nextInt();
				v = sc.nextInt();
				table[b-1][f-1][r-1] += v;
			}

			Show(table);

		}
	}

	//結果を表示
	static void Show(int[][][] t) {
		for (int i=0; i < 4; i++) {
			for (int j=0; j < 3; j++) {
				for (int k=0; k < 10; k++) {
					System.out.print(" "+t[i][j][k]);
				}
				System.out.print('\n');
			}
			if (i != 3)System.out.println("####################");
		}
	}
}


Measured memory_bytes: 29256
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/

bool comp_by_se(Pii _a, Pii _b){
    if(_a.se != _b.se){
        return _a.se < _b.se;
    }
    else{
        return _a.fi < _b.fi;
    }
}

/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/


    int n; cin >> n;
    vector<Pii> a;
    rep(i, n){
        int f;
        cin >> f;
        a.pb(mp(i, f));
    }

    sort(all(a), comp_by_se);

    rep(i, n){
        cout << a[i].fi+1 << " ";
    }
    cout << endl;

return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
long long arr[13][13],price[13],total=0,smarts[13],N,M,X,minim=1e7;
bool cek(){
	for(long long i=0; i<M; i++){
		if(smarts[i]<X)return false;
	}
	return true;
}
void solve(long long x){
	if(x==N){
		if(cek()){
			minim=min(minim,total);
		}
	}else{
		solve(x+1);
		total+=price[x];
		for(long long i=0; i<M; i++){
			smarts[i]+=arr[x][i];
		}
		solve(x+1);
		for(long long i=0; i<M; i++){
			smarts[i]-=arr[x][i];
		}
		total-=price[x];
	}
}
int main(){
	cin>>N>>M>>X;
	for(long long i=0; i<N; i++){
		cin>>price[i];
		for(long long j=0; j<M; j++){
			cin>>arr[i][j];
		}
	}
	solve(0);
	if(minim==1e7){
		cout<<-1<<'\n';
	}else{
		cout<<minim<<'\n';
	}
}

Measured memory_bytes: 3648
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
ans = []
for i in range(H):
  for j in range(W - 1):
    if A[i][j] % 2 == 1:
      A[i][j] -= 1
      A[i][j + 1] += 1
      ans.append([i+1,j+1,i+1,j+2])

# 最後に右端を上から
for i in range(H - 1):
  if A[i][-1] % 2 == 1:
    A[i][-1] -= 1
    A[i + 1][-1] += 1
    ans.append([i+1,W,i+2,W])

print(len(ans))
for i in ans:
  print(" ".join(map(str,i)))
  

Measured memory_bytes: 30640
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define LL long long

#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"

using namespace std;

int inp(){
	int x;
	scanf("%d",&x);
	return x;
}

void outp(int i){
	printf("%d",i);
}

void loutp(LL i){
	printf("%lld",i);
}

LL mod(LL i){
	return i % 1000000007;
}



int Lucky_7(){
	LL N = inp();

	while(N > 0){
		int i = N % 10;
		if(i == 7) {
			printf("Yes");
			return 0;
		}
		N = N / 10;
	}
	printf("No");

	return 0;

}

int FizzBuzz_Sum(){
	LL N = inp();

	LL sum = 0;

	for(int i = 1;i <= N;i++){
		if(i % 3 != 0 && i % 5 != 0){
				sum += i;
		}
	}

	loutp(sum);

	return 0;

}
signed main() {
	//Lucky_7();
	FizzBuzz_Sum();
	return 0;
}


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

int main()
{
    int n;
    std::cin >> n;
    std::map<std::string, long long> m;
    for (int i = 0; i < n; i++) {
        char c[12] = {};
        for (int j = 0; j < 10; j++) { std::cin >> c[j]; }
        std::sort(c, c+ 10);
        m[std::string(c)]++;
    }

    long long c =0;
    for (auto it = m.begin(); it != m.end(); it++) {
        for (int i = 0; i < it->second; i++) { c+=i; }
    }

    std::cout << c << std::endl;

    return 0;
}


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

using namespace std;

int main()
{
    int n, a[128];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a, a+n, greater<int>());
    int bob = 0, alice = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) bob += a[i];
        else alice += a[i];
    }

    cout << bob - alice << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (1000003LL)
typedef long long Int;

int n, mi, memo[60000*4], cs[60000][2];
vector<int> g[60000];
bool has[60000];

void add(int p, int q) {
    if (p > q) swap(p, q);
    g[p].push_back(q);
}

int pre(int p, int q) {
    if (p+1 == q) return -1;
    const int k = mi++;
    has[k] = false;
    if (g[p].back() == q) {
        has[k] = true;
        g[p].pop_back();
    }
    const int r = g[p].back();
    rep (b, 4) memo[k*4|b] = -1;
    cs[k][0] = pre(p, r);
    cs[k][1] = pre(r, q);
    return k;
}

int rec(int k, int b) {
    if (k == -1) return b == 0 || b == 3;
    const int sig = k*4|b;
    if (memo[sig] != -1) return memo[sig];
    const int x = b&2, y = b&1;
    const int p = cs[k][0], q = cs[k][1];
    Int ans = 0;
    ans += (Int)rec(p, x) * rec(q, 2|y);
    ans += (Int)rec(p, x|1) * rec(q, y);
    if (b==3 && has[k]) {
        ans += (Int)rec(p, 0) * rec(q, 2);
        ans += (Int)rec(p, 1) * rec(q, 0);
    }
    return memo[sig] = ans % MOD;
}

int main() {
    for (;;) {
        int m, a, b;
        scanf("%d%d", &n, &m);
        if (n == 0) return 0;
        rep (_, m) {
            scanf("%d%d", &a, &b);
            add(a-1, b-1);
        }
        rep (i, n) add(i, (i+1)%n);
        rep (i, n) sort(g[i].begin(), g[i].end());
        mi = 0;
        pre(0, n-1);
        printf("%d\n", rec(0, 3));
    }
}

Measured memory_bytes: 11812
#define fast ios::sync_with_stdio(false); cin.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int sz = 1e6 + 5;
ll dv[sz];
bitset<sz> sieve;
inline int mylg(ll b, ll a) {
	int cnt = 0;
	while (a&&(a%b == 0)) {
		cnt++;
		a /= b;
	}
	return cnt;
}
void prec() {
	foru(i, 1, 1e6 + 1)dv[i] = 1;
	foru(i, 2, 1e6 + 1) {
		if (!sieve[i]) {
			sieve[i] = 1;
			dv[i] *= 2;
			for (int j = i + i; j <= 1e6; j += i) {
				sieve[j] = 1;
				dv[j] *= (mylg(i, j) + 1);
			}
		}
	}
}

int main() {
	fast;
	prec();
	ll n, a, b, c;
	cin >> n;
	ll sm = 0;
	foru(j, 1, n)sm += dv[j];
	cout << sm << endl;
	return 0;
}

Measured memory_bytes: 11096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

int main() {
    ll N;
    cin >> N;
    int up = -1;
    for (ll i = 1; i <= N; i++) {
        if (i * (i + 1) / 2 >= N) {
            up = i;
            break;
        }
    }
    set<int> ans;
    for (int i = up; i >= 1; i--) {
        if (N - i >= 0) {
            ans.insert(i);
            N -= i;
        }
    }
    for (auto temp : ans) {
        cout << temp << endl;
    }
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[] = new int[100];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		System.out.print(a[n - 1]);
		for(int i = n - 2; i >= 0; i--) {
			System.out.print(" " + a[i]);
		}
		System.out.println();
	}
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 26248
fun main(args: Array<String>) {
    val mod = 1e9.toInt() + 7
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map(String::toInt).toList()
    val m : MutableMap<Int, Int> = mutableMapOf()
    for ( i in l ) {
        m[i] = if (m[i] != null) m[i]!!+1 else 1
    }
    var cur = if (n % 2 == 0) 1 else 0
    var ok = true
    while(cur < n) {
        val x = if (cur == 0) 1 else 2
        if (m[cur] == null || m[cur] != x) {
            ok = false
            break
        }
        cur += 2
    }
    var ans = 0
    if (ok) {
        ans = 1
        for (i in 1..n/2) ans = ans * 2 % mod
    }
    println(ans)
}

Measured memory_bytes: 59988
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException {
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Collections.reverseOrder()); int N = readInt();
		for(int i = 1; i<=N; i++) pq.add(readInt()); int A = 0, B = 0;
		while(!pq.isEmpty()) {A += pq.poll(); if(!pq.isEmpty()) B += pq.poll();} println(A-B);
		exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	public void close() throws IOException {
		if (din == null)
			return;
		din.close();
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 22868
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <bitset>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<long long int,long long int> 
#define ff first
#define pb push_back
#define ss second
#define ll long long 
#define ull unsigned long long
#define vi vector<long long int>
#define vii vector<pii>
#define vvi vector <vi>
#define rep(x,a,b,c) for(int x=a;x<=b;x+=c)
#define repp(x,a,b) rep(x,a,b,1)
#define rev(x,a,b,c) for(int x=a;x>=b;x-=c)
#define revv(x,a,b) rev(x,a,b,1)
#define OO (int)2e9
#define INF (ll)1e18
 
using namespace std;

int a,b,c,rect,pal;

int main()
{
	pal=0;
	rect=0;
	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF)
	{
		if(a*a+b*b==c*c)
		rect++;
		else if(a==b)
		pal++;
	}
	printf("%d\n%d\n",rect,pal);
	return 0;
}

Measured memory_bytes: 3156
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>

#define int long long
#define rr register

#define inf 1e9
#define MAXN 200010

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void print(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar(x % 10 + 48);
}

int n;

char s[MAXN], f[MAXN];

int ans;

signed main() {
	cin >> s >> f;
	n = strlen(s);
	for (rr int i = 0; i < n; i++) if (s[i] != f[i]) ans++;
	cout << ans;
}

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

typedef long long ll;

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

ll lcm(ll a, ll b) {
  return a*b / gcd(a, b);
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> la(n);
  ll s = 1;
  int n2 = 0;
  for (ll &a: la) {
    cin >> a;
    s = lcm(s, a/2);
    int tmp = a;
    int n3 = 0;
    while (tmp % 2 == 0) { 
      tmp /= 2;
      n3 += 1;
    }
    if (n2 > 0 && n2 != n3) { 
      cout << 0 << endl;
      return 0;
    }
    n2 = n3;
    if (s > m) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = (m-s)/(2*s)+1;
  cout << ans << endl;
}



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

int main() {
    int n; cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p.at(i);
    }
    
    int cnt=0;
    for (int i = 0; i < n-2; i++)
    {
        if(p[i]<p[i+1]&&p[i+1]<p[i+2]) ++cnt;
        if(p[i]>p[i+1]&&p[i+1]>p[i+2]) ++cnt;
    }
    cout << cnt << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 501, maxm = maxn * maxn;
const int d[][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int n, p[maxm], dis[maxm];
bool vis[maxm];
inline int idx(int x, int y) {
	return x * n + y;
}
inline void rdx(int id, int &x, int &y) {
	x = id / n;
	y = id % n;
}
int main() {
	scanf("%d", &n);
	int m = n * n;
	for(int i = 0; i < m; ++i) {
		scanf("%d", p + i);
		--p[i];
	}
	for(int i = 0, id = 0; i < n; ++i)
		for(int j = 0; j < n; ++j, ++id) {
			dis[id] = min(min(i + 1, n - i), min(j + 1, n - j));
			vis[id] = 0;
		}
	int ans = 0;
	for(int i = 0; i < m; ++i) {
		vis[p[i]] = 1;
		ans += --dis[p[i]];
		queue<int> Q;
		Q.push(p[i]);
//		printf("force dis (%d, %d) <- %d\n", p[i] / n, p[i] % n, dis[p[i]]);
		while(!Q.empty()) {
			int u = Q.front(), ux, uy;
			Q.pop();
			rdx(u, ux, uy);
			for(int k = 0; k < 4; ++k) {
				int vx = ux + d[k][0], vy = uy + d[k][1];
				if(vx < 0 || vx >= n || vy < 0 || vy >= n)
					continue;
				int v = idx(vx, vy), tmp = dis[u] + !vis[v];
				if(dis[v] > tmp) {
//					printf("dis (%d, %d) <- %d\n", vx, vy, tmp);
					dis[v] = tmp;
					Q.push(v);
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5996
import sys

# import re
# import math
# import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
# import copy
# import heapq
# import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    d = [0, 0, 0]

    ans = 1
    for ai in a:
        ans *= d.count(ai)
        ans %= MOD
        for i in range(3):
            if d[i] == ai:
                d[i] += 1
                break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 55584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>

const int mod = 1e9 + 7;
const int N = 45;
const int S = 1 << 17 | 1;
int f[N][S], g[S][11];
int n, x, y, z;

inline void add(int &x, int y)
{
	x += y;
	x >= mod ? x -= mod : 0;
}

int main()
{
	scanf("%d%d%d%d", &n, &x, &y, &z);
	y += x; z += y;
	const int C = 1 << z;
	for (int i = 1; i <= C; ++i)
		for (int j = 1; j <= 10; ++j)
		{
			g[i][j] = 1;
			if (i == C)
				g[i][j] = C;
			else 
			{
				for (int k = 0; k < z; ++k)
					if (1 << k & i)
					{
						int tmp = k + j;
						if (tmp <= z && !(k < y && tmp > y) && !(k < x && tmp > x))
							g[i][j] |= 1 << tmp;
					}
				if (g[i][j] >= C)
					g[i][j] = C;
			}
		} 	
	f[0][1] = 1;
	for (int i = 0; i < n; ++i)
		for (int j = 1; j <= C; ++j)
		if (f[i][j])
		{
			for (int k = 1; k <= 10; ++k)
				add(f[i + 1][g[j][k]], f[i][j]);
		}
	printf("%d\n", f[n][C]);
	return 0;
} 

Measured memory_bytes: 28928
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}		
int ma[32769][15];
int maa[6436][15];
int a[15];
int b[15];
signed main(){
	ic(n) ic(m)
	rep(0,i,n)cin>>a[i];
	for(int bit=0;bit<(1<<n);bit++)rep(0,i,n)if(bit&(1<<i))ma[bit][i]=1;
	int sum=0;
	rep(0,i,pow(2,n)){
		int cnt=0;
		rep(0,j,n)if(ma[i][j]==1)cnt++;	
		if(cnt==m){
			rep(0,j,n){
				maa[sum][j]=ma[i][j];
			}
			sum++;
		}	
	}
	int ans=1145141919810;
	rep(0,i,sum){
		int sum1=0;
		rep(0,k,n)b[k]=a[k];
		rep(1,j,n){
			if(maa[i][j]==1){
				sum1+=max(maxi(b,0,j)+1-a[j],0);
				b[j]+=max(maxi(b,0,j)+1-a[j],0);
			}
		}
		ans=min(sum1,ans);
	}
	c(ans)		
}	

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

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0)
            cout << " " << i;
        else {
            for (; x > 0; x /= 10) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[100010]={},sum=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+100010);
	reverse(a,a+100010);
	for(int i=0;i<n-1;i++){
		// cout << "前" << endl;
		// cout << "a[" << i << "]:" << a[i] << endl;
		// cout << "a[" << i+1 << "]:" << a[i+1] << endl;
		if(a[i]==a[i+1]){
			a[i]=0;
			a[i+1]=0;
		}
		// cout << "後" << endl;
		// cout << "a[" << i << "]:" << a[i] << endl;
		// cout << "a[" << i+1 << "]:" << a[i+1] << endl;
	}
	for(int i=0;i<n;i++){
		if(a[i]!=0){
			sum++;
		}
	}
	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    string s;
    cin >> s;
    int c=0;
    REP(i,4) c+=(s[i]=='2'?1:0);
    cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int d, n;
    cin >> d >> n;
    int m = n == 100 ? 101: n;
    int ans = pow(100,d) * m;
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i,j,k;
  int n,m,s,t,u;
  while(cin>>n>>m>>s>>t>>u,n||m||s||t||u){
    --s;
    --t;
    --u;
    int a[100][100];
    fill(a[0],a[0]+n*100,1<<28);
    for(i=0;i<n;++i)
      a[i][i]=0;
    for(i=0;i<m;++i){
      int p,q,r;
      cin>>p>>q>>r;
      --p;
      --q;
      a[p][q]=r;
    }
    for(k=0;k<n;++k)
      for(i=0;i<n;++i)
	for(j=0;j<n;++j)
	  a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
    int mn=1<<30;
    for(i=0;i<n;++i)
      mn=min(mn,a[s][i]+a[i][t]+a[i][u]);
    cout<<mn<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
    int Y = sc.nextInt();
    int Z = sc.nextInt();
    String ans = Z + " " + X + " " + Y;
    System.out.println(ans);
    return;
  }
}

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

int main(){
	bool N=false;
	bool S=false;
	bool E=false;
	bool W=false;
	string schedule;
	cin >> schedule;
	for(const char& c : schedule){
		switch(c){
		case 'N':N=true;break;
		case 'S':S=true;break;
		case 'E':E=true;break;
		case 'W':W=true;break;
		}
	}
	if(N==S && E==W){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    double ans = (double)(n-n/2)/n;
    printf("%.6lf\n", ans);
    return 0;
}

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

long long int N, A, a;

int main(){
    scanf("%lld%lld", &N, &A);
    a = A;
    for(int i = 1; i < N; ++i){
        scanf("%lld", &A);
        a /= __gcd(a, A);
        a *= A;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))
s = []
for k in range(D):
    s.append(list(map(int, input().split())))

#print(s)
ans = [s[k].index(max(s[k]))+1 for k in range(D)]

for k in range(D):
    print(ans[k])


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

int main() {
	int a,b,c;
	cin >> a;
  	b=a/100;
  	c=a%100;
	if((b>12&&c==0)||(b==0&&c>12)||(b==0&&c==0)||(b>12&&c>12))
      cout<<"NA"<<endl;
  	else if(b<=12&&c<=12&&b!=0&&c!=0)
      		cout<<"AMBIGUOUS"<<endl;
 		 else if((b<=12&&c>12)||(b<=12&&c==0))
           		cout<<"MMYY"<<endl;
  			  else 
                cout<<"YYMM"<<endl;
        
        
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC099_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];

            Console.WriteLine((b-a)*(b-a+1)/2 -b);
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include<iostream>
#include<stack>
#include <cstring>

using namespace std;

stack<char> stk;

char s[101];

int main(void){
	int i;
	
	while(1) {
		if(gets(s) == NULL) break;
		if(s[0] == '.' && s[1] == '\0') break;

		while(!stk.empty())
			stk.pop();
		int flag = 0;
		int l = strlen(s);
		int m = 0, k = 0;
		char past = '\0';

		for(i = 0; i < l && flag == 0; i++) {
			if( s[i] == '(' ) {
				stk.push('(');
			}
			if( s[i] == ')' ) {
				if(stk.empty()){
					flag=1;
					break;
				}
				if(stk.top() == '(') stk.pop();
				else flag = 1;
			}
			if( s[i] == '[' ) {
				stk.push('[');
			}
			if( s[i] == ']' ) {
				if(stk.empty()){
					flag=1;
					break;
				}
				if(stk.top() == '[') stk.pop();
				else flag = 1;
			}

		}

		if( !stk.empty() ) flag = 1;

		if( flag == 0 ) printf("yes\n");
		else printf("no\n");

	}

	return 0;
}

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

int main() {
  int n, q;
  cin >> n >> q;
  dsu d(n);
  for (int i = 0; i < q; i++) {
    int t, u, v;
    cin >> t >> u >> v;
    if (t == 0) {
      d.merge(u, v);
    } else {
      cout << d.same(u, v) << endl;
    }
  }
}


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

int main() {
	string s; cin >> s;
	int n = s.size(), l = 0, r = 0; bool ok = false;
	for (int i = 0; i < n; i++) {
		if (s[i] == s[i + 1]) {
			l = i + 1, r = i + 2, ok = true;
			break;
		}
		if (i < n - 2 && s[i] == s[i + 2]) {
			l = i + 1, r = i + 3, ok = true;
			break;
		}
	}
	if (ok)cout << l << ' ' << r << endl;
	else cout << -1 << ' ' << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a.at(i);
	int mark=1;
	int cnt=0;
	bool flag=false;
	for(int i=0;i<n;i++){
		if(a.at(i)!=mark){
			cnt++;
		}
		else if(a.at(i)==1&&n<2)flag=true;
		else if(a.at(i)==mark){
			mark++;
			flag=true;
		}
	}
	if(flag)cout<<cnt<<endl;
	else cout<<"-1"<<endl;
	return 0;
}


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

using namespace std;

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    vector<int> c(3);
    for(int i = 0; i < 3; ++i)
      cin >> c[i];
    sort(c.begin(), c.end());
    cout << (c[2] != c[1] + c[0] ? "No": "Yes") << '\n';
    
    return 0;
}



Measured memory_bytes: 3596
#include<stdio.h>
int main(void)
{
	int a,b,N,p,i=0,f;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d %d",&a,&b);
		a=a%b;
		if(a==0) a=b;
	printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int num1, num2;
        StringBuilder in1 = new StringBuilder();
        StringBuilder in2 = new StringBuilder();
        Scanner sc = new Scanner(System.in);
        num1 = sc.nextInt();
        sc.nextLine();

        for (int i = 0; i < num1; i++) {
            in1.append(sc.nextInt());
            //System.out.println(in1);
        }

        num2 = sc.nextInt();
        sc.nextLine();

        for (int i = 0; i < num2; i++) {
            in2.append(sc.nextInt());
            //System.out.println(in2);
        }

        if (in1.toString().compareTo(in2.toString()) >= 0)
            System.out.println(0);
        else
            System.out.println(1);

    }

}


Measured memory_bytes: 33020
#include <bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define maxn 2005
#define name "bai2"
#define mod 1000000007

using namespace std;
ll n,k,a[maxn],b[maxn],c[maxn],d[maxn],e[maxn],res,s1,s2;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(name".inp","r",stdin);
    //freopen(name".out","w",stdout);

    cin>>n>>k;
    f(i,1,n)
    {
        cin>>a[i];
        b[a[i]]++;
        f(j,a[i]+1,maxn-3)
        {
            c[j]++;
        }
    }
    f(i,1,maxn-3)
    {
        c[i]*=b[i];
        s1+=c[i];
    }
    f(i,1,n-1)
    {
        f(j,i+1,n)
        {
            if(a[i]>a[j])
            {
                d[i]++;
            }
        }
        s2+=d[i];
    }
    res= ((s1*((k*(k-1)/2)%mod)%mod)+((s2*k)%mod))%mod;
    cout<<res<<endl;
}


Measured memory_bytes: 384
/*
 * Created by Dipta Das on 10-05-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

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

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


    int n;
    cin >> n;
    vector<ll> ar(n + 1);
    vector<ll> left(n + 1);
    vector<ll> right(n + 1);

    for (int i = 1; i <= n; ++i) cin >> ar[i];
    
    if (n == 2) {
        cout << max(ar[1], ar[2]) << endl;
        return 0;
    }

    left[3] = gcd(ar[1], ar[2]);
    for (int i = 4; i <= n; ++i) left[i] = gcd (ar[i-1], left[i-1]);
    // i = 4, left[4] = gcd (ar[3], left[3])
    // i = 5, left[5] = gcd (ar[4], left[4])
    // left[1], left[2]
    right[n-2] = gcd (ar[n-1], ar[n]);
    for (int i = n-3; i >= 0; --i) right[i] = gcd (ar[i+1], right[i + 1]);
    // n = 10
    // done -> right[10-2 = 8] = gcd (ar[9], ar[10])
    // right[10-3 = 7] = gcd (right[8], ar[8]);
    // right[9]
    // right[10]
    // right[n], right[n-1] <-- left
    right[n] = left[n];
    right[n-1] = gcd (left[n-1], ar[n]);
    left[1] = right[1];
    left[2] = gcd (right[2], ar[1]);

    ll ans = 1;
    for (int i = 1; i <= n; ++i) {
        ans = max (ans, gcd(left[i], right[i]));
    }

    cout << ans << endl;




    return 0;
}



Measured memory_bytes: 2560
N = gets.to_i
S = N.times.map{
	gets.strip
}

T = S.map{|si|
	(0...N).select{|j| si[j] == ?1 }
}
IandD = lambda{|dbase|
	i, d, ds, q = nil, 0, [nil]*N, [nil]*N
	ds[dbase] = 1
	q.clear; q << dbase
	until q.empty?
		d += 1
		q.size.times{
			T[i=q.shift].each{|j|
				case ds[j]
				when nil
					ds[j] = d+1
					q << j
				when d+1
				when d-1
				else
					raise
				end
			}
		}
	end
	return i, d
}

begin
	i,* = IandD[1]
	*,d = IandD[i]
	p d
rescue RuntimeError
	p(-1)
end


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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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

const int mod = 1000000007;

struct Robo {
    ll x, l;
};

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

    int n; cin >> n;
    vector<Robo> robo(n);
    for (int i = 0; i < n; i++) {
        ll x, l;
        cin >> x >> l;
        robo.at(i).x = x;
        robo.at(i).l = l;
    }

    sort(robo.begin(), robo.end(), [](auto const &lhs, auto const &rhs) {return lhs.x+lhs.l < rhs.x+rhs.l;});

    ll used = 1;
    ll pt = robo.at(0).x + robo.at(0).l;
    for (int i = 1; i < n; i++) {
        ll x, l;
        x = robo.at(i).x;
        l = robo.at(i).l;
        if (pt <=  x - l) {
            used++;
            pt = x + l;
        }
    }

    cout << used << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

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

ll b[30];

int main() {
    ll h, w; cin >> h >> w;
    rep(i, 0, h){
        string s; cin >> s;
        rep(j, 0, w){
            b[s[j]-'a']++;
        }
    }
    
    ll g1 = 0, g2 = 0, g4 = 0;
    
    if(h%2 != 0 && w%2 != 0){
        g1 = 1;
        g2 = h/2 + w/2;
        g4 = (h/2)*(w/2);
    }else{
        g1 = 0;
        g4 = (h/2)*(w/2);
        g2 = (h*w - g4*4)/2;
    }

    // cout << "g1 : " << g1 << endl;
    // cout << "g2 : " << g2 << endl;
    // cout << "g4 : " << g4 << endl;

    // rep(i, 0, 26) cout << b[i] << " \n"[i==24];

    if(g1){
        rep(i, 0, 26){
            if(b[i]%2 == 1){
                b[i]--;
                break;
            }
        }
    } 
    ll t = 0;
    while(g4){
        rep(i, 0, 26){
            if(b[i] >= 4){
                b[i] -= 4;
                g4--;
                if(!g4) break;
            }
        }
        t++;
        if(t >= 100000){
            co("No");
            return 0;
        }
    }
    
    // rep(i, 0, 26) cout << b[i] << " \n"[i==24];

    t = 0;
    while(g2){
        rep(i, 0, 26){
            if(b[i] && b[i]%2 == 0){
                b[i] -= 2;
                g2--;
                if(!g2) break;
            }
        }
        t++;
        if(t >= 100000){
            co("No");
            return 0;
        }
    }

    // rep(i, 0, 26) cout << b[i] << " \n"[i==24];

    bool f = true;
    rep(i, 0, 26){
        if(b[i]) f = false;
    }
    if(f) co("Yes");
    else co("No");

    return 0;
}
 
 


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = ull;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

template<typename T>
string join(const vector<T>& vec, string sep = " "){
    stringstream ss;
    for(int i = 0; i < vec.size(); i++){
        ss << vec[i] << (i + 1 == vec.size() ? "" : sep);
    }
    return ss.str();
}

Int solve(int n){
    V ls(87);
    ls[0] = 2;
    ls[1] = 1;
    for(int i = 2; i < 87; i++){
        ls[i] = ls[i - 1] + ls[i - 2];
    }
    return ls[n];
}

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

    int n;
    cin >> n;
    cout << solve(n) << endl;

    return 0;
}


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

string s;

int main()
{
    cin>>s;
    for(int i=0;i<s.size()-1;i++)
        if(s[i]=='A'&&s[i+1]=='C')
        {
            cout<<"Yes";
            return 0;
        }
    cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int x, y;
    cin >> x >> y;
    int ans = x;
    int cnt = 0;
    while (ans <= y) {
        ans *= 2;
        cnt++;
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
    int W = 0, H = 0, x = 0, y = 0, r = 0;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if (x + r > W || x - r < 0 || y + r > H || y - r < 0) {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");

    return 0;
}



Measured memory_bytes: 2616
# -*- coding: utf-8 -*-
"""
C - Scc Puzzle
https://atcoder.jp/contests/arc069/tasks/arc069_a

"""
import sys


def solve(s, c):
    ans = min(s, c//2)
    s -= ans
    c -= (ans * 2)
    s += (c // 2)
    c //= 2
    ans += min(s, c//2)
    return ans


def main(args):
    s, c = map(int, input().split())
    ans = solve(s, c)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060