akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int main(){
    int n,p = 1,pow = 0,plu = 0;
    int64_t m = 10000000;
    cin >> n;
    int x[n];
    for(int i = 0;i < n;i++){
        cin >> x[i];
    }
    for(int i = 0;i < n;i++){
        pow += x[i]*x[i];
        plu += x[i];
    }
    for(;p <=100;p++){
        m = min(m,(int64_t)(pow-2*p*plu+p*p*n));
    }
    cout << m;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
using namespace std;
using ll =long long;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
int main() {
	int K;
	ll sum=0;
	cin >> K;
	for (int i = 1; i <= K; i++) {
		for (int j = i; j <= K; j ++) {
			for (int k = j; k <= K; k++) {
				if (i == j && j == k) {
					sum += gcd(gcd(i, j), k);
				}
				if (i == j && j != k) {
					sum += 3*gcd(gcd(i, j), k);

				}
				if (i != j && j == k) {
					sum += 3 * gcd(gcd(i, j), k);

				}

				if (i != j && j != k) {
					sum += 6*gcd(gcd(i, j), k);

				}
			}

	}
	
	}
	cout << sum;
}

Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

ll dp[105][105][305];
pair<ll, ll> g[105];


int main()
{
	ll N, W;
	cin >> N >> W;

	ll w0 = 0;
	int offset = 0;
	REP(i, N)
	{
		ll w, v;
		cin >> g[i].first >> g[i].second;
		if (i == 0)
		{
			w0 = g[i].first;
		}
		g[i].first -= w0;
		offset += g[i].first;
	}

	//memset(dp, 0, sizeof(dp));

	REP(i, N)
	{
		for (int j = 1; j <= i + 1; ++j)
		{
			REP(k, j * 3 + 1)
			{
				ll wi = g[i].first;
				if (k - wi < 0 || j*w0 + k>W)
				{
					dp[i + 1][j][k] = dp[i][j][k];
					continue;
				}
				dp[i + 1][j][k] = std::max(dp[i][j][k], dp[i][j - 1][k - wi] + g[i].second);
			}
		}
	}

	ll max = 0;
	REP(i, N + 1)
	{
		REP(j, offset + 1)
		{
			max = std::max(max, dp[N][i][j]);
		}
	}

	cout << max << endl;
	return 0;
}

Measured memory_bytes: 23552
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  ll a;
  ld b;
  cin >> a >> b;
  ll ans = a*b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <iterator>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
int GCD(int A,int B){
  if(B==0){
    return A;
  }else{
    return GCD(B,A%B);
  }
}
int main(){
  int W,H,C;
  cin>>W>>H>>C;
  int N=GCD(W,H);
  cout<<(W/N)*(H/N)*C<<endl;
  return 0;
}


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

int MAX_INT = 1e9;

int N, A, B, C;
int l[1000];

int dfs(int cur, int a, int b, int c) {
  if(cur == N) {
    if(min(a, min(b, c)) > 0) {
      return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }
    else {
      return MAX_INT;
    }
  }

  int ret0 = dfs(cur + 1, a, b, c);
  int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
  int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
  int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;

  return min(min(ret0, ret1), min(ret2, ret3));
}

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

  cin >> N >> A >> B >> C;
  for(int i = 0; i < N; i++) {
    cin >> l[i];
  }

  cout << dfs(0, 0, 0, 0) << endl;

  return 0;
}


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

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

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	priority_queue<pair<int,int>> Q;
	rep(i,n){
		int a; scanf("%d",&a);
		Q.emplace(a,1);
	}
	rep(i,m){
		int b,c; scanf("%d%d",&b,&c);
		Q.emplace(c,b);
	}

	long long ans=0;
	while(n>0){
		auto x=Q.top(); Q.pop();
		int val=x.first,num=x.second;
		ans+=1LL*val*min(num,n);
		n-=min(num,n);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int a,b;
    cin>>a>>b;
    if((a*b)%2==0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

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

    sort(a, a + N);
    vector<pair<int, int>> v;
    int tmp = 1;
    for(int i = 1; i < N; i++) {
        if(a[i - 1] != a[i]) {
            v.push_back({a[i - 1], tmp});
            tmp = 1;
        } else
            tmp++;
    }
    v.push_back({a[N - 1], tmp});

    if(v.size() > 3)
        cout << "No";
    else if(v.size() == 3 && N % 3 == 0) {
        if((v[0].first ^ v[1].first) == v[2].first && v[0].second == N / 3 && v[1].second == N / 3 && v[2].second == N / 3) {
            cout << "Yes";
        } else
            cout << "No";
    } else if(v.size() == 2 && N % 3 == 0 && v[0].second == N / 3 && v[0].first == 0)
        cout << "Yes";
    else if(v.size() == 1 && v[0].first == 0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
using namespace std;
#define max_n 100
#define INF 100000000

int main()
{
    char a[max_n];
    scanf("%s",a);
    size_t r=strlen(a);
    stack<char> s;
    stack<char> t;
    for(int i=0;i<r;i++){
        if(a[i]=='1'){
            s.push(a[i]);
        }else if(a[i]=='0'){
            s.push(a[i]);
        }else{
            if(!s.empty()){
                s.pop();
            }
        }
    }
    int q=s.size();
    for(int j=0;j<q;j++){
        t.push(s.top());
        s.pop();
    }
    for(int d=0;d<q;d++){
        cout<<t.top();
        t.pop();
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
Imports System
Class C
	Shared Function Main() As Integer

		Dim n As Integer = Integer.Parse(Console.ReadLine())
		Dim inputs() As String
		Dim data(n) As Integer
		inputs = Console.ReadLine().Split()
		For i As integer = 0 To n-1
			data(i) = Integer.Parse(inputs(i))
		Next

		Dim ans As Integer = -1
		For pos As Integer = 1 To 100
			Dim sum As Integer = 0
			For i As Integer = 0 To n-1
				sum += (data(i)-pos)*(data(i)-pos)
			Next i
			
			If ans = -1
				ans = sum
			Else
				If ans > sum
					ans = sum
				End If
			End If
		Next

		Console.WriteLine(ans)
		
		Return 0
	End Function
End Class


Measured memory_bytes: 13140
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
left=0
right=0
s=a[0]
answer = 0
while True:
    if left >= N or right >= N:
        break
    if s <= x:
        if s == x:
            answer = max(answer,right-left+1)
        if s < x:
            if right-left < N-1:
                answer = max(answer,right-left+1)
        right += 1
        if right < N:
            s += a[right]
        continue
    if s > x:
        s -= a[left]
        left += 1
        continue
print(answer)

Measured memory_bytes: 3064
<?php

fscanf(STDIN, "%d %d %d %d", $a_info, $a_math, $a_sci, $a_eng);
fscanf(STDIN, "%d %d %d %d", $b_info, $b_math, $b_sci, $b_eng);

$a = [$a_info, $a_math, $a_sci, $a_eng];
$b = [$b_info, $b_math, $b_sci, $b_eng];

echo max(array_sum($a), array_sum($b)), "\n";


Measured memory_bytes: 9192
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr int kNum = 1e5 + 1;
enum Color{
  kUnknown = 99, kBlack = 0, kWhite = 1
};

struct Edge {
  int src;
  int dst;
  int weight;
};

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

  Color node[kNum];
  for (int i = 1; i <= N; ++i) node[i] = kUnknown;

  std::vector<Edge> edges[kNum], redges[kNum];
  for (int i = 0; i < N; ++i) {
    Edge e; std::cin >> e.src >> e.dst >> e.weight;
    edges[e.src].push_back(e);
    redges[e.dst].push_back(e);
  }

  node[1] = kBlack;
  std::queue<int> que;
  que.push(1);

  while(!que.empty()) {
    int index = que.front();
    que.pop();

    for (const auto& e : edges[index]) {
      int target = e.dst;
      int weight = e.weight;
      if (node[target] != kUnknown) continue;

      que.push(target);
      if (weight%2 == 0) {  // same
        node[target] = node[index];
      } else {
        node[target] = (node[index] == kBlack) ? kWhite : kBlack;
      }
    }

    for (const auto& e : redges[index]) {
      int target = e.src;
      int weight = e.weight;
      if (node[target] != kUnknown) continue;

      que.push(target);
      if (weight%2 == 0) {  // same
        node[target] = node[index];
      } else {
        node[target] = (node[index] == kBlack) ? kWhite : kBlack;
      }
    }
  }

  for (int i = 1; i <= N; ++i) {
    std::cout << node[i] << std::endl;
  }
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  auto good = [&](long long mask) {
    for (int i = 0; i < n; i++) {
      vector<int> can(51, false);
      can[a[i]] = true;
      for (int j = 50; j >= 0; j--) {
        if (can[j]) {
          for (int u = 1; u <= 50; u++) {
            if (mask & (1LL << u)) {
              can[j % u] = true;
            }
          }
        }
      }
      if (!can[b[i]]) {
        return false;
      }
    }
    return true;
  };
  long long mask = (1LL << 51) - 1;
  if (!good(mask)) {
    cout << -1 << '\n';
    return 0;
  }
  for (int bit = 50; bit >= 0; bit--) {
    if (good(mask ^ (1LL << bit))) {
      mask ^= (1LL << bit);
    }
  }
  cout << mask << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long

using namespace std;

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

  char c; cin >> c;

  if (c == 'A') cout << 'T';
  if (c == 'T') cout << 'A';
  if (c == 'C') cout << 'G';
  if (c == 'G') cout << 'C';
  cout << endl;

  return 0;
}


Measured memory_bytes: 768
while True:
 H,W = map(int,input().split())
 if H==0 and W==0:break
 for j in range(H):
     for i in range(W):
         if i==0 or i==W-1 or j==0 or j==H-1:
          print("#",end="")
         else:
          print(".",end="")
     print()
 print()


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

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

    double k = pow(a, 2) + pow(b, 2);
    double m_t = (double)m * 6;
    double h_t = 30 * h + 0.5 * m;
    double pi = acos(-1);
    double t = 0.0;
    if(m_t >= h_t){
        t = m_t - h_t;
    }else{
        t = h_t - m_t;
    }
    
    if(t > 180){
        t = 360 - t;
    }

 
    k -= 2 * a * b * cos((pi * t) / 180.0);
    double ans = sqrt(k);

    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 4192
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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

int dp[3100][3100];
int main(){
    vector<P> x;
    int N, T;
    cin >> N >> T;
    for(int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        x.emplace_back(P(a, b));
    }
    sort(x.begin(), x.end());
    for(int i = 0; i < 3100; i++){
        for(int j = 0; j < 3100; j++){
            dp[i][j] = 0;
        }
    }

    int res = 0;
    for(int i = 0; i < N; i++){
        int a = x[i].fs, b = x[i].sc;
        for(int j = 0; j < T; j++){
            dp[i+1][j] = dp[i][j];
        }
        for(int j = 0; j < T; j++){
            if(j + a < T){
                int val = max(dp[i][j+a], dp[i][j] + b);
                dp[i+1][j+a] = max(dp[i+1][j+a], val);
                res = max(res, dp[i+1][j+a]);
            }
            else{
                int val = dp[i][j] + b;
                res = max(res, val);
            }
        }
    }
    cout << res << endl;


    return 0;
}




Measured memory_bytes: 37888
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid +i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for(int k = left; k < right; k++) {
        cnt++;
        if(L[i] <= R[j]) A[k] = L[i++];
        else A[k] = R[j++];
    }
}

void mergeSort(int A[], int n, int left, int right) {
    if(left+1 < right) {
        int mid = (right + left) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main() {
    int A[MAX], n, i;
    cnt = 0;
    
    cin >> n;
    for(i=0;i<n;i++) cin >> A[i];
    mergeSort(A, n, 0, n);
    
    for( i = 0; i < n; i++) {
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    
    cout << cnt << endl;
    
    return 0;
}



Measured memory_bytes: 6988
def palindrome(s):
    #print(s)
    n = len(s)
    for i in range(n//2):
        if s[i] != s[n-1-i]:
            return False

    return True

def main():
    s = input()
    if not palindrome(s):
        print('No')
        return

    n = len(s)
    s1 = s[:(n-1)//2]
    if not palindrome(s1):
        print('No')
        return

    s2 = s[((n+3)//2)-1:]
    if not palindrome(s2):
        print('No')
        return

    print('Yes')
    


main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;


int main()
{
    ll N;
    ll* L;
    cin >> N;
    L = new ll[N];
    ll total = 0;
    ll max = 0;
    for(ll i = 0; i < N; i ++){
        cin >> L[i];
        total += L[i];
        if(max < L[i]){
            max = L[i];
        }
    }
    
    if(total - max > max){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;

    ll res = 0;
    for (ll i = k; i <= n+1; ++i) {
        res += i * (n - i + 1) + 1;
        res %= MOD;
    }
    cout << res << endl;
}

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

#define ll  long long


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int a,b;
    cin>>a>>b;

    for(int i=1;i<=1250;i++){
        int x= i*8/100,y=i*10/100;
        if(x<1&& y<1)continue;
        if(x==a &&y==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

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

int main(){
    long x,y;
    cin >> x >> y;
    if(x==y) cout << 0 << endl;
    else if(y==-x||y==x+1) cout << 1 << endl;
    else cout << min({abs(x+y+1),abs(x-y),abs(x+y-1),abs(x-y+2)})+2 << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
 int n;
 cin >> n;
 map<string,int> mp;
 rep(i,n){
   string s;
   cin >> s;
   mp[s]++;
 }
 int m = -1;
 for(auto itr = mp.begin(); itr != mp.end(); itr++){
   m = max(m,itr->second);
 }
 vector<string> a;
 for(auto itr = mp.begin(); itr != mp.end(); itr++){
   if(itr->second == m) a.push_back(itr->first);
 }
 sort(a.begin(),a.end());
 rep(i,a.size()) cout << a.at(i) << endl;
}

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

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

  int a, b, c;
  cin >> a >> b >> c;

  for (int i = 1; i <= b; ++i) {
    if (a * i % b == c % b) {
      cout << "YES" << "\n";
      return 0;
    }
  }

  cout << "NO" << "\n";
}


Measured memory_bytes: 3652
N,M=list(map(int,input().split()))
W=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
BOX=[[1,1]]
BOX.extend([[1,0] for _ in range(N)])
for i in range(M):
    BOX[W[i][0]][0]=BOX[W[i][0]][0]-1
    BOX[W[i][1]][0]=BOX[W[i][1]][0]+1
    if(BOX[W[i][0]][1]==1):
        BOX[W[i][1]][1]=1
        if(BOX[W[i][0]][0]==0):
            BOX[W[i][0]][1]=0
print(sum(list(map(lambda x:x[:][1],BOX))))
    


Measured memory_bytes: 36024
#include<iostream>
using namespace std;
int main()
{
  	int a,b,c,d;
  	cin>>a>>b>>c>>d;
  if(a>=b)
    if(c>=d)
      cout<<b+d;
  	else
      cout<<b+c;
  else
    if(c>=d)
      cout<<a+d;
  	else
      cout<<a+c;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int H,W; cin >> H >> W;
    vector<vector<char> > a(H,vector<char>(W));
    for(int i=0;i<H;i++) for(int j=0;j<W;j++) cin >> a[i][j];

    vector<bool> is_height(W,false);
    vector<bool> is_width(H,false);

    //縦のチェック(1列ずつみる)
    for(int j=0;j<W;j++){
        for(int i=0;i<H;i++){
            if(a[i][j] == '#'){
                is_height[j] = true;
                break;
            }
        }
    }

    //横のチェック(1行ずつみる)
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(a[i][j] == '#'){
                is_width[i] = true;
                break;
            }
        }
    }


    for(int i=0;i<H;i++) {
        if(is_width[i] == false)continue;
        for(int j=0;j<W;j++){
            if(is_height[j]==false) ;
            else
                cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}
    

Measured memory_bytes: 256
try:
    while True:
        x=list(sorted(map(int, input().split())))
        a=x[0]
        b=x[1]
        while b%a != 0:
            c=a
            a=b%a
            b=c
        print(a, x[0]*x[1]//a)
except EOFError:
    pass

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

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    string s;
    cin >> s;
    sort(s.begin(), s.begin()+4);
    if(s.at(0) == s.at(1) && s.at(1) != s.at(2) && s.at(2) == s.at(3)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main(){
    int n,k,i,max=0,head=0,tail=0;scanf("%d%d",&n,&k);
    int a[n+1],sum[n+1];for(i=1;i<=n;i++){scanf("%d",&a[i]);}


    for(i=1;i<=n;i++){sum[i]=0;}
    for(i=1;i<=k;i++){sum[1]+=a[i];}//sumは隣接k項の和
    head=k;tail=1;//先頭と末尾の初期化
    max=sum[1];
    
    for(i=2;i<=n-k+1;i++){//漸化式で求める->a[]の先頭を移動して足し、a[]の末尾を引いてから移動させる。
        sum[i]=sum[i-1]+a[++head]-a[tail++];
        if(sum[i]>max){max=sum[i];}
    }

    printf("%f\n",(max+k)/2.0);//期待値計算
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    long long int *a=new long long int[n+1];
    long long int *b=new long long int[n];
    for(long long int i=0;i<n+1;i++)
    {
        cin>>a[i];
    }
    for(long long int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    long long int sum=0;
    for(long long int i=0;i<n;i++)
    {
        if(b[i]>=a[i])
        {
            sum+=a[i];
            b[i]=b[i]-a[i];
            if(b[i]>=a[i+1])
            {
                sum+=a[i+1];
                b[i]=b[i]-a[i+1];
                a[i+1]=0;
            }
            else
            {
                a[i+1]=a[i+1]-b[i];
                sum+=b[i];
                b[i]=0;
            }
            
        }
        else
        {
            a[i]=a[i]-b[i];
            sum+=b[i];
        }   
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
int main(){
  ll N,t;
  cin >> N >> t;
  if(N < t)cout << "0" << endl;
  else cout << N - t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,string> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int dp0[n];
  int dp1[n];
  dp0[0]=min(s[0]-'0',11-(s[0]-'0'));
  dp1[0]=min(s[0]-'0'+1,10-(s[0]-'0'));
  rep(i,1,n){
    int x=s[i]-'0';
    dp0[i]=min(dp0[i-1]+x,dp1[i-1]+10-x);
    dp1[i]=min(dp0[i-1]+x+1,dp1[i-1]+9-x);
  }
  cout<<dp0[n-1]<<endl;
}

Measured memory_bytes: 9220
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}

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

int main(){
	vector<char> word;
	char ch;

	while(cin>>ch) word.push_back(ch);

	for(int i=0;i<word.size();i++){
		cout<<(word[i]>67 ? char(word[i]-3) : char(word[i]+23));
	}

	cout<<endl;
	return 0;
}

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

int main()
{
    ll W, H, X, Y;
    cin >> W >> H >> X >> Y;

    if (X * 2 == W && Y * 2 == H)
    {
        cout << fixed << setprecision(10) << (W * H) / 2.0 << " " << 1 << endl;
        return 0;
    }

    cout << fixed << setprecision(10) << (W * H) / 2.0 << " " << 0 << endl;

    return 0;
}


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

using ll = long long;

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

  int len = S.size();

  ll ans{};
  for (int i{}; i < (1 << (len-1)); ++i) {
    ll n = S[0] & 0xF;
    for (int j{}; j < (len-1); ++j) {
      if (i & (1 << j)) {
        ans += n;
        n = 0;
      }
      n *= 10;
      n += S[j+1] & 0xF;
    }
    ans += n;
  }

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


Measured memory_bytes: 256
k,n=map(int,input().split())
a=list(map(int,input().split()))
max_d=0
for i in range(n):
    x=0
    if i==n-1:
        if a[0]==0:
            x=k-a[i]
        else:
            x=k-a[i]+a[0]
    else:
        x=a[i+1]-a[i]
    if x>max_d:
        max_d=x
print(k-max_d)

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

using namespace std;

#define MAX 200005
#define INF (1<<26)

int segN=1000000;
struct data{
    int value;
    data* ch[2];
    
    void init(){
        value=INF;
        ch[0]=new data;
        ch[1]=new data;
        ch[0]->ch[0]=NULL;
        ch[1]->ch[0]=NULL;
    }
    
    void set(int i, int x, int l, int r){
        int m=(l+r)/2;
        if(ch[0]==NULL)init();
        if(i<l || r<=i)return;
        if(x<value)value=x;
        if(r-l==1)return;
        ch[0]->set(i,x,l,m);
        ch[1]->set(i,x,m,r);
    }
    
    void set(int i,int x){
        set(i,x,0,segN);
    }
    
    int min(int a,int b,int l,int r){
        int m=(l+r)/2;
        if(ch[0]==NULL)init();
        if(b<=l || r<=a)return INF;
        if(a<=l && r<=b)return value;
        int lc=ch[0]->min(a,b,l,m);
        int rc=ch[1]->min(a,b,m,r);
        return (lc<rc?lc:rc);
    }
    
    int min(int a,int b){
        if(0<=a&&a<b)return min(a,b,0,segN);
        else return INF;
    }
};

int rak[MAX+1];
int tmp[MAX+1];
int n,k;

bool compare_sa(int i,int j){
    if(rak[i]!=rak[j])return (rak[i]<rak[j]);
    else{
        int ri=(i+k<=n?rak[i+k]:-1);
        int rj=(j+k<=n?rak[j+k]:-1);
        return ri < rj;
    }
}

void construct_sa(string s,int *sa){
    n=s.size();
    for(int i=0;i<=n;i++){
        sa[i]=i;
        rak[i]=(i<n?s[i]:-1);
    }
    for(k=1;k<=n;k*=2){
        sort(sa,sa+n+1, compare_sa );
        tmp[sa[0]]=0;
        for(int i=1;i<=n;i++){
            tmp[sa[i]]=tmp[sa[i-1]]+
            (compare_sa(sa[i-1],sa[i])?1:0);
        }
        for(int i=0;i<=n;i++)rak[i]=tmp[i];
    }
}


int search(string &target,int *sa,string &s){
    int l=0,r=n,m;
    int size=target.size(),res;
    while(l<r){
        m=(l+r)/2;
        res=s.compare(sa[m],size,target);
        if(res>=0)r=m;
        else l=m+1;
    }
    if(s.compare(sa[l],size,target)<0)return n+1;
    return l;
}

int search2(string &target,int *sa,string &s){
    int l=0,r=n,m;
    int size=target.size(),res;
    while(l<r){
        m=(l+r)/2;
        res=s.compare(sa[m],size,target);
        if(res>0)r=m;
        else l=m+1;
    }
    if(s.compare(sa[l],size,target)<=0)return n+1;
    return l;
}

data T,T2;
string s,s2;
string x,y;
int m;
int sa[MAX+1];
int sa2[MAX+1];

int main(){
    T.init();
    T2.init();
    
    cin>>s;
    s2=s;
    reverse(s2.begin(),s2.end());
    
    construct_sa(s2,sa2);
    construct_sa(s,sa);
    
    for(int i=0;i<=n;i++){
        T.set(i,sa[i]);
        T2.set(i,sa2[i]);
    }
    
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        reverse(y.begin(),y.end());
        int xl=search(x,sa,s),xr=search2(x,sa,s);
        int yl=search(y,sa2,s2),yr=search2(y,sa2,s2);
        int xs=x.size();
        int X=T.min(xl,xr);
        int Y=T2.min(yl,yr);
        if(Y!=INF)Y=n-Y;
        
        if(Y<X+xs)cout<<0<<endl;
        else if(X==INF||Y==INF)cout<<0<<endl;
        else cout<<Y-X<<'\n';
        
    }
    
    return 0;
}

Measured memory_bytes: 55004
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define int long long


class ANewYear {
public:
	void solve(std::istream& in, std::ostream& out) {
    int m;
    in >> m;
    out << 24 + (24 - m) << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	ANewYear solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3624
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    double N = Double.parseDouble(S[0]+S[1]);
    int M = (int)Math.sqrt(N);
    String ans = (int)N == M*M ? "Yes" : "No";
    System.out.println(ans);
  }
}

Measured memory_bytes: 21588
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n=ni()
h=nl()

dp=[10**5]*(n+1)

dp[0]=0

dp[1]=abs(h[1]-h[0])

for i in range(2,n):
  dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))


print(dp[n-1])


Measured memory_bytes: 84440
//周♂雨扬是最强的！！！
//大佬祝您AK
//沈哲♂贝是最强的！！！
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<fstream>
using namespace std;
//ifstream fin(.in);
//ofstream fout(.out);
long long t;
long long x,xx=1;
long long gcd(long long a,long long b){
	if(!b){
		return a;
	}
	return gcd(b,a%b);
}
int main(){
	cin>>t;
	while(t--){
		cin>>x;
		long long gcdd=gcd(xx,x);
		xx=xx/gcdd*x;
	}
	cout<<xx<<endl;
	return 0;
}
//沈♂哲贝是最强的！！！
//大佬祝您AK
//周♂雨扬是最强的！！！

Measured memory_bytes: 256
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){int x,a,b;
cin>>x>>a>>b;
if(fabs(x-a)<fabs(x-b))cout<<"A"<<"\n";
else cout<<"B"<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<int> M;
  int cnt = 0;
  for (int i = 1; i < N; i++) {
    if (S[i-1] == S[i]) {
      cnt++;
    } else {
      cnt++;
      M.push_back(cnt);
      cnt = 0;
    }
  }
  M.push_back(cnt+1);
  for (int i = 0; i < M.size(); i+=2) {
    int r = M[i];
    int l = M[i+1];
    int rnum = ((r+1)/2) + (l/2);
    int lnum = r + l - rnum;
    for (int j = 0; j < r - 1; j++) {
      cout << 0 << " ";
    }
    cout << rnum << " " << lnum << " ";
    for (int j = 0; j < l - 1; j++) {
      cout << 0 << " ";
    }
  }
  cout << endl;
  return 0;
}


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

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> A;
	for(int a = 0; a < N; a++){
		int temp;
		cin >> temp;
		A.push_back(temp);
	}
	sort(A.begin(), A.end());
	int sum = 0;
	for(int a = 0; a < K; a++)
		sum += A[a];
	cout << sum << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main() {

	int n, k,temp;
	long long d=0;
	cin >> n >> k;

	int* p = new int[n];

	for (int i = 0; i < n; i++) {

		cin >> p[i];
	}
	
	for (int i = 0; i < n; i++) {

		for (int t = i+1; t < n; t++) {

			if (p[i] > p[t])
			{
				temp = p[i];
				p[i] = p[t];
				p[t] = temp;
			}

		}
	}

	for (int i = 0; i < k; i++) {
	 
		d = d + p[i];
	}

	cout << d;


}

Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(void){
    int n, max, n_max = 0;
    cin >> n;
    int a[n], b[n];
    for(int i = 0; i < n; ++i){ 
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b+n);
    max = b[n-1];
    n_max = b[n-2];
    if(n_max == 0) n_max = max;
    for(int i = 0; i < n; ++i){
        if(a[i] != max) {
            cout << max << "\n";
        } else {
            cout << n_max << "\n";
        }
    }
}


Measured memory_bytes: 3200
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func solve(N int, s []byte) {
	ans := 0
	c := make([][3]int, N)
	r := 0
	g := 0
	b := 0
	for i := N - 1; i >= 0; i-- {
		switch s[i] {
		case 'R':
			r++
		case 'G':
			g++
		case 'B':
			b++
		}
		c[i][0] = r
		c[i][1] = g
		c[i][2] = b
	}
	for i := 0; i < N; i++ {
		switch s[i] {
		case 'R':
			// out("R", c[i][1], c[i][2])
			ans += c[i][1] * c[i][2]
		case 'G':
			// out("G", c[i][0], c[i][2])
			ans += c[i][0] * c[i][2]
		case 'B':
			// out("B", c[i][0], c[i][1])
			ans += c[i][0] * c[i][1]
		}
	}
	// out(ans)
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			k := j + j - i
			if j < N && k < N {
				if s[i] != s[j] && s[j] != s[k] && s[i] != s[k] {
					ans--
				}
			}
		}
	}

	out(ans)
}

func solve2(N int, s []byte) {
	ans := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if s[i] == s[j] {
				continue
			}
			for k := j + 1; k < N; k++ {
				if s[i] == s[k] || s[j] == s[k] {
					continue
				}
				if j-i != k-j {
					ans++
				}
			}
		}
	}
	out(ans)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()
	s := getString()

	// N := 4000
	// s := make([]byte, N)
	// for i := 0; i < N; i++ {
	// 	switch i % 3 {
	// 	case 0:
	// 		s[i] = 'R'
	// 	case 1:
	// 		s[i] = 'G'
	// 	case 2:
	// 		s[i] = 'B'
	// 	}
	// }

	solve(N, []byte(s))

}


Measured memory_bytes: 1872
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cstdio>
#include <string>
#include <utility>
#include <iomanip>
#include <numeric>
#include <functional>
#include <list>
#include <regex>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <climits>
using namespace std;


typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

#define pb(c,num) c.push_back(num)

// loops
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define tr(c, it) \
for(auto it = c.begin(); it != c.end(); ++it)


#define all(c) c.begin(), c.end()

// set,map
#define present(c, element) (c.find(element) != c.end())
//vectors
#define cpresent(c, element) (find(all(c), element) != c.end())




int main(){
    std::ios_base::sync_with_stdio(false);

//    ifstream input;
//    ofstream output;
//    input.open("input.in");
//    output.open("output.out");
    

    int n;
    cin >> n;
    map<int, int> k;

    int a;
    rep(i,n){
        cin >> a;
        k[a] = i+1;
    }

    for(auto x: k){
        cout<< x.second << " ";
    }
//    input.close();
//    output.close();
//
    
    return 0;
}
    


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define eprintf(...) fprintf(stderr,__VA_ARGS__)

int I,O,T,J,L,S,Z;

int main(){
	scanf("%d%d%d%d%d%d%d",&I,&O,&T,&J,&L,&S,&Z);
	ll ans=0LL+I/2*2+J/2*2+L/2*2;
	if(I&&J&&L) ans=max(ans,3LL+(I-1)/2*2+(J-1)/2*2+(L-1)/2*2);
	ans+=O;
	printf("%lld\n",ans);
}

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

int main(){
    int X=0;
    int Y=0;

    cin>>X;
    cin>>Y;
    int ans=abs(abs(X)-abs(Y));


    if(Y>X&&X>=0||Y>X&&0>=Y){
    }
    
    
    
    
    else if(X>Y&&Y>0||0>X&&X>Y){
        ans+=2;
    }else{
        ans+=1;
    }

    cout<<ans<<endl;

    return 0;
}

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

int main() {
  char S[4];
  cin >> S;
  int num = atoi(S);
  int top = num / 100;
  int bottom = num % 100;
  bool top_is_y, bottom_is_y;
  bool top_is_m, bottom_is_m;
  if (0 <= top && top <= 99) {
    top_is_y = true;
    if (0 < top && top <= 12) {
      top_is_m = true;
    }
    else {
      top_is_m = false;
    }
  }
  else {
    top_is_y = false;
    top_is_m = false;
  }
  if (top_is_y && !top_is_m) {
    if (0 < bottom && bottom <= 12)
      cout << "YYMM" << endl;
    else
      cout << "NA" << endl;
  }
  else if (top_is_y && top_is_y) {
    if (0 < bottom && bottom <= 12)
      cout << "AMBIGUOUS" << endl;
    else
      cout << "MMYY" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int  long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 998244353
// order_of_key and *find_by_order
#define N 100001
int32_t main() {
	fast;
	int n;
	cin >> n;
	int rem = ceil(n / 1000.0);
	cout << rem * 1000 - n;


}











Measured memory_bytes: 3768
#include<stdio.h>

int main(){
  int ns,nt,i,j;
  int count=0;

  scanf("%d",&ns);
  int S[ns];
  for(i=0 ; i<ns ; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&nt);
  int T[nt];
  for(j=0 ; j<nt ; j++){
    scanf("%d",&T[j]);
  }

  for(i=0 ; i<nt ; i++){
    for(j=0 ; j<ns ; j++){
if(S[j] == T[i]){
  count++;
  break;
}
}
}

printf("%d\n",count);


return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int x;
    cin >> x;
    cout << (x < 1200 ? "ABC" : "ARC") << endl;

    return 0;
}

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

int main()
{
	int arr[6];
	for(int i=0; i<6; i++)
	{
		cin>>arr[i];
	}
	int sa = arr[4] - arr[0];
	if(sa<=arr[5])
	{
		cout<< "Yay!" <<endl;
	}
	else
	{
		cout<< ":(" << endl;
	
	}
}



Measured memory_bytes: 256
def readinput():
    x,n=list(map(int,input().split()))
    if (n>0):
        p=list(map(int,input().split()))
    else:
        p=[]
    return x,n,p

def main(x,n,p):
    if (len(p)==0):
        return x

    mindist=102
    nearest=0
    for y in range(0,102):
        if y in p:
            continue
        if abs(x-y) < mindist:
            mindist = abs(x-y)
            nearest=y        
    return nearest

if __name__=='__main__':
    x,n,p=readinput()
    ans=main(x,n,p)
    print(ans)


Measured memory_bytes: 9212
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    long n = sc.nextLong();

    int r = (int) Math.sqrt(n);

    long min = Long.MAX_VALUE;
    for (int i = 1; i <= r; i++) {
      if (n % i == 0) {
        long j = n / i;
        long val = i - 1 + j - 1;
        min = Math.min(min, val);
      }
    }
    os.println(min);
  }

}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	string s, t;
	cin >> s >> t;

	cout << t << s << endl;


	return 0;

}

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

using namespace std;
vector<int> Prime;
bool isPrime[10100];

void PrimeCalc()
{
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < 10100; ++i)
	{
		if(isPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 10100; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n, n)
	{
		int count = 0;
		for(int i = 0; i < Prime.size(); ++i)
		{
			int pos = i + 1;
			int sum = Prime[i];
			while(sum < n)
			{
				sum += Prime[pos];
				++pos;
			}
			if(sum == n)
			{
				++count;
			}
		}
		cout << count << endl;
	}
}

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

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

int asc(const void *, const void *);

int asc(const void *a, const void *b){
  return *(long int *)a - *(long int *)b;
}

struct operation {
  long int card;
  long int integer;
};

int asc2(const void *, const void *);

int asc2(const void *a, const void *b){
  struct operation *A = (struct operation *)a;
  struct operation *B = (struct operation *)b;
  return A->integer - B->integer;
}


int
main(int argc, char *argv[])
{
  long int n, m, a[100000], b, c;
  struct operation op[100000];
  scanf("%ld %ld", &n, &m);
  for(int i = 0; i < n; i++)scanf("%ld", &a[i]);
  for(int i = 0; i < m; i++){
    scanf("%ld %ld", &b, &c);
    op[i].card = b;
    op[i].integer = c;
  }
    

  qsort(a, n, sizeof(long int), asc);

  qsort(op, m, sizeof(struct operation), asc2);

  long int j = 0, cnt;

  for(int i = m - 1; i >= 0; i--){
    cnt = 0;
    while(a[j] < op[i].integer && cnt < op[i].card){
      a[j++] = op[i].integer;
      cnt++;
    }
  }

  long int sum = 0;

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

  printf("%ld\n", sum);

  return 0;

}

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

using namespace std;

typedef long long ll;

/*
ll peso[100], v[100];
ll n, w;
ll mochila(ll i, ll p ) {
    if ( i == n ) return 0;
    if ( p + peso[i] <= w) {
        return max(v[i]+mochila(i+1,p+peso[i]), mochila(i+1,p) );
    } else {
        return mochila(i+1,p);
    }
}
*/

int main()
{
    ll n, w;
    cin >> n >> w;

    ll p[n], v[n];

    for(int i=0; i<n; ++i) {
        cin >> p[i] >> v[i];
    }

    ll dp[w+5][n+5];

    for (ll i=w; i>=0; --i) {
        for(ll j=n; j>=0; --j ) {
            if ( j == n ) {
                dp[i][j] = 0;
            } else if ( i + p[j] <= w) {
                dp[i][j] = max( v[j]+dp[ i+p[j] ][j+1], dp[i][j+1] );
            } else {
                dp[i][j] = dp[i][j+1];
            }
        }
    }
    /*
    for (ll i=0; i<=w; ++i) {
        for(ll j=0; j<=n; ++j ) {
            cerr << dp[i][j] << ' ';
        }
        cerr << '\n';
    }
    */

    cout << dp[0][0] << '\n';
}

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

using namespace std;

#define show(x) cerr << #x << " = " << x << endl;

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

  int maxValue  = a*b/__gcd(a,b);

  bool flag = false;
  for(int x=a; x<=maxValue; x+=a)
  {

    if((x-c)%b==0)
    {
      flag=true;
      break;
    }
  }


  if(flag)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }

  return 0;
}


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

using namespace std;

int main() {
	int n;
	int mini;
	while (1) {
		cin >> n;
		if (n == 0)break;
		int* a = new int[n];
		for (int i = 0;i < n;i++) {
			cin >> a[i];
		}
		mini = INT_MAX;
		for (int i = 0;i < n;i++) {
			for (int j = i + 1;j < n;j++) {
				mini = min(abs(a[i] - a[j]), mini);
			}
		}
		cout << mini << endl;
	}
}



Measured memory_bytes: 3136