akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
bool A[10][10];
int main() {
    init();
    ll H, W, K;
    cin >> H >> W >> K;
    vc<string> S(H);
    rep(i, H) cin >> S[i];

    ll ans = 0;
    rep(bit, 1<<(H+W)){
        rep(i, H) rep(j, W) A[i][j] = 0;

        ll cnt = 0;
        rep(h, H){
            if (bit & 1 << h) rep(i, W) A[h][i] = 1;
        }
        rep(w, W){
            if (bit & 1 << (H + w)) rep(i, H) A[i][w] = 1;
        }

        rep(i, H) rep(j, W) if (A[i][j] == 0 and S[i][j] == '#') cnt++;

        if (cnt == K) ans++;
    }

    cout << ans << endl;
}

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

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

	int ans = INT_MAX;

	for (int i = 0; i < n - 1; ++i) {
		int sum1 = 0, sum2 = 0;
		for (int j = 0; j <= i; ++j) {
			sum1 += a[j];
		}
		for (int j = i + 1; j < n; ++j) {
			sum2 += a[j];
		}
		ans = min(ans, abs(sum1 - sum2));
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <queue>

using namespace std;
const int MAXN = 25;
int h, w, dis[MAXN][MAXN], ans, farX, farY, all;
char maze[MAXN][MAXN];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

void bfs(int x, int y) {
    memset(dis, -1, sizeof(dis));
    queue<int> q;
    q.push(x);
    q.push(y);
    dis[x][y] = 0;
    ans = 0;
    farX = x;
    farY = y;
    while (!q.empty()) {
        x = q.front();
        q.pop();
        y = q.front();
        q.pop();
        for (int i = 0; i < 4; ++i) {
            int xx = x + dx[i];
            int yy = y + dy[i];
            if (xx > 0 && xx <= h && yy > 0 && yy <= w && maze[xx][yy] == '.' && dis[xx][yy] == -1) {
                dis[xx][yy] = dis[x][y] + 1;
                q.push(xx);
                q.push(yy);
                if (dis[xx][yy] > ans) {
                    ans = dis[xx][yy];
                    farX = xx;
                    farY = yy;
                }
            }
        }
    }
}

int main() {
    cin >> h >> w;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin >> maze[i][j];
        }
    }
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (maze[i][j] == '.') {
                bfs(i, j);
                all = max(all, ans);
            }
        }
    }
    cout << all << endl;
    return 0;
}

Measured memory_bytes: 3588
//https://codeforces.com/problemset/problem/1095/E
#include<bits/stdc++.h>

using namespace std;


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";
#define  ll  long long

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






template <class T> inline T biton(T n, T pos)
{
	return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
	return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
	return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
	while (b)
	{
		a = a % b;
		swap(a, b);
	}
	return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
	T ret = 1;
	for (; e > 0; e >>= 1)
	{
		if (e & 1)
			ret = (ret * p) % m;
		p = (p * p) % m;
	}
	return (T)ret;
};

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " is " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif




void solve()
{
	long double a, b;
	cin >> a >> b;

	a = a * b;

	long long res = a;
	cout << res << nl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);
	cout.tie(nullptr);
	cin.tie(nullptr);

	int t = 1;

	while (t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll N, x;
  cin >> N >> x;
  vector<int> a(N);
  ll ans = 0;
  rep(i, N) {
    cin >> a[i];
    ans += a[i];
  }
  for (int i=1; i<N; i++) {
    int tmp = a[N-1];
    for (int j=N-1; j>0; j--)
      chmin(a[j], a[j-1]);
    chmin(a[0], tmp);
    ll sum = 0;
    rep(j, N) sum += a[j];
    chmin(ans, sum+i*x);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int fc[100001], in[100001];

int pwmd(int a, int n = mod - 2)
{
	if (!n)
		return 1;
	int pt = pwmd(a, n / 2);
	pt *= pt, pt %= mod;
	if (n & 1)
		pt *= a, pt %= mod;
	return pt;
}
int nCr(int n, int r)
{
     fc[0] = in[0] = 1;

	for (int i = 1; i <= 100000; ++i)
	{
		fc[i] = (i * fc[i - 1]) % mod;
		in[i] = pwmd(fc[i]);
	}

	int ans = fc[n];
	ans = (ans * in[r]) % mod;
	ans = (ans * in[n - r]) % mod;

	return ans;
}
int pow(int a,int b)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)
			ans*=a;
		a*=a;
		b=b>>1;
	}
	return ans;
}
//vector<pair<int,int>> vec;
bool compare(pair<int,int> v1,pair<int,int> v2)
{
	return v1.ss<v2.ss;
}

vector<int> adj[200005];
int dis[200005];
void dfs1(int par, int u)
{
	for(int x:adj[u])
	{
		if(x==par)
			continue;
		dis[x]=dis[u]+1;
		dfs1(u,x);
	}
}

