akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        WriteLine($"ABC{N}");
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N, K, A[1000]; cin >> N >> K;
	REP(i, N) cin >> A[i];
	sort(A, A+N);
	int ans = 0;
	REP(i, K) ans += A[i];
	cout << ans << ln;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> f(n, 0);
	for (auto&& fi : f)
		for (int i = 0; i < 10; i++)
		{
			int j;
			cin >> j;
			fi |= (j << (9 - i));
		}
	vector<vector<int>> p(n, vector<int>(11));
	for (auto&& pi : p)
		for (auto&& pii : pi)
			cin >> pii;

	int maxp = INT_MIN;
	for (int i = 1; i < 1024; i++)
	{
		int curp = 0;
		for (int j = 0; j < n; j++)
		{
			int count = 0;
			int check = f[j] & i;
			for (int k = 0; k < 10; k++)
				count += ((check >> k) & 1);
			curp += p[j][count];
		}
		maxp = max(maxp, curp);
	}
	cout << maxp << endl;
	return 0;
}


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

using namespace std;

int main(){
	string w;
	cin >> w;

	sort(w.begin(), w.end());

	if (w.length() % 2 == 1){
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < w.length() - 1; i += 2){
		if (w[i] != w[i+1]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


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

//kieutrave ten ham(tham so)
//s.substr(noibatdau,soluong)
int main(){
	long long a,b,c,k,tong;
	cin>>a>>b>>c>>k;
	if (a<k){
		k=k-a;
		tong=a;
	}
	else{
		tong=k;
		cout<<tong;
		return 0;
	}
	// a<k
	if (b<k){
		k=k-b;
	}
	else {
	cout<<tong;
	return 0;
}
// b<k
	if (c>=k){	
		tong=tong -k;
	}
	cout<<tong;
	return 0;
}

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

using namespace std;

#define rep0(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repU(i,bottom,ceiling) for(int (i)=(bottom);(i)<=(ceiling);(i)++)
#define repD(i,ceiling,bottom) for(int (i)=(ceiling);(i)>=(bottom);(i)--)
#define V vector
#define Vi vector<int>
#define VVi vector<vector<int>>
#define Vdb vector<double>
#define VVdb vector<vector<double>>
#define pub push_back
#define pob pop_back
#define pf printf
#define sf scanf
#define ci(a) cin>>a
#define lco(a) cout<<a<<endl
#define co(a) cout<<a
#define Vci(v) for(int i=0;i<v.size();i++) cin>>v[i]
#define Vco(v) for(int i=0;i<v.size();i++){ cout<<v[i]<<' '; } cout<<endl
#define P pair
#define Pii pair<int,int>
#define mP make_pair
#define fir first
#define sec second
#define Re return 

typedef long long ll;
typedef double db;

const string alphabet("abcdefghijklmnopqrstuvwxyz");
const vector<pair<int,int>> dir={{0,0},{1,0},{1,1},{0,1},{-1,1},{0,-1},{-1,-1},{0,-1},{1,-1}};
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const int Inf=(int)2e9+1e8;
const int Mod=(int)1e9+7;

template <typename T,typename U>                                                   
pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir+r.fir,l.sec+r.sec};                                    
} 

template <typename T,typename U> 
pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir-r.fir,l.sec-r.sec};                                    
} 

template <typename T,typename U>                                                   
pair<T,U> operator*(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir*r.fir,l.sec*r.sec};                                    
}

template <typename T,typename U>                                                   
pair<T,U> operator/(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir/r.fir,l.sec/r.sec};                                    
}

template <typename T> void Swap(T *x,T *y){ T tem=*x; *x=*y; *y=tem; }

long long int rem(long long int n,long long int m){
	if(!m) return 0;
	return (n<0?(n%m)+m:(n%m));
}
             
/*The main code follows below*/

int main(){
	int n; ci(n);
	V<bitset<100>> Bit;
	rep0(i,n){
		unsigned long long m; ci(m);
		bitset<100> b(m);
		Bit.pub(b);
	}
	unsigned long long cnt=0;
	int right=0;
	bitset<100> Xb;
	rep0(i,n){
		cnt+=max(1,(right-i+1));
		Xb|=Bit[i];
		for(right=max(i,right);right<n-1;right++){
			unsigned long long ull=Xb.to_ullong()+Bit[right+1].to_ullong();
			bitset<100> res(ull);
			if((Xb^Bit[right+1])!=res) break;
			Xb^=Bit[right+1];
			cnt++;
		}
		Xb^=Bit[i];
	}
	lco(cnt);
	return 0;
}

