akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;cin>>x;
  ll ans=(360*x)/(__gcd(360ll,x)*x);
  print(ans);
  return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int main(){
    ll n;
    cin >> n;
    ll sa = INF+1, idx;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int ans_1 = a[n-1];

    REP(i, n-1) {
        if(abs(a[n-1] - 2*a[i]) < sa) {
            idx = i;
            sa = abs(a[n-1] - 2*a[i]);
        }
    }

    cout << ans_1 << " " << a[idx] << endl;

    return 0;
}


Measured memory_bytes: 1024
N = int(input())
txy = []
for _ in range(N):
    txy.append(tuple(map(int, input().split())))

fault=0
for el in txy:
    t, x, y = el
    #print(t,x,y)
    if t % 2 == 0 and (x+y) % 2 == 0 or\
        t % 2 == 1 and (x+y) % 2 == 1:
        pass
    else:
        fault = 1
if fault == 1:

    print('No')
else:
    txy.insert(0, (0,0,0))
    for i in range(N):
        time = txy[i+1][0] - txy[i][0]
        distance = abs(txy[i+1][1]- txy[i][1]) +\
            abs(txy[i+1][2] - txy[i][2])
        #print(distance, time)
        if time >= distance:
            pass
        else:
            fault=1
    if fault == 1:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 17320
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int pre[100005],suf[100005],a[100005];
int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;++i)
    cin >> a[i];
    pre[1] = a[1];
    for(int i=2;i<n;++i)
    {
        pre[i] = __gcd(pre[i-1],a[i]);
    }
    suf[n] = a[n];
    for(int i=n-1;i>=0;--i)
    {
        suf[i] = __gcd(suf[i+1],a[i]);
    }
    int ans = 1;
    for(int i=1;i<=n;++i)
    {
        ans = max(ans,__gcd(pre[i-1],suf[i+1]));
    }

    cout << ans;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define pf push_front
#define ll long long
#define uxy pair<int, pair<int, int> >
using namespace std;
void TxtRead(){
    freopen("closing.in","r", stdin);
    freopen("closing.out","w", stdout);
}
void TheTime(){
    ios_base::sync_with_stdio(false);
	cin.tie();
}
const int N = 1e5+5;
const ll INF = 1e9+5;
const ll MOD = 1e9+7;
const double PI = 3.141592653589793116;

int n, w;
ll wr[N], vr[N];
ll dp[N];

int main()
{
    //TxtRead();
    TheTime();

    scanf("%d %d", &n, &w);
    for(int i=0; i<n; i++){
        scanf("%lld %lld", &wr[i], &vr[i]);
    }

    fill(dp, dp+N, INF);
    dp[0]=0;
    for(int i=0; i<n; i++){
        for(int j=N; j>=vr[i]; j--){
            if(dp[j-vr[i] ]!=-1)
                dp[j]=min(dp[j], dp[j-vr[i] ]+wr[i]);
        }
    }
    int ans=0;
    for(int i=0; i<N; i++){
        if(dp[i]<=w) ans=max(ans, i);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <iomanip>
#include <functional>
#include <array>
#include <memory>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#undef NDEBUG
#include <assert.h>

using namespace std;
typedef long long ll;

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

	int n;
	cin >> n;
	
	
	// A
	// cout << ((n & 1) ? 2 * n : n) << endl;




	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())

lists = []
for _ in range (N):
    S = input().split(' ')
    lists.append([S[0],int(S[1])])

list_sorted = lists.copy()

list_sorted.sort()
list_sorted.sort(key=lambda x:(x[0],-x[1]),reverse =False)
for sorted in range (N):
    for result in range(N):
        if lists[result] == list_sorted[sorted]:
            print(result+1)

Measured memory_bytes: 3064
raw_input()
t=map(int, raw_input().split(" "))
count=0

while True:
    flag=True
    for i in t:
        if i % 2 != 0:
            flag=False
    if not flag:
        break
    else:
        t = [x / 2 for x in t]
        count+=1
        
print count

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

    cout << (n + 1) / 2 << endl;
}

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