void dfs(int par, int u,bool *vis)
{
	vis[u]=true;
	for(int x:adj[u])
	{
		if(x==par)
			continue;
		dfs(u,x,vis);
		vis[x]=true;
	}
}

vector<int> vec[100001];
int32_t main()
{       
    FIO;
    int n;
    cin>>n;
    int a[n];

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

    int c[1000005];
    memset(c,0,sizeof(c));
    for(int i=0;i<n;i++)
    {
    	if(a[i]>n)
    		continue;
    	int t=(i+1)+a[i];
    	c[t]++;
    }
    
    int ans=0;
    for(int i=0;i<n;i++)
    {
    	int x=(i+1)-a[i];
    	if(x>=0)
    		ans+=c[x];
    	if(x==((i+1)+a[i]))
    		ans--;
    }

    cout<<ans;
   
}

Measured memory_bytes: 19988
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) max_element(x.begin(),x.end())
#define MIN(x) min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//fixed<<setprecision(15);

signed main(){
    int n; cin >> n;
    vstr s(n); rep(i,n) cin >> s[i];
    int m; cin >> m;
    vstr t(m); rep(i,m) cin >> t[i];
    int res=-1*INF;
    map<string,int> map;
    rep(i,n) map[s[i]]++;
    rep(i,m) map[t[i]]--;
    rep(i,n) chmax(res,map[s[i]]);
    if(res<0) cout<<0<<endl;
    else  cout<<res<<endl;
}

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

using namespace std;

long long inf=1000000007;

int main(){
	int n;
	cin>>n;
	vector<int> box(n+1);
	vector<int> ball(n+1,0);
	queue<int> que;
	for(int i=0;i<n;i++) cin>>box.at(i+1);
	int ans=0;

	for(int i=n;i>0;i--){
		int cnt=0;
		for(int j=i;j<=n;j+=i){
			if(ball.at(j)==1) cnt++;
		}
		if(cnt%2!=box.at(i)){
			ball.at(i)++;
			ans++;
			que.push(i);
		}
	}

	cout<<ans<<endl;
	while(!que.empty()){
		cout<<que.front();
		que.pop();
		if(!que.empty()) cout<<" ";
		else cout<<endl;
	}

	return 0;
}


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


#define	ll_int	long long int
#define	INF	1000000001


int main()
{
	int n, m;
	ll_int *A, *B;
	int count;
	int i, j, k;

	scanf("%d", &n);
	A = (ll_int *)malloc(sizeof(ll_int) * (n + 1));
	for(i = 0; i < n; i++)
		scanf("%lld", &A[i]);
	A[n] = INF;

	scanf("%d", &m);
	B = (ll_int *)malloc(sizeof(ll_int) * (m + 1));
	for(i = 0; i < m; i++)
		scanf("%lld", &B[i]);
	B[m] = INF;


	// 表示
	j = k = count = 0;
	for(i = 0; i < n + m - count; i++){
		if(A[j] < B[k])
			printf("%lld\n", A[j++]);
		else if(B[k] < A[j])
			printf("%lld\n", B[k++]);
		else{
			printf("%lld\n", A[j++]);
			k++;
			count++;
		}
	}

	return 0;
}


Measured memory_bytes: 4984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;


int main(){
  int i,j;
  ll t1,t2;
  cin>>t1>>t2;
  ll a1,a2,b1,b2;
  cin>>a1>>a2>>b1>>b2;
  if(a1<b1){
    swap(a1,b1);
    swap(a2,b2);
  }
  if(a2>b2){
    cout<<0<<endl;
    return 0;
  }
  ll a=a1-b1;
  ll b=b2-a2;
  
  ll da=a*t1;
  ll db=b*t2;
  if(da==db){
    cout<<"infinity"<<endl;
    return 0;
  }
  else if(da>db){
    cout<<0<<endl;
    return 0;
  }
  else {
    ll d=db-da;
    ll k=da/d;
    if(da!=k*d) cout<<2*k+1<<endl;
    else cout<<2*k<<endl;
  } 
  return 0;
}

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