Measured memory_bytes: 6384
table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]
 
N = int(input())
 
for loop in range(N):
    house_id,floor,room,add = map(int,input().split())
    table[house_id-1][floor-1][room-1] += add
 
 
x = 0
 
for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1
 
    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()



Measured memory_bytes: 5624
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline

n = int(input())
INF = 1 << 35
M = -INF
m = INF
d0 = []
d1 = []
for i in range(n):
    x, y = map(int, input().split())
    a = x - y
    b = x + y
    d0.append(a)
    d1.append(b)
print(max(max(d0) - min(d0), max(d1) - min(d1)))


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

int main() {
	int a,b,c;
	cin >>a>>b>>c;
	if(a==b&&b!=c){
		cout <<"Yes";
	}
	else if(a==c&&b!=c){
		cout <<"Yes";
	}
	else if(c==b&&b!=a){
		cout <<"Yes";
	}
	else{
		cout <<"No";
	}
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int x3,y3,x4,y4;
    x3=x2-(y2-y1);
    y3=y2+(x2-x1);
    x4=x1-(y2-y1);
    y4=y1+(x2-x1);
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[105];
long double ans;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        ans+=(long double)1.0/(long double)a[i];
    }
    ans=1.0/ans;
    cout<<fixed<<setprecision(7)<<ans;
}

Measured memory_bytes: 256
n = int(input())
plist = list(map(int,input().split()))
counter = 0
for i in range(1,n-1):
    if (plist[i-1]<plist[i]<plist[i+1]) or (plist[i-1]>plist[i]>plist[i+1]):
        counter += 1

print(counter)

Measured memory_bytes: 3060
#include<stdio.h>
long long a[100010];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	int zero = 0;
	for (int i = 0; i < n; i++)
		if (a[i] == 0)
			zero++;
		if (zero > 0)
		{
			printf("0\n");
			return 0;
		}
	long long sum = 1;
	for (int i = 0; i < n; i++)
	{
		if (a[i] <= 1000000000000000000/sum)
			sum *= a[i];
		else
		{
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", sum);
}


Measured memory_bytes: 2924
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  cout << abs(a[n-1] - a[0]) << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<int,int>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n;cin>>n;

  vector<int>v[1010];
  rep(i,1,n+1){
    rep(j,0,n-1){
      int x;cin>>x;
      v[i].push_back(x);
    }
  }

  bool b[1010];CLR(b);

  ll count=0;
  rep(j,0,n*(n-1)/2){
    bool p=false;
    rep(i,1,n+1){
      if(v[i].size()==0)continue;

      if(!b[i]&&!b[v[i][0]]){
        if(v[v[i][0]][0]==i){
          b[i]=true;b[v[i][0]]=true;
          v[v[i][0]].erase(v[v[i][0]].begin());
          v[i].erase(v[i].begin());
          p=true;
        }
      }
    }
    count++;
    bool e=true;
    rep(l,1,n+1){
      if(v[l].size()!=0){e=false;break;}
    }
    if(e){out(count);return 0;}
    if(!p){out(-1);return 0;}
    memset(b,false,sizeof(b));

  }

  return 0;
}


Measured memory_bytes: 6272
#include<stdio.h>
#define ARR_SUM(a, b) (  ((a) + (b))*((b) - (a) + 1) / 2 )

