akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(void){
  int n;
  cin>>n;
  vector<int> b(n-1);
  r(i,n-1)cin>>b.at(i);

  vector<int> a(n);
  int sum=0;

  r(i,n-1){
    if(i==0){
    a.at(i)=b.at(i);
    }else{
      a.at(i)=min(b.at(i),b.at(i-1));
    }
    sum+=a.at(i);
  }
  sum+=b.at(n-2);

  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int a[300][300];

int main(void) {
    int i, j, k, n;
    scanf("%d",&n);
    REP (i,n) REP (j,n) scanf("%d",&a[i][j]);

    long long ans = 0;
    REP (i,n) REP (j,i) ans += a[i][j];
    REP (i,n) REP (j,i) REP (k,n) if (k != i && k != j) {
        if (a[i][k] + a[k][j] == a[i][j]) {
            ans -= a[i][j];
            break;
        }
        else if (a[i][k] + a[k][j] < a[i][j]) {
            puts("-1");
            return 0;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
num_list = [0, 0, 0, 0]
for n in range(3):
    a, b = map(int, input().split())
    num_list[a - 1] += 1
    num_list[b - 1] += 1

if 3 in num_list:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 2940
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 


inline void solve(){
    int  n, m, inf = 1000000 ; 
    cin >> n >> m ; 
    vi g[100005];
    for (int i=0;i<m;i++){
    	int a,b; cin >> a >> b ; 
    	g[a]. pb(b) ; 
    	g[b]. pb(a) ; 
    }
    int  r = inf , ans = 0 ; 
    for (int i=1;i<n;i++){
	    for (auto it: g[i]){ 
	    	if (it>i)  
	    		r = min(r,it); 
	    }
	    if (r - i == 1) { 
	    	ans++; 
	    	r = inf ; 
	    }
    }
    co (ans) ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 9408
n,m,x = map(int,input().split())
li = list(map(int,input().split()))
if x < li[0] or x > li[m-1] :
    print(0)
else :
    for i in range(m-1) :
        if x > li[i] and x < li[i+1] :
            print(min(i+1,m-i-1))


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
ll A[100009],B[100009];

ll calc(ll a,ll b){
    ll res=0;
    if(a<b) res=b-a;
    else{
        if(a%b==0) res=0;
        else res=b-(a%b);
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N) cin>>A[i]>>B[i];
    
    reverse(A,A+N);
    reverse(B,B+N);
    
    ll cnt=0;
    rep(i,N){
        if(A[i]==0) continue;
        cnt+=calc(A[i]+cnt,B[i]);
    }
    cout1(cnt)
}

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

const bool DEBUG = 1;

int n;
int a,b,c,d;
string s;

bool check(int i, int j) {
	string r = s.substr(i,j-i+1);
	for (int i = 0; i < r.length()-1; i++)
		if (r[i] == '#' && r[i+1] == '#')
			return 0;
	return 1;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif


	cin >> n;
	cin >> a >> b >> c >> d;
	a--;b--;c--;d--;
	cin >> s;

	if (d<c) {
		while (b<d) {
			if (s[b-1] == s[b+1] && s[b-1] == s[b])
				break;
			if (s[b+1]=='.')
				b++;
			else if (s[b+2]=='.')
				b+=2;
			else break;
		}
		if (s[b-1] != '.' || s[b+1] != '.')
			cout << "No" << endl;
		else 
			cout << (check(a,c) && check(b,d) ? "Yes" : "No") << endl;
	} else 
		cout << (check(a,c) && check(b,d) ? "Yes" : "No") << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 720
import math

N = int(input())

step = N - 1

for i in range(2, N):
    if N % i == 0:
        if step > (i - 1) + ((N / i) - 1):
            step = (i - 1) + ((N / i) - 1)

    if i > math.sqrt(N):
        break
print(int(step))

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

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int K;
    cin >> K;
    auto A = vc(int, K);
    lpn(i, K) cin >> A[K - i - 1];
    ll omx = 2, omn = 2;
    ll mx, mn;
    lpn(i, K)
    {
        mx = (omx) / A[i] * A[i] + A[i] - 1;
        mn = (omn + A[i] - 1) / A[i] * A[i];
        if (mn > mx)
        {
            cout << -1 << endl;
            return 0;
        }
        omx = mx;
        omn = mn;
    }
    cout << mn << " " << mx << endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())
N_List = []
for i in range(N):
    N_List.append(int(input()))
NMax = max(N_List)
if N_List.count(NMax) == 1:
    NMax2 = sorted(N_List)[-2]
    for i in N_List:
        print((NMax,NMax2)[i==NMax])
else:
    for i in N_List:
        print(NMax)

Measured memory_bytes: 19088
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, int> P;

vector<P> graph[6];

int main() {
	string p;

	graph[0].push_back(P(0, 2));
	graph[0].push_back(P(1, 3));
	graph[2].push_back(P(1, 4));
	graph[3].push_back(P(0, 2));
	graph[4].push_back(P(0, 5));
	graph[4].push_back(P(1, 1));
	graph[5].push_back(P(0, 1));
	graph[5].push_back(P(1, 3));
	graph[1].push_back(P(0, 3));
	graph[1].push_back(P(1, 2));

	while (cin >> p) {
		if (p == "#") {
			break;
		}
		int ichi = 0;
		bool hantei = false;
		for (int i = 0; i < p.size(); i++) {
			bool hantei2 = true;
			int j;
			for (j = 0; j < graph[ichi].size(); j++) {
				if (graph[ichi][j].first == p[i]-'0') {
					ichi = graph[ichi][j].second;
					hantei2 = false;
					break;
				}
			}
			if (hantei2) {
				break;
			}
			if (i == p.size()-1 && ichi == 1) {
				hantei = true;
			}
		}
		if (hantei) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define int long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second

    using namespace std;
int power(int base, int exp)
{
    if (exp == 0)
       return 1;
    else if (exp == 1)
       return base;
    else
    {
       int calc;
       if (exp % 2 == 0)
       {
         calc = power(base, exp/2);
         calc =(calc* calc)%mod;
       }
       else
       {
         calc = (base*power(base, exp-1))%mod;
       }
       return calc%mod;
    }
}
    int32_t main()
    {
        std::ios::sync_with_stdio(false);
        int n;
        cin>>n;
        cout<<pow(n,3)<<endl;
        return 0;
    }


Measured memory_bytes: 4120
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x<1200) {
			System.out.println("ABC");
		}else {
			System.out.println("ARC");
		}
	}
}


Measured memory_bytes: 21844
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        x: isize,
    }

    for i in -200..200isize {
        for j in -200..200isize {
            let res = i.pow(5) - j.pow(5);
            if res == x {
                println!("{} {}", i, j);
                return;
            }
        }
    }
}


Measured memory_bytes: 2152
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int k[150];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int a, b, c;
    while (cin >> a >> b >> c) {
        bool ans = false;
        FOR(i,0,b+1) {
            if ((a * i) % b == c)
                ans = true;
        }
        if (ans)
            cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}


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

const ll mod = 1e9 + 7;
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n)
        cin >> a[i];
    ll sum = a[n - 1];
    ll ans = 0;
    rep (i,n - 1){
        ans += a[n - 2 - i] * sum;
        ans %= mod;
        sum += a[n - 2- i];
        sum %= mod;
    }
    cout << ans << endl;
}

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