int main(){
  ll N;
  cin >> N;
  vector<ll> div(N+1,0);
  
  for(ll i=1;i<N+1;i++){
    for(ll j=i;j<N+1;j+=i){
      div.at(j)++;
    }
  }
  
  /*
  for(int i=1;i<100;i++){
    cout << div.at(i) << endl;
  }
  */
  
  ll ans=0;
  
  for(int i=1;i<=N;i++){
    ans += i*div.at(i);
  }
  
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 81404
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
	ll x, k, d;
	cin >> x >> k >> d;


	if(x < 0) x *= -1;
	if((double)x / (double)d >= (double)k){
		cout << x - k * d << endl;
		return 0;
	}
	if(x % d == 0){
		if((x / d) % 2 == k % 2){
			cout << 0 << endl;
		}else{
			cout << d << endl;
		}
		return 0;
	}
	ll sa = x - ((x / d) * d);

	if((x / d) % 2 == k % 2){
		cout << sa << endl;
	}else{
		cout << d - sa << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string a,b;
    cin >> a >> b;
    int r = 0;
    for(int i = 0; i < a.size(); i++){
        r+=(a[i]!=b[i]);
    }
    cout << r << endl;
    return 0;
}
/*
5
1 0 1
20 1 0
300 0 1
4000 0 0
50000 1 0
1 2
2 3
2 4
1 5
*/


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int D, T, S;	
	cin >> D >> T >> S;
	if( D <= T * S)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int t=a;
	a=c;
	c=b;
	b=t;
	cout<<a<<' '<<b<<' '<<c<<endl;
	return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];

    int ans = 0;
    int cnt = 0;
    int pre = 0;
    rep(i, N) {
        int h = H[i];
        if (h <= pre) {
            cnt ++;
        }else{
            cnt = 0;
        }
        ans = max(ans, cnt);
        pre = h;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val number = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toInt() }
    var count = 0
    var min = 0
    p.forEach {
        if (it <= min || min == 0){
            if (min == 0) {
                min = it
            }
            count++
        }
        if (min > it){
            min = it
        }
    }
    println(count)
}

Measured memory_bytes: 82876
N,K = map(int,input().split())
V = list(map(int,input().split()))

ans = 0
for l in range(N):
    if l > K: break
    for r in range(N-l+1):
        if l+r > K: break
        vs = V[:l] + (V[-r:] if r>0 else [])
        vs.sort()
        k = K-l-r
        t = 0
        for v in vs:
            if v < 0 and k > 0:
                k -= 1
                continue
            t += v
        ans = max(ans,t)
print(ans)

Measured memory_bytes: 3064
import java.util.HashMap;
import java.util.Scanner;


class Main {

	public static void main (String [] a){
		
		String longestWord = "";
		String mostFreqWord = "";
		
		Scanner in = new Scanner(System.in);
		String inputText = in.nextLine();

		String[] words = inputText.split(" ");
		HashMap<String, Integer> tempWordCtr = new HashMap<String, Integer>();
				
		for (String s: words){
			s = s.toLowerCase();
			
			if (s.length() > longestWord.length()){
				longestWord = s;
			}
			
			if (tempWordCtr.keySet().contains(s)){
				Integer count = tempWordCtr.get(s) + 1;
				tempWordCtr.put(s, count);
			} else {
				tempWordCtr.put(s, 1);
			}
		}
		
		Integer tempFreq = null;
		for (String s: tempWordCtr.keySet()){

			Integer i = tempWordCtr.get(s);
			if (tempFreq == null){
				tempFreq = i;
				mostFreqWord = s;
			}
			
			if (i > tempFreq){
				tempFreq = i;
				mostFreqWord = s;
			}
		}
		
		System.out.println(mostFreqWord + " " + longestWord);
	}
}

Measured memory_bytes: 26036
import java.util.*;
public class Main{
	public static void main(String[] args) {
		int data[] = new int[18];
		for(int i=0;i<18;i++){
			data[i]=i*i;
		}
		int num[] = new int[301];//カウント
		for(int i=0;i<300;i++)num[i]=0;//全て0
		num[0]=1;
		for(int s=1;s<18;s++){//全ての場合
			for(int i=data[s];i<301;i++){//倍数ずつ進む
				if((i-s*s)>=0){
					num[i]+=num[i-data[s]];
				}
			}
		}
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n==0)break;
			System.out.println(num[n]);
		}
	}
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    ll mini = numeric_limits<ll>::max();
    rep(i, S.size() - 2) {
        string temp = string(S.begin() + i, S.begin() + i + 3);
        mini = min(abs(stoll(temp) - 753LL), mini);
    }
    cout << mini << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define pb push_back
#define ff first
#define ss second
#define SIZE 200010
#define INF 2e9 + 9
#define acmpIN "input.txt"
#define acmpOUT "output.txt"

//#pragma GCC optimize("Ofast")

ll n, a[SIZE], cnt[SIZE];
ll pref[SIZE];



void solve()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }
    pref[1] = cnt[1] * (cnt[1] - 1) / 2;
    for(int i = 2; i <= 200000; i++)
    {
        pref[i] = pref[i - 1];
        pref[i] += cnt[i] * (cnt[i] - 1) / 2;
    }
    for(int i = 0; i < n; i++)
    {
        ll curAns = 0;
        curAns += pref[a[i] - 1];
        curAns += (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
        curAns += pref[200000] - pref[a[i]];
        cout << curAns << endl;
    }
}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen(acmpIN, "r", stdin);
//    freopen(acmpOUT, "w", stdout);

    solve();

    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
const ll mod=1e9+7;
 