int main()
{
    int N, L, ans;
    scanf("%d %d", &N, &L);
    int max = L + N - 1;
    if(L >= 0) { ans = ARR_SUM(L+1, max); }
    else if(L < 0 && max >= 0) { ans = ARR_SUM(L, max); }
    else { ans = ARR_SUM(L, max-1); }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  
  int ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (z >= 0 && z <= K)
        ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
#a, b, h, m = map(int, input().split())
#al = list(map(int, input().split()))
#al=[list(input()) for i in range(h)]

l = 1
total = 26

while n > total:
    l += 1
    total += 26**l

last = total-26**l
v = n-last-1

ans = ''
# 26進数だと見立てて計算
for i in range(l):
    c = v % 26
    ans += chr(ord('a')+c)
    v = v//26
print("".join(ans[::-1]))


Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[] = {0,0,1,0,2,0,2,0,0,2,0,2,0};
    int x,y; cin >> x >> y;
    if(a[x] == a[y]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
using vs = vector<string> ;
#define all(v) v.begin(),v.end()

ll ans=0;
ll N,M,Q;
ll a[51],b[51],c[51],d[51];

ll calc_sum(vector<int> A){
  ll res=0;
  rep(i,Q){
    if(A[b[i]-1]-A[a[i]-1]==c[i]) res+=d[i];
  }
  return res;
}

void dfs(vector<int> A){
  if(int(A.size())==N){ans = max(ans,calc_sum(A));}
  else{
    for(int i=A[A.size()-1];i<=M;++i){
      A.push_back(i);
      dfs(A);
      A.erase(A.end()-1);
    }
  }
}

int main(){
  cin>>N>>M>>Q;
  rep(i,Q) cin>>a[i]>>b[i]>>c[i]>>d[i];
  vector<int> A;
  A.push_back(1);
  dfs(A);
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int add(vector<int> &v, int x, int y){
    v[x]++;
    return v[x] >= y;
}

int main() {
    int n, a, b, m;
    cin >> n >> a >> b >> m;
    if(n == 1){
        if(a >= 2) a = INF<int>;
        if(b >= 2) b = INF<int>;
    }
    using P = pair<int, int>;
    map<int, P> v, u;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int y;
            cin >> y;
            v[y] = {i, j};
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int y;
            cin >> y;
            u[y] = {i, j};
        }
    }
    vector<int> x(2*n+2), y(2*n+2);
    int X = 0, Y = 0;
    for (int i = 0; i < m; ++i) {
        int z;
        scanf("%d", &z);
        if(v.count(z)){
            auto p = v[z];
            if(add(x, p.first, n)) X++;
            if(add(x, p.second+n, n)) X++;
            if(p.first == p.second) {
                if(add(x, 2*n, n)){
                    X++;
                }
            }
            if(p.first == n-p.second-1) {
                if(add(x, 2*n+1, n)){
                    X++;
                }
            }
        }
        if(u.count(z)){
            auto p = u[z];
            if(add(y, p.first, n)) Y++;
            if(add(y, p.second+n, n)) Y++;
            if(p.first == p.second) {
                if(add(y, 2*n, n)){
                    Y++;
                }
            }
            if(p.first == n-p.second-1) {
                if(add(y, 2*n+1, n)){
                    Y++;
                }
            }
        }
        int f = X >= a, g = Y >= b;
        if(f+g == 1){
            puts(f ? "USAGI" : "NEKO");
            return 0;
        }else if(f+g >= 2){
            puts("DRAW");
            return 0;
        }
    }
    puts("DRAW");
    return 0;
}


Measured memory_bytes: 21028
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



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

  int n;
  cin >> n;
  vector<pair<int, int>> a(n), b(n);
  rep(i, n) {
    cin >> a[i].first;
    a[i].second = i;
  }
  rep(i, n) {
    cin >> b[i].first;
    b[i].second = i;
  }
  
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  rep(i, n) {
    if (a[i].first > b[i].first) {
      cout << "No\n";
      return 0;
    }
  }
  rep(i, n - 1) {
    if (a[i + 1].first <= b[i].first) {
      cout << "Yes\n";
      return 0;
    }
  }
  vector<int> c(n);
  rep(i, n) c[a[i].second] = b[i].second;
  int cnt = 0, res = 0;
  bool f = true;
  while (f) {
    cnt++;
    res = c[res];
    if (!res) f = false;
  }
  cout << (cnt == n ? "No\n" : "Yes\n");

  




  
  return 0;
}

Measured memory_bytes: 5228
#pragma GCC optimize("O3")
#include <iostream>
using namespace std;

template<typename T> inline void fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

