akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}/*swap 交換*/
ll max2(ll a,ll b){return a>=b?a:b;}/*2つのうち大きい数を返す*/ 
ll min2(ll a,ll b){return a>=b?b:a;}/*2つのうち小さい数を返す*/ 
ll ABS(ll a){return a>=0?a:(-a);}/*絶対値*/ 
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    ll n,a,b,ans=0;
    scanf("%lld%lld%lld",&n,&a,&b);
    if(a==0){
        printf("0\n");
        return 0;
    }
    // rep(i,0,n){
    //     scanf("%lld",&[i]);
    // }
    ans+=n/(a+b)*a;
    n-=(n/(a+b)*(a+b));
    ans+=n>a?a:n;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, A, B = map(int, readline().split())
    X = list(map(int, readline().split()))
    ans = 0
    for i in range(N-1):
        ans += min((X[i+1]-X[i])*A,B)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18468
using System;
class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            string[] data = Console.ReadLine().Split(' ');
            int H = int.Parse(data[0]);
            int W = int.Parse(data[1]);
            if (H == 0 && W == 0)
            {
                return;
            }

            string line = "";
            for (int i = 0; i < W; i++)
            {
                line = line + "#";
            }
            for (int i = 0; i < H; i++)
            {
                Console.WriteLine(line);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 5292
def lucas(n):

    l0 = 2
    l1 = 1
    l2 = 0
    if n == 0:
        return l0
    elif n == 1:
        return l1
    else:
        while n > 1:
            l2 = l0 + l1
            l0 = l1
            l1 = l2
            n -= 1

        return l2

N = int(input())
print(lucas(N))

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

int main()
{
	int n,x;
	int count=0;
	while(1){
		cin>>n>>x;
		if(n==0&&x==0) break;
		for(int i=1;i<=n-2;i++){
			for(int j=i+1;j<=n-1;j++){
				for(int k=j+1;k<=n;k++){
					if(i+j+k==x) count++;
					
				}
			}
		}
		
		cout<<count<<endl;
		count=0;

	}

	return 0;
}

Measured memory_bytes: 3092
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
ac = [False] * n
count = [0] * n
sum_wa = 0
for i in range(len(l)):
    # print(l[i][0], l[i][1])
    if l[i][1] == "WA" and ac[int(l[i][0]) - 1] == False:
        count[int(l[i][0]) - 1] += 1
    elif l[i][1] == "AC":
        sum_wa += count[int(l[i][0]) - 1]
        count[int(l[i][0]) - 1] = 0
        ac[int(l[i][0]) - 1] = True
print(ac.count(True), sum_wa)

Measured memory_bytes: 27456
#include<stdio.h>
int main(void){
  int a,b,c,count,i;
  while(scanf("%d%d", &a,&b)!=EOF){
    count=0;
  c=a+b;
  for(i=0;i<2000000;i++){
    c=c/10;
    count=count+1;
    if(c==0)
      break;
  }
  printf("%d\n",count);
  }
  return 0;

}

Measured memory_bytes: 600
using System;


namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string amount = Console.ReadLine();

            if (Char.IsUpper(Char.Parse(amount)))
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine("a");
            }
            
        }
    }
}


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

using namespace std;

const int N = 1e6+10;
long long int a[N], b[N], c[N];