int main(){
    int n; cin >> n;
    vector<int> dp(100010);
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        dp[i] = dp[i-1] + 1;
        for(int l = 6; l <= i; l*=6){
            if(dp[i] > dp[i-l]){
                dp[i] = min(dp[i], dp[i-l]+1);
            }
        }
       for(int l = 9; l <= i; l*=9){
            if(dp[i] > dp[i-l]){
                dp[i] = min(dp[i], dp[i-l]+1);
            }
        } 
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define PR pair
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define REP(i, x, y)   for(int i = (int)(x); i <= (int)(y); i++)
#define FOR(i, x, y)   for(int i = (int)(x); i <  (int)(y); i++)
#define PER(i ,x, y)  for(int i = (int)(x); i >= (int)(y); i--)
#define CH	         ch = getchar()
#define Exit(...)    printf(__VA_ARGS__), exit(0)
#define dln()        fprintf(stderr,"\n")
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef double	  db;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI > VII;
typedef PR<int,int> PII;
typedef vector<PII> VPI;
const	int inf=2e9;
const	LL Inf=1e10;
const	int P=1e9+7;
const	int N=300005;

inline LL IN(){
	LL x = 0;
	int ch = 0, f = 0;
	for (CH; ch != -1 && (ch < 48 || ch > 57); CH) f = (ch == '-');
	for (; ch >= 48 && ch <= 57; CH) x = (x << 1) + (x << 3) + ch - '0';
	return f ? (-x) : x;
}
template<typename T> inline int chkmin(T &a, const T &b){if(b < a) return a = b, 1; return 0;}
template<typename T> inline int chkmax(T &a, const T &b){if(b > a) return a = b, 1; return 0;}

void renew(int &x, const int &y){
	x += y;
	if(x >= P) x -= P;
	if(x <  0) x += P;
}

int Pow(int x, int y, int p){
	int a = 1;
	for (; y; y >>= 1, x = (LL)x * x %p) if(y & 1) a=(LL)a * x%p;
	return a;
}

int n, m;
int perm[N], A[N];

int check(int val){
	REP(i, 1, n) A[i] = (perm[i] >= val);
	int x = (n + 1) >> 1;
	if(A[x] == A[x - 1] || A[x] == A[x + 1]) return A[x];
	int l = x, r = x;
	while(l && A[l] != A[l - 1]) l --; l ++;
	while(r <= n && A[r] != A[r + 1]) r ++; r --;
	int s = min(r - x + 1, x - l + 1);
	s = min(s, m);
	return (s & 1) ^ A[x];
}

int main(){
	scanf("%d", &n);
	m = n - 1;
	n = (n << 1) - 1;
	REP(i, 1, n) scanf("%d", perm + i);
	int l = 1, r = n, aim = n;
	while(l <= r){
		int md = (l + r) >> 1;
		if(check(md)){
			aim = md;
			l = md + 1;
		}else{
			r = md - 1;
		}
	}
	printf("%d\n", aim);
	return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
typedef long long ll;

ll n, m;
ll x, y;

ll ball[100005];
_Bool red[100005];

ll ans;

int main()
{
    red[1] = 1;
    
    scanf("%lld %lld", &n, &m);

    for (int i = 1; i <= n; i++) {
        ball[i] = 1;
    }
    
    for (ll i = 0; i < m; i++) {
        scanf("%lld %lld", &x, &y);

        ball[x]--;
        ball[y]++;

        red[y] = red[y] | red[x];

        if (ball[x] == 0) {
            red[x] = 0;
        }
    }

    for (ll i = 1; i <= n; i++) {
        if (red[i]) ans++; 
    }

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

    return 0;
}


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> p(n);
  rep(i, n) cin >> p[i];

  int sum = 0;
  for (int i = 1; i < n - 1; i++)
  {
    int mn = std::min({p[i - 1], p[i], p[i + 1]});
    int mx = std::max({p[i - 1], p[i], p[i + 1]});
    if (p[i] != mn && p[i] != mx)
      sum++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    N = int(inputs[0])
    prev = 0
    for i in range(1, 100000):
        if i * i > N:
            return prev
        prev = i * i


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#include <algorithm>
#include <cmath>
using namespace std;
pair<ll,ll> norm(ll a,ll b)
{
  if(a<0)
  {
    a*=-1;
    b*=-1;
  }
  else if ((a==0)&&(b<0))
  {
    b*=-1;
  }
  ll d=__gcd(abs(a),abs(b));
  a=(ll)(a/d);
  b=(ll)(b/d);
  pair <ll,ll> p=mp(a,b);
  return p;
}
bool decreasing(pair<ll,ll> a,pair<ll,ll> b) 
{ 
       if(a.first>b.first)
       return true;
       else if(a.first==b.first)
       {
        if(a.second<b.second)
        return false;
        else
        return true;
       } 
       else
       return false;
} 
ll expo(ll x,ll y) 
{ 
    ll res = 1;  
    while(y>0) 
    {  
        if(y&1) 
        res=(res*x)%1000000007;  
        y=y>>1;
        x=(x*x)%1000000007; 
    } 
    return res; 
}
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // int T,p;
    // cin>>T;
    // for(p=1;p<=T;p++)
    // { 
      ll N;
      cin>>N;
      ll i,j,k,a,b,c;
      ll count=0;
      for(i=1;i<N;i++)
      {
        a=N-1;
        b=(ll)(a/i);
        count+=b;
      }
      cout<<count;
  return 0;
}

Measured memory_bytes: 3608
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue
import itertools
import functools 

n = int(input())
if n % 2 == 1:
  print((n + 2) // 2)
else:
  print(n // 2)

Measured memory_bytes: 22776
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define inf 2e15
const int minnodes=1005;
#define ll long long

#define EPS 0.000000001
#define N 2000000 


 
int32_t main()
{
    IOS;

    int a,b,c;
    cin >> a >> b >> c;
    int z = a - b;
    cout << max((ll)0,c-z);


}
 

Measured memory_bytes: 256
import java.io.*;
 
public class Main {
    public static void main(String[] args) {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));       
        try {
        	String line;
        	while((line=r.readLine())!=null){
                /* input from here */
        		int m,n;
        		m = Integer.parseInt(line.split(" ")[0]);
        		n = Integer.parseInt(line.split(" ")[1]);
        		if(m<n){
        			int t = m;
        			m = n;
        			n = t;
        		}
                /* input till here */
                /* processing from here */
        		while(n!=0){
            		int t = n;
            		n = m%n;
            		m = t;
        		}
                /* processing till here */
                /* output */
    			System.out.println(m);        		
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 16924
#include <bits/stdc++.h>
using namespace std;
typedef int64_t LL;
LL GCD(LL a,LL b){return(b==0)?a:GCD(b,a%b);}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int main()
{
  int A,N,M;
  LL x=1;
  cin>>N>>M;
  while(cin>>A){x=LCM(x,(A+1)/2);if(x>M||(2*x/A)%2==0)return cout<<0<<endl,0;}
  return cout<<(M/x+1)/2<<endl,0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <regex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	int ans = 700;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'o') {
			ans += 100;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vii vector <int>::iterator 
#define vd vector <double>
#define vdd vector <double>::iterator
#define vs vector <string>
#define vss vector <string>::iterator
#define vc vector <char>
#define vcc vector <char>::iterator
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
#define SORT(x)     sort(x.begin(),x.end())
#define fill(x,y)   memset(x, y, sizeof(x))
#define PI 2*acos(0.0)
#define fio ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
bool isprime(int n){
    int i;
    if(n==1)
        return false;
    else if(n==2)
        return true;
    for(i=2;i*i<=n;i++){
        if(n%i==0)
            return false;
    }
    return true;
}
int main(){
    fio;
    string s;
    cin >> s;
    ll l = s.size();
    if(s[l-1] == 's')
        cout << s << "es" << endl;
    else
        cout << s << 's' << endl;
}

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

int main(){
  int N;
  string ans = "YES";
  cin >> N;
  set<string> A;
  for (int i = 0; i < N; i++){
    string a;
    cin >> a;
    A.insert(a);
  }
  if (A.size() != N){
    ans = "NO";
  }
  cout << ans << endl;
}

Measured memory_bytes: 19228
#include<stdio.h>

int K[10900][10900];
void knapsack(int n, int wMax,int W[],int b[])
{

    for(int i=1;i<=n;i++)
    {
        for(int w=0;w<=wMax;w++)
        {
            if(W[i] <= w)
            {
                if(b[i] + K[i-1][w-W[i]] > K[i-1][w])
                {
                    K[i][w] = b[i] + K[i-1][w-W[i]];
                }else
                {
                    K[i][w] = K[i-1][w];
                }
            }else
            {
                K[i][w]=K[i-1][w];
            }
        }
    }
    
    printf("%d\n",K[n][wMax]);
}


int main()
{
    int N,Weight;
    int V[10900],W[10900];
    
    scanf("%d %d",&N,&Weight);getchar();
    for(int i=1;i<=N;i++)
    {
        scanf("%d %d",&V[i],&W[i]);getchar();
    }
    
    knapsack(N,Weight,W,V);
    
    return 0;
}



Measured memory_bytes: 6036
#include <stdio.h>

void branch(int a, int b) {
    if (a < b) {
        printf("a < b\n");
    } else if (a == b) {
        printf("a == b\n");
    } else {
        printf("a > b\n");
    }
}

int main(void) {
    int a, b;

    scanf("%d %d", &a, &b);
    branch(a, b);
    
    return 0;
}


Measured memory_bytes: 2096
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  vector<ll> v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll k; cin >> k;
  cout << v[k-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    REP(i, n) cin >> a[i];

    int inc = -1;
    ll ans = 1;

    REP(i, n-1){
        if (a[i] == a[i+1]) continue;
        else if (a[i] > a[i+1]){
            
            if (inc == 1){
                ans++;
                inc = -1;
            }
            else inc = 0;
            
        }
        else{
            if (inc == 0){
                ans++;
                inc = -1;
            }
            else inc = 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	string s;cin>>s;
	int n=s.length();
	
	int open=0;int ans=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='S')open++;
		if(s[i]=='T' and open)ans+=2,open--;
	}
	cout<<n-ans;
}


Measured memory_bytes: 3644
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        int z,x,c;
        z=input.nextInt();
        x=input.nextInt();
        c=input.nextInt();
        String s=(String.valueOf(z)+String.valueOf(x)+String.valueOf(c));
        int y=Integer.parseInt(s);
        if(y%4==0)
            System.out.println("YES");
        else System.out.println("NO");
    }
    
}


Measured memory_bytes: 27116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private class HashSet {

		private int M = 1046527;
		private String[] H = new String[M];
		
		private int getChar(char ch) {
			if (ch=='A') return 1;
			else if (ch=='C') return 2;
			else if (ch=='G') return 3;
			else if (ch=='T') return 4;
			else return 0;
		}
		
		private int getKey(String str) {
			int sum = 0, p = 1;
			for (int i = 0; i < str.length(); i++) {
				sum += p*(getChar(str.charAt(i)));
				p *= 6;
			}
			return sum;
		}

		private int h1(int key) {return key % M;}
		private int h2(int key) {return 1 + (key % (M-1));}

		public boolean find(String str) {
			int key, i, h;
			key = getKey(str);
			for (i = 0 ;; i++) {
				h = (h1(key) + i * h2(key)) % M;
				if (H[h] != null && H[h].equals(str)) return true;
				else if (H[h] == null || H[h].length() == 0) return false;
			}
		}
		
		public void insert(String str) {
			int key, i, h;
			key = getKey(str);
			for (i = 0 ;; i++) {
				h = (h1(key) + i * h2(key)) % M;
				if (H[h] != null && H[h].equals(str)) return;
				else if (H[h] == null || H[h].length() == 0) {
					H[h] = new String(str);
					return;
				}
			}
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		HashSet set = new HashSet();
		int n = Integer.parseInt(reader.readLine());
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			String cmd = st.nextToken();
			String str = st.nextToken();
			if (cmd.equals("insert")) {
				set.insert(str);
			} else if (cmd.equals("find")) {
				if (set.find(str)) {
					System.out.println("yes");
				} else {
					System.out.println("no");
				}
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 127788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
	vector<int> time;
	int n,m,a,b;
	cin>>n;
	rep(i,n){
		cin>>a>>b;
		time.push_back(a*60+b);
	}
	cin>>m;
	rep(i,m){
		cin>>a>>b;
		time.push_back(a*60+b);
	}
	sort(time.begin(),time.end());
	time.erase(unique(time.begin(),time.end()),time.end());
	rep(i,time.size()){
		cout<<time[i]/60<<':';
		int mi=time[i]%60;
		if(mi<10)cout<<'0'<<mi;
		else cout<<mi;
		if(i==time.size()-1)cout<<endl;
		else cout<<" ";
	}
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = 1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

int main(void)
{
    int n;
    cin >> n;
    
    v_int a(n);

    irep(i, n) {
        cin >> a[i];
    }

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

    int max_a = INF;
    
    irep(i, n-1) {
        if(abs(a[n-1]/2-a[i]) <= abs(a[n-1]/2-max_a)) {
            max_a = a[i];
        }
    }
    cout << a[n-1] << " " << max_a << endl;
    return 0;
}

/*atcoder*/


Measured memory_bytes: 3792
'use strict';

const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const sMpI = (str) => str.split(' ').map(v => parseInt(v, 10));
const pI = v => parseInt(v, 10);

const number = pI(inputs.shift());

console.log(number + number ** 2 + number ** 3);

Measured memory_bytes: 29684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const double pi = 3.141592653589793238;
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    double space = a * b - x;
    if (space > x) {
        double h = x * 2 / b;
        double ans = atan2(b, h) * 180 / pi;
        printf("%.10f\n", ans);
    }
    else {
        double h = space * 2 / a;
        double ans = atan2(h, a) * 180 / pi;
        printf("%.10f\n", ans);
    }
    return 0;
}


Measured memory_bytes: 384
from math import *


n = int(raw_input())
seq = map(int, raw_input().split())

total = 1

has_zero = False

for x in seq:
    if x == 0:
        has_zero = True


limit = int(10 ** 18)

if has_zero == True:
    print(0)
else:
    big = False
    for x in seq:
        total = total * x
        if total > limit:
            big = True
            break
    if big == True:
        print(-1)
    else:
        print(total)


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

const int mxN=1e5+1;
vector<string>op(mxN);

vector<char>ans;

signed main(){
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if((i%n)==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}

Measured memory_bytes: 6252
n,k=map(int,input().split())
A=list(map(int,input().split()))
S=[0 for _ in range(k)]

for i in range(1,k+1):
    if i!=k:
        S[i-1]=A[i]-A[i-1]
    else:
        S[i-1]=A[0]+n-A[k-1]

print(n-max(S))


Measured memory_bytes: 32368
import itertools

N,K=map(int,input().split())
dA=list(input().split() for _ in range(2*K))
ans=[0]*K

for i in range(2*K):
    if i%2!=0:
        ans[i//2]=dA[i]
print(N-len(set(list(itertools.chain.from_iterable(ans)))))

Measured memory_bytes: 67624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    stack<char> sc;
    for(char c : s){
        if(c != 'B') sc.push(c);
        else if(!sc.empty()){
            sc.pop();
        }
    }
    string ans = "";
    while(!sc.empty()){
        ans += sc.top();
        sc.pop();
    }
    reverse(all(ans));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define N 30

using namespace std;

int sim[N][N], hgt[N][N];

struct DICE{
  int x, y;
  int t, b, n, s, e, w;

  DICE(int t_, int n_){
    x=N/2, y=N/2;
    t=1, b=6, n=2, s=5, e=4, w=3;
    if(t_==2) south();
    if(t_==3) east();
    if(t_==4) west();
    if(t_==5) north();
    if(t_==6) north(), north();
    while(n != n_) spin();
  }
  void north(){ swap(t,s), swap(s,b), swap(b,n); }
  void south(){ swap(t,n), swap(n,b), swap(b,s); }
  void east(){ swap(t,w), swap(w,b), swap(b,e); }
  void west(){ swap(t,e), swap(e,b), swap(b,w); }
  void spin(){ swap(n,e), swap(e,s), swap(s,w); }

  bool drop(){
    int k=0;
    char c='\0';
    if(n>3 && hgt[x][y]>hgt[x-1][y] && k<n) k=n, c='n';
    if(s>3 && hgt[x][y]>hgt[x+1][y] && k<s) k=s, c='s';
    if(e>3 && hgt[x][y]>hgt[x][y+1] && k<e) k=e, c='e';
    if(w>3 && hgt[x][y]>hgt[x][y-1] && k<w) k=w, c='w';
    if(!k) return false;
    if(c=='n') --x, north();
    if(c=='s') ++x, south();
    if(c=='e') ++y, east();
    if(c=='w') --y, west();
    return true;
  }
  void solve(){
    while(1){
      if(!drop()) break;
    }
    sim[x][y]=t;
    ++hgt[x][y];
  }
};

void init(){
  for(int i=0; i<N; ++i){
    for(int j=0; j<N; ++j){
      sim[i][j] = 0;
      hgt[i][j] = 0;
    }
  }
}

void print(){
  int ans[] = {0,0,0,0,0,0};
  for(int i=0; i<N; ++i){
    for(int j=0; j<N; ++j){
      if(sim[i][j]) ++ans[sim[i][j]-1];
    }
  }
  for(int i=0; i<6; ++i){
    cout << ans[i] << (i==5 ? '\n' : ' ');
  }
}

int main(){
  int n, a, b;
  while(1){
    cin >> n;
    if(!n) break;
    init();
    for(int i=0; i<n; ++i){
      cin >> a >> b;
      DICE(a,b).solve();
    }
    print();
  }
  return 0;
}

Measured memory_bytes: 1168
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
using namespace std;
int dp[100][100][4];//????????????
int main(){
	int w, h;
	while (cin >> w >> h,w) {
		dp[0][0][0] = dp[0][0][2] = 1;
		dp[0][0][1] = dp[0][0][3] = 0;
		for (int i = 0; i < w; i++) {
			for (int j = 0; j < h; j++) {
				if (i) {
					dp[i][j][1] = (dp[i - 1][j][0] + dp[i - 1][j][1])%100000;
					dp[i][j][0] = dp[i - 1][j][3];
				}
				if (j) {
					dp[i][j][3] = (dp[i][j - 1][2] + dp[i][j - 1][3])%100000;
					dp[i][j][2] = dp[i][j - 1][1];
				}
			}
		}
		cout << (dp[w - 1][h - 1][0] + dp[w - 1][h - 1][1] + dp[w - 1][h - 1][2] + dp[w - 1][h - 1][3] )%100000<< endl;
	}
	return 0;
}

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

int main()
{
  string s, t;
  cin >> s >> t;
  int d = s.length() - t.length();
  int len = t.length();
  int ans = t.length();
  for (int i = 0; i < d + 1; i++) {
    int c = 0;
    for (int j = 0; j < len; j++) {
      if (s[i + j] != t[j]) c++;
    }
    ans = min(ans, c);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/
int main()
{
	double a, A, b, B, c, C, d, D;
	while (cin >> a >> A >> b >> B >> c >> C >> d >> D)
	{

		double x, X, y, Y;
		x = b - a;
		X = d - c;
		y = B - A;
		Y = D - C;
		if (fabs(x*X + y*Y)<=EPS)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1216
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<ctime>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<cstring>
#include<stack>
#include<cctype>
#include<cstdio>
#include<bitset>
using namespace std;
int x[110][110],ans;
int main()
{
  	int N,D;
  	cin>>N>>D;
  	for(int i=0;i<N;i++)
      	for(int j=0;j<D;j++)
          	cin>>x[i][j];
 	for(int i=0;i<N;i++)
      	for(int j=0;j<i;j++)
        {
          	long long cnt=0LL;
          	for(int k=0;k<D;k++)
              	cnt+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
          	if(sqrt(cnt)==floor(sqrt(cnt)))
              	ans++;
        }
 	cout<<ans<<endl;
  	return 0;
}

Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

a, b = readmi()
print(max(a + b, a - b, a * b))


Measured memory_bytes: 7752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

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

ll m_dist(ll p1[], ll p2[]){
    ll dist = abs(p1[0] - p2[0]) + abs(p1[1] - p2[1]);
    return dist;
}

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

    int n, m;
    cin >> n >> m;
    
    ll ab[n][2], cd[m][2];
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ab[i][0] = a;
        ab[i][1] = b;
    }
    rep(i, m) {
        int c, d;
        cin >> c >> d;
        cd[i][0] = c;
        cd[i][1] = d;
    }
    
    rep(i, n){
        ll min_dist = 1e9;
        int min_idx;

        rep(j, m){
            if(m_dist(ab[i], cd[j]) < min_dist){
                min_dist = m_dist(ab[i], cd[j]);
                min_idx = j;
            }
        }
        cout << min_idx+1 << endl;
    }
    


}

Measured memory_bytes: 256
def main():
    N = int(input())
    a = list(map(int, input().split()))
    l = []
    if abs(max(a)) >= abs(min(a)):
        i = a.index(max(a))
        t = max(a)
        for j in range(1, N+1):
            l.append((i+1, j))
        for i in range(N):
            a[i] += t
        for i in range(N-1):
            if True:
                l.append((i+1, i+2))
                a[i+1] = a[i] + a[i+1]
    else:
        i = a.index(min(a))
        t = min(a)
        for j in range(1, N+1):
            l.append((i+1,j))
        for i in range(N):
            a[i] += t
        for i in range(N-1, 0, -1):
            if True:
                l.append((i+1, i))
                a[i-1] = a[i] + a[i-1]
    print(len(l))
    for i in l:
        print(i[0], i[1])
main()



Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        aa: [i64;n]
    }
    let s: Vec<i64> = aa.iter().scan(0, |a,&v| {
        *a += v;
        Some(*a)
    }).collect();
    let last = s.iter().last().unwrap();
    let res = s.iter().take(n-1).map(|v| (v - (last - v)).abs()).min().unwrap();
    println!("{}", res);
}


Measured memory_bytes: 12540
#include <iostream>
#include <vector>

using namespace std;

int gcd(int a, int b) {
        return b ? gcd(b, a % b) : a;
}

int main() {
    int N, max = 1; cin >> N;
    vector<int> A(N, 0), L(N, 0), R(N, 0), gcds(N, 0); // L[i]はA[0]からA[i]までの最大公約数、R[i]はA[i]からA[N - 1]までの最大公約数
    for(int i = 0; i < N; i++) cin >> A[i];
    L[0] = A[0]; R[N - 1] = A[N - 1];
    for(int i = 1; i < N; i++) {
        L[i] = gcd(L[i - 1], A[i]); R[N - 1 - i] = gcd(R[N - i], A[N - 1 - i]);
    }
    gcds[0] = R[1]; gcds[N - 1] = L[N - 2];
    for(int i = 1; i < N - 1; i++) gcds[i] = gcd(L[i - 1], R[i + 1]);
    for(int i = 0; i < N; i++) {
        if(max < gcds[i]) max = gcds[i];
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define NO 1000000007
using namespace std;

int main()
{
	int n,a,b,t;
	int min = 1000000;
	cin >> n >> t;
	while (n--)
	{
		cin >> a >> b;
		if(b<=t&&a<min)
			min = a;
	}
	if(min == 1000000)
		cout << "TLE";
	else
		cout << min;
    return 0;
}

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

int main() {
	int w,n;
	cin>>w;
	cin>>n;
	int a[n];
	int b[n];
	char s[n];
	for(int i=0;i<n;i++){
		cin>>a[i]>>s[i]>>b[i];
	}
	int x[n+1];
	for(int i=1;i<=w;i++){
		x[i]=i;
		for(int j=0;j<n;j++){
			if(x[i]==a[j]){
				x[i]=b[j];
			}else if(x[i]==b[j]){
				x[i]=a[j];
			}
		}
	}
	for(int i=1;i<=w;i++){
		for(int j=1;j<=w;j++){
			if(x[j]==i){
				cout<<j<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2980