template<typename T> void fastout(T &n) {
  T N = n, rev, count = 0;
  rev = N;
  if (N == 0) { 
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}

int main(){
  int N, T; fastin(N); fastin(T);
  int t[N];
  for (int i = 0; i < N; ++i) fastin(t[i]);
  int64_t dp[N];
  dp[0] = T;
  for (int i = 0; i < N; ++i) {(t[i + 1] - t[i] >= T) ? dp[i + 1] = dp[i] + T : dp[i + 1] = dp[i] + t[i + 1] - t[i];}
  fastout(dp[N - 1]);
  return 0;
}


Measured memory_bytes: 2560
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n, d, x, a, ans;
  scanf("%lld%lld%lld", &n, &d, &x);
  for (int i = 0; i < n; i++)
  {
    scanf("%lld", &a);
    for (int j = 1; j <= d; j += a)
    {
      ans++;
    }
  }
  printf("%lld\n", ans + x);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int[] a = new int[4];
			int[] b = new int[4];
			for (int i = 0; i < b.length; i++) {
				a[i]=sc.nextInt();
			}
			for (int i = 0; i < b.length; i++) {
				b[i]=sc.nextInt();
			}
			int hit=0;
			int blow=0;
			for (int i = 0; i < b.length; i++) {
				if(a[i]==b[i]){
					hit++;
					a[i]=b[i]=-1;
				}
			}
			for (int i = 0; i < b.length; i++) {
				for (int j = 0; j < b.length; j++) {
					if(a[i]==-1 || b[j]==-1)continue;
					if(i!=j && a[i]==b[j])blow++;
				}
			}
			System.out.println(hit+" "+blow);
		}
	}

}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
struct UnionFind {
  vll par ;  //iの親
  vll rank ; //木の深さ
  vll siz ; //iの属する集合の要素数
  
  //n要素の初期化
  void init(ll n){
    REP(i,n){
      par.PB(i) ;
      rank.PB(0) ;
      siz.PB(1) ;
    }
  }
  
  //木の根を求める
  //根が一緒なら同じ集合と判断するため
  ll find(ll x){
    if(par[x]==x){
      return x ;
    }
    else{
      return par[x] = find(par[x]) ;
    }
  }
  
  //木の併合
  //記録してあるrankをもとに併合
  void unite(ll x,ll y){
    x = find(x) ;
    y = find(y) ;
    if(x==y){
      return ;
    }
    
    if(rank[x] < rank[y]){
      par[x] = y ;
      siz[y] += siz[x] ;
    }
    else{
      par[y] = x ;
      siz[x] += siz[y] ;
      if(rank[x]==rank[y]){
        rank[x]++ ;
      }
    }
  }
  
  //xとyが同じ集合に属するか
  bool same(ll x,ll y){
    return find(x) == find(y) ;
  }
  
  //iが根であるかを返す
  bool root(ll x){
    return x==find(x) ;
  }
    
  
  //xの属する集合の要素数を返す
  ll size(ll x){
    return siz[find(x)] ;
  }
  
  //グラフ全体で何個の集合があるか返す
  ll cnt(ll n){
    ll res = 0 ;
    REP(i,n){
      if(i==find(i)){
        res++ ;
      }
    }
    return res ;
  }
  
};
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m;
    cin >> n >> m;
    vll p(n);
    vpll pai(n);
    REP(i,n){
        ll q;
        cin >> q;
        q--;
        p[i] = q;
        pai[i] = MP(i,q);
    }
    UnionFind tree;
    tree.init(n);
    REP(i,m){
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        tree.unite(x,y);
    }
    ll ans = 0;
    REP(i,n){
        ll fi = pai[i].FI;
        ll se = pai[i].SE;
        if(tree.same(fi,se)){
            ans++;
        }
    }

    cout << ans <<endl;



    
    return 0;
}



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

int main () {
  int a = 0 , b = 0 ;
  int w , h ;
  cin >> w >> h ;
  for (int i = 0 ; i < w ; i++ ) {
    for (int j = 0 ; j < h ; j++ ) {
      string x ;
      cin >> x ;
      if ( x == "snuke" ) {
        a = i ; b = j ;
      }
    }
  }
  vector<char> line ;
  line = {'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'};
  cout << line.at(b) << a + 1 << endl ;
}


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