int main(void){
    int n, t;
    cin >> n >> t;
    
    int c, tm;
    int ans = 1001;
    int i;
    for(i = 1; i <= n; i++){
        cin >> c >> tm;
        if(tm <= t && c < ans){
            ans = c;
        }
    }
    
    if(ans <= 1000){
        cout << ans << endl;
    }else{
        cout << "TLE" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
/* title: Party
 * source: JOI2009-2010 Yosen No.3
 * hint:
 * テ・ツ、ツ堙ゥツ?づァツつケテヲツ慊?ァツ淞ュティツキツッテ」ツつ津ヲツ篠「テァツエツ「テ」ツ?療」ツ?ヲティツ?ェテ・ツ按?」ツ?凝」ツつ嘉」ツ?ョティツキツ敕ゥツ崢「テ」ツ??テ、ツサツ・テ、ツクツ凝」ツ?ョテ」ツつづ」ツ?ョテ」ツつ津・ツ按療ヲツ個凖」ツ?凖」ツつ古」ツ?ーテ」ツつ暗」ツ??
 * テヲツ慊?ァツ淞ュティツキツッテヲツ篠「テァツエツ「テ」ツ?ッDijkstra, Bellman-Ford, Warshall-Floydテ」ツ?ェテ」ツ?ゥテ」ツ?ョテ」ツつ「テ」ツδォテ」ツつエテ」ツδェテ」ツつコテ」ツδ?」ツ?古ヲツ慊嘉・ツ青?
 * Warshall-Floyd テ」ツ?古、ツクツ?ァツ閉ェテァツーツ。テ・ツ債佚」ツ?ェテ」ツ?ョテ」ツ?ァテ」ツ?禿」ツつ古」ツ??」ツ?妥」ツ?ァテ」ツつづィツヲツ堙」ツ?暗」ツ?ヲテ」ツ?甘」ツ?禿」ツ??
 * テ」ツ?ァテ」ツつづ・ツョツ淌ゥツ堋崚」ツ??、ツコツ暗ゥツ?クテ」ツ?ッテ・ツ?ィテ」ツ?ヲテ」ツ?ョティツウツ?ヲツ鳴凖」ツつ津ヲツ個?ィツセツシテ・ツ渉ッティツδステ」ツ?ェテ」ツ?ョテ」ツ?ァティツヲツ堙」ツ?暗」ツ?ヲテ」ツ??」ツつ凝・ツソツ?ィツヲツ?」ツつづ」ツ?ェテ」ツ??
 * ティツ淞サテヲツ慊ャテ」ツ?ョテ」ツ?ゥテ」ツ?禿」ツ?ォティツシツ嘉」ツ?」テ」ツ?ヲテ」ツ??」ツつ凝」ツ?凝」ツ?静」ツつ嘉」ツ??」ツ?ッティツヲツ堙」ツ?暗」ツ?ヲテ」ツ?甘」ツ?禿」ツ??
 */



#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


const int INF = 1 << 30;


int main()
{
	while(true) {
		int N, M;
		cin >> N >> M;

		if(!(N || M)) break;

		vector<vector<int> > G(N, vector<int>(N, INF));
		for(int i = 0; i < M; i++) {
			int a, b;
			cin >> a >> b;
			G[a-1][b-1] = G[b-1][a-1] = 1;
		}

		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++)
				for(int k = 0; k < N; k++)
					if(G[i][k] != INF && G[k][j] != INF)
						G[i][j] = min(G[i][j], G[i][k] + G[k][j]);

		// G[0][1] テ」ツ?凝」ツつ?G[0][N-1] テ」ツ?セテ」ツ?ァテ」ツ?ョ2テ、ツサツ・テ、ツクツ凝」ツ?ョテ・ツ?、テ」ツつ津ヲツ閉ーテ」ツ?暗」ツつ気++11テ」ツ?ョテヲツゥツ淌ィツδス
		// C++11テ」ツ?古・ツ按?」ツ?凝」ツつ嘉」ツ?ェテ」ツ?妥」ツつ古」ツ?ーテヲツ卍ョテゥツ?堙」ツ?ォforテヲツ鳴?」ツ?ァテヲツ閉ーテ」ツ?暗」ツつ暗」ツ??
		cout << count_if(G[0].begin()+1, G[0].end(), [](int l){ return l <= 2; }) << endl;
	}
}

Measured memory_bytes: 2128
package main

import (
	"fmt"
)

func main() {
	var x int64
	var k int64
	var d int64

	fmt.Scan(&x)
	fmt.Scan(&k)
	fmt.Scan(&d)

	if x < 0 {
		x = -x
	}

	var ans int64
	if x/d > k {
		ans = x - d*k
	} else {
		m := x / d
		n := k - m

		remain := x - m*d
		if n%2 == 0 {
			ans = remain
		} else {
			ans = d - remain
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1768
from sys import stdin
import numpy as np

N, X = [int(x) for x in stdin.readline().rstrip().split()]
L = [int(x) for x in stdin.readline().rstrip().split()]

count = 1
dn = 0
dn_1 = 0

for i in range(N):
    dn = dn_1 + L[i]
    dn_1 = dn
    if dn <= X:
        count = count + 1
    else:
        break

print(count)


Measured memory_bytes: 21548
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int x, y;
    cin>>x>>y;
    if(y%2!=0){
        cout<<"No\n";
        return;
    }
    int x2=y/2;
    if(x>=(x2+1)/2&&x<=x2)cout<<"Yes\n";
    else cout<<"No\n";
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

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

const int MAX_N = (int)(5e2 + 5);

int n, m, q;

int scan[MAX_N][MAX_N];

int main(void) {
  // Here your code !
  scanf("%d %d %d", &n, &m, &q);

  for (int i = 0; i < m; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);
    scan[l][r] += 1;
  }

  for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) {
    scan[i][j] += scan[i][j - 1];
  }
  for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) {
    scan[i][j] += scan[i - 1][j];
  }

  for (int i = 0; i < q; ++i) {
    int p, q;
    scanf("%d %d", &p, &q);
    int ans = scan[q][q] + scan[p - 1][p - 1] - scan[q][p - 1] - scan[p - 1][q];
    printf("%d\n", ans);
  }

  return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define PI 3.142857

int main()
{
int r,area1,area2,result;

area1=PI*1;

scanf("%d",&r);

area2=PI*r*r;

result=r*r;

printf("%d",result);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 999;// 1e25;
static const ll MAX_N = 100001;

priority_queue<int> q;
int main() {
	ll n, m; cin >> n >> m;
	rep(i, 0, n) {
		ll a; cin >> a;
		q.push(a);
	}

	while (m--) {
		ll t = q.top(); q.pop();
		t /= 2;
		q.push(t);
	}
	ll ans = 0;
	while (!q.empty()) {
		ans += q.top(); q.pop();
	}

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


Measured memory_bytes: 892
local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local mod = 1000000007
local function bmul(x, y)
  local x1, y1 = x % 10000, y % 10000
  local x2, y2 = mfl(x / 10000) % 10000, mfl(y / 10000) % 10000
  local x3, y3 = mfl(x / 100000000), mfl(y / 100000000)
  local ret = (x1 * y1 + (x1 * y2 + x2 * y1) * 10000) % mod
  ret = (ret + (x1 * y3 + x2 * y2 + x3 * y1) * 10000 % mod * 10000 % mod) % mod
  ret = (ret + (x2 * y3 + x3 * y2) * 10000 % mod * 10000 % mod * 10000) % mod
  ret = (ret + x3 * y3 * 930000007) % mod
  return ret
end

local function modpow(src, pow)
  local res = 1
  while (0 < pow) do
    if (pow % 2 == 1) then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res;
end

local function modinv(src)
  return modpow(src, mod - 2)
end

local cmb = 1
local n, a, b, c = io.read("*n", "*n", "*n", "*n")
local e = 0
local ta = bmul(a, modinv(a + b))
local tb = bmul(b, modinv(a + b))
for x = n, 2 * n - 1 do
  if x == n then cmb = 1
  else
    cmb = bmul(cmb, x - 1)
    cmb = bmul(cmb, modinv(x - 2 - (n - 1) + 1))
  end
  -- local cmb = getComb(x - 1, n - 1)
  local p1 = cmb
  local q = modpow(ta, n)
  local r = modpow(tb, x - n)
  p1 = bmul(p1, bmul(q, r))
  p1 = bmul(p1, x)

  local p2 = cmb
  q = modpow(tb, n)
  r = modpow(ta, x - n)
  p2 = bmul(p2, bmul(q, r))
  p2 = bmul(p2, x)

  local p = p1 + p2
  -- print(p1, p2)
  p = bmul(p, modinv(a + b))
  p = bmul(p, 100)
  e = (e + p) % mod
end
print(e)


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int h, w;
ll mp[10];
ll c[10][10];
 
void init(){
    rep(i, 10)mp[i] = c[i][1];
    mp[1] = 0;
    rep(n, 10)rep(i, 10)rep(j, 10)if(i != 1)mp[i] = min(mp[i], mp[j]+c[i][j]);
}
int main(){
    cin >> h >> w;
    rep(i, 10)rep(j, 10)cin >> c[i][j];
    int a[h][w];
    rep(i, h)rep(j, w)cin >> a[i][j];
    init();
    ll ans = 0;
    rep(i, h)rep(j, w)if(a[i][j] >= 0)ans += mp[a[i][j]];
    cout << ans << endl;
}


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


string S;

int main() {
  cin>>S;
  bool OK = true;
  rep(i,S.length()) {
    if (i % 2 == 0) {
      if (!(S[i] == 'R' || S[i] == 'U' || S[i] =='D')) {
        OK = false;
        break;
      }
    } else {
      if (!(S[i] == 'L' || S[i] == 'U' || S[i] == 'D')) {
        OK = false;
        break;
      }
    }
  }

  if (OK) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 44

int main()
{
    int n,A[MAX+1], res;
    scanf("%d", &n);
    n++;
    A[0] = 1;
    A[1] = 1;
    if(n>2)
        for(int i=2; i<n+2; i++)
        {
            A[i] = A[i - 2] + A[i - 1];
        }
    
    printf("%d\n", A[n-1]);
    return 0;
}


Measured memory_bytes: 2052
#include <iostream>

int main()
{
	int a, b, c;
	int temp;

	std::cin >> a >> b >> c;

	if (a > b) {
		temp = b;
		b = a;
		a = temp;
	}

	if (b > c) {
		temp = c;
		c = b;
		b = temp;
	}

	if (a > b) {
		temp = b;
		b = a;
		a = temp;
	}

	std::cout << a << " " << b << " " << c << std::endl;

}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}



void solve(std::vector<std::string> s){
    REP(i,3){
        cout << (char)toupper(s[i][0]);
    }
    cout << endl;
}

int main(){
    std::vector<std::string> s(3);
    for(int i = 0 ; i < 3 ; i++){
        std::cin >> s[i];
    }
    solve(std::move(s));
    return 0;
}


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;

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  string ans;
  rep(i,n) {
    ans += s[i];
    ans += t[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int n;
  string s;
  cin >> s;
  
  string ans;
  bool easy = true;
  rep(i, s.size()){
    if (i % 2 == 0){
      if (s[i] == 'L'){
        easy = false;
        break;
      }
    }
    else{
      if (s[i] == 'R'){
        easy = false;
        break;
      }
    }
  }
  if (easy){
    ans = "Yes";
  }
  else{
    ans = "No";
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
static int n, a, m1, m2, m4;
int main(void) {
    scanf("%d", &n);
    while (n--) {
        scanf("%d", &a);
        if (a % 2)
            ++m1;
        else
            if (a % 4)
                ++m2;
            else
                ++m4;
    }
    if (m2)
        puts(m1 - m4 > 0 ? "No" : "Yes");
    else
        puts(m1 - m4 > 1 ? "No" : "Yes");
    return 0;
}


Measured memory_bytes: 128
// ALDS1_11_C.cpp
// Graph I - BFS
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct Vertex
{
    int id = 0;
    vector<int> adjList;
};
int tt = 0;
void bfs(vector<Vertex> &V, vector<int> &dist, int i)
{
    queue<Vertex> mq;
    mq.push(V[i]);
    dist[i] = 0;
    while(!mq.empty()) {
        Vertex tmpV = mq.front();
        mq.pop();
        for (int j = 0; j < tmpV.adjList.size(); j++) {
            int next = tmpV.adjList[j];
            if (dist[next] == -1) {
                mq.push(V[next]);
                dist[next] = dist[tmpV.id] + 1;
            }
        }
    }
}

int main()
{
    int n;
    cin >> n;
    vector<Vertex> V(n);
    vector<int> dist(n, -1);
    int id;
    int num;
    for (int i = 0; i < n; i++) {
        cin >> id >> num;
        id--;
        V[id].id = id;
        int tmp;
        for (int j = 0; j < num; j++) {
            cin >> tmp;
            tmp--;
            V[id].adjList.push_back(tmp);
        }
    }
    bfs(V, dist, 0);
    for (int i = 0; i < n; i++) {
        cout << i + 1 << " " << dist[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
       if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
    int f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
inline ll readll() {
    ll f=1,x=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
    return f*x;
}
void fl(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
          dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
ll n;
int main(){
    cin>>n;
    if(n<30)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}
/* stuff to remember
    * int overflow, array bounds
    * special cases (n=1? n=0?)
    * do something instead of nothing and stay organized
    * USE STATIC ARRAYS
    * DEFINING ARRAYS BEFORE main()
    * DO NOT DEFINE ARRAYS IN main()
    * USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 3580
n = gets.to_i
as = gets.split.map(&:to_i)

sum = 0
s = 1
n.times do |i|
  sum += s * as[i]
  s *= -1
end

bs = []

0.upto(n-1) do |i|
  bs << sum
  sum = 2 * as[i] - sum
end

puts bs.join(' ')


Measured memory_bytes: 14084
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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 all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int n;
vin a(11);
int m=inf;

void dfs(int res,int tmp,int sum){
    if(res==11){
        if((n-tmp)%81==0&&0<=(n-tmp)/81&&(n-tmp)/81<=8){
            sum+=(n-tmp)/81;
            m=min(m,sum);
        }
        return;
    }
    res++;
    if(res<8)for(int i=0;i<=min(5,n/a[res-1]);i++){
        tmp+=a[res-1]*i;
        sum+=i;
        dfs(res,tmp,sum);
        tmp-=a[res-1]*i;
        sum-=i;
    }
    else if(res==8)for(int i=0;i<=min(3,n/a[res-1]);i++){
        tmp+=a[res-1]*i;
        sum+=i;
        dfs(res,tmp,sum);
        tmp-=a[res-1]*i;
        sum-=i;
    }
    else for(int i=0;i<=min(8,n/a[res-1]);i++){
        tmp+=a[res-1]*i;
        sum+=i;
        dfs(res,tmp,sum);
        tmp-=a[res-1]*i;
        sum-=i;
    }
}

int main(){
    cin>>n;
    a[0]=1;
    rep(i,6)a[i+1]=6*a[i];
    a[7]=9;
    a[8]=729;//計算量を減らすには81をなくすのが最も良い
    rep2(i,9,11)a[i]=9*a[i-1];
    int res=0;int tmp=0;int sum=0;
    dfs(res,tmp,sum);
    cout<<m<<endl;
}

Measured memory_bytes: 256
def cin():
    return input().split()
n = int(input())
a = []
for i in range(10001):
    a.append(0)
for x  in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            res = x*x + y*y + z*z + x*y + y*z + z*x
            if res <= 10000:
                a[res] += 1
for i in range(1,n+1):
    print(a[i])



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

using namespace std;

int h[100005];

int memo[100005];

int main(){
    int n;
    cin >> n;
    for(int i=0;i<100005;i++){
        memo[i] = INT_MAX;
    }

    memo[1] = 0;

    for(int i=1;i<n+1;i++){
        cin >> h[i];
    }
    for(int i=1;i<n;i++){
        if(i==n-1){
            memo[i+1] = min(memo[i+1], memo[i]+abs(h[i]-h[i+1]));
        }
        else{
            memo[i+1] = min(memo[i+1], memo[i]+abs(h[i]-h[i+1]));
            memo[i+2] = min(memo[i+2], memo[i]+abs(h[i]-h[i+2]));
        }
    }
    cout << memo[n] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    ll N, M;
    cin>>N>>M;
    vector<ll> H(N);
    rep(i, N){
        cin>>H[i];
    }
    vector<bool> G(N, true);
    vector<ll> A(M), B(M);
    rep(i, M){
        cin>>A[i]>>B[i];
        A[i]--; B[i]--;
        if(H[A[i]]>=H[B[i]]){
            G[B[i]]=false;
        }
        if(H[A[i]]<=H[B[i]]){
            G[A[i]]=false;
        }
    }
    ll Ans=0;
    rep(i, N){
        if(G[i])Ans++;
    }
    cout<<Ans<<endl;
   
    
}

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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}

int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    ll a,b;

    cin >> a >> b;
    for (ll i=0; i<=2000; i++){
        if(ll(i*0.08L)==a && ll(i*0.1L) ==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;


	return 0;
}



Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let s: String = sc.read();
    let t: String = sc.read();
    let tc: Vec<char> = t.chars().collect();

    let mut ans = 0;

    for (i, v) in s.chars().enumerate() {
        if *tc.get(i).unwrap() != v {
            ans = ans + 1;
        }
    }

    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 3336
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMOD = 998244353;

if __name__ == "__main__":
    # sys.stdin = open("input.txt","r")  # <<<  ^o^  Comment this line  ^_^  >>>
    n = int(input())
    ans = 1
    li = get_array()
    maxii = int(1e18)
    flag = flag2 = False
    for i in li:
        if not flag2:
            ans *= i
        if i == 0:
            flag = True
        if ans > maxii:
            flag2 = True
            ans = -1
        # printchk(ans)
    if flag:
        ans = 0
    print(ans)


# #############################################################################
'''
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
>>> DO NOT PLAGIARISE.
TESTCASES:
'''

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

int main(){
  int N,M,sum_A;
  cin>>N>>M;
  sum_A=0;

  for(int i=0;i<M;i++){
  int A;
  cin>>A;
  sum_A+=A;
  }
  N-=sum_A;
  if(N>=0){
  cout<<N<<endl;
  }
  if(N<0){
  cout<<-1<<endl;
  }
}

Measured memory_bytes: 3632
N=int(input());A=sorted((int(x),i)for i,x in enumerate(input().split()));t=[0]*N**2
for w in range(N):
 a,j=A[w]
 for l in range(N-w):
  r=l+w;p=a*abs(j-l);t[l*N+r]=max(p+t[(l+1)*N+r],a*abs(j-r)+t[l*N+r-1])if w else p
print(t[N-1])

Measured memory_bytes: 135660
//#pragma GCC optimize ("O3")
//#pragma GCC target ("tune=native")
//#pragma GCC target ("avx")
//#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const ld PI = 3.14159265358979323846;
const ld EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define N 110
ld res[N];
ll x[N], y[N], cnt[N];
ld sqr(ld a){
	return a*a;
}
ld sqr(ld a, ld b){
	return sqr(a)+sqr(b);
}
int main(){
	random_device rnd;
	mt19937_64 mt(rnd());
	int n;
	cin>>n;
	rep(i, n) cin>>x[i]>>y[i];
	ll l = 1e6;
	rep(i, l){
		ld a = cos(2*PI*i/l)*1e12, b = sin(2*PI*i/l)*1e12;
		int p = 0;
		ld mn = sqr(a-x[0], b-y[0]);
		rep(j, n){
			ld t = sqr(a-x[j], b-y[j]);
			if(mn>t){
				mn = t;
				p = j;
			}
		}
		cnt[p]++;
	}
	cout.precision(10);
	rep(i, n) cout<<fixed<<(ld)cnt[i]/l<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
int t;
int gcd(int a, int b) {
	return !b ? a : gcd(b, a % b);
}
int main() {
	t = read();
	if (360 % t == 0)
		cout << 360 / t << endl;
	else {
		if (gcd(360, t) == 1) {
		/*	int m = 360 % t;
			int cnt = 1, cntt = m;
			while (cntt % t != 0) cntt += m, cnt++;
			cout << 360 + cntt / t << endl;
			*/
			cout << 360 << endl;
		}
		else {
			int n = 360 / t;
			int m = 360 % t;
			int cnt = 1, cntt = m;
			while (cntt % t != 0) cntt += m, cnt++;
			cout << n*cnt + cntt / t << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3568
k,n=map(int,input().split())
a=list(map(int,input().split()))
ans=min(a[-1]-a[0],k-(a[1]-a[0]),k-(a[n-1]-a[n-2]))
for i in range(1,n-1):
    ans=min(k-(a[i]-a[i-1]),k-(a[i+1]-a[i]),ans)
print(ans)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int h,w,k;
    cin>>h>>w>>k;
    string grid[h];
    for(int i=0;i<h;i++) cin>>grid[i];
    int res=0;
    for(int mask=0;mask<(1<<(h+w));mask++) {
        int cnt=0;
        for(int row=0;row<h;row++) {
            for(int col=0;col<w;col++) {
                if(grid[row][col]!='#') continue;
                if((mask&(1<<row)) or (mask&(1<<(h+col)))) continue;
                cnt++;
            }
        }
        if(cnt==k) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3600
main :: IO ()
main = do
    ss <- getLine
    ts <- getLine
    print $ solve ss ts

solve :: String -> String -> Int
solve ss ts = minimum (map (\xs ->
    foldr (\(s, t) acc -> if s == t then acc else acc + 1) 0 $ zip xs ts)
    sss)
      where
        sss = drop (tslen - 1) . snd $ foldr (\_ (n, acc) -> (n + 1, take tslen (drop n ss) : acc)) (0, []) ss
        tslen = length ts


Measured memory_bytes: 6212
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];

    int b = 0;
    int c = 0;

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 0) {
        b++;
        if (a[i] % 3 == 0 || a[i] % 5 == 0) {
          c++;
        }
      }
    }

    if (b == c) {
      System.out.println("APPROVED");
    } else {
      System.out.println("DENIED");
    }


  }

}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

int ans[N];

LL powermod(LL a, LL b, LL mod) {
    if (b == 0) return 1%mod;
    LL res = powermod(a, b/2, mod);
    res = (res * res)%mod;
    if (b & 1) res = (res * a)%mod;
    return res;
}

void solve() {
    ans[0] = 0;
    ans[1] = 1;
    for (int i=2;i<N;++i) {
        int go = __builtin_popcount(i);
        ans[i] = ans[i % go] + 1;
    }
    int n;
    cin >> n;
    string s;
    cin >> s;
    int p = 0;
    for (int i=0;i<n;++i) {
        if (s[i] == '1') ++p;
    }
    int x = 0, y = 0, z = 0;
    for (int i=0;i<n;++i) {
        if (s[i] == '1') {
            if (p > 0) y += powermod(2, n-1-i, p);
            if (p > 1) x += powermod(2, n-1-i, p-1);
            if (p > 0) z += powermod(2, n-1-i, p+1);
            if (x >= p-1) x -= (p-1);
            if (y >= p) y -= p;
            if (z >= (p+1)) z -= (p+1);
        }
    }
    for (int i=0;i<n;++i) {
        if (s[i] == '1') {
            if (p == 1) {
                cout << "0\n";
            } else if (p == 2) {
                cout << "1\n";
            } else {
                int now = x;
                now -= powermod(2, n-1-i, p-1);
                if (now < 0) now += p-1;
                if (now >= p-1) now -= p-1;
                cout << ans[now] + 1 << '\n';
            }
        } else {
            int now = z;
            now += powermod(2, n-1-i, p+1);
            if (now >= p+1) now -= (p+1);
            cout << ans[now] + 1 << '\n';
        }
    }
} 

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

Measured memory_bytes: 4560
from itertools import permutations
from math import factorial

N = int(input())

points = []
for i in range(0,N):
    points.append(list(map(int,input().split())))

p = permutations(points,N)

average = 0

for j in p:
    for k in range(0,len(j)-1):
        average += ((j[k+1][0] -j[k][0])**2 + (j[k+1][1] -j[k][1])**2)**0.5

print('{:.10f}'.format(average/factorial(N)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define se second
#define fi first
#define pb push_back
#define cn cout<<"\n"
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repr(i,a,b) for(int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

#define _ ios::sync_with_stdio(0); cin.tie(0);

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>
#define flush fflush(stdout)

const int INF = 1e8;
const ll MOD = 1e9 + 7;

using namespace std;

int main(){
	_

	int t = 1;

	cin>>t;

	vi v;
	int aux;
	int ans = 0;
	rep(i, 0, t){
		cin>>aux;

		bool y = 1;
		rep(j, 0, v.size())
			if(v[j] > aux) y = 0;

		v.pb(aux);
		if(y) ans++;
	}

	cout<<ans; cn;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s;
int main() {
  cin >> s;
  char c[128]; fill(begin(c), end(c), 0);

  if (s.size() < 26) {
    for (char a : s) c[(lli)a]++;
    for (char a='a'; a<='z'; ++a) {
      if (c[(lli)a] == 0) {
        s.push_back(a);
        cout << s << endl;
        return 0;
      }
    }
  }

  for (lli i=25; i>=0; --i) {
    char a = s[i];
    for (char b = a+1; b<='z'; ++b) {
      if (c[(lli)b] > 0) {
        s[i] = b;
        s = s.substr(0, i+1);
        cout << s << endl;
        return 0;
      }
    }
    c[a]++;
  }
  cout << -1 << endl;
  return 0;
}


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

int main()
{
    int n;
    cin>>n;
    
    int a[n][3];
    
    for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)cin>>a[i][j];
    
    int dp[n][3][3];
    memset(dp,0,sizeof(dp));
   
    
    
    
    for(int i = 0; i < 3; i++)
	{
			dp[0][i][0] = a[0][i];
			dp[0][i][1] = a[0][i];
			dp[0][i][2] = a[0][i];
	}
	
	for(int i=1;i<n;i++)
	{
	    for(int j=0;j<3;j++)
	    {
	        for(int k=0;k<3;k++)
	        {
	            if(j==k) continue;
					dp[i][j][k] = a[i][j] + max(dp[i-1][k][0],max(dp[i-1][k][1],dp[i-1][k][2]));
	        }
	    }
	}
    
    int ans = INT_MIN;
		for (int k = 0; k < 3; k++)
		{
			for (int l = 0; l < 3;l++)
			{
				if(k==l) continue;
				ans = max(ans,dp[n-1][k][l]);
			}
		}
		cout << ans << endl;
   
    
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


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

    ll cnt = b - a;
    ll cc = (b / c) - (a / c);
    ll dd = (b / d) - (a / d);
    ll g = LCM(c, d);
    ll ee = (b / g) - (a / g);

    cout << (cnt - cc - dd + ee) << endl;
}

Measured memory_bytes: 256
while True:
 a,op,b = map(str,input().split())
 a=int(a)
 b=int(b)
 if op=="+":print(a+b)
 elif op=="-":print(a-b)
 elif op=="*":print(a*b)
 elif op=="/":print(a//b)
 else:break


Measured memory_bytes: 5596
#include <iostream>
#define INF 1000000000
using namespace std;

int cost[100][100];
int mincost[100];
bool used[100];
int n;
int prim();
main(){
  int m;
  while(1){
    cin >> n;
    if(n==0) break;
    cin >> m;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cost[i][j]=INF;
      }
    }
    for(int i=0;i<m;i++){
      int a, b, c;
      scanf("%d,%d,%d", &a, &b, &c);
      cost[a][b]=cost[b][a]=c;
    }
    
    cout << (prim()/100)-(n-1) << endl;
  }
  return 0;
}

int prim(){
  for(int i=0;i<n;++i){
    mincost[i]=INF;
    used[i]=false;
  }
  mincost[0]=0;
  int res=0;

  while(true){
    int v=-1;
    for(int u=0;u<n;u++){
      if(!used[u] && (v==-1 || mincost[u]<mincost[v])) v=u;
    }
    if(v==-1) break;
    used[v]=true;
    res+=mincost[v];
    for(int u=0;u<n;u++){
      mincost[u]=min(mincost[u], cost[v][u]);
    }
  }
  return res;
}

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

typedef long long ll;
int sizeeee = 1e5+10;

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

//しっかり制約確認したか?
int main()
{
    int n; cin >> n;
    int ans = 0;
    string t; cin >> t;
    int r = n-1, w = 0;
    string s = t;
    for(int i = 0; i < n; i++){
        if(t[i] == 'W')w++;
        if(s[i] == 'R')continue;
        while(r > 0 && s[r] != 'R'){
            r--;
        }
        s[i] = 'R';
        s[r] = 'W';
        ans++;

    }
    cout << ans-w << endl;


    system("pause");
}


Measured memory_bytes: 3920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC135
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ');
            var a = int.Parse(ab[0]);
            var b = int.Parse(ab[1]);

            var k = Math.Abs(a - b);
            if (k % 2 == 0)
            {
                Console.WriteLine(k / 2 + Math.Min(a, b));
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  int s[N];
  for (int i=0 ; i<N ; i++) {
    cin >> s[i];
  }
  bool dp[110][10010];
  for (int i=0 ; i<110 ; i++) {
    for (int j=0 ; j<10010 ; j++ ) {
      dp[i][j] = false;
    }
  }
  dp[0][0] = true;
  dp[0][s[0]] = true;
  for (int i=1 ; i<N ; i++) {
    for (int j=0 ; j+s[i]<10010 ; j++) {
      if (dp[i-1][j]) {
        dp[i][j] = true;
        dp[i][j+s[i]] = true;
      }
    }
  }
  for (int i=10009 ; i>=0 ; i--) {
    if (i%10 != 0 && dp[N-1][i]) {
      cout << i << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<math.h>

struct zahyo{
	double x;
	double y;
};

int main(){
	
	struct zahyo P1,P2;
	double rangeX,rangeY;
	
	scanf("%lf %lf %lf %lf", &P1.x, &P1.y, &P2.x, &P2.y);
	
	rangeX = (P1.x-P2.x)*(P1.x-P2.x);
	rangeY = (P1.y-P2.y)*(P1.y-P2.y);
	
	printf("%f\n", sqrt( rangeX + rangeY ) );
	
	return 0;
}



Measured memory_bytes: 2084
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>

using namespace std;

int main() {
	int n, max = 0;
	cin >> n;
	vector<pair<int, int> > pairs(n);
	for (int i = 0; i < n; i++) {
		int a, v;
		cin >> a >> v;
		pairs[i] = make_pair(a, v);
	}
	sort(pairs.begin(), pairs.end());

	for (int i = 0; i < n; i++) {
		max = pairs[i].second > pairs[max].second? i: max;
	}
	cout << pairs[max].first << ' ' << pairs[max].second << endl;
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
//#include <ext/numeric>


using namespace std;
//using namespace __gnu_cxx;


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("fence.out", "w", stdout);
#endif

    int n;
    cin >> n;
    vector<int> arr(n);
    for (int &x : arr)
        cin >> x;
    int l;
    cin >> l;

    int log = ceil(log2(n));
    vector<vector<int>> par(n, vector<int>(log + 1));
    auto build = [&]() {
        int j = n - 1;
        for (int i = n - 1; ~i; --i) {
            while (arr[j] - arr[i] > l)
                --j;
            par[i][0] = j;
        }
    };
    build();



    for (int v = n - 1; ~v; --v) {
        for (int p = 1; p <= log; ++p)
            par[v][p] = par[par[v][p - 1]][p - 1];
    }


    int q;
    cin >> q;
    while(q--) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        if (u > v)
            swap(u, v);
        int ans = 0;
        for (int p = log; ~p; --p) {
            if (par[u][p] < v) {
                ans += (1 << p);
                u = par[u][p];
            }
        }
        cout << ans + 1 << '\n';
    }


    return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    ll n; cin >> n;
    vll a(n); REP(i, n) cin >> a[i];

    ll mxa = 0;
    ll ans = 0;
    REP(i, n) {
        ans += max((ll)0, mxa-a[i]);
        chmax(mxa, a[i]);
    }

    print(ans);

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 4784