akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (n, m, c) = parse_line!(usize, usize, i32);
    let b = parse_vec!(i32);
    let mut i = 0;
    let mut j = 0;
    let mut sum = 0;
    let mut code: i32 = 0;
    let mut ans = 0;
    while i < n {
        let a = parse_vec!(i32);
        while j < m {
            sum += &a[j] * &b[j];
            j += 1;
        }
        j = 0;
        code = sum + c;
        if code > 0 {
            ans += 1;
        }
        i += 1;
        sum = 0;
    }
    println!("{}", ans);
}


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

int d[5] = {0, 1, 0, -1, 0};
int dis[800][800];

int main(void){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    int si, sj;
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
        for (int j = 0; j < w; ++j) {
            dis[i][j] = 10000000;
            if (s[i][j] == 'S') {
                si = i;
                sj = j;
            }
        }
    }
    queue<int> qi, qj;
    qi.push(si);
    qj.push(sj);
    dis[si][sj] = 0;
    while (qi.size()) {
        int pi = qi.front();
        int pj = qj.front();
        qi.pop();
        qj.pop();
        for (int i = 0; i < 4; ++i) {
            int ti = pi + d[i];
            int tj = pj + d[i + 1];
            if (ti >= 0 && ti < h && tj >= 0 && tj < w && s[ti][tj] != '#' && dis[ti][tj] > dis[pi][pj] + 1) {
                dis[ti][tj] = dis[pi][pj] + 1;
                qi.push(ti);
                qj.push(tj);
            }
        }
    }
    int ans = 10000000;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (dis[i][j] <= k) {
                ans = min(ans, (min({i, j, h - i - 1, w - j - 1}) + k - 1) / k + 1);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
#include<iomanip>
#include<algorithm>
#include<map>
#include<math.h>
#include<string.h>
#define ll long long
#define eb emplace_back
#define pb push_back
#define ins insert 
#define mp make_pair
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define inf 1000000000000000000
using namespace std;
const int M=1e9+7;
void add(int& a,int b){
    a+=b;
    if(a>=M)
        a-=M;
}
void sub(int& a,int b){
    a-=b;
    if(a<0)
        a+=M;
}
void solve(){
    ll n , k;
    cin>>n>>k;
    vector<int> dp(k+1,0);
    dp[0]=1;
    for (int i = 0; i < n; ++i)
    {
        ll maxVal;
        cin>>maxVal;
        vector<int> store(k+1);
        for (int usedTillNow = k; usedTillNow>=0;--usedTillNow)
        {
            int upperLimit=usedTillNow+min(k-usedTillNow,maxVal);
            int lowerLimit=usedTillNow+1;
            int temp=dp[usedTillNow];
            if(lowerLimit<=upperLimit)
                add(store[lowerLimit],temp);
            if(upperLimit<=k-1)
                sub(store[upperLimit+1],temp);
        }
        int prefix=0;
        for (int j = 0; j<=k; ++j)
        {
            add(prefix,store[j]);
            add(dp[j],prefix);
        }
    }
    cout<<dp[k]<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1,t1=1;
    //cin>>t;
    while(t--){
        //cout<<"Case #"<<t1++<<": ";        
        solve();
    }
    return 0 ;
}

Measured memory_bytes: 1024
#include<stdio.h>
int n,i;
int isprime(int n){
	int i;
	for(i=2;i*i<=n;i++){
		if(n%i==0)	return 0;
	}
	return 1;
}
int main(){
	int p,q;
	while(1){
		scanf("%d",&n);
		if(n==0)	break;
		for(i=n;i>1;i--){
			if(isprime(i)==1 && isprime(i-2)==1){
				p=i-2;	q=i;
				break;
			}
		}
		printf("%d %d\n",p,q);
	}
	return 0;
}

Measured memory_bytes: 1804
#include<iostream>
using namespace std;
int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) { 
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c;
        if (total == X) ++res;
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <set>
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<ll,ll>;
const ll M = 1e9+7;

int main() {
  ll n; cin>>n;
  ll ii; for(ll i=1;i<=n;i<<=1) if (n&i) ii=i;
  ll a=1,b=0,c=0;
  while(ii>0) {
    //cout<<ii<<" "<<a<<" "<<b<<" "<<c<<endl;
    ll d,e,f;
    if (n&ii) {
      d=a, e=a+b, f=2*b+3*c;
    } else {
      d=a+b, e=b, f=b+3*c;
    }
    a=d%M,b=e%M,c=f%M;
    ii>>=1;
  }
  //cout<<ii<<" "<<a<<" "<<b<<" "<<c<<endl;
  cout<<(a+b+c)%M<<endl;
  
  /*
  set<P> se;
  for(ll i=0;i<=n;i++) {
    for(ll j=0;j<=n;j++) {
      if ((i^j)>n) continue;
      if (i+j>n) continue;
      se.insert({i^j,i+j});
    }
  }
  for(P x : se) {
    //caut(x.first,x.second);
  }
  cout<<se.size()<<endl;
  */
}

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
typedef long long ll;
typedef pair<ll, ll> P;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<long long> dijkstra(vector<vector<pair<long long, long long>>> graph, long long s) {
    vector<long long> ans(graph.size(), -1);
    priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>>
        pq;
    pq.push({0, s});
    while (pq.size() > 0) {
        ll cur1 = 0;
        ll cur2 = 0;
        if (ans[pq.top().second] != -1) {
            pq.pop();
        } else {
            cur1 = pq.top().first;
            cur2 = pq.top().second;
            pq.pop();
            ans[cur2] = cur1;
            for (long long i = 0; i < graph[cur2].size(); i++) {
                pq.push({cur1 + graph[cur2][i].second, graph[cur2][i].first});
            }
        }
    }
    return ans;
}
signed main() {
    long long n;
    cin >> n;
    vector<int> as(n);
    vector<int> cnt(1e6 + 23);
    REP(i, n) {
        cin >> as[i];
        cnt[as[i]]++;
    }
    sort(as.begin(), as.end());
    int ans = 0;
    REP(i, n) {
        if(as[i] == 0) continue;
        if (cnt[as[i]] > 1) {
            // cout << as[i] << endl;
            continue;
        }
        bool div = false;
        for (int j = 1; (long long)j * j <= as[i]; j++) {
            // cout << as[j] << endl;
            if (as[i] % j == 0 && j != as[i]) {
                if (cnt[j] > 0) {
                    div = true;
                }
                if (cnt[(as[i] / j)] > 0 && as[i] / j != as[i]) {
                    div = true;
                }
            }
        }
        if (div == false) {
            // cout << endl;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7944
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define p(a,b) (b-a)*(b-a)
#define rep(i,n) for(int i = 0 ; i < n ; i++)

ll compute(int a,int b,int c,int d){
  int e[4] = {a,b,c,d};
  int res = (1<<29);

  rep(i,4){
    rep(j,4){
      if(i == j) continue;
      rep(k,4){
	if(i == k || j == k) continue;
	rep(l,4){
	  if(i == l || j == l || k == l) continue;
	  res = min(res,p(e[j],e[i])+p(e[k],e[j])+p(e[l],e[k]));
	}
      }
    }
  }
 
  return res;
}

int main(){
  int a,b;

  while(cin >> a >> b , a | b){
    vector<P> c,d;
    for(int i = 1 ; i*i <= a ; i++){
      if(a % i == 0){
	c.push_back(P(i,a/i));
      }      
    }

    for(int i = 1 ; i*i <= b ; i++){
      if(b % i == 0){
	d.push_back(P(i,b/i));
      }
    }

    ll ans = (1<<29);
    rep(i,(int)c.size()){
      rep(j,(int)d.size()){
	ans = min(ans,compute(c[i].first,c[i].second,d[j].first,d[j].second));
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1196
n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]

xy.sort()
if n == 1:
    print(1)
    exit()
ans = 10**7

for i in range(n-1):
    for j in range(i+1, n):
        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]
        a = 0
        for k in range(n):
            if [xy[k][0] - p, xy[k][1] - q] not in xy:
                a += 1
        ans = min(a, ans)

print(ans)


Measured memory_bytes: 41452
/******************
*  Writer: Oh no  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a;
	cin>>a;
	if(a<1200){
		cout<<"ABC"<<endl;
		return 0;
	}else{
		if(a<2800){
			cout<<"ARC"<<endl;
			return 0;
		}else{
			cout<<"AGC"<<endl;
			return 0;
		}
	}
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    ll a=1;
    while(a*a<n){
        a++;
    }
    ll b=a;
    if(abs(a*a-n)>abs((a-1)*(a-1)-n)){
        while(a*b>n){
            a--;
        }
        if(a*b<n)a++;
    }
    ll d=a*b-n;
    vl c;
    c.PB(0);c.PB(0);c.PB(a);c.PB(1);c.PB(d);c.PB(b);
    rep(i,c.size())cout<<c[i]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0); // cin, cout の高速化
#define MOD 1000000007
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)

int main()
{
    IOS;

    int n;
    cin >> n;
    while (1)
    {
        string tmp = std::to_string(n);
        char x = tmp[0];
        bool flg = true;
        for (size_t i = 1; i < tmp.size(); i++)
        {
            if (tmp[i] != x)
            {
                flg = false;
                break;
            }
        }
        if(flg){
            break;
        }
        n+=1;
    }
    cout << n << endl;
}

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

int main() {
  int N;
  cin >> N;
  int a = N/1000;
  int b = N%1000/100;
  int c = N%1000%100/10;
  int d = N%1000%100%10;

  if ((a == b && b == c) || (b == c && c == d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    pair<int,int> ans = make_pair(0,0);
    for(int i=0; i<=f/(100*a); i++){
        int x = f - 100*a*i;
        for(int j=0; j<= x/(100*b); j++){
            int y = min(e*(a*i+b*j),f-100*(a*i+b*j));
            int z = 0;
            for(int k=0; k<=y/c; k++){
                z = max(z,c*k+((y-c*k)/d)*d);
            }
            if(z*ans.first >= (z+100*(a*i+b*j))*ans.second){
                ans = make_pair(z+100*(a*i+b*j),z);
            }
        }
    }
    cout << ans.first << ' ' << ans.second << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[1000005];
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p)*(b))%m;
		b=((b)*(b))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll a,b,k;
	cin>>k>>a>>b;
	for (int i = a; i <= b; ++i)
	{
		if (i%k==0)
		{
			cout<<"OK"<<endl;
			return 0;
		}
	}
			cout<<"NG"<<endl;
	return 0;
}


Measured memory_bytes: 27088
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
using namespace std;

typedef complex<double> P;
const double eps = 1e-8;

bool cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

int main() {
  int Tc;
  cin >> Tc;
  while(Tc--) {
    vector<P> ps(4);
    for(int i = 0; i < 4; ++i) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    if(abs(cross(ps[1]-ps[0], ps[3]-ps[2])) < eps) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

int main(){
  int n;

  while(cin>>n&&n!=0){
    int min=n+1;
    int count=0;
    for(int i=min;i<=2*n;i++){
      if(i==2||i==3) count++;
      else if(i%2!=0){
        for(int j=2;j<=(int)(sqrt(i));j++){
          if(i%j==0) break;
          if(j==(int)(sqrt(i))){
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }

  return 0;
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
int N, M;

void solve() {
	map<LL, LL> memo;
	LL ret = 0;
	LL t = 0;
	memo[0] = 1;
	for (int i : range(N)) {
		int A;
		cin >> A;
		t += A;
		t %= M;
		LL s = memo[t];
		ret += s;
		memo[t]++;
	}
	cout << ret << endl;
}
int main() {
	while (cin >> N >> M)solve();

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  bool c = false;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y"){
      c++;
      break;
    }
  }
  if (c){
      cout << "Four" << endl;
    }
    else {
      cout << "Three" << endl;
    }

    


  

  // ここにプログラムを追記
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int a,b,c;
    cin>>a>>b>>c;
   if(b>=c){
    cout<<"delicious"<<endl;
    return 0;
   }
if(a+b>=c){cout<<"safe"<<endl; return 0;} cout<<"dangerous"<<endl;
    return 0;
}


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

int main(){
  int x;
  cin >> x;
  int n,m;
  n=x%100;
  m=x/100;
  if(n <= m*5) cout << 1 <<endl;
  else cout << 0 <<endl;
}

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

#define eb emplace_back
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using Vi = vector<int>;

void run() {
 	int a, b, c;
 	cin >> a >> b >> c;
 	cout << (a+b+c>=22 ? "bust":"win") << endl;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    double st = clock();

    run();

    cerr << "\n" << "time = " << (clock() - st) / CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){

    int n,x,c,j,k,i;
    
    while(1){ 
        c= 0;
            scanf("%d %d", &n,&x);
            if(n == 0 && x == 0)
            {
                return 0;
            }
    for(i = 1; i <= n; i++)
    {
        for(j = i + 1  ; j<= n; j++)
        {
            for(k = j + 1; k <= n; k++)
            {
                if(x == i + j + k){
                    c = c + 1;
                }
                    
                }
            }

        }
    printf("%d\n" , c);
    
}
    return 0;

}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	vvl dp(n+1,vl(3,-linf));
	dp[0][0] = a[0];
	dp[1][1] = a[1];
	dp[2][2] = a[2];
	REP(i,2,n){
		chmax(dp[i][0],dp[i-2][0] + a[i]);
		if(i > 2){
			chmax(dp[i][1],dp[i-2][1] + a[i]);
			chmax(dp[i][1],dp[i-3][0] + a[i]);
		}
		if(i > 3){
			chmax(dp[i][2],dp[i-2][2] + a[i]);
			chmax(dp[i][2],dp[i-3][1] + a[i]);
			chmax(dp[i][2],dp[i-4][0] + a[i]);
		}
	}
	ll ans;
	if(n & 1) ans = max({dp[n-3][0],dp[n-2][1],dp[n-1][2]});
	else ans = max(dp[n-2][0],dp[n-1][1]);
	cout << ans << endl;
}


Measured memory_bytes: 15668
#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,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    ll N;
    cin >> N;
    vector<pair<ll,ll> > pairs(N);
    bool flag = 0;
    for(int i = 0; i < N; i++){
        cin >> pairs[i].second >> pairs[i].first;
    }
    sort(pairs.begin(), pairs.end());
    ll time = 0;
    for(int i = 0; i < N ; i++){
        time += pairs[i].second;
        if(time > pairs[i].first){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long gcd(long long a, long long b);

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

	vector<int> a(n), l(n), r(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i++) {
		l[i] = gcd(l[i - 1], a[i - 1]);
	}
	for (int i = n - 2; i >= 0; i--) {
		r[i] = gcd(r[i + 1], a[i + 1]);
	}

	long long mx = 0;
	for (int i = 0; i < n; i++) {
		mx = max(mx, gcd(r[i], l[i]));
	}
	cout << mx << endl;

	return 0;
}

long long gcd(long long a, long long b)
{
	if (a < b) {
		long long t = a;
		a = b;
		b = t;
	}

	if (b == 0) {
		return a;
	}

	long long r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

Measured memory_bytes: 4580
h, w = map(int, input().split())
data = [input() for i in range(h)]


def able_black(line, row):
    if data[line][row] == '.':
        return True
    else:
        for dx in range(-1, 2):
            for dy in range(-1, 2):
                if 0 <= line+dx <= h-1 and 0 <= row+dy <= w-1 and not ((dx == 0 and dy == 0) or (abs(dx) == 1 and abs(dy) == 1)):
                    if data[line+dx][row+dy] == '#':
                        return True
        return False


for i in range(h):
    for j in range(w):
        if not able_black(i, j):
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for(long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for(long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                                                            \
    (upper_bound((V).begin(), (V).end(), X) -                                  \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                                                               \
    {                                                                          \
        cerr << #v << ':';                                                     \
        for(auto xv : v) cerr << xv << ' ';                                    \
        cerr << endl;                                                          \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) {
    if(a > b) a = b;
    return a > b;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) {
    if(a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

signed main() {
    ll N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
}

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

typedef pair<int, int> pii;

int N, M;
string S;
vector<int> D;
vector<vector<int> > adj;
vector<int> vis;
int sum = 0;

bool dfs(int u) {
    bool ret = u == 0 || u == N;
    vis[u] = 1;
    sum += (u == N - u)? D[u] : D[u] + D[N - u];
    sum %= 26;

    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(vis[v]) continue;
        ret |= dfs(v);
    }
    return ret;
}

int f(int x) { return min(x, N - x); }

int main() {
    cin >> S;
    N = S.size();

    D = vector<int>(N + 1, 0);
    for(int i = 0; i < N - 1; i++) {
        D[i + 1] = (S[i] - S[i + 1] + 26) % 26;
    }

    scanf("%d", &M);

    adj.resize(N + 1);
    for(int i = 0; i < M; i++) {
        int l, r; scanf("%d %d", &l, &r);
        l--; r--;

        adj[ f(l) ].push_back( f(r + 1) );
        adj[ f(r + 1) ].push_back( f(l) );
    }

    vis = vector<int>(N + 1, 0);
    for(int i = 0; i <= N - i; i++) if(!vis[i]) {
        sum = 0;
        if(!dfs(i) && sum) {
            printf("NO");
            return 0;
        }
    }
    printf("YES");
}


Measured memory_bytes: 6528
N = int(input())
ns = []
for i in range(N):
    n, s = input().split()
    ns.append([n, int(s)])
    ns[i].append(i+1)
ns.sort(reverse=True, key=lambda x:x[1])
ns.sort(key=lambda x:x[0])
[print(x[2]) for x in ns]

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int R;

int main(void) {
	cin >> R;

	if (R <= 1199) { cout << "ABC" << endl; }
	else if (R <= 2799) { cout << "ARC" << endl; }
	else { cout << "AGC" << endl; }

	//system("pause");
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll h, w, m, hin, win;
  cin >> h >> w >> m;
  vector<ll> ah(h, 0);
  vector<ll> aw(w, 0);
  set<ll> hash;
  for(int i = 0; i < m; ++i)
  {
    cin >> hin >> win;
    hin--;
    win--;
    ah[hin]++;
    aw[win]++;
    hash.insert((hin << 32LL) + win);
  }
  ll ah_max_ind = distance(ah.begin(), max_element(ah.begin(), ah.end()));
  ll aw_max_ind = distance(aw.begin(), max_element(aw.begin(), aw.end()));

  vector<ll> ah_ind;
  vector<ll> aw_ind;
  for(int i = 0; i < h; ++i)
  {
    if (ah[i] == ah[ah_max_ind])
    {
      ah_ind.emplace_back(i);
    }
  }
  for(int i = 0; i < w; ++i)
  {
    if (aw[i] == aw[aw_max_ind])
    {
      aw_ind.emplace_back(i);
    }
  }

  ll ans = ah[ah_max_ind] + aw[aw_max_ind];
  for(const auto& ih : ah_ind) for(const auto& iw : aw_ind)
  {
    if (hash.find( (ih << 32LL) + iw ) == hash.end())
    {
      cout << ans;
      return;
    }
  }

  if (hash.find( (ah_max_ind << 32LL) + aw_max_ind ) != hash.end()) ans--;
  cout << ans << endl;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int findsum(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
  
int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int total;
  for(int i = 1; i <= N; i++){
    int sum = findsum(i);
    if(sum >= A && sum <= B){
      total += i;
    }
  }
  
  cout << total << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define vi vector<int>
#define pi pair<int,int>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define ll long long 

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod=1e9+7;

int mul(int a,int b)
{
	return (a*1ll*b)%mod;
	}
	
	int add(int a,int b)
	{
		a+=b;
		if(a>=mod)return a-mod;
		return a;
		}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
		}
		return res;
	}



void solve()
{
int n;
cin>>n;
int dp[n+1],h[n]={0};
for(int i=0;i<=n;i++)dp[i]=1e9;
dp[0]=0;
cin>>h[0];
for(int i=1;i<n;i++)
{
	cin>>h[i];
	dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
	if(i>1)dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	
	}	
	cout<<dp[n-1];
}
	
	
int main()
{   ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		}
	
	
	}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

from collections import Counter

class Mint:
    
    MOD = 10**9+7
    
    def __init__(self, x=0):
        self.x = (x%self.MOD + self.MOD) % self.MOD
    
    def __iadd__(self, other):
        self.x += other.x
        if self.x >= self.MOD:
            self.x -= self.MOD
        return self
    
    def __isub__(self, other):
        self.x += self.MOD - other.x
        if (self.x >= self.MOD):
            self.x -= self.MOD
        return self
    
    def __imul__(self, other):
        self.x *= other.x
        self.x %= self.MOD;
        return self;
    
    def __add__(self, other):
        ans = Mint(self.x)
        ans += other
        return ans
        
    def __sub__(self, other):
        ans = Mint(self.x)
        ans -= other
        return ans
    
    def __mul__(self, other):
        ans = Mint(self.x)
        ans *= other
        return ans
    
    def __pow__(self, n):
        if n == 0:
            return Mint(1)
        a = self.__pow__(n >> 1)
        a *= a
        if n&1:
            a *= self
        return a
    
    def inv(self):
        return self**(self.MOD-2)
    
    def __ifloordiv__(self, other):
        self *= other.inv()
        return self
    
    def __floordiv__(self, other):
        ans = Mint(self.x)
        ans //= other
        return ans
        
    

def Main(N, A):
    counter = Counter(A)
    if len(A)%2 == 0:
        v = counter.values()
        s = set(v)
        if len(s) > 1:
            return 0
        else:
            k = list(counter.keys())
            k.sort()
            for i, e in enumerate(k):
                if e != 2*i+1:
                    return 0
            return (Mint(2)**(len(A)//2)).x
    else:
        if 0 not in counter:
            return 0
        if 0 in counter and counter[0] != 1:
            return 0
        del counter[0]
        v = counter.values()
        s = set(v)
        if len(s) > 1:
            return 0
        else:
            k = list(counter.keys())
            k.sort()
            for i, e in enumerate(k):
                if e != 2*(i+1):
                    return 0
            return (Mint(2)**(len(A)//2)).x           
                    
                

res = Main(N, A)
print(res)

Measured memory_bytes: 14948
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    while (true)
    {
        int a,b;
        char op;
        cin >> a >> op >> b;
        if (op == '?')
            break;
        if (op == '+')
        {
            cout << a + b << endl;
        }
        else if (op == '-')
        {
            cout << a - b << endl;
        }
        else if (op == '*')
        {
            cout << a * b << endl;
        }
        else
        {
            cout << a / b << endl;
        }
    }
}


Measured memory_bytes: 3100
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  for (;;) {
    int h, w;
    cin >> h >> w;
    if (h == 0) break;

    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++)
	putchar(((x + y) & 1) ? '.' : '#');
      putchar('\n');
    }
    putchar('\n');
  }

  return 0;
}

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

int main()
{
	int a,b,total=0;
	cin>>a>>b;
	int c[100005]={0};
	for(int i=1;i<=b;++i)
		cin>>c[i];
	for(int i=1;i<=b;++i)
		a-=c[i];
	if(total>a)
		cout<<"-1"<<endl;
	else
	{
		int d=a-total;
		cout<<d<<endl;
	}
	return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <unordered_map>
 
using namespace std;
using ll = long long;
// constexpr int MOD = 1e9+7;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define RemoveIf(a, f) a.erase(remove_if(Range(a), f), a.end())
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Tie(T, ...)  T __VA_ARGS__; tie(__VA_ARGS__)

#include <queue>

int main(void){
    Cin(int, n);
    Cin(string, s);
    int l = 0, r = 0;
    For(i, n){
        if(s[i] == '(') l ++;
        else if(l > 0) l --;
        else r ++;
    }

    Rep(r) cout << '(';
    cout << s;
    Rep(l) cout << ')';
    cout << "\n";
}



Measured memory_bytes: 256
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main(void) {
    int time;
    cin >> time;
    int hour = time / 3600;
    int min = (time % 3600) / 60; 
    int sec = time - (hour * 3600) - (min * 60);
    cout << hour << ":" << min << ":" << sec << endl;
    return 0;
}

Measured memory_bytes: 1164
Row=int(input()) 
List=[int(i) for i in input().split()]

flg=0
for Num in List:
  if Num % 2 == 0 and(Num  % 3 != 0 and Num % 5 != 0):
    flg = 1
    break

print('DENIED' if  flg else 'APPROVED')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<time.h>
using namespace std;
#define int long long
#define inf 1e9+7
typedef pair<int, int> P;

int dt[30][220000];

signed main() {
	int n, c;
	cin >> n >> c;
	for (int i = 0; i < n; i++) {
		int s, t, d;
		cin >> s >> t >> d;
		s = s * 2 - 1;
		t *= 2;
		d--;
		dt[d][s]++;
		dt[d][t]--;
	}
	
	for (int i = 0; i < c; i++) {
		for (int j = 0; j < 200000; j++) {
			dt[i][j + 1] += dt[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i <= 200000; i++) {
		int sum = 0;
		for (int j = 0; j < c; j++)if(dt[j][i]>0)sum++;
		ans = max(ans, sum);
	}
	cout << ans << endl;

}

Measured memory_bytes: 51456
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

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

int main(){
  ll k; cin >> k;
  ll ans=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        ans+=gcd(gcd(i,j),l);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
"use strict";

var divArray = function divArray(arr, num) {
  return arr.map(function (elem) {
    return elem / num;
  });
};

var hasDecimal = function hasDecimal(arr) {
  return arr.filter(function (elem) {
    return !Number.isInteger(elem);
  }).length > 0;
};

var culc = function culc(arr, count) {
  var result = divArray(arr, 2);

  if (hasDecimal(result)) {
    console.log(count);
  } else {
    count++;
    culc(result, count);
  }
};

var main = function main(input) {
  var input_arr = input.split('\n');
  var N = parseInt(input_arr[0], 10);
  var A = input_arr[1].split(" ");
  var count = 0;
  culc(A, 0);
};

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

Measured memory_bytes: 7756
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

    ll N;
    cin >> N;


    string S;

    while(N!=0){
        if(N%2 != 0){
            N--;
            S = "1" + S;
        }else{
            S = "0" + S;
        }

        N = N/(-2);

    }

    if(S==""){
        S = "0";
    }

    cout << S << endl;

    return 0;

}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> mountains;
    for(int i=0; i<N; ++i){
        int tmp;
        cin >> tmp;
        mountains.push_back(tmp);
    }
    int highest = 0;
    int count = 0;
    for(auto m : mountains){
        if(m>=highest){
            ++count;
            highest = m;
        }
    }
    cout << count << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 59;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  vector<string> s(3);
  rep(i, 3) cin >> s[i];
  rep(i, 3) cout << (char)toupper(s[i][0]);
  cout << endl;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    int sum = 0;

    for (int i = A; i <= B; i++) {
        string S = to_string(i);
        string temp = S;

        for (int j = 0; j < S.size() / 2;  j++) {
            swap(S[j], S[S.size() - j - 1]);
        }
        if (S == temp) {
            sum++;
        }

    }
    cout << sum << endl;
    
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int a,b;
  cin>>a>>b;
  if(a!=1&&b!=1){
    cout<<1<<endl;
    return 0;
  }
  if(a!=2&&b!=2){
    cout<<2<<endl;
    return 0;
  }
  if(a!=3&&b!=3){
    cout<<3<<endl;
    return 0;
  }
}

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

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 1e+8;

typedef long long ll;

#define MAX_N 50
#define MAX_M 50
vector<ll> a(MAX_N), b(MAX_N), c(MAX_M), d(MAX_M);

int dist(int i, int j) {
  return abs(a[i] - c[j]) + abs(b[i] - d[j]);
}

int main() {
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  for(int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < M; i++) {
    cin >> c[i] >> d[i];
  }

  for(int i = 0; i < N; i++) {
    int nj = M-1;
    int nd = dist(i, M-1);
    for(int j = M-2; j >= 0; j--) {
      int d = dist(i, j);
      if( d <= nd ) {
        nj = j;
        nd = d;
      }
    }
    cout << nj+1 << "\n";
  }



  return 0;
}


Measured memory_bytes: 256