akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = [int(a) for a in input().split()]
aaa=[]
if n==2:
  print(a[0]*2)
else:
  aaa.append(a[0])
  for i in range (1,n-1):
    aa = min(a[i-1],a[i])
    aaa.append(aa)
  aaa.append(a[n-2])
  print(sum(aaa))

Measured memory_bytes: 3188
#coding:utf-8

def add_count(zero_count):
    if zero_count >= 2:
        return zero_count - 1
    else:
        return zero_count

N = int(input())
p_list = list(map(int, input().split(" ")))

count = 0
for i in range(N):
    if p_list[i] == i + 1:
        if i == N - 1:
            p_list[i] ,p_list[i - 1] = p_list[i - 1] ,p_list[i]
        else:
            p_list[i], p_list[i + 1] = p_list[i + 1], p_list[i]
        count += 1

print (count)


Measured memory_bytes: 13880
function main(input){
  input = Number(input);
  
  for(var i = 1;i < 10;i++){
    if(input % i === 0){
      if(input / i < 10){
        console.log("Yes");
        return;
      }
    }
  }
  console.log("No");
}

main(require("fs").readFileSync("/dev/stdin","utf8"));

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

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

	for (int i = n; i <= 999; i++)
	{
		if(i/100==i/10%10&&i/100==i%10){
			cout<<i<<endl;
			return 0;
		}
	}


}

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

int main() {
    int N, temp;
    vector<int> d;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        d.push_back(temp);
    }
    sort(d.begin(), d.end(), greater<>());
    int ans = 1;
    for (int i = 0; i < N - 1; ++i) if (d[i] > d[i + 1]) ++ans;
    cout << ans << endl;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A = np.zeros(5, np.int32)
for i in range(5):
    A[i] = ir()

remain = A % 10
remain = remain[remain>0]
ceil10 = (np.ceil(A/10) * 10).astype(np.int32)
answer = ceil10.sum()
if len(remain) != 0:
    minus = 10 - remain.min()
    answer -= minus
print(answer)


Measured memory_bytes: 13092
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

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

    ll ans = INF;
    exrep(i, 1, n-1) {
        chmin(ans, abs((rui[n] - rui[i]) - rui[i]));
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 3328
N, Y = map(int, input().split())

ans = (-1, -1, -1)
for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        if z < 0:
            continue
        if 10000 * x + 5000 * y + 1000 * z == Y:
            ans = (x, y, z)
print(ans[0], ans[1], ans[2])


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

const int inf = 1LL << 60;

int up(int a, int b){ 
  // a/b　切り上げ　を返す
  if( a >= 0 && b > 0 ){ return (a+b-1)/b;}
  else if( a >= 0 && b < 0 ){ b = -b; return -(a/b);}
  else if( a < 0 && b > 0 ){ a = -a; return -(a/b);}
  else{
    a = -a;
    b = -b;
    return (a+b-1)/b;
  }
}

int down(int a, int b){
  // a/b 切り捨て　を返す
  if( a >= 0 && b > 0 ){ return a/b;}
  else if( a >= 0 && b < 0 ){ b = -b; return -(a+b-1)/b;}
  else if( a < 0 && b > 0 ){ a = -a; return -(a+b-1)/b;}
  else{
    a = -a;
    b = -b;
    return a/b;
  }
}
    
signed main(void){ 
  
 
  int N,K; cin >> N >> K;
  vector<int> A(N);
  for(int i = 0; i < N; i++){ cin >> A[i];}
  
  sort(A.begin(),A.end());
  
  int left = -inf; int right = inf;
  
  while(right-left > 1){
    
    int X = left+(right-left)/2;
    int cnt = 0;
    

    for(int i = 0; i < N; i++){ 
      
      if( A[i] < 0 ){ 
        int j = lower_bound(A.begin(),A.end(),up(X,A[i]))-A.begin();
        cnt += N-j;
        if( j <= i ){ cnt--; } 
      }
      else if( A[i] == 0 ){ 
        if( X >= 0 ){ cnt += N-1;}
      }
      else{ 
        int j = upper_bound(A.begin(),A.end(),down(X,A[i]))-A.begin();
        j--;
        cnt += j+1;
        if( i <= j ){ cnt--;}
        
        
      }
      
      
      
    }
    
    cnt /= 2; //ダブルカウント注意
    
    if(false){ cout << X << " " << cnt << endl; } 
    
    if( cnt >= K ){ right = X;}
    else{ left = X;}
  }
  
  cout << right << endl;
  
  return 0;
} 
    

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


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

  int max,sum =0;

   for(int i=0;i<n;i++){
     int l;
     cin>>l;
     sum+=l;
     if(l>max)max=l;
   }
  sum-=max;
   if(sum>max)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

Measured memory_bytes: 256
//B.cpp
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  int N;
  cin >> N;
  string Sa,Sb;
  map<string,int> chk;
  cin >> Sa;
  ++chk[Sa];
  bool flag = true;
  for(int i = 1; i < N; i++){
    cin >> Sb;
    ++chk[Sb];
    if(Sa[Sa.size()-1]!=Sb[0]){
      flag = false;
    }
    Sa = Sb;
  }

  for(auto x: chk){
    if(x.second!=1){
      flag = false;
      break;
    }
  }

  if(flag) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, m;
  cin >> n >> m;
  vll p(m);
  vs s(m);
  vll ans(n, 0);
  vll ansp(n, 0);
  rep(i, m){
    cin >> p[i] >> s[i];
    p[i]--;
    if(s[i][0] == 'A'){
      ans[p[i]] = 1;
    }else{
      if(ans[p[i]] >= 1){
        
      }else{
        ansp[p[i]]++;
      }
    }
  }
  ll a = 0, b = 0;
  rep(i, n){
    if(ans[i]){
      b += ansp[i];
      a++;
    }
  }
  print(a, b);
}