int main () {
    long long int n;
    cin >> n;
    for(int i = 0 ; i < n-1 ; i++ ) {
        cin >> a[i];
    }
    b[0]=a[0];
    long long int ans = b[0];
    for(int i = 1 ; i < n ; i++ ) {
        if(i==n-1) {
            b[i]=a[i-1];
            ans+=b[i];
            break;
        }
        b[i]=min(a[i],a[i-1]);
        ans+=b[i];
    }
    cout << ans;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    bool a = s[0] != s[n - 1];
    bool b = n & 1;
    if (a == b) {
        cout << "First" << '\n';
    } else {
        cout << "Second" << '\n';
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  double_t a, b, x; cin >> a >> b >> x;
  const double_t PI = std::acos(-1);
  
  auto mid = (a * b * a/ 2);
  double_t res{};
  if (x >= mid) {
    auto s = x / a;
    auto c = s * 2 / a - b;
    res = std::atan2(b - c, a);
  } else {
    auto s = x / a;
    auto d = s * 2 / b;
    res = std::atan2(b, d);
  }
  auto ans = res / PI * 180;
  cout << std::setprecision(10) << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

int main() {
	
	string S;
	cin >>S;
	
	bool a, b;
	a=true;
	b=true;
	
	for(int i=0; i<S.size(); i+=2){
		
		if(S.at(i)=='L'){
			
			a=false;
			
		}
		
	}
	for(int i=1; i<S.size(); i+=2){
		
		if(S.at(i)=='R'){
			
			b=false;
			
		}
		
	}
	
	if(a==true&&b==true){
		
		cout <<"Yes" <<endl;
		
	}
	else{
		
		cout <<"No" <<endl;
		
	}
	
}

Measured memory_bytes: 256
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-03-06(Fri)
   note
**********************************************************************/

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

int main() {
  int Takahashi_HP, Takahashi_ATK, Aoki_HP, Aoki_ATK;
  cin >> Takahashi_HP >> Takahashi_ATK >> Aoki_HP >> Aoki_ATK;
  int remain_Takahashi_HP; //= Takahashi_HP - Aoki_ATK;
  int remain_Aoki_HP; //= Aoki_HP - Takahashi_ATK;
  //int ans;

  // TakahashiがAokiのHPを0以下にするのに要したカウント
  int count_Takahashi = 1;
  for (int i = 1; i <= 100; i++) {
    remain_Aoki_HP = Aoki_HP - Takahashi_ATK*i;
    if (remain_Aoki_HP <= 0) {
      break;
    }
    count_Takahashi++;
  }

  // AokiがTakahashiのHPを0以下にするのに要したカウント
  int count_Aoki = 1;
  for (int i = 1; i <= 100; i++) {
    remain_Takahashi_HP = Takahashi_HP - Aoki_ATK*i;
    if (remain_Takahashi_HP <= 0) {
      break;
    }
    count_Aoki++;
  }
  //cout << count_Takahashi << endl;
  //cout << count_Aoki << endl;

  if (count_Takahashi <= count_Aoki) {
    cout << "Yes" << endl;
  }
  else if (count_Takahashi > count_Aoki) {
    cout << "No" << endl;
  }
 }


Measured memory_bytes: 3620
N = int(input())
XL = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0]+x[1])
last = XL[0][0]-XL[0][1]
cnt = 0
for i in range(N):
    if last<=XL[i][0]-XL[i][1]:
        last = XL[i][0]+XL[i][1]
        cnt+=1
print(cnt)

