akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x, a, b;
    cin >> x >> a >> b;
    int da,db;
    da = abs(x-a);
    db = abs(x-b);
    if(da<db){
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }
    return 0;
}




Measured memory_bytes: 256
def main():
    mod = 10**9+7
    h,w = map(int,input().split())
    grid = []
    for i in range(h):
        grid.append(input())

    dp = [[0 for j in range(w)] for i in range(h)]
    for j in range(w):
        if grid[0][j] == '.':
            dp[0][j] = 1
        else:
            break

    for i in range(h):
        if grid[i][0] == '.':
            dp[i][0] = 1
        else:
            break

    for i in range(1,h):
        for j in range(1,w):
            if grid[i-1][j] == '.':
                dp[i][j] += dp[i-1][j]
            if grid[i][j-1] == '.':
                dp[i][j] += dp[i][j-1]

            dp[i][j] %= mod

    print(dp[-1][-1])

main()


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

int main()
{
  int a[6] = {1, 5, 10, 50, 100, 500};
  int kanade = 0;

  for (int i = 0; i < 6; i++) {
    int tmp; cin >> tmp;
    kanade += tmp * a[i];
  }

  if (kanade >= 1000) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3128
n=int(input())
a = [int(i) for i in input().split()]

length = sum(a)
if length %2 ==0:
    check = 0
    half = length//2
    idx = 0
    for i in range(len(a)):
        check+=a[i]
        if check > half:
            idx = i
            break
    if check - half > half - (check-a[idx]):
        check -=a[idx]
    
    ans = abs((half-check)*2)
else:
    check = 0
    half = length//2
    idx = 0
    for i in range(len(a)):
        check+=a[i]
        if check > half:
            idx = i
            break
    check -=a[idx]
    afte = sum(a[idx:])
    ans = half-check+afte-half
    
    check +=a[idx]
    afte = sum(a[idx+1:])
    ans = min(ans,abs(check-half)+abs(afte-half))
    
print(ans)
    
                
            

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

void fnInput(int& rnNum)
{
  cin >> rnNum;
}

int fnDigitSum(int nNum)
{
  int nDigitSum = 0;
  while (nNum)
  {
    nDigitSum += nNum % 10;
    nNum /= 10;
  }

  return nDigitSum;
}

int fnHarshadCheck(int nNum)
{
  if (nNum % fnDigitSum(nNum) == 0) return 1;
  else                              return 0;
}

int main()
{
  int nNum;
  fnInput(nNum);

  if (fnHarshadCheck(nNum)) cout << "Yes" << endl;
  else                      cout << "No"  << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ; 
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
//template<class C> min(C x,C y){ if(x>y) return y ; return x ; } 
//template<class C> max(C x,C y){ if(x>y) return x ; return y ; } 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main() 
{
	int n ; cin>>n ; //, k ; cin>>n>>k ; 
	//cout<<n*n*n<<endl;	
	ll ans = 0 ; 
	vi B(n-1) ;
	vi A(n,INT_MAX) ;
	for(int i = 0 ; i < n-1 ; i++ )
	{
		cin>>B[i] ; 
		A[i] = min(A[i],B[i]) ;
		A[i+1] = min(A[i+1],B[i]) ;  
	}
	for(int i = 0 ;i<n ; i++ )
		ans += A[i] ; 
	cout<<ans<<endl;
}

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

void search(int& answer, int G, int pNum, int score, vector<int> p, vector<int> c, int depth, int depthMax, vector<bool>& b){
    // 最後の枝まで探索
    if(depth == depthMax){
        if(score >= G){
            if(pNum < answer){
                answer = pNum;
            }
            return;

        }
        else{
            //貪欲で解を求める
            int greedy = score;
            bool end = false;
            for(int i=0;i<depthMax;i++){
                if(b.at(i) == false){
                    for(int j=0;j<p.at(i)-1;j++){
                        greedy += (depthMax-i) * 100;
                        pNum++;
                        if(pNum >= answer){
                            return;
                        }
                        if(greedy >= G){
                            if(pNum < answer){
                                answer = pNum;
                            }
                            return;
                        }
                    }
                }
            }
            return;
        }
    }

    if(score >= G){
        if(pNum < answer){
            answer = pNum;
            return;
        }
    }

    b.at(depth) = false;
    if(pNum < answer){
        search(answer, G, pNum, score, p, c, depth+1, depthMax, b);
    }
    // ボーナスまで解く
    b.at(depth) = true;
    if(pNum + p.at(depth) < answer){
        // スコアを計算
        int newScore = (depthMax - depth) * 100 * p.at(depth) + c.at(depth);
        search(answer, G, pNum+p.at(depth), score + newScore, p, c, depth+1, depthMax, b);
    }
}

int main() {
    int D, G;
    cin >> D >> G;
    vector<int> p(D);
    vector<int> c(D);
    vector<bool> b(D);
    int answer = 0;
    for(int i=0;i<D;i++){
        cin >> p.at(D-i-1) >> c.at(D-i-1);
        b.at(D-i-1) = false;
    }

    //貪欲で暫定解を求める
    int greedy = 0;
    bool end = false;
    for(int i=0;i<D;i++){
        for(int j=0;j<p.at(i);j++){
            greedy += (D-i) * 100;
            if(j == p.at(i)-1){
                greedy += c.at(i);
            }
            answer++;
            if(greedy >= G){
                end = true;
                break;
            }
        }
        if(end){
            break;
        }
    }
    search(answer, G, 0, 0, p, c, 0, D, b);
    cout << answer << endl;    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
evidence = [[] for _ in range(N)]

for i in range(N):
  A = int(input())
  for _ in range(A):
    x,y = map(int,input().split())
    evidence[i].append((x-1,y))
  
result = 0
for i in range(1,2**N):
  consistent = True
  for j in range(N):
    if (i>>j)&1 == 1:
      for x,y in evidence[j]:
        if (i>>x)&1 != y:
          consistent = False
          break
      if not consistent:
        break
  if consistent:
    result = max(result,bin(i)[2:].count("1"))
    
print(result)

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

long long x[10000010], y[10000010];

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   string s;
   cin >> s;
   bool a = false, b = false, ans = false;
   int cnt = 0, h = 1, w = 1, p, q;

   rep(i, s.size())
   {
      if (s[i] == '<')
      {
         b = false;
         if (ans == true)
         {
            q = w;
            cnt = cnt - min(p, q);
            ans = false;
         }
         if (a == false)
         {
            h = 1;
            cnt = cnt + h;
            a = true;
         }
         else
         {
            h++;
            cnt = cnt + h;
         }
      }
      else
      {
         a = false;
         if (s[i - 1] == '<')
         {
            p = h;
            ans = true;
         }
         if (b == false)
         {
            w = 1;
            cnt = cnt + w;
            b = true;
         }
         else
         {
            w++;
            cnt = cnt + w;
         }
      }
   }
   if (ans == true)
   {
      q = w;
      cnt = cnt - min(p, q);
   }
   cout << cnt << '\n';
}

Measured memory_bytes: 1172
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long


int main() {
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << 2 * a << endl;
    } else if (a > b){
       cout << 2 * a - 1 << endl;
    } else {
        cout << 2 * b - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <string_view>
#include <vector>

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vi = vector<int>;
using vsz = vector<size_t>;

int main ()
{
    string s, t;
    cin >> s >> t;
    if (t.substr (0, t.size () - 1) == s)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main () {
    int N , M ;
    cin >> N >> M ;
    vector<int> a (M);
    rep(i, M){
        cin >> a[i] ;
    }
    ll total = 0 ;
    rep(i, M){
        total += a[i];
    }
    if (N - total < 0)
    {cout << -1 << endl;}
    else {
    cout << N - total << endl;
    }
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#define N 1009
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
 
LL fun(LL n, LL m)
{
    if((m / 2) < n) return  m / 2;
    LL ans = n;
    m = m - n * 2;
    ans = ans + m / 4;
    return ans;
}
 
 
int main()
{
    LL n, m;
    scanf("%lld%lld", &n, &m);
    LL ans = fun(n, m);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	cout.precision(20);
	long double a,b,v;
	cin >> a >> b >> v;
	if(v==a*a*b){
		cout << 0 << endl;
		return 0;
	}
	if(v>=a*a*b/2){
		cout << 90 - atan(a*a*a/(2*(a*a*b - v)))*180/(M_PI) << endl;
	}else{
		cout << 90 - atan(2*v/(a*b*b))*180/(M_PI) << endl;
	}
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
set<int> s[100010];
set<int>::iterator it;
int n,m;
int h[100010];
int a,b;
int ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>h[i],s[i].insert(h[i]);
	for(int i=0;i<m;i++){
		cin>>a>>b;
		s[a].insert(h[b]);
		s[b].insert(h[a]);
		if(h[a]==h[b])s[a].insert(h[a]+1),s[b].insert(h[a]+1);
	}
//	for(int i=1;i<=n;i++){
//		it=s[i].begin();
//		for(;it!=s[i].end();it++)cout<<*it<<' ';
//		cout<<'\n';
//	}
	for(int i=1;i<=n;i++){
		it=s[i].end();it--;
		int num=*it;
//		cout<<num<<' '<<i<<'\n';
		if(num==h[i])ans++;//,cout<<i<<'\n';
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 22760
#include <iostream>

using namespace std;

int main(void){

  long long a;
  long long b;
  long long result;
  long long temp1;
  long long temp2;

  while( cin >> a >> b ){

    temp1 = a;
    temp2 = b;

    while(1){
      result = a % b;
      if( result == 0 )break;
      else a = b;  b = result;
    }
    cout << b << " " << temp1 / b * temp2 << endl;
  }
  return 0;
} 

Measured memory_bytes: 1156
def main():
    n, k = map(int, input().split())
    D = set(input().split())

    numbers = [str(number) for number in range(n, 10 * n)]
    for number in numbers:
        if ok(number, D):
            print(number)
            break


def ok(number, D):
    return len({c for c in number} & D) == 0


main()


Measured memory_bytes: 8728
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;


#define ll long long
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)

int main()
{
    ll n;
    cin >> n;
    ll sum = 0;
    for (int i = 1; i < n; i++)
    {
        sum += i;
    }
    cout << sum << endl;
}

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

using namespace std;

using lint = long long;
using ldouble = long double;

const int INF = 1 << 30;

map<int, int> compress(vector<int>& v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    map<int, int> ret;
    for (int i = 0; i < v.size(); ++i) ret[v[i]] = i;
    return ret;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
    }

    auto xs = x, ys = y;
    xs.push_back(-INF);
    ys.push_back(-INF);
    auto revx = compress(xs);
    auto revy = compress(ys);

    int X = xs.size(), Y = ys.size();
    vector<vector<int>> imos(X, vector<int>(Y, 0));
    for (int i = 0; i < N; ++i) {
        ++imos[revx[x[i]]][revy[y[i]]];
    }

    for (int i = 1; i < X; ++i) {
        for (int j = 0; j < Y; ++j) {
            imos[i][j] += imos[i - 1][j];
        }
    }
    for (int i = 0; i < X; ++i) {
        for (int j = 1; j < Y; ++j) {
            imos[i][j] += imos[i][j - 1];
        }
    }

    for (int i = 0; i < M; ++i) {
        int lx, ly, rx, ry;
        cin >> lx >> ly >> rx >> ry;
        lx = *(--lower_bound(xs.begin(), xs.end(), lx));
        ly = *(--lower_bound(ys.begin(), ys.end(), ly));
        rx = *(--upper_bound(xs.begin(), xs.end(), rx));
        ry = *(--upper_bound(ys.begin(), ys.end(), ry));

        cout << imos[revx[rx]][revy[ry]] - imos[revx[rx]][revy[ly]] -
                    imos[revx[lx]][revy[ry]] + imos[revx[lx]][revy[ly]]
             << endl;
    }
    return 0;
}



Measured memory_bytes: 101276
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import re

def main():
    N = int(input())
    As = list(map(int, input().split()))

    first = 0
    for i, A in enumerate(As):
        if i % 2 == 0:
            first += A
        else:
            first -= A
    first = int(first / 2)
    print(2*first, end="")
    prev = first
    for i in range(len(As)-1):
        X = As[i] - prev
        prev = X
        print(" {}".format(int(2*X)), end="")

if __name__ == '__main__':
    main()


Measured memory_bytes: 63856
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  cin>>h>>w;
  vector<vector<ll> > dp(h+3,vector<ll>(w+3));
  vector<string> mp(h);
  rep(i,h){
      cin>>mp[i];
  }
  dp[0][0]=1;
  REP(i,1,h){
      if(mp[i][0]!='#'){
	  dp[i][0]=dp[i-1][0];
      }
  }
  REP(i,1,w){
      if(mp[0][i]!='#'){
	  dp[0][i]=dp[0][i-1];
      }
  }
  REP(i,1,h){
      REP(j,1,w){
	  if(mp[i][j]!='#'){
	      dp[i][j]=dp[i][j-1]+dp[i-1][j];
	  }
	  dp[i][j]%=1000000007;
      }
  }
  cout<<dp[h-1][w-1]<<'\n';
  return(0);
}



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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  vector<vi> v(n, vi(3));

  rep(i, n) rep(j, 3) cin >> v[i][j];

  rep(x, 101) rep(y, 101) {
    int h = 1;
    bool ok = true;

    rep(i, n) if (v[i][2] > 0) {
      h = v[i][2] + abs(v[i][0] - x) + abs(v[i][1] - y);
      break;
    }
    rep(i, n) if (max(h - abs(v[i][0] - x) - abs(v[i][1] - y),0LL) != v[i][2]) ok = false;

    if (ok) {
      cout << x << " " << y << " " << h << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3652
num=int(input())
s=[int(i) for i in input().split()]
s.sort(reverse=True)
array=[]
for (i,j) in enumerate(s):
    if i==0:
        array.append(j)
    else:
        array.append(j)
        array.append(j)
point=0
for i in range(num-1):
    if i==0:
        point+=array[i]
    else:
        point+=array[i]
print(point)

Measured memory_bytes: 31752
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi v(n); rep(i, n) cin >> v[i];
	vector<vector<ll>> dp(n + 1, vector<ll>(2, -1));
	dp[0][0] = 0;
	rep(i, n) rep(j, 2) if(dp[i][j] >= 0){
		rep(k, 2){
			int cur = v[i] - k - j;
			if(cur < 0) continue;
			ll tmp = dp[i][j] + cur / 2 + j;
			dp[i + 1][k] = max(dp[i + 1][k], tmp);
		}
	}
	cout << max(dp[n][0], dp[n][1]) << endl;
	return 0;
}

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

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll A,B, ans = 0;

void solve(){
    ans += max(A,B);

   if(ans == A)
        ans += max(B,A-1);
   else
        ans += max(A,B-1);     


    cout << ans << endl;
}

int main(){
    cin >> A >> B;

    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
 
signed main(){
    int p,q;
    cin>>p>>q;
    int g=gcd(p,q);
    q/=g;
    for(int i=2;i*i<=q;i++){
        if(q%i)continue;
        while(q%i==0)q/=i;
        q*=i;
    }
    cout<<q<<endl;
    return 0;
}

Measured memory_bytes: 3128
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,a[6]={0};
	double l;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l;
		if(l<165)a[0]++;
		else if(165<=l&&l<170)a[1]++;
		else if(170<=l&&l<175)a[2]++;
		else if(175<=l&&l<180)a[3]++;
		else if(180<=l&&l<185)a[4]++;
		else a[5]++;
			
	}
	
	for(int i=0;i<6;i++){
		cout<<i+1<<":";
			
		for(int j=0;j<a[i];j++)
		cout<<"*";
		cout<<endl;
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vl a(n);
  int mnum = 0;
  bool zero = false;
  rep(i, n) {
    int num;
    cin >> num;
    if(num < 0) mnum++;
    if(num == 0) zero = true;
    a[i] = abs(num);
  }
  ll ans = 0;
  rep(i, n) ans += abs(a[i]);
  if(!zero && mnum % 2) ans -= 2 * *min_element(all(a));
  cout << ans << endl;
}

Measured memory_bytes: 1152
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
p=i2()
i=0
a=0
while i<n:
 if p[i]==i+1:
   a+=1
   i+=1
   if i<n and p[i]==i+1:
    i+=1
 else:
   i+=1
print(a)

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

import static java.lang.Double.*;
import static java.lang.Math.sqrt;

public class Main {
    static PrintWriter prnt = new PrintWriter(System.out);
    static StringTokenizer st;
    static BufferedReader read;

    static void numberOfPoints() throws IOException {
        read = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(read.readLine());

        double N = parseDouble(st.nextToken());
        double D = parseDouble(st.nextToken());

        int countPoint = 0;
        for (int i = 0; i < N; i++) {
            st = new StringTokenizer(read.readLine());
            double x1 = parseDouble(st.nextToken());
            double x2 = parseDouble(st.nextToken());

            double d = sqrt((x1 * x1) + (x2 * x2));

            if (D >= d) {
                countPoint++;
            }
        }
        prnt.println(countPoint);
    }

    public static void main(String[] args) throws IOException {
        numberOfPoints();
        prnt.close();
    }
}

Measured memory_bytes: 55024
def read():
    N, M = list(map(int, input().strip().split()))
    A = list(map(int, input().strip().split()))
    return N, M, A


def solve(N, M, A):
    s = sum(A)
    threshold = 1.0 * s / (4 * M)
    count = sum([a >= threshold for a in A])
    return 'Yes' if count >= M else 'No'
    

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        h: usize,
        n: usize,
        v: [usize; n],
    }

    if h <= v.iter().sum() {
        println!("Yes")
    } else {
        println!("No")
    }
}


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

using namespace std;

int main()
{
    unsigned long long h, w;
    cin >> h >> w;

    unsigned long long x1, x2;

    if(h == 1 || w == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    if(w % 2 == 1)
    {
        x1 = (w+1)/2;
        x2 = x1-1;
    }
    else
    {
        x1 = w/2;
        x2 = x1;
    }

    unsigned long long ans = (h+1)/2 * x1 + h/2 * x2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  set<int> st{a, b, c};
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 256
import copy

move = ((1, 0), (0, 1), (0, -1), (-1, 0), (1, 1), (-1, -1), (-1, 1), (1, -1))


def dfs(start):
    field[start[1]][start[0]] = '0'
    CP = [start]
    while CP:
        NP = []
        for cp in CP:
            for m in move:
                n_p = (cp[0]+m[0], cp[1]+m[1])
                if not(n_p[0] < 0 or n_p[1] < 0 or n_p[1] >= h or n_p[0] >= w) and field[n_p[1]][n_p[0]] == '1':
                    field[n_p[1]][n_p[0]] = '0'
                    NP.append(n_p)
        CP = NP


while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0:
        break
    field = [list(input().split()) for _ in range(h)]
    count = 0
    for y in range(h):
        for x in range(w):
            if field[y][x] == '1':
                dfs((x, y))
                count += 1
    print(count)



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

int ans;

int main(void) {
  // Here your code !
  cin >> s;

  int zero = 0;
  int one = 0;

  for (auto e: s) {
    if (e == '0') zero += 1;
    else one += 1;
  }

  ans = min(zero, one) * 2;

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

  return 0;
}


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

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	
	long long res = 0;
	
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 5 == 0) continue;
		res += i;
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string str;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for (register int i = 0; i < n; i++)
    {
        cin >> str;
        if (str == "AC")
            ac++;
        if (str == "WA")
            wa++;
        if (str == "TLE")
            tle++;
        if (str == "RE")
            re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
 
int main(){
  int i=0,A[100];
  char stuck[100];
  
 
  while(scanf("%s",stuck)!=EOF){
    if(stuck[0]=='+'){
      A[i-2]=A[i-2]+A[i-1];
      i--;
    }
    else if(stuck[0]=='-'){
      A[i-2]=A[i-2]-A[i-1];
      i--;
    }
    else if(stuck[0]=='*'){
      A[i-2]=A[i-2]*A[i-1];
      i--;
    }
    else{
      A[i]=atoi(stuck);
      i++;
    }
  }
  printf("%d\n",A[i-1]);      
  return 0;
}

Measured memory_bytes: 548
N, *A = map(int, open(0).read().split())
cnt = 0


def insertion(A, N, g):
    global cnt
    for i in range(g, N):
        v = A[i]
        j = i-g
        while j >= 0 and A[j] > v:
            A[j], A[j+g] = A[j+g], A[j]
            cnt += 1
            j -= g


m = 1
G = [1]
while 3*G[-1]+1 < N:
    m += 1
    G.append(3*G[-1]+1)
G = G[::-1]

for g in G:
    insertion(A, N, g)

print(m)
print(*G)
print(cnt)
[print(a) for a in A]



Measured memory_bytes: 120484
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


def g(c):  # i*(i+1) <= c たる最大のiを返す
    left = 0  # ok
    right = c  # ng
    while left + 1 < right:
        mid = (left + right)//2
        if mid*(mid+1) <= c:
            left = mid
        else:
            right = mid
    return left


def query(a,b):
    if a == b:
        return a+b-2
    if a > b:
        a,b = b,a
    i0 = g(a*b)
    return i0+(a*b-1)//(i0+1)-1


Q = I()
for i in range(Q):
    a,b = MI()
    print(query(a,b))


Measured memory_bytes: 66052
/*
Till the roof comes off, till the lights go out
Till my legs give out, canâ��t shut my mouth.
Till the smoke clears out. Am I high? Perhaps
I'ma rip this shit till my bones collapse.
*/
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string.h>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <complex>


#define ll long long
#define X real()
#define Y imag()
#define f first
#define s second
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define lngth(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)

using namespace std;

const int N=100005;
typedef pair<int,int>ii;
typedef pair<ii,int>event;
typedef complex<double>point;
const double EPS = 1e-9;
const int INF=100000;

const double PI = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

int n,m,a[N],g[101][101],k;

int main()
{
   // freopen("test.in","r",stdin);
   //freopen("output.txt","w",stdout);
    scanf("%d%d%d",&n,&m,&k);
    for(int i=0;i<k;i++)
        scanf("%d",&a[i]);
    int cur=0;
    for(int i=0;i<n;i++){
       if(i%2==0){
        for(int j=0;j<m;j++){
            if(a[cur])
                g[i][j]=cur+1;
            else{
                cur++;
                g[i][j]=cur+1;
            }
            a[cur]--;
        }
       }
       else{
        for(int j=m-1;j>=0;j--){
            if(a[cur])
                g[i][j]=cur+1;
            else{
                cur++;
                g[i][j]=cur+1;
            }
            a[cur]--;
        }
       }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)cout<<g[i][j]<<' ';
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
import functools

def prime_factor(n):
    res = {}
    i = 2
    while i * i <= n:
        while n % i == 0:
            res[i] = 1
            n //= i
        i+=1
    if n != 1:
        res[n] = 1
    return res.keys()
    
N = int(input())
target = functools.reduce(lambda a, b: a * b, range(1, N + 1))

factors = prime_factor(target)
total = 1
for f in factors:
    count = 1
    while target % f == 0:
        target //= f
        count += 1
    
    total *= count

print(total % (10**9 + 7))

Measured memory_bytes: 39152
//abc148_c.cpp
//Sun Dec 22 20:45:51 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

//最大公倍数、最大公約数（ユークリッド互除法）
ll gcd (ll a, ll b){ //最大公約数
	if (b == 0){
		return a;
	}
	return gcd(b, a%b);
}

ll lcm (ll a, ll b){ //最小公倍数
	ll temp = gcd(a,b);
	return (a/temp)*b;
}


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

	ll ans = lcm(a,b);

	cout << ans << endl;
//	printf("%.4f\n",ans);

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

ll mypow(ll x, ll n) {
    if (n == 0) return 1;
    if (n%2 == 0) return mypow(((x%mod)*(x%mod))%mod, n/2);
    else return ((x%mod) * mypow(((x%mod)*(x%mod))%mod, (n-1)/2))%mod;
}

int main(){
    int N;
    cin >> N;
    cout << N/3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int N, Q, com, u, v;
    cin >> N >> Q;
    dsu uf(N);
    rep(_,Q){
        cin >> com >> u >> v;
        if(com == 0)uf.merge(u, v);
        else cout << uf.same(u, v) << endl;
    }
    return 0;
}


Measured memory_bytes: 4092
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

alias Point = Tuple!(int, "x", int, "y", int, "c");

void main() {
    int n;
    scan(n);

    int ans = 10^^9;

    foreach (a ; 1 .. n) {
        ans = min(ans, s(a) + s(n - a));
    }

    writeln(ans);
}

int s(int x) {
    return x > 0 ? s(x/10) + (x % 10) : 0;
}
































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<vector<int>> v;
	for (int i = 0; i < n; ++i)
	{
		int a,b,c;
		cin>>a>>b>>c;
		vector<int>temp;
		temp.push_back(a);
		temp.push_back(b);
		temp.push_back(c);
		v.push_back(temp);
	}
	vector<vector<int>> dp(n,vector<int> (3));
	dp[0][0] = v[0][0];
	dp[0][1] = v[0][1];
	dp[0][2] = v[0][2];

	for(int i = 1; i<n;i++)
	{
		for(int j = 0; j<3;j++)
		{
			if(j == 0)
			{
				dp[i][j] = v[i][j] + max(dp[i-1][1],dp[i-1][2]);
			}
			else if (j == 1)
			{
				dp[i][j] = v[i][j] + max(dp[i-1][0],dp[i-1][2]);
			}
			else if (j == 2)
			{
				dp[i][j] = v[i][j] + max(dp[i-1][0],dp[i-1][1]);
			}
		}
	}
	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}

Measured memory_bytes: 11568
#include <stdio.h>
 
int main(void){
 
int n,i,min,max;

long int sum;
 
sum = 0;
 
int a[10000];
 
scanf("%d",&n);
 
 for(i=0;i<n;i++){
 
scanf("%d",&a[i]);

 };
 
min = a[0];
 
max = a[0];
 
for(i=0;i<n;i++){
 
sum = sum + a[i];
 
};
 
for(i=0;i<n;i++){
 
if(a[i]<min){
 
min = a[i];
 
};

};
 
 for(i=0;i<n;i++){
 
if(a[i]>max){
 
max = a[i];
 
};
 
};
 
printf("%d %d %ld\n",min,max,sum);
 
return 0;
 
};

Measured memory_bytes: 640
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,c,k = inpl()
t = inpln(n)
t.sort()
u = [(i+k) for i in t]
res = 0
now = 0
while now < n:
    time = u[now]
    for i in range(c):
        if now == n:
            break
        if t[now] <= time:
            now += 1
        else:
            break
    res += 1
print(res)

Measured memory_bytes: 51800
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n; cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s; cin >> s;
        mp[s]++;
    }
    int maa=0;
    for(auto itr=mp.begin();itr!=mp.end();++itr) chmax(maa,itr->se);
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        if(maa==itr->se){
            cout << itr->fi<<endl;
        }
    }
}


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

using namespace std;

const int N = 202;
int a[N];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int res = 0;
    while (1) {
        bool is = true;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 1) {
                is = false;
                break;
            }
        }
        if (!is) break;
        res++;
        for (int i = 0; i < n; i++) {
            a[i] /= 2;
        }
    }
    cout << res;
    return 0;
}

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