Measured memory_bytes: 8064
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,M;
    cin >> N >> M;
    ll out = 0;
    if(M==1);
    else if(M/2<=N) out = M/2;
    else{
        out += N;
        ll O = M-2*N;
        out += O/4;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int n;
  cin>>n;
  double ans=0;
  for(int i=0;i<n;i++){
    double x;
    string u;
    cin>>x>>u;
    if(u=="JPY")ans+=x;
    else ans+=x*380000.0;
  }
  printf("%.10lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int f[1010],n,k,sum;
int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++) cin>>f[i];
	sort(f+1,f+n+1);
	for (int i=1;i<=k;i++) sum+=f[i];
	cout<<sum;
    return 0;
}


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

int keta(int num){
  int ans= 0 ;
  int rem;

  for (int i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}


int main() {
  string S, T, tmp;
  cin >> S;
  T = {};
  
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  bool can1 = true;

  // 後ろから解くかわりにすべての文字列を「左右反転」する
  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

  for(int itr = 0; itr < S.size();){
    bool can2 = false;

    for (int j = 0; j < 4; j++){
      string d = divide[j];      
      if(S.substr(itr,  d.size()) == d){
        can2 = true;
        itr += d.size();
      }
    }
    if (!can2){
      can1 = false;
      break; 
    }
  }
  if (can1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 512
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

import copy
N = int(input())
S = input()

# ct = 0

# def dfs(index, RGB, indexs):
#     global ct
#     if RGB[S[index]] == 1:
#         return
#     else:
#         RGB[S[index]] = 1
#         indexs += [index]
        
#         if len(indexs) == 2:

#             for key, value in RGB.items():
#                 if value == 0:
#                     ct += Counter(S[index+1:])[key]
#                     h = indexs[1]+indexs[1] - indexs[0] +1
#                     if 0 < h <= N and S[h-1] == key:
#                         ct -= 1

#                     return

#         for i in range(index+1, N):
#             dfs(i, RGB.copy(), copy.copy(indexs))

# for i in range(N):
#     dfs(i, {"R":0, "G":0, "B":0}, [])

# print(ct)

c = Counter(S)
al = c["R"] * c["G"] * c["B"]

for i in range(N):
    for j in range(i+1, N):
        k = 2*j - i
        if k >= N: break
        if S[i] != S[k] and S[i] != S[j] and S[j] != S[k]:
            al -= 1
print(al)

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

int main() {
  int64_t h, w;
  cin >> h >> w;
  if (h >= 2 && w >= 2) {
    cout << (h * w + 1) / 2 << endl;
  } else {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main()
{ 	
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]%2==0&&a[i]%5!=0&&a[i]%3!=0)
		{
			cout<<"DENIED";
			break;
		}
		else if(i==n)
		{
			cout<<"APPROVED";
		}
	}
	return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
s=input()
cnt=0
B=0
for i in range(n):
    if s[i]=='a' and cnt<a+b:
        cnt+=1
        print('Yes')
    elif s[i]=='b' and cnt<a+b and B<b:
        cnt+=1
        B+=1
        print('Yes')
    else:
        print('No')


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

long long suusiki(string s) {}

int main() {
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<int>> ans(h, vector<int>(w));
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < h; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < w; j++) {
        for (int k = 0; k < n; k++) {
          if (a.at(k) != 0) {
            ans.at(i).at(j) = k;
            a.at(k)--;
            break;
          }
        }
      }
    } else {
      for (int j = w - 1; j >= 0; j--) {
        for (int k = 0; k < n; k++) {
          if (a.at(k) != 0) {
            ans.at(i).at(j) = k;
            a.at(k)--;
            break;
          }
        }
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (j == w - 1) {
        cout << ++ans.at(i).at(j);
        continue;
      }
      cout << ++ans.at(i).at(j) << " ";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    int a,b;
    cin>>a>>b;
    if(a<=0&&b>=0)
        cout<<"Zero"<<"\n";
    else if(a<0&&b<0){
        if((b-a)%2!=0)
            cout<<"Positive"<<"\n";
        else
            cout<<"Negative"<<"\n";
    }
    else 
        cout<<"Positive"<<"\n";
    
}

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

typedef long long ll;

using namespace std;

int num[500];
string w;

int main() {
	cin >> w;
	for (int i = 0; i < w.size(); i++)
	{
		num[w[i]] = 1 - num[w[i]];
	}

	for (char c = 'a'; c <= 'z'; c++) {
		if (num[c] == 1) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define FASTIO ios_base::sync_with_stdio(NULL); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define MOD 1000000007

using namespace std;

void init(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin) ;
  freopen("output.txt", "w", stdout) ;
  #endif
}

// code from below
int arr[int(1e5)+1][3];

void solve(){
	int n;
    cin>>n;
    FOR(i,n)
        FOR(j,3)
        cin>>arr[i][j];
    // find the answer, from bottom up

    // we have to do exaushtive search and take max from all possiblities and this
    // would be too intensive using recursion but using dp it would be easy
    for(int i=n-2;i>=0;i--){
        arr[i][0]+=max(arr[i+1][1],arr[i+1][2]);
        arr[i][1]+=max(arr[i+1][0],arr[i+1][2]);
        arr[i][2]+=max(arr[i+1][1],arr[i+1][0]);
    }

    // answer would be max at row 0
    cout<<max(arr[0][0],max(arr[0][1],arr[0][2]))<<endl;
}

int main(){
    int t=1;
    // cin>>t;
    // cin.ignore(numeric_limits<streamsize>::max(),'\n'); 
    while(t--)
        solve();
}

Measured memory_bytes: 4720
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
total = 0

cnt = Counter(A)
for i in cnt:
    total+=int(((cnt[i])*(cnt[i]-1))/2)

for i in range(N):
    t = cnt[A[i]]
    print(int(total - (t*(t-1)/2) + ((t-1)*(t-2)/2)))

Measured memory_bytes: 33924
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()][::-1]

ng = []
for i in range(n):
    if a[i] == b[i]:
        ng.append(i)

if len(ng) == 0:
    print('Yes')
    print(*b)
    sys.exit()

min_ng = min(ng)
max_ng = max(ng)

left = 0
right = n - 1

for i in ng:
    if b[i] != b[left] and a[left] != b[i]:
        b[i], b[left] = b[left], b[i]
        left += 1
        continue
    if b[i] != b[right] and a[right] != b[i]:
        b[i], b[right] = b[right], b[i]
        right -= 1

flag = 1

for i in range(n):
    if a[i] == b[i]:
        flag = 0

if flag:
    print('Yes')
    print(*b)
else:
    print('No') 



Measured memory_bytes: 124244
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
string st;
int main()
{
    while(1){
        getline(cin,st);
        if(st[0]=='.')return 0;
        stack<char>s;
        L l=st.length();
        for(L i=0;i<l;i++){
            if(st[i]=='(' || st[i]=='['){
                s.push(st[i]);
            }
            else if(st[i]==']' || st[i]==')' ){
                if(!s.empty()){
                    if(st[i]==']'){
                        if(s.top()!='['){
                            break;
                        }
                        else s.pop();
                    }
                    else if(st[i]==')'){
                        if(s.top()!='('){
                            break;
                        }
                        else s.pop();
                    }
                }
                else{
                    s.push(')');break;
                }
            }
        }
        if(!s.empty())printf("no\n");
        else printf("yes\n");
    }


    return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) int64 x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(a);
    cii(b);
    auto ans = -1;
    rep1(i, 1009){
        if ((int)(i*0.08) == a && (int)(i*0.1) == b){
            ans = i;
            break;
        }
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 256
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define ra read_alpha()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline char read_alpha() { char c = ge; while(!isalpha(c) && c != EOF) c = ge; return c; }
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int MAXN = 1010;
const int MAXM = 200010;

struct Edge {
	int u, v;

	Edge() {}
	Edge(int u, int v):u(u), v(v) {}
}E[MAXM];

vector<int>to[MAXN];

int Mark[MAXN];
bitset<MAXN>vis;
bool G1[MAXN][MAXN];
bool G2[MAXN][MAXN];

inline void dfs1(int x, int st) {
	G1[st][x] = 1, vis.set(x);
	for(auto u : to[x]) if(!vis[u]) dfs1(u, st);
}

inline void dfs2(int x, int col, int k, int st) {
	if(k) G2[st][x] = Mark[x] != col;
	else Mark[x] = col; vis.set(x);
	for(auto u : to[x]) if(!vis[u]) dfs2(u, col, k, st);
}

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n = ri, m = ri;
	for(int i = 1; i <= m; i++) {
		int u = ri, v = ri;
		to[u].push_back(v);
		E[i] = Edge(u, v);
	}
	for(int i = 1; i <= n; i++) vis.reset(), dfs1(i, i);
	for(int i = 1; i <= n; i++) {
		vis.reset(), vis.set(i);
		memset(Mark, 0, sizeof(Mark));
		int d = to[i].size();
		for(int j = 0; j < d; j++) if(!vis[to[i][j]]) dfs2(to[i][j], j + 1, 0, i);
		vis.reset(), vis.set(i);
		for(int j = d - 1; ~j; --j) if(!vis[to[i][j]]) dfs2(to[i][j], j + 1, 1, i);
	}
	for(int i = 1; i <= m; i++)
		puts(G1[E[i].v][E[i].u] ^ G2[E[i].u][E[i].v] ? "diff" : "same");
	return 0;
}

Measured memory_bytes: 6528
using System;

namespace abc070a
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int len = input.Length;

            for (int i = 0; i < len; i++)
            {
                if (input[i] != input[len - i - 1])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 11092
import sys

if sys.platform =='ios':
   sys.stdin=open('input_file.txt')

#+++++

#a,b = map(int, input().split())
#n = int(input().strip())
s=int(input().strip())
t=int(input().strip())
a=[1,2,3]
a.remove(s)
a.remove(t)
print(a[0])


Measured memory_bytes: 2940
#include<stdio.h>

int main()
{
   int A,B,C,temp;
scanf("%d %d %d",&A,&B,&C);
temp=A;
A=B;
B=temp;
temp=A;
A=C;
C=temp;
printf("%d %d %d",A,B,C);
return 0;
}

Measured memory_bytes: 128
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	vector<int> v(n);
	for(auto &x : v){
		cin>>x;
	}
	vector<int> pre(n);
	pre[n-1] = v[n-1];
	for(int i=n-2;i>=0;i--){
		pre[i] = v[i] + pre[i+1];
	}
	int ans = 0;
	for(int i=0;i<(n-1);i++){
		ans += v[i]*(pre[i]-v[i]);
	}
	cout<<ans;
	return 0;
}
//.........

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#define WHITE 0 //未発見
#define GRAY 1 //発見
#define BLACK 2 //探索済み
#define NIL -1
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector< vector<int> > table;

void bfs(table& m,int s)
{
    vector<int> color(m.size(),WHITE);
    vector<int> dist(m.size(),NIL);
    queue<int> q;
    q.push(s);
    color[s]=GRAY;
    dist[s]=0;

    while (!q.empty())
    {
        int u=q.front();q.pop();
        rep(v,m.size())
        {
            if(dist[v]!=NIL)continue;
            if(m[u][v]==1 && color[v]==WHITE)
            {
                dist[v]=dist[u]+1;
                color[v]=GRAY;
                q.push(v);
            }
        }
        color[u]=BLACK;
    }
    
    rep(i,m.size()) cout<<i+1<<" "<<dist[i]<<endl;
}

int main()
{
    int n;
    cin>>n;
    table m(n,vector<int>(n,0));
    rep(i,n)
    {
        int u,k;
        cin>>u>>k;
        rep(j,k)
        {
            int v;
            cin>>v;
            m[u-1][v-1]=1;
        }
    }

    bfs(m,0);

    return 0;
}


Measured memory_bytes: 3176
order = [int(input()) for i in range(5)]
diff = (sorted(map(lambda x: (x % 10), order)))
diff = [i for i in diff if i != 0]

sum_order = sum(list(map(lambda x: -(-x //10), order))) * 10

if diff != []:
    sum_order += (-10 + diff[0])
    
print (sum_order)


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main  {
  int H,W;
  void run() {
    Scanner sc = new Scanner(System.in);
    H = sc.nextInt();
    W = sc.nextInt();
    for(int i = 0; i < H; i++) {
      String s = sc.next();
      System.out.println(s);
      System.out.println(s);
    }
  }
  public static void main(String[] args) {
    new Main().run();
  }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string s; cin >> s;
    ll q; cin >> q;
    bool order = false;
    rep(i, q) {
        ll query; cin >> query;
        if (query == 1) {
            order = !order;
        } else {
            ll f; char c;
            cin >> f >> c;
            if      ((f + order) % 2) s.insert(s.begin(), c);
            else s.push_back(c);
        }
    }

    if (order) reverse(all(s));
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 900
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-18
inline ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0';
    return tmp*f;
}
using namespace std;
ll a[200010],b[200010];
ll tmp[200010];
int n;
ll find(ll k)
{
    int l=1,r=n+1;
    while(l<r){
        int mid=(l+r)>>1;
        if(tmp[mid]>=k)r=mid;else l=mid+1;
    }
    return l;
}
int main()
{
    int i,k;
    n=read();
    for(i=1;i<=n;i++)a[i]=read();
    for(i=1;i<=n;i++)b[i]=read();
    ll ans=0;
    for(k=1;k<=29;k++){
        ll base=(1<<k)-1;
        for(i=1;i<=n;i++)tmp[i]=b[i]&base;
        sort(tmp+1,tmp+n+1);
        ll cnt=0; 
        for(i=1;i<=n;i++)
            cnt+=n-find((1<<(k-1))-(a[i]&base))+1;
        for(i=1;i<=n;i++)
            cnt-=find((1<<k)+(1<<(k-1))-(a[i]&base))-find((1<<k)-(a[i]&base));
        if(cnt&1)ans+=(1<<(k-1));
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

int main() {
    LL K;
    cin >> K;
    int N = 50;
    vector<long long> As;
    LL cycle = K / N;
    LL residue = K - N * cycle;
    for (int i = 0; i <= N; ++i){
        if (i == N - residue) continue;
        As.push_back(i + cycle );
    }
    cout << N << endl;
    for (int i = 0; i != N; ++i) cout << As[i] << ((i == N - 1)? '\n' : ' ');
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int N;
long long a[100001], O;
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
		scanf("%lld", a + i);
	for (int i = 1; i <= N; i++)
		if (a[i])
		{
			long long G = a[i];
			while (i < N && a[i + 1])
				G += a[++i];
			O += G >> 1;
		}
	printf("%lld\n", O);
}


Measured memory_bytes: 896
import java.io.IOException
import java.io.InputStream
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (a, b, c) = sc.nextInts(3)
    println(Math.min(b / a, c))
}

class Scanner(private val `in`: InputStream) {
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0

    companion object {
        private fun isPrintableChar(b: Byte): Boolean = b in 33..126
        private fun isNumericChar(b: Byte): Boolean = b in 48..57
        private fun digit(b: Byte): Int = b - 48
    }

    fun hasNextByte(): Boolean {
        if (ptr < buflen) return true
        ptr = 0
        try {
            buflen = `in`.read(buffer)
        } catch (e: IOException) {
            e.printStackTrace()
        }
        return 0 < buflen
    }

    private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        return buildString {
            var b = readByte()
            while (isPrintableChar(b)) {
                appendCodePoint(b.toInt())
                b = readByte()
            }
        }
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextInts(n: Int): Array<Int> = Array(n) { nextInt() }

    fun nextIntArray(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextIntArrays(n: Int, m: Int): Array<IntArray> {
        val arrays = Array(m) { IntArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextInt() } }
        return arrays
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextLongs(n: Int): Array<Long> = Array(n) { nextLong() }

    fun nextLongArray(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextLongArrays(n: Int, m: Int): Array<LongArray> {
        val arrays = Array(m) { LongArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextLong() } }
        return arrays
    }

}

Measured memory_bytes: 29484
str = input()

if str != str[::-1]:
    print("No")
else:
    fstr = str[:(len(str)-1)//2]
    tstr = str[(len(str)+3)//2-1:]

    if fstr == fstr[::-1] and tstr == tstr[::-1]:
        print("Yes")
    else:
        print("No")


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

using namespace std;
#define int long long
#define INF ((10e9)+7)
#define pb push_back
int call(int i,int j,vector<int>&A,vector<vector<bool > >&vis,vector<vector<int > >& dp)
{
    if(i>j)
    {
        return 0;
    }
    if(vis[i][j]) return dp[i][j];
    vis[i][j]=true;
    
    return dp[i][j]=max(A[i]-call(i+1,j,A,vis,dp),A[j]-call(i,j-1,A,vis,dp));
    
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin>>N;
    vector<vector<int > >dp(N,vector<int > (N));
    vector<vector<bool > >vis(N,vector<bool >(N,false) );
    
    vector<int> A(N);
    for(int i=0;i<N;i++)
    {
        cin>>A[i];
    }
    
    cout<<call(0,N-1,A,vis,dp);
    
    return 0;
    
}

Measured memory_bytes: 72192
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    ll AB=min(A+B,2*C);
    ll res=0;
    while(X>0&&Y>0){
        res+=AB;
        X--;
        Y--;
    }
    while(X>0){
        chmin(A,C*2);
        res+=A;
        X--;
    }
    while (Y>0)
    {
        chmin(B,C*2);
        res+=B;
        Y--;
    }
    cout<<res<<endl;
}


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



int main() {
    string S;
    cin>>S;
    if(S.size()%2==1){cout<<"No"<<endl;}
    else{
        string P;
        for(int i=1;2*i<=S.size();i++){
            P.push_back('h');
            P.push_back('i');
        }
        if(S==P){cout<<"Yes"<<endl;}
        else{cout<<"No"<<endl;}
    }
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    int a, b;
    std::cin >> a >> b;
    if(a % 3 && b % 3 && (a + b) % 3){
        std::cout << "Impossible" << std::endl;
    }else{
        std::cout << "Possible" << std::endl;
    }
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s[0] != 'A') {
    puts("WA");
    return 0;
  }
  int f = 0;
  for (int i = 1; i < s.size(); i++) {
    if (i >= 2 && i <= s.size() - 2 && s[i] == 'C') {
        f++;
    } else {
      if ('A' <= s[i] && s[i] <= 'Z') {
        puts("WA");
        return 0;
      }
    }
  }
  if (f == 1) {
    puts("AC");
  } else {
    puts("WA");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    int l, r;
    cin >> l >> r;
    cnt += r - l + 1;
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 3148
import math,sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=0
r=10**9+2
while math.ceil(l)<math.floor(r):
  tr=(l+r)/2
  temp=0
  for i in range(n):
    temp+=math.ceil(a[i]/tr)-1
  if temp<=k:
    r=tr
  else:
    l=tr
tr=math.ceil(l)
if tr==0:
  print(1)
  sys.exit()
temp=0
for i in range(n):
  temp+=a[i]//tr
  if a[i]%tr==0:
    temp-=1
if temp<=k:
  print(tr)
else:
  print(tr+1)

Measured memory_bytes: 93736
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int cnt[4],n;
char s[N];
void dfs(int x,int last1,int last2){
	if (x>n){
		puts("YES");
		exit(0);
	}
	if (cnt[0]&&last1!=1&&last2!=1){
		cnt[0]--;
		dfs(x+1,last2,1);
		cnt[0]++;
	}
	if (cnt[1]&&last2!=2&&last1!=2){
		cnt[1]--;
		dfs(x+1,last2,2);
		cnt[1]++;
	}
	if (cnt[2]&&last2!=3&&last1!=3){
		cnt[2]--;
		dfs(x+1,last2,3);
		cnt[2]++;
	}
}
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	for (int i=1;s[i];i++)cnt[s[i]-'a']++;
	dfs(1,0,0);
	puts("NO");
}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
#define N 246912
int main(){
  int n,a[246912];
  for(int i=0;i<N;i++)a[i]=i+1;
  for(int i=0;i<N;i++)a[i]=true;
  a[0]=a[1]=false;
  for(int i=0;i<N;i++)
    if(a[i]==true)
      for(int j=i*2;j<N;j+=i)
	  a[j]=false;

  while(1){
    int count=0,n;
    cin>>n;
    if(n==0)break;
    for(int i=n+1;i<=2*n;i++)
      if(a[i]==true)count++;    
    cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 2124
a,b,c,d = gets.chop.split.map(&:to_i)

class Array
  def lcm
  	self.inject{|a,b| a.lcm(b)}
  end
end

ary=[c,d]
cd_lcm=ary.lcm

count_c=b/c-(a-1)/c
count_d=b/d-(a-1)/d
count_cd=b/(cd_lcm)-(a-1)/(cd_lcm)

puts (b-a+1)-(count_c+count_d-count_cd)


Measured memory_bytes: 1788
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append([i for i in input()])
h_count = []
for h_ in range(h):
    if a[h_] == ["."] * w:
        h_count.append(h_)
w_count = []
for w_ in range(w):
    if list(map(lambda x: x[w_], a)) == ["."] * h:
        w_count.append(w_)
h_get = [i for i in range(h) if i not in h_count]
w_get = [i for i in range(w) if i not in w_count]

for i in h_get:
    temp = a[i]
    temp_1 = []
    for j in w_get:
        temp_1.append(temp[j])
    print("".join(temp_1))

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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--)
    {
    string str;
    cin>>str;
    int n=str.size();
    int arr[n+1]={0};
    for(int i=0;i<n;i++)
    {
        if(str[i]=='<'){
            arr[i]=0;
            int j=i+1;
            int val=1;
            while(str[j]==str[j-1]){
                arr[j]=val;
                val++;
                j++;
            }
            i=j-1;
        }

    }
    for(int i=n-1;i>=0;i--)
    {
        if(str[i]=='>'&&i!=0){
            arr[i]=max(arr[i+1]+1,arr[i-1]+1);
        }else if(str[i]=='>'&&i==0){
        arr[i]=arr[i+1]+1;
        }

    }
    if(str[n-1]=='<'){
        arr[n]=arr[n-1]+1;
    }
    ll sum=0;
    for(int i=0;i<=n;i++){
        sum+=arr[i];
    }
    cout<<sum<<endl;

    }


    return 0;

}


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

const int N = 505;

int n, m;
char mx[N][N], a[N][N], b[N][N];

int main() {
#ifdef HOME
	freopen("agc4c.in", "r", stdin);
	freopen("agc4c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		cin >> (mx[i] + 1);

	for (int i = 1; i <= n; ++i)
	for (int j = 1; j <= m; ++j)
		a[i][j] = b[i][j] = '.';

	for (int i = 1; i <= n; ++i) {
		a[i][1] = b[i][m] = '#';
		for (int j = 1; j <= m; ++j)
			(i % 2 ? a : b)[i][j] = '#';
		a[i][m] = b[i][1] = '.'; }

	for (int i = 1; i <= n; ++i)
	for (int j = 1; j <= m; ++j) if (mx[i][j] == '#')
		a[i][j] = b[i][j] = '#';

	for (int i = 1; i <= n; ++i)
		cout << (a[i] + 1) << '\n';
	cout << '\n';
	for (int i = 1; i <= n; ++i)
		cout << (b[i] + 1) << '\n';

	return 0; }


Measured memory_bytes: 1536
N,M = list(map(int,input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

ans = 0
divisors = make_divisors(M)
for divisor in divisors:
    if N <= M//divisor:
        ans = max(ans,divisor)

print(ans)

Measured memory_bytes: 3188
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B = map(int, input().split())

        ans = 0
        for n in range(A, B + 1):
            s_n = str(n)
            f = True
            for i in range(len(s_n) // 2):
                if s_n[i] != s_n[-(i + 1)]:
                    f = False
                    break
            if f:
                ans += 1

        print(ans)


if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 39536
import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    if N % K == 0:
        print(0)
    else:
        d = gcd(N, K)
        n = N // d
        k = K // d
        cand = n % k
        print(d * min(cand, k - cand))
    

if __name__ == "__main__":
    main()


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

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

ll solve(ll a, ll b)
{
    ll x = min(a, b);
    ll y = max(a, b);

    if(y % x == 0) return 2 * x * (y / x) - x;
    return 2 * x * (y / x) + solve(x, y % x); 
}

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

    cout << N + solve(N - X, X) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
    ll x,y;
    cin>>x>>y;
    ll d=abs(y)-abs(x);
    ll ans=0;
    if(d>=0){
        ans+=abs(d);
        if(x<0)ans++;
        if(y<0)ans++;
    }
    else {
        ans+=abs(d);
        if(x>0)ans++;
        if(y>0)ans++;
    }
    cout <<ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int main() {
	int N;cin>>N;
	cout << N * N * N << endl;
	return 0;
}

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

int main()
{
	int a,b,M;
	cin>>a>>b;
	
	if(a+b>a-b)
		M=a+b;
	else
		M=a-b;
	
	if(a*b>M)
		M=a*b;
	
	cout<<M;
		
	return 0;
}


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

int N;

int f(int n) {
  if (n / 10 == 0) return n;
  return f(n / 10);
}

int main() {
  cin >> N;
  unordered_map<int, unordered_map<int, int>> c;

  for (int i = 1; i <= N; ++i) {
    int tail = (i % 10);
    int head = f(i);
    c[head][tail] += 1;
  }

  int ans = 0;
  for (int i = 1; i < 10; ++i) {
    for (int j = 1; j < 10; ++j) {
      ans += c[i][j] * c[j][i];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt(), x = sc.nextInt();
		boolean[] a = new boolean[n + 1];
		for (int i = 0; i < m; i++)
			a[sc.nextInt()] = true;

		int cost = 0, min = Integer.MAX_VALUE;
		for (int i = x; i < a.length; i++) {
			if (a[i])
				cost++;
		}
		min = Math.min(cost, min);
		cost = 0;
		for (int i = x; i > 0; i--) {
			if (a[i])
				cost++;
		}
		min = Math.min(cost, min);

		System.out.println(min);
	}

}

Measured memory_bytes: 27096
n = int(input())
p = list(map(int,input().split()))
x = 0
ans = 0
for cnt,num in enumerate(p):
    if cnt+1 == num:
        if x == 0:
            ans += 1
            x = 1
        else:
            x = 0
        
    else:
        x = 0
print(ans)

Measured memory_bytes: 14008
import numpy as np

N=int(input())
a_lst=[int(_) for _ in input().split()]
a_arr=np.array(a_lst)
idx=np.absolute(a_arr).argmax() + 1 #1origin

if a_lst[idx-1]==0:
    print(0)
else:
    print(2*N-2)
    for i in range(1, N+1):
        if i != idx:
            print(idx, i)
    if a_lst[idx-1]>0:
        for i in range(1, N):
            print(i, i+1)
    elif a_lst[idx-1]<0:
        for i in range(N, 1, -1):
            print(i, i-1)

Measured memory_bytes: 12508
from math import sqrt
while 1:
    n=int(input())
    if n==0:
        break
    else:
        l=[int(i) for i in input().split()]
        a=sum(l)/n
        l_=[(x-a)**2 for x in l]
        print("{:.5f}".format(sqrt(sum(l_)/n)))


Measured memory_bytes: 5788
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    S.replace(0, 4, "2018");
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s,t;
  cin>>s>>t;
  t+=s;
  cout<<t<<endl;
  return 0;
}


Measured memory_bytes: 256