Measured memory_bytes: 66776
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());

        var t = new int[n];
        var a = new int[n];
        for (int i = 0; i < n; i++)
        {
            var ta = Console.ReadLine().Split();
            t[i] = int.Parse(ta[0]);
            a[i] = int.Parse(ta[1]);
        }

        var x = 1L;
        var y = 1L;

        for (int i = 0; i < n; i++)
        {
            var p = Math.Max(
                ceil(x, t[i]),
                ceil(y, a[i]));

            x = t[i] * p;
            y = a[i] * p;
        }

        Console.WriteLine(x + y);
    }

    static long ceil(long a, long b)
    {
        return a % b == 0 ? a / b : a / b + 1;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
int main(){
	ll a,b,n;
	scanf("%lld%lld%lld",&a,&b,&n);
	int ans=0;
	if((b+a-1)/a<=n){
		ans=max(1ll*ans,((b+a-1)/a)*a/b-a*((b+a-1)/a/b));
	}
	n=min(n,b-1);
	ans=max(ans*1ll,(a*n)/b-a*(n/b));
	for(int i=0;i<=min(a,n);i++){
		ans=max(1ll*ans,(a*i)/b-a*(i/b));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3816
n = int(input())
ip = []

for i in range(n):
  a = int(input())
  ip.append(a)
  for j in range(a):
    x,y = map(int,input().split())
    ip.append([x,y])

max = 0    
for i in range(n) :
  max += 2**i

ans = 0
for i in range(0,max+1) :
  s = [2 for _ in range(n)]
  bit = i
  count = 0
  index = 0
  check = 0
  for j in range(n) :
    if bit%2 == 1 :
      if s[j] == 0 :
        check = 1
      s[j] = 1
    else :
      if s[j] == 1 :
        check = 1
      s[j] = 0
    bit = bit//2
    for k in range(ip[index]) :
      if s[j] == 1 :
        if ip[index+1+k][1] == 1 :
          if s[ip[index+1+k][0]-1] == 0 :
            check = 1
          s[ip[index+1+k][0]-1] = 1
        elif ip[index+1+k][1] == 0 :
          if s[ip[index+1+k][0]-1] == 1 :
            check = 1
          s[ip[index+1+k][0]-1] = 0
    index += ip[index] + 1
  if ans < s.count(1) and check ==0 :
    ans = s.count(1)

print(ans)

Measured memory_bytes: 48860
import sys 

input = sys.stdin.readline
# sys.setrecursionlimit(25000)

q = int(input())
qry = [None] * q


mn = 10 ** 5
mx = 0
for i in range(q):
    qry[i] = list(map(int, input().split()))
    if qry[i][0] < mn:
        mn = qry[i][0]
    if qry[i][1] > mx:
        mx = qry[i][1]

def is_prime(n):
    if n == 1:
        return False
    i = 2
    while(i * i <= n):
        if n % i == 0:
            return False
        i += 1
    return True


cum = [0] * (mx + 1)
cum[0] = 0

for i in range(1, len(cum)):
    d = 0
    if i % 2 == 0:
        d = 0
    if is_prime(i) and is_prime((i + 1) // 2):
        d = 1
    cum[i] = cum[i - 1] + d

for i in range(q):
    print(cum[qry[i][1]] - cum[qry[i][0] - 1])
    


Measured memory_bytes: 59868
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/29 06:10:49 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	double	a, b, x;
	cin >> a >> b >> x;

	double	h;
	h = b - (x / (a * a));
	if (2 * h <= b)
		cout << atan2(2 * h, a) * 180.0 / M_PI << endl;
	else
	{
		double	s;
		s = x / a;
		cout << atan2(b, 2 * s / b) * 180.0 / M_PI << endl;
	}
}
// END

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


Measured memory_bytes: 384
def main():
    x = int(input())
    a, b = 1, 0

    while True:
        for b in reversed(range(-a + 1, a)):
            # print(a, b)
            q = a**5 - b**5
            if q == x:
                print(f'{a} {b}')
                return
        a += 1

main()

Measured memory_bytes: 9096
H,W = list(map(int,input().split()))
A = [list(str(input())) for i in range(H)]
 
black = []
 
cnt = 0
 
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            black.append([i,j])
 
length = len(black)
            
while (length < H*W):
    gray = []
    for l in black:
        if l[1] != 0:
            c1 = (l[0],l[1]-1)
            if A[c1[0]][c1[1]] == ".":
                gray.append(c1)
                A[c1[0]][c1[1]] = "#"
        if l[1] != W-1:
            c2 = (l[0],l[1]+1)
            if  A[c2[0]][c2[1]] == ".":
                gray.append(c2)
                A[c2[0]][c2[1]] = "#"
        if l[0] != 0:
            c3 = (l[0]-1,l[1])
            if  A[c3[0]][c3[1]] == ".":
                gray.append(c3)
                A[c3[0]][c3[1]] = "#"
        if l[0] != H-1:
            c4 = (l[0]+1,l[1])
            if  A[c4[0]][c4[1]] == ".":
                gray.append(c4)
                A[c4[0]][c4[1]] = "#"
    
    gray = list(set(gray))
    black = [l for l in gray]
    
    cnt += 1
    length += len(black)
    
print(cnt)

Measured memory_bytes: 178560
b = []
count = []
while True:
    inp = input()
    a = inp.split()
    a[0] = int(a[0])
    a[1] = int(a[1])
    if a[0] == 0 and a[1] == 0:
        break
    else:
        b.append(a)
        count.append(0)
for i in range(len(b)):
    for j in range(1,b[i][0]):
        for k in range(j+1,b[i][0]):
               for l in range(k+1,b[i][0]+1):
                    if b[i][1]-j-k-l == 0:
                        count[i] += 1
for i in range(len(count)):
    print(count[i])


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b > c+d)
    cout << "Left" << endl;
  else if (a+b < c+d)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 200000+10
int n, q;
string s;
char t[maxn], d[maxn];

bool left(int pos)
{
    for (int i = 0; i < q; i++) {
        if (s[pos] == t[i]) {
            if (d[i] == 'L') pos--;
            else pos++;
        }
        if (pos == -1) return true;
    }
    return false;
}

bool right(int pos)
{
    for (int i = 0; i < q; i++) {
        if (s[pos] == t[i]) {
            if (d[i] == 'L') pos--;
            else pos++;
        }
        if (pos == n) return true;
    }
    return false;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    cin >> n >> q;
    cin >> s;
    for (int i = 0; i < q; i++) {
        scanf(" %c %c", &t[i], &d[i]);
        //cout << t[i] << " " << d[i] << endl;
    }
    int l1 = -1, r1 = n;
    while (r1-l1>1) {
        int mid = (r1+l1)/2;
        if (left(mid)) l1 = mid;
        else r1 = mid;
    }
    int l2 = -1, r2 = n;
    while (r2-l2>1) {
        int mid = (r2+l2)/2;
        if (right(mid)) r2 = mid;
        else l2 = mid;
    }
    printf("%d\n", n-(n-r2+l1+1));
    return 0;
}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FORD(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

ll aabs(ll a) {
	if(a  >= 0) {
		return a;
	} else {
		return -a;
	}
}

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

	if(c-(a-b) > 0) {
		ans = c-(a-b);
	} else {
		ans = 0;
	}


    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size() - 1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min + (max - min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n, vector<ll> &ret) {
	for (ll 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());

}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n, z, w;
	cin >> n >> z >> w;
	vector<ll> a(n);
	rep(i, n)cin>>a[i];
	if (n == 1) {
		cout << abs(a[0] - w);
		return 0;
	}
	ll max = abs(w - a[n - 1]);
	chmax(max, abs(a[n - 1] - a[n - 2]));
	cout << max;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    c = b - a
    high = (c + 1) * c / 2
    print(int(high - b))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;


ll N, M;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;

	ll res = 0;
	if(N <= M / 2) {
		res += N;
		N = 0;
		M = M - 2 * res;
	} else {
		res += M / 2;
		M -= res * 2;
		N -= res;
	}

	while(M >= 4) {
		res++;
		M -= 4;
	}
	cout << res << endl;
	
}


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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	string s;
	int ans = 10000;
	
	
	cin>>s;
	
	for(int i = 0; i + 2 < s.size(); i++){
		int num = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0')*1;
		ans = min(abs(num-753),ans);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

using namespace std;

const int N = 1e5 + 3;

struct Edge {
  int u, v, w;
  Edge() {};
  Edge(int _u, int v_, int w_) : u(_u), v(v_), w(w_) {};
  bool operator< (Edge b) {
    return w < b.w;
  }
};

struct cmp
{
    bool operator() (const Edge &a,const Edge &b)
    {
        return a.w > b.w;
    }
};

struct Point {
  int x, y, id;
} a[N];

int n, par[N];
priority_queue <Edge, vector <Edge>, cmp> q;

int findSet(int x) {
  if (par[x] < 0) return x;
  return (par[x] = findSet(par[x]));
}

void join(int x, int y) {
  if ((x = findSet(x)) == (y = findSet(y))) return;
  if (par[x] > par[y]) swap(x, y);
  par[x] += par[y]; par[y] = x;
}

int main() {
  #ifdef GG
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
  #endif
  ios_base::sync_with_stdio(0); cin.tie(NULL);
  memset(par, -1, sizeof(par));
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].x, &a[i].y);
    a[i].id = i;
  }
  sort(a, a + n, [](Point a, Point b) { return a.x < b.x; });
  for (int i = 0; i < n - 1; ++i) {
    q.push(Edge(a[i].id, a[i + 1].id, abs(a[i].x - a[i + 1].x)));
  }
  sort(a, a + n, [](Point a, Point b) { return a.y < b.y; });
  for (int i = 0; i < n - 1; ++i) {
    q.push(Edge(a[i].id, a[i + 1].id, abs(a[i].y - a[i + 1].y)));
  }
  long long ans = 0;
  while (! q.empty()) {
    Edge tmp = q.top(); q.pop();
    int x = findSet(tmp.u);
    int y = findSet(tmp.v);
    if (x != y) {
      ans = ans + 1LL * tmp.w;
      join(x, y);
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 6516
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	ll x;
	cin >> x;
	ll div_eleven = x / 11, mod_eleven = x % 11;
	ll ans = div_eleven * 2;
	if(0 < mod_eleven && mod_eleven <= 6){
		ans++;
	}else if(6 < mod_eleven){
		ans += 2;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n=0, ans=0;	
  	cin >> n;
  	vector<int> a(n+1);
  	for(int i=9;i<=n;i+=2){
      for(int j=1;j<=i;j++){
        if(i%j==0){
          a[i]++;
        }
      }
    }
	
	for(int i=1;i<=n;i++){
      if(a[i]==8){
        ans++;
      }
    }	  
  	cout << ans <<endl;	
}



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

int main(){
  int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int temp=1;
  int ans=0;
  for(int i=0;i<N;i++){
    if(A[i]==temp){
      temp++;
      continue;
    }
    else ans++;
  }
  if(ans==N){
    cout<<-1<<endl;
    return 0;
    
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll a[10]={};

int main(){
	REP(i,0,7) cin >> a[i];
	ll pos=a[0]-a[0]%2+a[3]-a[3]%2+a[4]-a[4]%2;
	if(a[0]&&a[3]&&a[4]){
		a[0]--; a[3]--; a[4]--;
		pos=max(pos, 3+a[0]-a[0]%2+a[3]-a[3]%2+a[4]-a[4]%2);
	}
	
	cout << pos+a[1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int n;
   cin >> n;
   n = n%10;
   if(n==2 || n== 4||n==5||n==7||n==9) cout <<"hon";
   if(n==0 || n==1||n==6||n==8) cout << "pon";
   if(n==3) cout <<"bon";
   
   return 0;
}

Measured memory_bytes: 3636
// finish date: 2019/07/20

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N, D;
    cin >> N >> D;
    cout << (N - 1) / (2 * D + 1) + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    if(X == 3 || X == 5 || X == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import math
while True:
    sv = 0
    N = int(input())
    if N == 0:
        break
    data = list(map(int, input().split()))

    av = sum(data)/N

    for i in range(N):
        sv += (data[i]-av)**2

    print('{0:6f}'.format(math.sqrt(sv/N)))


Measured memory_bytes: 5704
n,l=map(int,input().split())
taste=[l+i for i in range(n)]
absTaste=[abs(l+i) for i in range(n)]
eat=min(enumerate(absTaste),key=lambda x:x[1])[0]
# print(taste,eat)
ans=0
for i in range(n):
    if i!=eat:
        ans+=taste[i]

print(ans)


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

int main(){

    int m, n; cin >> m >> n;     //m　コマンド数　n スキル数    

    //コマンドiを取得するための条件　各スキルjに対して
    //l[i][j] <= skill_point[j] <= u[i][j]
    vector<vector<int> > u(m, vector<int> (n, 101));
    vector<vector<int> > l(m, vector<int> (n, -1));
    
    vector<bool> isGet(m, false);
    vector<int> skill_point(n, 0);


    for(int i = 0; i < m; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int s, t;
            string cond; cin >> s >> cond >> t;
            s--;
            if(cond == "<=") u[i][s] = min(u[i][s], t);
            else l[i][s] = max(l[i][s], t);
        }
    }

    //例外処理
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            if(l[i][j] > u[i][j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }


    for(int c = 0; c < m; c++){

        //取れるコマンドを探す
        bool ok = false;
        for(int i = 0; i < m; i++){
            
            //すでに取得済みなら
            if(isGet[i]) continue;

            vector<int> tmp_skill_point(n);
            for(int j = 0; j < n; j++){
                tmp_skill_point[j] = max(skill_point[j], l[i][j]);
            }

            //未だとってないコマンドが、iの後にとれるか
            bool i_ok = true;
            for(int k = 0; k < m; k++){

                //iかもうすでに取っていたら
                if(k == i || isGet[k]) continue;

                //kは大丈夫？
                bool k_ok = true;
                for(int j = 0; j < n; j++){
                    if(tmp_skill_point[j] > u[k][j]){
                        k_ok = false;
                        break;
                    }
                }

                if(!k_ok){
                    i_ok = false;
                    break;
                }
            }

            //iが取れるなら、とる
            if(i_ok){
                isGet[i] = true;
                ok = true;
                for(int j = 0; j < n; j++) skill_point[j] = tmp_skill_point[j];
                break;
            }

        }

        if(!ok){
            cout << "No" << endl;
            return 0;
        }

    }

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

}


Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define X first
#define Y second
#define INF 1000 * 1000 * 1000
#define PB push_back
const int MAX = 505;
using namespace std;

int main()
{
	int a , b , c;
	cin >> a >> b >> c;
	cout << ((a == b && b == c) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())

    xs = set()
    ys = set()
    rect = []
    for _ in range(N):
        x1, y1, x2, y2 = map(int, input().split())
        xs.add(x1)
        xs.add(x2)
        ys.add(y1)
        ys.add(y2)
        rect.append((x1, y1, x2, y2))
    X = sorted(xs)
    Y = sorted(ys)
    dx = {x: i for i, x in enumerate(X)}
    dy = {y: i for i, y in enumerate(Y)}
    #print(dx, dy, dx[1])
    
    H = len(xs)
    W = len(ys)
    grid = [[0] * (W + 1) for _ in range(H + 1)]
    for x1, y1, x2, y2 in rect:
        grid[dx[x1]][dy[y1]] += 1
        grid[dx[x2]][dy[y1]] -= 1
        grid[dx[x1]][dy[y2]] -= 1
        grid[dx[x2]][dy[y2]] += 1
    #print(grid)
    for i in range(H):
        grid[i] = list(accumulate(grid[i]))
    #print(grid)
    for i in range(H):
        for j in range(W):
            grid[i + 1][j] += grid[i][j]
    #print(grid)
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j]:
                ans += (X[i + 1] - X[i]) * (Y[j + 1] - Y[j])
    return ans


if __name__ == "__main__":
    print(main())
    
    


Measured memory_bytes: 343836
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int h, w; cin >> h >> w;
	VVI a(h, VI(w)), b(h, VI(w));
	REP(i, h)REP(j, w)cin >> a[i][j];
	REP(i, h)REP(j, w)cin >> b[i][j];
	bool dp[81][81][12801] = { 0 };
	dp[0][0][abs(a[0][0] - b[0][0])] = true;
	REP(i, h) {
		REP(j, w) {
			REP(k, 12800) {
				if (i != h - 1) {
					if (dp[i][j][k]) {
						dp[i + 1][j][k + abs(a[i + 1][j] - b[i + 1][j])] = true;
						dp[i + 1][j][abs(k - abs(a[i + 1][j] - b[i + 1][j]))] = true;
					}
				}
				if (j != w - 1) {
					if (dp[i][j][k]) {
						dp[i][j + 1][k + abs(a[i][j + 1] - b[i][j + 1])] = true;
						dp[i][j + 1][abs(k - abs(a[i][j + 1] - b[i][j + 1]))] = true;
					}
				}
			}
		}
	}
	REP(i, 12800) {
		if (dp[h - 1][w - 1][i]) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 82432
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long Q,H,S,D,N; cin >> Q >> H >> S >> D >> N;
    if(2*Q <= H)
    {
        H = 2*Q;
    }
    if(2*H <= S)
    {
        S = 2*H;
    }
    if(2*S <= D)
    {
        D = 2*S;
    }
    if(N % 2 == 0)
    {
        cout << N/2*D << endl;;
    }
    else
    {
        cout << N/2*D+S << endl;
    }
}

Measured memory_bytes: 256
A,B,C,X,Y = gets.split.map(&:to_i)

if 2*C <= A+B

    if X <= Y

        if 2 * C <= B

            puts 2*C*Y

        else

            puts 2*C*X+B*(Y-X)

        end

    else

        if 2*C <= A 
            
            puts 2*C*X

        else

            puts 2*C*Y+A*(X-Y)

        end

    end

else

    puts A*X+B*Y

end

        

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
#include<stdlib.h>
#include<stdio.h>
  
int main()
{
    int a,b;
    int c=0;
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>b;
        if(!(b&1)){
            if(b%3!=0 && b%5!=0){
                c=1;
            }
        }
    }
    if(c)cout<<"DENIED\n";
    else
        cout<<"APPROVED\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int n,k;
int a[1111];
vector<ll> v;

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	cin>>n>>k;
	FOR(i,0,n){
		cin>>a[i];
	}
	FOR(i,0,n){
		ll sum=0;
		FOR(j,i,n){
			sum+=a[j];
			v.push_back(sum);
		}
	}
	ll ans=0;
	for(int j=40;j>=0;--j){
		int cnt=0;
		FOR(i,0,v.size())if(v[i]&(1ll<<j))cnt++;
		if(cnt<k)continue;
		else {
			ans+=(1ll<<j);
			vector<ll> nv;
			FOR(i,0,v.size())if(v[i]&(1ll<<j))nv.push_back(v[i]);
			v=nv;
		}
	}
	Tone(ans);
	return 0;
}


Measured memory_bytes: 6512
package main

import "fmt"

func main() {
	// Code for A - Falling Asleep
	var N int
	fmt.Scan(&N)
	s := make([]string, N)
	t := make([]int, N)
	var sum int
	ans := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&s[i], &t[i])
		sum += t[i]
		ans[i] = sum
	}

	var X string
	fmt.Scan(&X)

	for i := 0; i < N; i++ {
		if X == s[i] {
			fmt.Println(sum - ans[i])
			break
		}
	}
}


Measured memory_bytes: 1784
#include<iostream>
using namespace std;
int main(){
int h,w,N;
cin>>N>>h>>w;
int count=0;
for(int i=0;i<N;i++){
int a,b;
cin>>a>>b;
if(a>=h&&b>=w){
count+=1;
}
}
cout<<count<<endl;
return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  std::vector<int> h(n);
  std::vector<bool> ok(n,true);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  for (int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b;
    a--;b--;
    if (h.at(a) <= h.at(b)) ok.at(a) = false;
    if (h.at(b) <= h.at(a)) ok.at(b) = false;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) if (ok.at(i)) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3772
K= int(input())

visited = set()
remainder = 7
counter = 1

while True:
    remainder = remainder % K
    if remainder in visited:
        print(-1)
        exit()
    if remainder == 0:
        print(counter)
        exit()
    else:
        visited.add(remainder)
        remainder = 10 * remainder + 7
    counter += 1

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

typedef long long ll;

int main()
{
    int n,i;
    cin >> n;
    vector<int> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    for(i = 0;i < n;++i){
        if(a.at(i)%2 != 0){
            continue;
        }else{
            int b = a.at(i);
            if(!(b%3 == 0 || b%5 == 0)){
                cout << "DENIED" << endl;
                return 0;
            }else{
                continue;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // string s;
    // cin>>s;
   	// int flag=1;
    // for(int i=0;i<s.size();++i){
    // 	for(int j=i+1;j<s.size();++j){
    // 		if(s[i]==s[j]){
    // 			flag=0;
    // 			break;
    // 		}
    // 	}
    // }
    // cout<<((flag)?"yes":"no");



    // string s;
    // cin>>s;
    // set<char>c;
    // for(char k:s) c.insert(k);
    // cout<<((s.size()==c.size())?"yes":"no");
    


    // string s;
    // cin>>s;
    // map<char,int>m;
    // for(int i=0;i<s.size();++i){
    // 	if(m[s[i]]>0){
    // 		cout<<"no";
    // 		return 0;
    // 	}
    // 	++m[s[i]];
    // }
    // cout<<"yes";

    // int a,b;
    // cin>>a>>b;
    // int ans=a+b;
    // (ans>=10)?cout<<"error":cout<<ans;
    

    // int n;
    // cin>>n;
    // int a,mx=0,mi=1000;
    // for(int i=0;i<n;++i){
    // 	cin>>a;
    // 	if(mx<a) mx=a;
    // 	if(mi>a) mi=a;
    // }


    // int n;
    // cin>>n;
    // int ar[n];
    // for(int i=0;i<n;++i) cin>>ar[i];
   	// cout<<*max_element(ar,ar+n)-*min_element(ar,ar+n);
    

    // int n,m;
    // cin>>n>>m;
    // n+=2;
    // m+=2;
    // for(int i=0;i<n;++i){
    // 	for(int j=0;j<m;++j){
    // 		if(i==0 || i==n-1 || j==0 || j==m-1) cout<<"#";
    // 		else{
    // 			char c;
    // 			cin>>c;
    // 			cout<<c;
    // 		}
    // 	}
    // 	cout<<'\n';
    // }

    // int x,y;
    // cin>>x>>y;
    // int ar[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    // cout<<((ar[x]==ar[y])?"Yes":"No");
    

    // string a,b,c;
    // cin>>a>>b>>c;
    // cout<<(((a.back()==b.front()) && (b.back()==c.front()))?"YES":"NO");
    
    // int a,b,c;
    // cin>>a>>b>>c;
    // cout<<((a<=c && c<=b)?"Yes":"No");
   
	// string s(3,'0');
	// for(int i=0;i<3;++i) cin>>s.at(i);
	// int x=stoi(s);
	// cout<<((x%4==0)?"YES":"NO");       

    // int a,b,c;
    // cin>>a>>b>>c;
    // cout<<(((b*10+c)%4==0)?"YES":"NO");

    // int n,m;
    // cin>>n>>m;
    // m*=2;
    // int ar[m];
    // for(int i=0;i<m;++i) cin>>ar[i];
    // for(int i=1;i<=n;++i) cout<<count(ar,ar+m,i)<<'\n'; 
   
    int n,m;
    cin>>n>>m;
    vector<int>num(n,0);
    for(int i=0;i<m;++i){
    	int a,b;
    	cin>>a>>b;
    	++num.at(a-1);
    	++num.at(b-1);
    }
    for(int i=0;i<n;++i) cout<<num[i]<<'\n';
   return 0;
}

Measured memory_bytes: 3592
#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> ;
const int INF = 1e9;
const int MOD = 1000000007;
int n;
vector<int> ans;

bool ok(int x){
    int res = 0;
    vector<int> a;
    for(int i=x;i>0;i--){
        if(res + i > n) continue;
        res += i;
        a.push_back(i);
    }
    if(res ==n) ans = a;
    return res == n;
}

int main(){
    cin >> n;
    int left = -1,right = n+1;
    while(right - left > 1){
        int mid = (left + right)/2;
        if(ok(mid)) right = mid;
        else left = mid;

    }
    rep(i,ans.size()) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define init_random mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define sd(n) scanf("%lld", &n)
#define pd(n) printf("%lld\n", n)
#define MOD ((long long) (1000*1000*1000 + 7))
#define exit(a, b) return cout << a, b;
#define eps (double)1e-9
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

const int N = (int) 1e5 + 100;
int fac[N + 1], invfac[N + 1];
const int M = MOD;

int modexp (int a, int b) {
	if (b == 0) return 1;
	int ans = modexp(a, b/2);
	ans = (ans * ans) % M;
	if (b % 2) ans = (ans * a) % M;
	return ans;
}

inline int inv (int a) {
	return modexp(a, M - 2);
}

void prec () {
	fac[0] = 1;
	for (int i = 1; i <= N; i++) fac[i] = (fac[i - 1] * i) % M;
	invfac[N] = inv(fac[N]);
	for (int i = N - 1; i >= 0; i--) invfac[i] = (invfac[i + 1] * (i + 1)) % M;	
}

int c (int n, int r) {
	int ans = fac[n];
	ans *= invfac[n - r], ans %= M;
	ans *= invfac[r], ans %= M;
	return ans;
}

signed main()
{
  start_routine;
  #ifndef ONLINE_JUDGE
 // freopen("input.txt", "r", stdin);
  #endif
  prec();

  int n, m; cin >> n >> m;
  if (m == 1) {
  	exit(1, 0);
  }

  int ret = 1;
  for (int i = 2; ; i += 1) {
  	int cnt = 0;
  	while (m % i == 0) {
  		cnt += 1;
  		m /= i;
  	}
  	ret *= c(n + cnt - 1, cnt);
  	ret %= M;
  	if (m == 1) {
  		exit(ret, 0);
  	}
  }
  end_routine;
}

Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a, c)) << endl;
}


Measured memory_bytes: 256
S = list(input())
N = len(S)
isStrongPalindrome = False

if S == list(reversed(S)):
  if S[0:(N-1)//2] == list(reversed(S[0:(N-1)//2])):
    if S[(N+2)//2:] == list(reversed(S[(N+2)//2:])):
      isStrongPalindrome = True

if isStrongPalindrome:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = (1e9+7)*2;
ll a[200005];
int main(int argc, char * argv[]) 
{
	int n;
	ll sum = 0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum += a[i];
	}
	ll ans = 0;
	for(int i=0;i<n;i++){
		ans += ((sum-a[i])%mod)*a[i];
		ans %= mod;
	}
	cout<<ans/2<<endl;



    return 0;
}

Measured memory_bytes: 5148