int main(){
  ll N; cin >> N;
  string S; cin >> S;
  char c = ' ';
  ll ans = 0;
  for(ll i = 0; i < N; i++){
    if(S[i] != c) ans++;
    c = S[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include <cstdio>
#include<cctype>
 
using namespace std;
 
int main(){
     
    char ch;
     ch = getchar();
    while( ch != EOF)
	{
        if(islower(ch))
            ch = toupper(ch);
        else
            ch = tolower(ch);
        cout << ch;
		 ch = getchar();
    }  
  return 0;
}

Measured memory_bytes: 3012
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);
    sort!"a > b"(AS);
    long fst, bf;
    foreach (a; AS) {
        if (!bf) {
            bf = a;
            continue;
        }
        if (!fst && bf == a) {
            fst = a;
            bf = 0;
            continue;
        }
        if (bf == a) {
            writeln(fst * a);
            return;
        }
        bf = a;
    }
    writeln(0);
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};

vector<P> v[5555];
//bitset<4001000> b;
int a,c,i,b,k,d,n,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[5555];
int o[5400];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

long long x,y,z,mod=1000000007;
P u[111111];
double j[111];

stack<int> s;
queue<P> q;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int > p;
//list<int> l;
string r;
//char r[333][333];


bool as(P a,P b)
{
    if(a.x!=b.x) return a.x<b.x;
    return a.y>b.y;
}

int main()
{
    scanf("%d %d",&a,&b);
    if((a<0&&b>0)||(a==0||b==0)) puts("Zero");
    else if(a>0||(b-a)%2) puts("Positive");
    else  puts("Negative");

}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	char t[51]={0};
	int a,b,c;
	cin>>a>>b;
	sprintf(t,"%d%d",a,b);
	sscanf(t,"%d",&c);
	if(sqrt(c)-(int)sqrt(c)!=0){
		cout<<"No";
	}
	else {
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
double dmax(double a,double b){
    return a>b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int n,i,a,b,f[100010],m;
    //while(1){
        n=in();
        //if(!n)break;
        MEMSET(f);
        rep(i,n){
            a=in(),b=in();
            f[a]++,f[b+1]--;
        }
        m=0;
        for(i=1;i<100002;i++){
            f[i]+=f[i-1];
            if(f[i]>=i-1)m=i-1;
        }
        print(m);
    //}
    return 0;
}


Measured memory_bytes: 2240
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
o = readline().rstrip().decode('utf-8')
e = readline().rstrip().decode('utf-8')
ans = []
for i in range(len(e)):
    ans.append(o[i])
    ans.append(e[i])
if len(o) == len(e)+1:
    ans.append(o[-1])

print("".join(ans))

Measured memory_bytes: 38256
import java.util.concurrent.LinkedBlockingDeque
import kotlin.math.max

fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main() {
    data class Point(val y: Int, val x: Int, val count: Int)
    val (h, w) = intList()
    val area = mutableListOf<CharArray>()
    val queue = LinkedBlockingDeque<Point>()
    repeat(h) { y ->
        val line = readLine() ?: return
        line.forEachIndexed { x, c ->
            if (line[x] == '#') {
                queue.offer(Point(y, x, 0))
            }
        }
        area.add(line.toCharArray())
    }
    var count = 0
    while (queue.isNotEmpty()) {
        val (y, x, c) = queue.poll()
        if (y - 1 >= 0 && area[y - 1][x] == '.') {
            area[y - 1][x] = '#'
            queue.offer(Point(y - 1, x, c + 1))
            count = max(count, c + 1)
        }
        if (y + 1 < h && area[y + 1][x] == '.') {
            area[y + 1][x] = '#'
            queue.offer(Point(y + 1, x, c + 1))
            count = max(count, c + 1)
        }
        if (x + 1 < w && area[y][x + 1] == '.') {
            area[y][x + 1] = '#'
            queue.offer(Point(y, x + 1, c + 1))
            count = max(count, c + 1)
        }
        if (x - 1 >= 0 && area[y][x - 1] == '.') {
            area[y][x - 1] = '#'
            queue.offer(Point(y, x - 1, c + 1))
            count = max(count, c + 1)
        }
    }
    println(count.toString())
}


Measured memory_bytes: 111292
#define _USE_MATH_DEFINES
#define llint long long
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int d, n;

int main() {
    cin >> d >> n;
    
    int m = 1;
    while (d--) m *= 100;
    if (n == 100) n = 101;

    cout << m * n << endl;

    return 0;
}

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

int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n+1);
	for(int i =1; i<=n; i++)
		scanf("%d", &a[i]);
	sort(a.begin()+1,a.end());
	int ans= a[n]- a[1];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
import Data.List
main = getLine >>= putStrLn . solve . map read . words

solve :: [Int] -> String
solve [sx, sy, tx, ty] = replicate r 'R'
                        ++ replicate u 'U'
                        ++ replicate r 'L'
                        ++ replicate u 'D'
                        ++ "D"
                        ++ replicate (r + 1) 'R'
                        ++ replicate (u + 1) 'U'
                        ++ "LU"
                        ++ replicate (r + 1) 'L'
                        ++ replicate (u + 1) 'D'
                        ++ "R"
    where
        r = tx - sx
        u = ty - sy


Measured memory_bytes: 1020