int main()
{
    ll a,b,n;
    while(cin>>a>>b>>n)
    {
        if(n>b-1)
        {
            cout<<(a*(b-1)/b)-a*((b-1)/b)<<endl;
        }
        else
        {
            cout<<(a*(n)/b)-a*((n)/b)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#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    = 1'000'000'007;
constexpr ll MOD2   = 998'244'353;
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 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--------*/



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

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

    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int dp[100000-1];

    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; ++i){
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                    dp[i - 1] + abs(h[i] - h[i - 1]));
    }

    cout << dp[n - 1] << endl;

return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
map<char,int> m;
string s="MARCH";
ll ans=0;
void saiki(int n,int c,ll a){
    if(c==3){
        ans+=a;
    }
    else if(n<5){
        saiki(n+1,c+1,a*m[s[n]]);
        saiki(n+1,c,a);
    }
}


int main(void){
    int n;
    cin>>n;
    string str;
    m['M']=0;
    m['A']=0;
    m['R']=0;
    m['C']=0;
    m['H']=0;
    for(int i=0;i<n;i++){
        cin>>str;
        m[str[0]]++;
    }
    saiki(0,0,1);
    cout<<ans<<endl;
}


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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    int ai=0, bi=0, ci=0;

    char tmp = a[0];
    while(true){
        if(tmp=='a'){
            if(ai==a.size()){
                cout << "A" << endl;
                return 0;
            }
            tmp = a[ai];
            ++ai;
        }else if(tmp=='b'){
            if(bi==b.size()){
                cout << "B" << endl;
                return 0;
            }
            tmp = b[bi];
            ++bi;
        }else if(tmp=='c'){
            if(ci==c.size()){
                cout << "C" << endl;
                return 0;
            }
            tmp = c[ci];
            ++ci;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define lim 100010
#define mod 1e9 + 7
#define INF 1e9
#define REP(i, n) for (int i = 0; i < n; i++)

ll GCD(int x, int y){return x%y == 0 ? y : GCD(y, x % y);}

int main() {
  ll N;
  scanf("%d", &N);
  ll a;
  ll ans = 0;
  ll now = 1;
  bool existOne = false;
  for (ll i = 1; i<=N; i++){
    scanf("%lld", &a);
    if(a != now)ans++;
    else now++;
    if(a==1)existOne=true;
  }
  if(!existOne)ans = -1;
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int h,n;cin>>h>>n;
	ll sum = 0;
	for(int i=0;i<n;i++)
	{
		int x;cin>>x;
		sum+=x;
	}
	if(sum>=h) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 384
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    x: i64,
    }

    if x >= 30 {
      println!("Yes");
    }else{
      println!("No");

    }



}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,ans=0;
	cin >> N;
	vector<ll> A(N),B(N),C(N);
	FOR(i,0,N)cin>>A[i];
	FOR(i,0,N)cin>>B[i];
	FOR(i,0,N)cin>>C[i];
	SORT(A);SORT(B);SORT(C);
	FOR(i,0,N){
		ll x,y;
		x = POSL(A,B[i]);
		y = N - POSU(C,B[i]);
		ans += x*y;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,k,c;
cin>>n>>k>>c;
string s;
cin>>s;
vector<ll> a(n),b(n);
ll cnt=1;
for(ll i=0;i<n;i++)
{
	if(s[i]=='o')
	{
		a[i]=cnt;
		cnt++;
		i+=c;
	}
	if(cnt>k)
	break;
}
cnt=k;
for(ll i=n-1;i>=0;i--)
{
	if(s[i]=='o')
	{
		b[i]=cnt;
		cnt--;
		i-=c;
	}
	if(cnt<1)
	break;
}
for(ll i=0;i<n;i++)
{
	if(a[i] && a[i]==b[i])
	cout<<i+1<<el;
}

}



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


void calculatePrime( int M, vector<int>& prime )
{
    prime.push_back( 2 );
    for( int i = 3; i <= M; i += 2 ){
        bool isPrime = true;
        for( int j = 3; j*j <= i; j += 2 ){
            if( i % j == 0 && i != j ){
                isPrime = false;
                break;
            }
        }
        if( isPrime ) prime.push_back( i );
    }
}

vector<int> similarTo2017( vector<int>& prime )
{
    vector<int> similarTo2017;
    int pos = 0;
    for( int i = 0; i < prime.size(); ++i ){
        // while( prime[pos] < (prime[i]+1)/2 && pos < i ) ++pos;
        for( int j = pos; j < i; ++j ){
            if( (prime[i]+1)/2 == prime[j]  ){
                similarTo2017.push_back( prime[i] );
                break;
            }
        }
    }
    return similarTo2017;
}


int main()
{
    int Q;
    cin >> Q;
    vector<int> l(Q), r(Q);
    for( int i = 0; i < Q; ++i ) cin >> l[i] >> r[i];

    vector<int> prime, similar;
    calculatePrime( 1e+5, prime );
    similar = similarTo2017( prime );
        
    for( int i = 0; i < Q; ++i ){
        int ans = 0;
        for( int j = 0; j < similar.size(); ++j ){
            if( l[i] <= similar[j] && similar[j] <= r[i] ) ++ans;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1536
from math import gcd
from functools import reduce

def gcd3(*numbers):
    return reduce(gcd, numbers)

k = int(input())

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd3(a, b, c)

print(ans)

Measured memory_bytes: 69656
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
#define mod 1000000007

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; ++i)
            cin >> a[i];
        int cur = 1000;
        for (int i = 1; i < n; ++i)
        {
            if (a[i] > a[i - 1])
            {
                int cc = cur / a[i - 1];
                cur += cc * (a[i] - a[i - 1]);
            }
        }
        cout << cur << "\n";
    }
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m; cin >> n >> m;
    ll ans = 0;
    rep(i,0,m){
        ll tmp;
        cin >> tmp;
        ans += tmp;
    }
    if(n-ans>=0) cout << n-ans << endl;
    else cout << -1 << endl; 
}

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

char s[3000];
int a[3000][3000];
int cnt[3000];
int l[3000],r[3000];

int main(){
	int h,w;scanf("%d%d",&h,&w);
	rep(i,h){
		scanf("%s",s);
		rep(j,w){
			a[i][j]=(s[j]=='#');
		}
	}
	rep(i,h)rep(j,w-1){
		a[i][j]=a[i][j+1]^a[i][j];
	}
	int Max=h;
	w--;
	rep(i,h){
		rep(j,w){
			if(i==0||a[i][j]!=a[i-1][j])cnt[j]=1;
			else cnt[j]++;
		}
		stack<P>st;
		st.push(P(0,-1));
		rep(j,w){
			while(st.top().first>=cnt[j])st.pop();
			l[j]=st.top().second;
			st.push(P(cnt[j],j));
		}
		while(!st.empty())st.pop();
		st.push(P(0,w));
		for(int j=w-1;j>=0;j--){
			while(st.top().first>=cnt[j])st.pop();
			r[j]=st.top().second;
			st.push(P(cnt[j],j));
		}
		rep(j,w){
			Max=max(Max,(r[j]-l[j])*cnt[j]);
		}
	}
	cout<<Max<<endl;
}

Measured memory_bytes: 24832
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int n ;
	char *u, buf[5] ;
	double *x ;

	scanf("%d", &n) ; // 2 <= n <= 10
	if (n < 2 || n > 10)
		return -1 ;

	u = (char*)malloc(sizeof(char) * n) ;
	x = (double*)malloc(sizeof(double) * n) ;

	for (int i = 0; i < n; i++) {
		scanf("%lf %s", &x[i], buf) ;
		u[i] = buf[0] ;
	}

	double money = 0.0 ;

	for (int i = 0; i < n; i++) {
		if (u[i] == 'J') {
			money += x[i] ;
		}
		else {
			money += x[i] * 380000 ;
		}
	}
	printf("%lf\n",money) ;

	free(u) ;
	free(x) ;
}


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

int main() 
{
  int n;
  cin >> n;
  vector<int64_t> data(3 * n);
  for(int i = 0; i < 3 * n; i++)
  {
    cin >> data.at(i);
  }
  sort(begin(data), end(data));
  reverse(begin(data), end(data));
  int count = 0;
  int64_t answer = 0;
  for(int i = 1; i < 3 * n; i++)
  {
    if(count == n)
    {
      break;
    }
    if(i % 2 == 0)
    {
      count++;
      answer += data.at(i - 1);
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 2560
n, capacity = gets.split.map(&:to_i)
values, weights = n.times.map { gets.split.map(&:to_i) }.transpose

solve = -> {
  dp = Array.new(n+1) { |i|
    Array.new(capacity+1) { |j|
      (i == n) ? 0 : nil
    }
  }

  (n-1).downto(0) do |i|
    0.upto(capacity) do |j|
      if weights[i] > j
        dp[i][j] = dp[i+1][j]
      else
        dp[i][j] = [ dp[i+1][j-weights[i]] + values[i],
                     dp[i+1][j] ].max
      end
    end
  end

  dp[0][capacity]
}

puts solve.()

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

lnt fact[500000], invfact[500000];

lnt invmod(lnt a, lnt p){ // a^-1 mod p
	lnt b = p, u = 1, v = 0;
	while(b){
		lnt t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= p;
	if(u < 0) u += p;
	return u;
}

void factmod(lnt m){
	fact[0] = invfact[0] = 1;
	for(lnt i = 1; i < 500000; i++){
		fact[i] = (fact[i-1] * i) % m;
		invfact[i] = (invfact[i-1] * invmod(i, m)) % m;
	}
}

lnt nCrmod(lnt n, lnt r, lnt m){
	return (((fact[n] * invfact[r]) % m) * invfact[n-r]) % m;
}

int main(){
	summon_tourist;

	lnt S; cin >> S;
	factmod(MOD);
	lnt ans = 0;
	for(lnt sets = 1; sets <= S/3; sets++){
		lnt nokori = S - 3*sets;
		ans += nCrmod(nokori+sets-1, sets-1, MOD);
		ans %= MOD;
	}
	cout << ans << ln;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int a, b;cin >> a >> b;
    if(a+b >= 10){
        cout << "error" << endl;
    }else{
        cout << a+b << endl;
    }
    return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> l;
    for (int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        l.push_back(temp);
    }

    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    for (int i = 0; i < K; i++)
    {
        ans += l[i];
    }

    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int a,b,c,ans=0;
void work(){
	if(ans>1000) return ;
	if(a%2 or b%2 or c%2) {
		cout<<ans;exit(0);
	}
	int aa,bb,cc;
	aa=b/2+c/2,bb=a/2+c/2,cc=a/2+b/2;
	a=aa,b=bb,c=cc;
	ans++;work();
}
signed main(){
	cin>>a>>b>>c;
	work();
	puts("-1");
	
	return 0;
}

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

int main() {  
	int n;
	long double x = 0.0;
	cin >> n;
	for ( int i = 0; i < n; ++i ) {
		long double a;
		cin >> a;
		long double b = 1/a;
		x += b;
	}
	cout << 1/x << endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,x,i,flag;
    cin>>a>>b>>x;
    for(i=b;i>=0;i--){
        if(a+i==x){
            cout<<"YES";
            flag=1;
            break;}
        else
            flag=0;
    }
    if (flag==0)
        cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
#define N 102
// int a[3][N],road[3][N],n;

int main()
{

    int x,a,b,c,i,j,k,cnt=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(i = 0; i<=a; i++)
    {
      for(j = 0; j*100<=x-500*i&&j<=b; j++)
      {
        for(k = 0; k*50 <=x-500*i-100*j&&k<=c; k++)
        {
          if((i*500+j*100+k*50)==x){
          cnt++;
          // printf("i = %d, j = %d, k = %d\n",i,j,k);
        }
        }
      }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int man=1000005;
const int MAXM= 15000005;
string s,t;
int a[26];
int b[26];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin>>s>>t;
  for(int i=0;i<s.size();i++)
  {
      a[s[i]-'a']++;
      b[t[i]-'a']++;
  }
  sort(a,a+26);
  sort(b,b+26);
  for(int i=0;i<26;i++)
    if(a[i]!=b[i])
  {
      cout<<"No"<<endl;
      return 0;
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

vector<vi> adj;

int vis[200005];

int main(){

    int n, m; cin >> n >> m;
    adj.assign(n+5, vi());

    for(int i = 0; i < m; i++){
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    for(int u : adj[n])
        vis[u] = 1;
    for(int u : adj[1])
        if(vis[u]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    cout << "IMPOSSIBLE" << endl;
	return 0;
}


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

int main()
{
    std::vector<int> a(3);
    std::cin >> a[0] >> a[1] >> a[2];
    std::sort(a.begin(), a.end());
    std::cout << a[0] * a[1] / 2 << std::endl;

    return 0;
}


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

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;

ll n, k;
vector<ll> arr;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> k;
    arr.resize(n);
    for(int i = 0; i < n; i++) cin >> arr[i];
}

void process()
{
    ll g = arr[0];
    for(auto x:arr) g = __gcd(g, x);
    for(auto x:arr)
    {
        if(x-k >= 0 && (x-k)%g == 0)
        {
            cout << "POSSIBLE" << endl;
            return;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}



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

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

using ll = long long;
using pii = pair<int,int>;
using pid = pair<int,double>;

int w,n;
ll x[52525];
ll s[52525];

int imos[52525];

int main(){
  while(true){
    scanf("%d%d",&w,&n);
    if(w+n==0)break;
    REP(i,n)scanf("%lld",x+i);
    REP(i,n)s[i+1] = s[i] + x[i];
    int ok = w, ng = 0;
    while(abs(ok-ng)>1){
      int L = (ok+ng)/2;
      fill(imos,imos+n+1,0);
      imos[0] = 1; imos[1] = -1;
      bool go = false;
      REP(i,n){
        imos[i+1] += imos[i];
        if(imos[i] == 0)continue;
        if(s[n]-s[i]+n-i-1 <= w){
          go = true;
          break;
        }
        int ok2 = i+1, ng2 = n+1;
        while(abs(ok2-ng2)>1){
          int r = (ok2+ng2)/2;
          (s[r]-s[i]+r-i-1 <= w ? ok2 : ng2) = r;
        }
        int lb = ok2;
        ok2 = n, ng2 = i;
        while(abs(ok2-ng2)>1){
          int r = (ok2+ng2)/2;
          (s[r]-s[i]+1ll*L*(r-i-1)>=w ? ok2 : ng2) = r;
        }
        int ub = ok2;
        // printf("L=%d, i=%d: ub=%d, lb=%d\n",L,i,ub,lb);
        if(ub <= lb){
          imos[ub]++;
          imos[lb+1]--;
        }
      }
      (go ? ok : ng) = L;
    }
    printf("%d\n", ok);
  }
  return 0;
}




Measured memory_bytes: 4092
process.stdin.resume();
process.stdin.setEncoding("utf8");
let input = "";
process.stdin.on("data", function(chunk) {input += chunk;});
process.stdin.on("end", function() {main(input.split("\n"));});

function allocNode(key) {
	const p = {};
	p.key = key;
	p.parent = null;
	p.left = null;
	p.right = null;
	return p;
}

function insert(p,c) {
	if (p === null) return c;
	if (c.key < p.key) {
		p.left = insert(p.left,c);
		p.left.parent = p;
	}	else {
		p.right = insert(p.right,c);
		p.right.parent = p;
	}
	return p;
}

function find(p,key) {
	if (p !== null && p.key !== key) {
		if (key < p.key) p = find(p.left,key);
		else p = find(p.right,key);
	}
	return p;
}

function remove(root,key) {
	let next;
	const p = find(root,key);
	if (p === null) return;
	const pp = p.parent;
	if (p.right === null) next = p.left;
	else {
		next = p.right;
		if (p.left !== null) {
			while (next.left !== null) next = next.left;
			if (next.parent !== p) {
				next.parent.left = next.right;
				next.right = p.right;
			}
			next.left = p.left;
		}
	}
	if (pp !== null) {
		if (pp.left === p) pp.left = next;
		else pp.right = next;
	} else root = next;
	if (next !== null) next.parent = pp;
}

function inset(p,ary) {
	if (p === null) return;
	inset(p.left,ary);
	ary.push(p.key);
	inset(p.right,ary);
}

function preset(p,ary) {
	if (p === null) return;
	ary.push(p.key);
	preset(p.left,ary);
	preset(p.right,ary);
}

function dump(p,setfunc) {
	const ary = [];
	setfunc(p,ary);
	console.log(ary.map(x => ` ${x}`).join(""));
}


function main(lines){
	const n = Number(lines[0]);
	let p, key, line, root = null;

	for (let i = 0; i < n; i++) {
		line = lines[i+1].split(" ");
		switch(line[0][0]) {
		case "i":
			key = Number(line[1]);
			p = allocNode(key);
			root = insert(root,p);
			break;
		case "p":
			dump(root,inset);
			dump(root,preset);
			break;
		case "f":
			key = Number(line[1]);
			if (find(root,key) !== null) console.log("yes");
			else console.log("no");
			break;
		case "d":
			key = Number(line[1]);
			remove(root,key);
			break;
		}
	}
}



Measured memory_bytes: 215948
import java.util.*;

public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		System.out.println(Math.min(B/A, C));
    }
  
}


Measured memory_bytes: 22612
a,b=map(int, input().split())

t=0
for i in range(2,10**9+1):
    if a%b==0:
        break
    if a*i>=10**18:
        break
    elif a*i%b!=0:
        t=1
        break

if t==1: print(a*i)
else: print(-1)


Measured memory_bytes: 2940
#include <iostream>
using ll=long long;

using namespace std;

int GetDigit(ll num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}


int main(void){

  ll N;
  ll A;
  int ans;

  cin >> N;

  ans = GetDigit(N);
  
  for( A = 1; A*A <= N; A++ ){

    if( (N%A) != 0 ) {
      continue;
    }
    const ll B = N/A;

    int temp = max(GetDigit(A),GetDigit(B));
    if( ans > temp )
    ans = temp;
    
  }

  cout << ans;

  return 0;

  
}

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

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define pll  pair<ll,ll>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

void solve()
{
	string s;
	cin>>s;
	s=s.substr(0,s.size()-2);
	while(s.substr(0,s.size()/2)!=s.substr(s.size()/2,s.size()))
	{
		s=s.substr(0,s.size()-2);
	}
	cout<<s.size();
}            
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3608