#define pb push_back
#define mp make_pair


 
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    ll a;
    string b;
    cin>>a;
    cin>>b;
    //cout<<b[1]<<" ";
    ll k=(ll)(b[0]-'0')*100 + (ll)(b[2]-'0')*10 + (ll)(b[3]-'0');
    //cout<<k<<" ";
    ll d=(a*k)/100;
    cout<<d;
    
    return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    ll ans = 0;
    rep(i,t.size()){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3916
#include <iostream>
#include <iomanip>
/*cout <<setprecision(11)<<ret<<endl;で、数字部分を計11桁表示*/
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける

//////////////////
//  A
/*int main(void){
    int a,b;
    cin >>a>>b;
    if(a<=5) cout<< 0<<endl;
    else if(a<=12) cout<<(b/2)<<endl;
    else cout<<b<<endl;
    return 0;
}*/
//////////////////
//  B
int main(void){
    int r,D,x;
    cin>>r>>D>>x;
    long long int x_tmp=r*x-D;
    for(int i=1;i<=10;i++){
        cout<<x_tmp<<endl;
        x_tmp=r*x_tmp-D;
    }
    return 0;
}
//////////////////
//  C
/*int main(void){

    return 0;
}*/
//////////////////
//  D
/*int main(void){

    return 0;
}*/
//////////////////
//  E
/*int main(void){

    return 0;
}*/
//////////////////
//  F
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int MAXN = 100100;
const int P = (1 << 17);
const int MAXP = 2 * P + 100;

int N, M;
vector <pair <int, int> > event[MAXN];
ll seg[MAXP];

void upd (int cloc, ll x)
{
    cloc += P;
    while (cloc)
    {
        seg[cloc] = min (seg[cloc], x);
        cloc /= 2;
    }
}

ll ghi (int cloc)
{
    cloc += P;
    cloc++;
    ll res = 1e18;
    while (cloc > 1)
    {
        if (cloc & 1)
            res = min (res, seg[cloc-1]);
        cloc /= 2;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int l, r, c;
        cin >> l >> r >> c;
        l--, r--;
        event[r].push_back(make_pair (l, c));
    }

    for (int i = 0; i < MAXP; i++)
        seg[i] = 1e15;

    upd (N, 0);
    for (int i = 0; i < N; i++)
    {
        for (pair <int, int> pp : event[i])
        {
            int es = pp.first, np = pp.second;

            ll bv = ghi (N - es);
            //cout << i << " " << es << " " << bv << "\n";
            upd (N - i, bv + np);
        }
    }

    if (seg[P+1] < 2e14)
        cout << seg[P+1] << "\n";
    else
        cout << "-1\n";
}

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

int main()
{
	string s; cin>>s;
	int l = 0, r = s.size()-1;
	int ans = 0;
	while (l<r)
	{
		ans+= s[l] != s[r];
		l++;
		r--;
	}
	cout<<ans<<endl;
}

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

int main(){
    int a,b;
    string s="abcdefghijklmnopqrstuvwxyz",t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",u;
    cin>>a>>b>>u;
    for(int i=0;i<26;i++){
    	if(u[b-1]==t[i]){
    		u[b-1]=s[i];
    	}
    }
    cout<<u<<endl;
    
    
   return 0;
}

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

using namespace std;

typedef long long ll;

const int MAXN = 105;
const int MAXV = 1e5 + 5;
const int INF = 1e9 + 5;

int n, W;
int w[MAXN], v[MAXN], dp[MAXN][MAXV];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> W;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < MAXV; ++j) {
      dp[i][j] = INF;
    }
  }
  for (int i = 0; i < n; ++i) {
    cin >> w[i] >> v[i];
  }
  dp[0][v[0]] = w[0];
  dp[0][0] = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < MAXV; ++j) {
      dp[i][j] = dp[i - 1][j];
      if (j - v[i] >= 0) {
        dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < MAXV; ++j) {
      if (dp[i][j] <= W) {
        ans = max(ans, j);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 42628
import collections
N,P=map(int,input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c=collections.Counter(prime_factorize(P))
c=list(c.items())
ans=1
for i in range(len(c)):
    ans*=c[i][0]**(c[i][1]//N)
print(ans)

Measured memory_bytes: 3316
#E
inf = float("inf")
N,K,C = map(int,input().split())
S = list(str(input()))

old = -inf
used = [-1 for _ in range(N)] #if used then used[i] = 1
count = 0
for i in range(N):
    if S[i] == "o":
        if i > old+C and count < K:
            old = i
            used[i] = 1
            count+=1
        else:
            used[i] = 0
            
ans = []
front = N-1
#print(used)
hatu = True
for i in range(N):
    I = N-(i+1)
    if used[I] == 1:
        #print(I,front)
        flag = True
        if hatu:
            hatu = False
            rest = front-I
            for j in range(rest):
                if used[front-j-1] != -1:
                    front -= j+1
                    flag = False
                    break
        else:
            rest = front-I
            for j in range(rest):
                #print(I,front-j-1)
                if used[front-j-1] != -1 and front-j-1+C < front:
                    front -= j+1
                    if front != I:
                        flag = False
                    break
        
        if flag:
            ans.append(I+1)
            front = I
        #print(front)
            
    
ans.sort()                
for a in ans:
    print(a)
                    
    




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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> X(M, 0);
    for(size_t i = 0; i < M; i++)
        cin >> X[i];
    
    if (N >= M) {
        cout << 0 << endl;
        return 0;
    }
    sort(X.begin(), X.end());
    vector<int> Xdiff(M-1, 0);
    for(size_t i = 0; i < M-1; i++)
        Xdiff[i] = X[i+1] - X[i];
    
    sort(Xdiff.begin(), Xdiff.end());
    int score = X[M-1] - X[0];
    for(size_t i = 0; i < N-1; i++){
        score -= Xdiff[M-2-i];
        if (i == M-1)
            break;
    }
    cout << score << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
vector<int> R[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	for(int i=1,l,r;i<=n;i++) {
		cin >> l >> r;
		R[l].push_back(r);
	}
	priority_queue<int> L_pq,tem;
	for(int i=m;i>=1;i--) {
		for(int r : R[i])
			tem.push(r);
		if(!tem.empty()) {
			L_pq.push(-tem.top());
			tem.pop();
		}
	}
	for(int r : R[0])
		tem.push(r);
	set<int> wait;
	for(int i=1;i<=m;i++)
		wait.insert(i);
	while(!tem.empty()) {
		int now = tem.top();
		tem.pop();
		auto it = wait.lower_bound(now);
		if(it != wait.end())
			wait.erase(it);
	}
	int ans = (int)L_pq.size() + min(m - (int)L_pq.size(),m - (int)wait.size());
	while(!L_pq.empty()) {
		int r = -L_pq.top();
		L_pq.pop();
		auto it = wait.lower_bound(r);
		if(it != wait.end())
			wait.erase(it);
		ans = max(ans,(int)L_pq.size() + min(m - (int)L_pq.size(),m - (int)wait.size()));
	}
	cout << n - ans << endl;
	return 0;
}


Measured memory_bytes: 18680
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

  vector<string> v;

  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

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

  pair<int, string> ans[N];
  int k = 0;
  for (int i = 0; i < N; i++) {
    int count = 1;
    int j = i;
    while (j + 1 < N && v[j] == v[j + 1]) {
      count++;
      j++;
    }
    ans[k].first = -count;
    ans[k].second = v[i];
    k++;
    i = j;
  }


  sort(ans, ans + k);

  if (k == 1) {
    cout << ans[0].second << endl;
  }

  for (int i = 0; i < k - 1; i++) {
    if (ans[i].first != ans[i+1].first) {
      cout << ans[i].second << endl;
      break;
    } else {
      if (i == k - 2) {
        cout << ans[i].second << endl;;
        cout << ans[i+1].second << endl;
      } else{
        cout << ans[i].second << endl;
      }
    }
  }
}

Measured memory_bytes: 17392
#define CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<iomanip>
#include<math.h>
#include<vector>
#include<utility>
#include<functional>
#include<iostream>
#define sqr(x) x*x
#define REP(i,n) for(int i=0;i<n;i++)
const int INF = 100000000;
bool flg=false;
using namespace std;
typedef pair<int, int>P;


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	S[3] = '8';
	cout << S<< endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;

int main()
{
	char s[20];
	while(~scanf("%s", s))
	{
		int i;
		for (i = 0; s[i] != '\0'; i++)
		{
			if (s[i] == ',') 
			{
				printf(" ");
				continue;
			}
			printf("%c", s[i]);
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main() {
    int n;
    scanf("%d", &n);

    int ans = 0;

    while (n--) {
        int a;
        scanf("%d", &a);
        ans += (a & 1);
    }

    if (ans & 1) printf("NO");
    else printf("YES");
}


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

int main() {
	int W[10], K[10];
	rep(i, 10)scanf("%d", &W[i]);
	rep(i, 10)scanf("%d", &K[i]);
	sort(W, W + 10); sort(K, K + 10);
	cout << W[9] + W[8] + W[7] << ' ' << K[9] + K[8] + K[7] << endl;
	return 0;
}

Measured memory_bytes: 3236
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Deque<String> stack = new ArrayDeque<String>();
        while (true) {
            final String line = br.readLine();
            if (line == null) break;
            if ("0".equals(line)){
                String a = stack.poll();
                System.out.println(a);
            }else{
                stack.push(line);
            }
        }
    }
}

Measured memory_bytes: 16860
use std::io::prelude::*;

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a_s: Vec<i64> =
        (0..n).map(|_| input()).collect();
    let mut a = Vec::new();
    a.push(0);
    for i in a_s {
        a.push(i);
    }
    let mut b = vec![0; n+1];
    for i in (1..n+1).rev() {
        let mut sum =  0;
        let mut j = i+i;
        while j <= n {
            sum ^= b[j];
            j += i;
        }
        b[i] = sum^a[i];
    }
    let mut ans = vec![];
    for (k, &i) in b.iter().enumerate() {
        if i == 1 {
            ans.push(k);
        }
    }
    println!("{}", ans.len());
    for i in ans {
        println!("{}", i);
    }
}

Measured memory_bytes: 10492
#include <iostream>
    #include <algorithm>
    #define FAIL { cout << "No\n"; return 0; }
    using namespace std;
     
    int main() {
        int R, C, R2, C2, r, c;
        cin >> R >> C >> R2 >> C2;
     
        if (R % R2 == 0 && C % C2 == 0) FAIL;
     
        int b[500][500] = {};
        int useRow = (R%R2 != 0);
        for (r = 0; r < R; r++) {
            for (c = 0; c < C; c++) {
                if (useRow) {
                    b[r][c] = (r%R2 == 0) ? 1000*(R2-1)-1 : -1000;
                } else {
                    b[r][c] = (c%C2 == 0) ? 1000*(C2-1)-1 : -1000;
                }
     
            }
        }
     
        // check sum
        cout << "Yes\n";
        for (r = 0; r < R; r++) {
            cout << b[r][0];
            for (c = 1; c < C; c++) {
                cout << ' ' << b[r][c];
            }
            cout << '\n';
        }
    }

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    string b; cin >> b;
    for (int i = 0; i < b.size(); ++i) {
        if (b[i] == 'A') cout << 'T';
        if (b[i] == 'T') cout << 'A';
        if (b[i] == 'C') cout << 'G';
        if (b[i] == 'G') cout << 'C';
    }
    cout << endl;
}

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

int main(){
	int a,b,c,x,count;
	count = 0;
	cin >> a >> b >> c;
	for (x = a; x <= b; x++){
		if (c%x == 0){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int N, A, B, C;
string S[1 << 18];
bool dp[100009][8][8][8];
tuple<int, int, int> pres[100009][8][8][8];

int main() {
	cin >> N >> A >> B >> C;
	for (int i = 1; i <= N; i++) cin >> S[i];
	
	if (A + B + C >= 8) {
		vector<char> L;
		for (int i = 1; i <= N; i++) {
			if (S[i] == "AB") {
				if (A > B) { A--; B++; L.push_back('B'); }
				else { A++; B--; L.push_back('A'); }
			}
			if (S[i] == "AC") {
				if (A > C) { A--; C++; L.push_back('C'); }
				else { A++; C--; L.push_back('A'); }
			}
			if (S[i] == "BC") {
				if (B > C) { B--; C++; L.push_back('C'); }
				else { B++; C--; L.push_back('B'); }
			}
			if (A < 0 || B < 0 || C < 0) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		for (int i = 0; i < L.size(); i++) cout << L[i] << endl;
	}
	else {
		dp[0][A][B][C] = true;
		for (int i = 1; i <= N; i++) {
			for (int j = 0; j <= A + B + C; j++) {
				for (int k = 0; k <= A + B + C; k++) {
					for (int l = 0; l <= A + B + C; l++) {
						if (dp[i - 1][j][k][l] == false) continue;
						if (S[i] == "AB") {
							if (k >= 1) { dp[i][j + 1][k - 1][l] = true; pres[i][j + 1][k - 1][l] = make_tuple(j, k, l); }
							if (j >= 1) { dp[i][j - 1][k + 1][l] = true; pres[i][j - 1][k + 1][l] = make_tuple(j, k, l); }
						}
						if (S[i] == "AC") {
							if (l >= 1) { dp[i][j + 1][k][l - 1] = true; pres[i][j + 1][k][l - 1] = make_tuple(j, k, l); }
							if (j >= 1) { dp[i][j - 1][k][l + 1] = true; pres[i][j - 1][k][l + 1] = make_tuple(j, k, l); }
						}
						if (S[i] == "BC") {
							if (l >= 1) { dp[i][j][k + 1][l - 1] = true; pres[i][j][k + 1][l - 1] = make_tuple(j, k, l); }
							if (k >= 1) { dp[i][j][k - 1][l + 1] = true; pres[i][j][k - 1][l + 1] = make_tuple(j, k, l); }
						}
					}
				}
			}
		}

		int cx = 0, cy = 0, cz = -1;
		for (int i = 0; i <= A + B + C; i++) {
			for (int j = 0; j <= A + B + C; j++) {
				for (int k = 0; k <= A + B + C; k++) {
					if (dp[N][i][j][k] == true) {
						cx = i; cy = j; cz = k;
					}
				}
			}
		}
		if (cz == -1) {
			cout << "No" << endl;
			return 0;
		}

		vector<char> L;
		for (int i = N; i >= 1; i--) {
			tuple<int, int, int> I = pres[i][cx][cy][cz];
			if (cx > get<0>(I)) L.push_back('A');
			if (cy > get<1>(I)) L.push_back('B');
			if (cz > get<2>(I)) L.push_back('C');
			cx = get<0>(I); cy = get<1>(I); cz = get<2>(I);
		}
		reverse(L.begin(), L.end());
		cout << "Yes" << endl;
		for (int i = 0; i < L.size(); i++) cout << L[i] << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int n, m;	cin >> n >> m;
	
	vector <int> a(n);
	for(int& x : a)	scanf("%d", &x);
	
	vector <vector <int>> Adj(n);
	
	while(m--)
	{
		int x, y;	scanf("%d%d", &x, &y);	x--, y--;
		
		Adj[x].push_back(y);
		Adj[y].push_back(x);
	}
	
	int Ans = 0;
	
	for(int x = 0; x < n; x++)
	{
		bool Ok = true;
		
		for(int y : Adj[x])	Ok &= (a[x] > a[y]);
		
		if(Ok)	Ans++;
	}
	
	cout << Ans << endl;
}

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

int main(){

    long long int k,b=0,c=9;

    cin >> k;

    vector<long long int> a(k+3);

    if(k<=9){
        cout << k << endl;
        return 0;
    }

    a.at(0)=1;
    a.at(1)=2;
    a.at(2)=3;
    a.at(3)=4;
    a.at(4)=5;
    a.at(5)=6;
    a.at(6)=7;
    a.at(7)=8;
    a.at(8)=9;

    while(1){

        if(a.at(b)%10!=0){
            a.at(c)=(a.at(b)%10-1)+a.at(b)*10;
            c++;
        }

            a.at(c)=(a.at(b)%10)+a.at(b)*10;
            c++;
        
        if(a.at(b)%10!=9){
            a.at(c)=(a.at(b)%10+1)+a.at(b)*10;
            c++;
        }

        b++;

        if(c>=k){
            break;
        }

    }

    cout << a.at(k-1) << endl;



}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unistd.h>
#define inf 1000000007LL
#define INF 1000000000000000007LL
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define st first
#define nd second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector< pair<int,int> >
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define LOG(x) (63-__builtin_clzll(x))
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i, n) for(int i=1; i<=(n); ++i)
#define endr cerr<<'\n'
#define endl '\n'
#ifdef DEBUG
#define pv(...) cerr<<'\n',dbg(#__VA_ARGS__, __VA_ARGS__)
#define ps(x) {cerr<<'\n'<<#x<<":\n:";for(auto _q:(x)){cerr<<_q<<" ";}cerr<<'\n';}
#define pa(x, xs) {cerr<<'\n'<<#x<<":\n:";for(int _q=0; _q<=(xs); ++_q){cerr<<x[_q]<<" ";}cerr<<'\n';}
#define pal(x, xs) {cerr<<'\n'<<#x<<":\n";for(int _q=0; _q<=(xs); ++_q){cerr<<_q<<": "<<setw(_q? 3-(int32_t)log10(_q):3)<<x[_q]<<'\n';}cerr<<'\n';}
#define ppii(x, xs) {cerr<<'\n'<<#x<<":\n";for(int _q=0; _q<=(xs); ++_q){cerr<<_q<<": "<<setw(_q? 6-(int32_t)log10(_q):6)<<x[_q].first<<" "<<setw(5)<<x[_q].second<<'\n';}cerr<<'\n';}
#define pm(x, xn, xm) {cerr<<'\n'<<#x<<":\n";for(int _qa=0; _qa<=(xn); ++_qa){for(int _qb=0; _qb<=(xm); ++_qb){cerr<<setw(6)<<x[_qa][_qb]<<" ";}cerr<<'\n';}cerr<<'\n';}
#else
#define cerr if(0)cout
#define pv(...) if(0)endr
#define ps(x) if(0)endr
#define pa(x, xs) if(0)endr
#define pal(x, xs) if(0)endr
#define ppii(x, xs) if(0)endr
#define pm(x, xn, xm) if(0)endr
#endif
using namespace std;
template<class T> void dbg(const char* xn, T x){cerr<<xn<<": "<<x<<"\n";} template<class T, class... TA> void dbg(const char* xn, T x, TA... t){while(*xn!=',')cerr<<*xn++;cerr<<": "<<x<<",";dbg(xn+1, t...);}
template<class T> inline bool upd_max(T &x, T y){return y>x?x=y,true:false;} template<class T> inline bool upd_min(T &x, T y){return y<x?x=y,true:false;}
const int N = 1000007;
#define int long long

int X, Y;


void no()
{
  cout<<-1;
  exit(0);
}

void solve()
{
  cin>>X>>Y;

  if (Y == 1) no();
  if (X == Y) no();
  if (X%Y == 0) no();
  cout<<X;
}

int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cout<<fixed<<setprecision(10);

  solve();

return 0;
}


Measured memory_bytes: 256
<?php
$str1 = trim(fgets(STDIN));
$str2 = trim(fgets(STDIN));

for($i = 0; $i < strlen($str1); $i++){
    if(isset($map1[$str1[$i]]) && $map1[$str1[$i]] != $str2[$i]){
        echo "No";exit;
    }
    if(isset($map2[$str2[$i]]) && $map2[$str2[$i]] != $str1[$i]){
        echo "No";exit;
    }
    $map1[$str1[$i]] = $str2[$i];
    $map2[$str2[$i]] = $str1[$i];
}
echo "Yes";


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

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<pair<int,int>> edges;
    F0R(i,n-1) {
        int u,v;
        cin >> u >> v;
        if(u>v)
            swap(u,v);
        edges.push_back({u,v});
    }
    ll tot=0;
    FOR(i,1,n+1)
        tot+=(i*1LL*(i+1))/2;
    F0R(i,n-1)
        tot-=edges[i].first*1LL*(n+1-edges[i].second);
    cout << tot;
    
    return 0;
}


Measured memory_bytes: 5336
#include <bits/stdc++.h>
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int N = 50;
const int INF = 2e9;
const double PI = acos(-1);

int arr[N+10], cnt[30];

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

    memset(cnt,0,sizeof(cnt));
    bool flag = 1;

    int n;
    sf("%d",&n);
    if(n > 24) flag = 0;

    arr[0] = 0;
    for(int i=1;i<=n;++i){
        sf("%d",&arr[i]);
        cnt[arr[i]] += 1;
        if(cnt[arr[i]] == 3) flag = 0;
        if(!flag) break;
    }

    if(!flag){
        pf("0\n");
        return 0;
    }

    sort(arr,arr+n+1);

    for(int i=1;i<=n;++i){
        if(i%2 == 1){
            arr[i] = 24-arr[i];
        }
    }
    sort(arr,arr+n+1);

    int minn = INF;
    for(int i=1;i<=n;++i){
        minn = min(minn, arr[i]-arr[i-1]);
    }

    minn = min(minn, 24-arr[n]);
    if(minn == 24) minn = 0;
    pf("%d\n",minn);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int N=100000+10;

int n;
int x[N],l[N];
struct Item {
    int l,r;
    bool operator<(const Item&o)const{
        return r<o.r;
    }
} it[N];
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&x[i],&l[i]);
        it[i]=(Item){x[i]-l[i],x[i]+l[i]};
    }
    sort(it+1,it+1+n);
    int las=-1e9,ans=0;
    for(int i=1;i<=n;i++){
        //printf("[%d,%d]\n", it[i].l,it[i].r);
        if(it[i].l>=las){
            las=it[i].r; ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  ll H, W, ans;
  cin >> H >> W;
  if(W%2==0) ans=H*W/2;
  else{
    if(H%2==0){
      ans=(H/2)*W;
    }
    else{
      ans=(W+1)/2+((H-1)/2)*W;
    }
  } 
  if(H==1||W==1) ans=1;
  cout << ans << endl; 
  
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, M, T, P;

int main() {
    while (true) {
        cin >> N >> M >> T >> P;
        if (N == 0 && M == 0 && T == 0 && P == 0) break;

        vvi A(N, vi(M, 1));
        for (int i = 0; i < T; i++) {
            vvi B(N, vi(M, 0));
            int d, c;
            cin >> d >> c;
            if (d == 1) {  // →
                for (int x = 0; x < N; x++) {
                    for (int y = 0; y < M; y++) {
                        if (x < c) {
                            B[c - x - 1][y] += A[x][y];
                        } else {
                            B[x - c][y] += A[x][y];
                        }
                    }
                }
            } else {  // ↑
                for (int x = 0; x < N; x++) {
                    for (int y = 0; y < M; y++) {
                        if (y < c) {
                            B[x][c - y - 1] += A[x][y];
                        } else {
                            B[x][y - c] += A[x][y];
                        }
                    }
                }
            }
            A = B;
        }

        for (int i = 0; i < P; i++) {
            int x, y;
            cin >> x >> y;
            cout << A[x][y] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int M=1e3+3;
char s[M][M];
int sum[M][M],book[M],a[M];
int main(){
    int n,m,h;
    scanf("%d%d%d",&n,&m,&h);
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            sum[i][j]=sum[i-1][j]+(s[i][j]=='1');
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            sum[i][j]+=sum[i][j-1];
    int ans=inf;
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<=m;j++)
            book[j]=0;
        int tot=0;
        a[tot++]=0;
        for(int j=0;j<10;j++)
            if(i&(1<<j))
                a[tot++]=j+1;
        a[tot++]=n;
        int k=1;
        int las=0;
        int res=0;
        int sign=0;
        while(k<=m){
            int flag=0;
            while(k<=m){

                for(int j=1;j<tot;j++){
                    int l=a[j-1],r=a[j];
                    if(sum[r][k]-sum[r][las]-sum[l][k]+sum[l][las]>h)
                        flag=1;
                }
                if(flag)
                    break;
                k++;
            }
            las=k-1;
            if(flag)
                res++;
            for(int j=1;j<tot;j++){
                    int l=a[j-1],r=a[j];
                    if(sum[r][k]-sum[r][las]-sum[l][k]+sum[l][las]>h)
                        sign=1;
                }
            if(sign)
                break;
        }
        if(!sign)
            ans=min(ans,res+tot-2);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 2304