akhauriyash/Code-Regression huggingface dataset:
def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

N, X  = (int(i) for i in input().split())
x = (int(i) for i in input().split())
x = list(x)
x.append(X)
#print(x)
x = sorted(x)

ans = x[1]-x[0]
for i in range(2, N+1):
    ans = gcd(x[i]-x[i-1],ans)

print(ans)


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

int main(){
	int t;
	cin >> t;
	
	vector<int> d;
	set<int> st;
	
	for(int i = 0; i < 500; i++){
		for(int j = 0; j < 500; j++){
			if(i == 0 && j == 0) continue;
			int tmp = i * i + j * j;
			if(!st.count(tmp)){
				st.insert(tmp);
				d. push_back(tmp);
			}
		}
	}
	
	
	for(int i = 0; i < t; i++){
		int n, m;
		cin >> n >> m;
		int cnt = 0;
		for(int j = 0; j < (int)d.size(); j++){
			if((n * n + m * m) % d[j] == 0) cnt++;
		}
		cout << (cnt == 2 ? "P" : "C") << endl;
	}
}

Measured memory_bytes: 6696
#include<stdio.h>

int dp[50];

int fib(int n) {
  if ( n == 0 || n == 1 ) return dp[n] = 1;
  if ( dp[n] != -1 ) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}

int main() {
  int n, i;
  for ( i = 0; i < 50; i++ ) dp[i] = -1;

  scanf("%d", &n);
  printf("%d\n", fib(n));

  return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = (ll)1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    deque<ll> neg;
    deque<ll> nonneg;
    for (int i = 0; i < N; ++i) {
        ll a;
        cin >> a;
        if (a < 0) neg.push_back(a);
        else nonneg.push_back(a);
    }
    
    if (N == K) {
        ll ans = 1;
        int cnt = 0;
        for (int i = 0; i < neg.size(); ++i) {
            ans = (ans * neg[i]) % mod;
            cnt++;
        }
        for (int i = 0; i < nonneg.size(); ++i) {
            ans = (ans * nonneg[i]) % mod;
            cnt++;
        }
        cout << (mod + ans) % mod << endl;
        return 0;
    }

    if (K % 2 == 1 && neg.size() == N) {
        sort(neg.begin(), neg.end(), greater<ll>());
        ll ans = 1;
        int cnt = 0;
        for (int i = 0; i < N; ++i) {
            ans = (ans * neg[i]) % mod;
            cnt++;
            if (cnt == K) break;
        }
        cout << (mod + ans) % mod << endl;
        return 0;
    }

    sort(neg.begin(), neg.end());
    sort(nonneg.begin(), nonneg.end(), greater<ll>());

    int cnt = 0;
    ll ans = 1;
    while (cnt < K) {
        if (neg.size() <= 1) {
            ans = (ans * nonneg.front()) % mod; nonneg.pop_front();
            cnt++;
            continue;
        }
        if (nonneg.size() <= 1) {
            if (cnt + 1 == K) {
                ans = (ans * nonneg.front()) % mod; nonneg.pop_front();
                cnt++;
                continue;
            }
            ans = (ans * neg.front()) % mod; neg.pop_front();
            ans = (ans * neg.front()) % mod; neg.pop_front();
            cnt += 2;
            continue;
        }
        if (cnt + 1 < K && neg[0] * neg[1] > nonneg[0] * nonneg[1]) {
            ans = (ans * neg.front()) % mod; neg.pop_front();
            ans = (ans * neg.front()) % mod; neg.pop_front();
            cnt += 2;
            continue;
        }
        ans = (ans * nonneg.front()) % mod; nonneg.pop_front();
        cnt++;
    }
    cout << (mod + ans) % mod << endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e15;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 1e5 + 100;
const int LOG = 20;
const int mod = 1e9 + 7;
const int MX = 1e6 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;


int dp[3100][3100];

void solve() {
   string s,t;
   cin >> s >> t;
   int n = sz(s);
   int m = sz(t);
   s = "#" + s;
   t = "#" + t;
   for(int i=1;i<=n;++i){
       for(int e=1;e<=m;++e){
           dp[i][e] = max(dp[i-1][e],dp[i][e-1]);
           if(s[i]==t[e]){
               dp[i][e] = max(dp[i][e], dp[i-1][e-1] + 1);
           }
       }
   }
   dout << dp[n][m]<<"\n";

   string res = "";
   while(n >=1 && m >=1){
       if(s[n]==t[m] && dp[n][m] == dp[n-1][m-1] + 1){
           res.pb(s[n]);
           n--;
           m--;
       } else {
           if(dp[n][m] == dp[n][m-1]){
               m--;
           } else{
               n--;
           }
       }
   }
   reverse(all(res));
   cout << res<<"\n";
}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;

    while (t--)
        solve();
    dout << endl << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

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

int main(void)
{
	string str;
	
	cin >> str;

	for(int i = 0; i < str.length(); i++){
		str[i] = str[i] - 3;
		if(str[i] < 'A')
			str[i] += 26;
	}
	cout << str.c_str() << endl;



	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <math.h>
#include <set>

using namespace std;
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++)

static const double PI = 3.1415926535897932384626433;

///////////////////////////
////Prime Creator//////////
///////////////////////////
//bool Prime[100001] = {};
//void createPrime() {
//	ll n = 100001;
//	rep(i, 0, n) Prime[i] = true;
//	Prime[0] = false;
//	Prime[1] = false;
//	rep(i, 2, n) {
//		if (Prime[i]) {
//			rep(j, 2, n) {
//				if (j*i >= n)break;
//				Prime[j*i] = false;
//			}
//		}
//	}
//}
///////////////////////////
///////////////////////////

/////////////////////////
//Warshal Floyid/////////
/////////////////////////
//initialize`
//static const ll LL_MAX = (ll)1 << 55;
//static const ll WF_MAX = 300;
//rep(i, 0, N)rep(j, 0, N) wf[i][j] = LL_MAX;
//ll wf[WF_MAX][WF_MAX];
//void WarshalFloyid(int size) {
//	rep(k, 0, size)rep(i, 0, size)rep(j, 0, size)wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
//}

static const ll LL_MAX = (ll)1 << 55;
static const ll WF_MAX = 300;
ll wf[WF_MAX][WF_MAX];
ll wf2[WF_MAX][WF_MAX];
void WarshalFloyid(int size) {
	rep(k, 0, size)rep(i, 0, size)rep(j, 0, size)wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
}
//Union Find

ll N, M;
int main() {
	cin >> N >> M;
	rep(i, 0, N) {
		rep(j, 0, N) {
			if (i == j) {
				wf[i][j] = 0;
				wf2[i][j] = 0;
			}
			else {
				wf[i][j] = LL_MAX;
				wf2[i][j] = LL_MAX;
			}
		}
	}
	rep(i, 0, M) {
		ll a, b, c; cin >> a >> b >> c;
		wf[a - 1][b - 1] = c;
		wf[b - 1][a - 1] = c;
		wf2[a - 1][b - 1] = c;
		wf2[b - 1][a - 1] = c;
	}

	WarshalFloyid(N);

	ll res = 0;
	rep(i, 0, N) {
		rep(j, 0, N) {
			if (wf[i][j] == wf2[i][j] || wf2[i][j] == LL_MAX) {
				continue;
			}
			res++;
		}
	}
	cout << res / 2 << endl;
}

Measured memory_bytes: 768
/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
using namespace std;

int main()
{

    int n;
    cin >> n;
    string s;
    cin >> s;
    int l = 0,c = 0,r = n-1;
    while( l < r )
    {
        while(l < r && s[l] == 'R')l++;
        while(l < r && s[r] == 'W')r--;
        if(l >= r)
            break;
        swap(s[l],s[r]);
        c++;
        l++;
        r--;
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 3680
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define lo long
const long long lmax=1000000000;
const long long lmx=1999999999999999999;
long long N,X,sz[52],p[52];
string s;
long long go(long long n,long long x)
{
//	cout<<n<<" "<<x<<endl;
	if(x<=0)return 0;
	if(n<0)return 0;
	if(x>=sz[n])return p[n];
	if(x>=(sz[n]+1)/2)return p[n-1]+1+go(n-1,x-sz[n]/2-1);
    return go(n-1,x-1);
}
int main(){std::ios::sync_with_stdio(false);
cin>>N>>X;
sz[0]=p[0]=1LL;
for(long long i=1;i<=N;i++)
{
	sz[i]=sz[i-1]*2LL+3LL;
	p[i]=p[i-1]*2LL+1LL;
}
cout<<go(N,X)<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var t = nextstr();
  t = t.replace(/\?/g,"D");
  return t;
}

Measured memory_bytes: 37604
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int r;
    cin >> r;
    if(r >= 2800){
        cout << "AGC" << endl;
    }else if(r >= 1200){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

// エラトスネテスの篩
struct Eratos {
  vector<int> primes;
  vector<bool> isprime;
  vector<int> min_factor;
  Eratos(int MAX) : primes(),
  isprime(MAX+1, true),
  min_factor(MAX+1, -1) {
    isprime[0] = isprime[1] = false;
    min_factor[0] = 0, min_factor[1] = 1;
    for (int i=2; i<=MAX; ++i) {
      if (!isprime[i]) continue;
      primes.push_back(i);
      min_factor[i] = i;
      for (int j=i*2; j<=MAX; j+=i) {
        isprime[j] = false;
        if (min_factor[j]==-1) min_factor[j] = i;
      }
    }
  }
  // prime factorization
  vector<pair<int,int>> prime_factorize(int n) {
    vector<pair<int,int> > res;
    while (n!=1) {
      int prime = min_factor[n];
      int exp = 0;
      while (min_factor[n]==prime) {
        ++exp;
        n /= prime;
      }
      res.push_back(make_pair(prime, exp));
    }
    return res;
  }
};

int main() {
  int N;
  cin >> N;
  Eratos er(1100000);
  ll res = 0;
  for (int i=1; i<=N-1; i++) {
    auto pf = er.prime_factorize(i);
    ll num = 1;
    for (auto v: pf) num *= v.second+1;
    res += num;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 8356
#include<iostream>
main(){int n,m,i,a,c[1<<20];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;}

Measured memory_bytes: 5876
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int t=0;t<T;t++) {
			P p = new P(0, 0);
			P max = new P(0, 0);
			for(;;) {
				int dx = sc.nextInt(), dy = sc.nextInt();
				if( (dx|dy) == 0 ) break;
				p.x += dx; p.y += dy;
				if( max.compareTo(p) < 0 ) max = new P(p.x, p.y);
			}
			System.out.println(max.x + " " + max.y);
		}
	}
	
	class P implements Comparable<P>{
		int x, y;
		P(int x, int y) {
			this.x = x;
			this.y = y;
		}
		@Override
		public int compareTo(P p) {
			// TODO 自動生成されたメソッド・スタブ
			if( x*x + y*y - (p.x*p.x + p.y*p.y) != 0 )
				return x*x + y*y - (p.x*p.x + p.y*p.y);
			return x - p.x;
		}
		
		
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if (x == 0 && y == 0) {
				break;
			} else if (x < y) {
				System.out.print(x + " ");
				System.out.println(y);
			} else {
				System.out.print(y + " ");
				System.out.println(x);
			}
		}
	}
}


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

int main(){
  int n;
  cin >> n;
  int sum = 0, temp = n;
  while(temp > 0){
    sum += temp % 10;
    temp /= 10;
  }
  if(n % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

bool check(vector<pair<ll, ll>> l) {
  int h = 0;
  for (pair<ll, ll> p : l) {
    int lower = h + p.first;
    if (lower < 0) return false;
    h += p.second;
  }
  return true;
}

int main() {
  ll N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  vector<pair<ll, ll>> up, down;
  ll total = 0;
  for (auto s : S) {
    ll lower = 0, cur = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == '(') {
        cur++;
      } else {
        cur--;
        lower = min(lower, cur);
      }
    }
    if (cur > 0)
      up.push_back({lower, cur});
    else
      down.push_back({lower - cur, -cur});
    total += cur;
  }
  sort(up.rbegin(), up.rend());
  sort(down.rbegin(), down.rend());
  string ans = "No";
  if (check(up) && check(down) && total == 0) ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 65848
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
L = [0] * 2001
ans = 0
for i in range(N-2):
    for j in range(i+1):
        L[A[i+1] + A[j]] += 1
    ans += sum(L[A[i+2]+1:])

print(ans)

Measured memory_bytes: 42348
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,cnt=0; cin>>a>>b>>c;
  while(a!=b||b!=c){
    if(a==b&&b>c) c+=2;
    else if(b==c&&c>a) a+=2;
    else if(c==a&&a>b) b+=2;
    else if(a>b&&a>c) b++,c++;
    else if(b>c&&b>a) c++,a++;
    else if(c>a&&c>b) a++,b++;
    cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 3608
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<utility>//pair
#include<list>
#include<vector>//可変長配列
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<ll,ll>
#define F first
#define S second
int dx[8] = { 1,0,-1,0,1,-1,-1,1 };
int dy[8] = { 0,1,0,-1,1,1,-1,-1 };


int n, m;

int main() {
	cin >> n >> m;
	cout << ((n*(n-1))/2) + ((m*(m-1))/2) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,k;
vl a,b;

bool f(ll x){
	ll t=0;
	for(int i=0;i<n;i++) if(x>=a[i]) t+=(x-a[i])/b[i]+1;
	return t>=k;
}

int main(){
	cin>>n>>k;
	a=b=vl(n);
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	ll l=0,r=INF;
	while(r-l>1){
		ll m=(l+r)/2;
		if(f(m)) r=m;
		else l=m;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const long long INF = 123456789;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

map<ll, ll> mp;

int main()
{
    cin >> n >> m;
    vi v(n), va;
    REP(i, n)
    {
        cin >> v[i];
        mp[v[i]]++;
    }
    REP(i, 200005)
    {
        if (mp[i] != 0)
        {
            va.push_back(mp[i]);
        }
    }
    sort(RALL(va));
    if (va.size() <= m)
    {
        cout << 0 << endl;
    }
    else
    {
        FOR(i, m, va.size())
        {
            cnt += va[i];
        }
        cout << cnt << endl;
    }
}

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

// 繰り返し二乗法
ll power(ll a, ll b){
    if(a==1)return a;
    // if(a==0)re
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int MAX=2100000;

ll fact[MAX], fact_inv[MAX];

void init_fact(ll n){
    fact[0]=1;
    // 階乗の計算
    for(ll i=0; i<n; i++) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

ll perm(ll n, ll r){
    return (fact[n]*fact_inv[n-r])%MOD;
}

int main() {
    cout<<fixed<<setprecision(10);

    ll x; cin>>x;
    cout<<x/500*1000 + (x%500)/5*5<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vi h(n);
    REP(i, n) cin >> h[i];
    vector<bool> v(n, true);
    int a, b;
    REP(i, m) {
        cin >> a >> b;
        a--; b--;
        if (h[a] > h[b]) v[b] = false;
        else if (h[a] < h[b]) v[a] = false;
        else {v[a] = false; v[b] = false;}
    }
    int ans = 0;
    REP(i, n) if (v[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3728
// AOJ 2583: JAG-channel
// 2017.10.6 bal4u@uu
// 2017.11.24

#include <stdio.h>
#include <stdlib.h>

char s[1002][2000];

int main()
{
	int n, i, j, k;
	char buf[10], *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		for (i = 0; i < n; i++) {
			fgets(p=s[i], 2000, stdin);
			while (*p == '.') *p++ = ' ';
			if (--p >= s[i]) {
				*p = '+', k = p - s[i];
				for (j = i-1; s[j][k] == ' '; j--) s[j][k] = '|';
			}
		}
		for (i = 0; i < n; i++) printf(s[i]);
	}
    return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll x,y;
	cin>>x>>y;
	string ans="No";
for(int i=0;i<=x;i++)
  {
  	if(((i*2)+(x-i)*4)==y)
  	   {
  	   	ans="Yes";
		 }
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3552
N = int(input())
s = [input() for i in range(N)]

cnt = 0
ab_cnt = 0
b_cnt = 0
a_cnt = 0
for word in s:
    cnt += word.count('AB')
    l = word[0]
    r = word[-1]
    if l == 'B' and r == 'A':
        ab_cnt += 1
    elif l == 'B':
        b_cnt += 1
    elif r == 'A':
        a_cnt += 1

if ab_cnt == 0:
    ans = min(b_cnt, a_cnt)
elif a_cnt + b_cnt > 0:
    ans = ab_cnt + min(b_cnt, a_cnt)
else:
    ans = ab_cnt - 1

print(cnt + ans)

Measured memory_bytes: 3700
#include<stdio.h>
int main(void)
{
	int n,a;
	scanf("%d",&n);
	a=n*800;
	while(1){
		if(n>=15){
			a=a-200;
			n=n-15;
		}
		if(n<15)break;
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
from scipy.sparse import*
m=csr_matrix
n,*t=map(int,open(0).read().split())
s=[n+1]*2
r,c,d=t[1::3],t[2::3],[-c for c in t[3::3]]
u=set(csgraph.depth_first_order(m((d,(c,r)),s),n,1,0))
r,c,d=zip(*[(r,c,d)for r,c,d in zip(r,c,d)if r in u and c in u])
try:print(-int(csgraph.bellman_ford(m((d,(r,c)),s),1,[1])[0,n]))
except:print('inf')

Measured memory_bytes: 14364
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	/*int n,m;
	string s[111],t[111];
	
	int co=0,ans=-666;
	cin>>n;
	for(int i=0;i<n;i++)cin>>s[i];
	cin>>m;
	for(int i=0;i<m;i++)cin>>t[i];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)if(s[i]==s[j])co++;
		for(int j=0;j<m;j++)if(s[i]==t[j])co--;
		ans=max(ans,co);
		co=0;
	}
	if(ans<0)ans=0;
	cout<<ans<<endl;*/
	
	
			
	
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <queue>
#include <cstdio>
using namespace std;

int main() {
    int A;
    int B;
    cin >> A >> B;
    int count = 1;
    int times =0;
    while(count< B){
        count += A-1;

        times++;
    }

    
    cout << times << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;

    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    sort(d.begin(), d.end());
    auto new_end = unique(d.begin(), d.end());
    cout << distance(d.begin(), new_end) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long ord(long long n, long long p) {
	if (n%p != 0) {
		return 0;
	}
	else {
		return 1 + ord(n / p, p);
	}
}
long long rui(long long p, long long x) {
	if (x == 0) {
		return 1;
	}
	else {
		return p * rui(p, x - 1);
	}
}
int main() {
	long long n, pr;
	cin >> n >> pr;
	vector<long long> fr(40, 0);
	vector<long long> pri(40, 1);
	long long th = 0;
	long long i = 2;
	while (pr != 1 and i <= 1000 * 1000) {
		long long x = ord(pr, i);
		if (x >= 1) {
			fr[th] = x;
			pri[th] = i;
			th++;
			pr = pr / rui(i, x);
		}
		i++;
	}
	if (pr != 1) {
		fr[th] = 1;
		pri[th] = pr;
		th++;
	}
	long long ans = 1;
	for (int i = 0; i < 40; i++) {
		ans *= rui(pri[i], fr[i] / n);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
S = input()
for i,(a,b) in enumerate(zip(S,S[1:])):
    if a==b:
        print(i+1, i+2)
        exit()
for i,(a,b) in enumerate(zip(S,S[2:])):
    if a==b:
        print(i+1, i+3)
        exit()

print(-1, -1)

Measured memory_bytes: 3188
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

a,b,c,d = map(int,input().split())

def count(n,c,d):
    cn = n//c
    dn = n//d
    lcm = c*d//(gcd_core(c,d))
    both = n // lcm
    if lcm == c:
        # print("1")
        # print(cn, dn, both)
        return dn
    elif lcm == d:
        # print("2")
        # print(cn, dn, both)
        return cn
    else:
        # print("3")
        # print(cn,dn,both)
        return cn+dn-both

l = a-1-count(a-1,c,d)
r = b-count(b,c,d)
# print(l)
# print(r)

print(r-l)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll tempura = 1LL<<60 ;

int main(){
    int homu, homuhomu, homuhomuhomu;
    cin >> homu >> homuhomu >> homuhomuhomu;
    vector<ll> Homu(homu), Homuhomu(homuhomu);
    for(auto &pura : Homu){
        cin >> pura;
    }
    for(auto &pura : Homuhomu){
        cin >> pura;
    }
    Homu.push_back(-tempura);
    Homu.push_back(tempura);
    Homuhomu.push_back(-tempura);
    Homuhomu.push_back(tempura);
    sort(Homu.begin(), Homu.end());
    sort(Homuhomu.begin(), Homuhomu.end());

    while(homuhomuhomu--){
        ll pura;
        cin >> pura;
        auto homura = lower_bound(Homu.begin(), Homu.end(), pura);
        ll ho = *homura, mu = *prev(homura);
        homura = lower_bound(Homuhomu.begin(), Homuhomu.end(), pura);
        ll Ho = *homura, Mu = *prev(homura);
        ll HOMU = min(max(ho, Ho) - pura, pura - min(mu, Mu));
        HOMU = min(HOMU, Ho - mu + min(Ho - pura, pura - mu));
        HOMU = min(HOMU, ho - Mu + min(ho - pura, pura - Mu));
        cout<<HOMU<<endl;
    }
    return 0;

}


Measured memory_bytes: 2912
import java.io.*;
import java.util.*;

public class Main {
    FastScanner in;
    PrintWriter out;

    void solve() {
        int x = in.nextInt();
        Set<Integer> used = new HashSet<>();
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            used.add(in.nextInt());
        }
        for (int diff = 0; ; diff++) {
            for (int sign = -1; sign <= 1; sign += 2) {
                int check = x + diff * sign;
                if (!used.contains(check)) {
                    out.println(check);
                    return;
                }
            }
        }
    }


    final int mod = 988244353;

    int mul(int x, int y) {
        return (int) ((x * 1L * y) % mod);
    }

    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }

    void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();
        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}

Measured memory_bytes: 32836
N = int(input())
XY = []
for i in range(N):
  XY.append(list(map(int,input().split())))

ans = N
for i in range(N):
  for j in range(N):
    if i != j:
      p = XY[i][0] - XY[j][0]
      q = XY[i][1] - XY[j][1]
      tmp = 0
      for k in range(N):
        for l in range(N):
          if k != l and p == XY[k][0] - XY[l][0] and q == XY[k][1] - XY[l][1]:
            tmp +=1
      ans = min(ans, N-tmp)
print(ans)            

Measured memory_bytes: 42604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(0,c - a + b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  int A, B, ans=0;
  cin >> A >> B;
  if((A<10) && (B<10)){
    ans = A * B;
  }  
  else{
    ans = -1;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

void rotation_N(int* dise){
   int tmp[6];

   tmp[0] = dise[1];
   tmp[1] = dise[5];
   tmp[2] = dise[2];
   tmp[3] = dise[3];
   tmp[4] = dise[0];
   tmp[5] = dise[4];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}
void rotation_E(int* dise){
   int tmp[6];

   tmp[0] = dise[3];
   tmp[1] = dise[1];
   tmp[2] = dise[0];
   tmp[3] = dise[5];
   tmp[4] = dise[4];
   tmp[5] = dise[2];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}
void rotation_S(int* dise){
   int tmp[6];

   tmp[0] = dise[4];
   tmp[1] = dise[0];
   tmp[2] = dise[2];
   tmp[3] = dise[3];
   tmp[4] = dise[5];
   tmp[5] = dise[1];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}
void rotation_W(int* dise){
   int tmp[6];

   tmp[0] = dise[2];
   tmp[1] = dise[1];
   tmp[2] = dise[5];
   tmp[3] = dise[0];
   tmp[4] = dise[4];
   tmp[5] = dise[3];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}

int main(){

   int dise[6];
   string cmd;

   for(int i = 0; i < 6; i++){
      cin >> dise[i];
   }

   cin >> cmd;

   for(int i = 0; i < cmd.length(); i++){
      if(cmd[i] == 'N'){
         rotation_N(dise);
      }
      else if(cmd[i] == 'E'){
         rotation_E(dise);
      }
      else if(cmd[i] == 'S'){
         rotation_S(dise);
      }
      else{
         rotation_W(dise);
      }
   }

   cout << dise[0] << endl;

   return 0;
}


Measured memory_bytes: 3204
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  N = readline() |> parseInt
  A,B = zeros(Int, N),zeros(Int,N)
  for i in 1:N
    A[i],B[i]=readline() |> split |> parseArray
  end

  ans="Yes"
  ix=sortperm(B)
  A,B=A[ix],B[ix]
  t=0
  for i in 1:N
    if B[i]-t<A[i]
      ans="No"
      break
    end
    t+=A[i]
  end
  println(ans)
end

main()


Measured memory_bytes: 155368
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
b = 0
for i in range(0,n+1):
	b += int(abs(a[i+1]-a[i]))
for i in range(1,n+1):
	ans = b
	ans -= abs(a[i]-a[i-1])
	ans -= abs(a[i+1]-a[i])
	ans += abs(a[i+1]-a[i-1])
	print(ans)


Measured memory_bytes: 14176
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

int main()
{
  int x, y, a, b;
  cin >> x >> y;

  if (x < y)
    a = y, b = x;
  else
    a = x, b = y;

  while (a % b != 0)
  {
    int tmp_a = a;
    a = b, b = tmp_a % b;
  }

  cout << b << endl;
  return 0;
}

Measured memory_bytes: 3104
#include <stdio.h>

int main(void)
{

    int x;
    int y = 1;

    do {
    scanf("%d", &x);
    if (x != 0) {
        printf("Case %d: %d\n", y,  x);
        y++;
    }
    } while (x != 0);

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

struct Pair {
	int a, b;
	Pair(int a, int b) {
		this->a = a;
		this->b = b;
	}
	bool operator< (const Pair &p) const {
		return a - b < p.a - p.b;
	}
};

signed main() {
	int N;
	cin >> N;

	vector<Pair> prs;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		prs.push_back(Pair(a, b));
	}
	sort(all(prs));

	int pt = -1;
	rep(i, N) {
		if (pt == -1 && prs[i].a >= prs[i].b) pt = i;
	}

	if (pt == 0) {
		cout << 0 << endl;
		return 0;
	}

	int ret = 0;
	int minval = INT_MAX;
	rep(i, N) {
		ret += prs[i].a;
		if (prs[i].a > prs[i].b) {
			minval = min(minval, prs[i].b);
		}
	}
	ret -= minval;

	cout << ret << endl;

    return 0;
}


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

using namespace std;
#define ll long long


int main() 
{
    int n;
    cin>>n;
    ll sum=0;

    for(int i=1;i<=n;i++)
    {
        if(i%5==0 || i%3==0)
        {
            sum=sum+0;
        }
        else
        {
            sum=sum+i;
        }
    }
    cout<<sum<<endl;
    
}


Measured memory_bytes: 3604
import heapq
n,m=map(int,input().split())
c=[[] for _ in range(m+1)]
for i in range(n):
    a,b=map(int,input().split())
    if a<=m:
        c[a].append(-b)

ans=0
q=[]
for i in range(1,m+1):
    for v in c[i]:
        heapq.heappush(q,v)
    if q:
        ans-=heapq.heappop(q)

print(ans)
    

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
//#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  A.begin(), A.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))


#define forr(i,n) for(i=0; i<n; i++)
#define whilee(i,t) while(i!=t)
#define pb(x) push_back(x);

//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//accumulate(A.begin(), A.end(), 0);
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //vector <int> A;
    //deque <int> A;
    //queue <int> A;
    //stack <int> A;
    //set <int> A;
    //map <int,int> A;
    //pair <int,int> A ;
    //vector <pair <int,int>> A ;
    //string S, T;
    int i, j, k, a, b, c,d, l, m, n, p, q, r, s, t, x, y, z, cnt=0;
    cin>>a>>b>>c>>d;
    if(a<c)
    {
        if(b<d)
        {
            if((b-c)>0)
            {
                cout<<b-c<<endl;
            }
            else
            {
                cout<<0<<endl;
            }
        }
        else
        {
            if((d-c)>0)
            {
                cout<<d-c<<endl;
            }
            else
            {
                cout<<0<<endl;
            }
        }
    }
    else
    {
        if(b<d)
        {
            if((b-a)>0)
            {
                cout<<b-a<<endl;
            }
            else
            {
                cout<<0<<endl;
            }

        }
        else
        {
            if((d-a)>0)
            {
                cout<<d-a<<endl;
            }
            else
            {
                cout<<0<<endl;
            }

        }
    }
    return 0;
}



Measured memory_bytes: 256
max_1 = 0
max_2 = 0
max_3 = 0

10.times do
  x = gets.chomp.to_i
  if x > max_3
    max_3 = x
    if max_3 > max_2
      max_2,max_3 = max_3,max_2
      if max_2 > max_1
        max_1,max_2 = max_2,max_1
      end
    end
  end
end

puts max_1
puts max_2
puts max_3

Measured memory_bytes: 8524
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000007
 int h,w;
 char ar[105][105];
 int dp[105][105];
 int help(int r,int c)
 {
     if(r==h-1&&c==w-1){

        return 0;
     }
     if(r==h||c==w)
        return INT_MAX;
        if(dp[r][c]!=-1)
            return dp[r][c];
     int op1 = help(r+1,c);
     if(ar[r][c]=='.'&&ar[r+1][c]=='#')
        op1 += 1;
     int op2 = help(r,c+1);
     if(ar[r][c]=='.'&&ar[r][c+1]=='#')
        op2 += 1;
     dp[r][c] = min(op1,op2);
     return dp[r][c];
 }
signed main(){
    gok
    memset(dp,-1,sizeof(dp));
    cin>>h>>w;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
          cin>>ar[i][j];
          int an;
     if(ar[0][0]=='#')
    an = help(0,0) + 1;
    else
        an = help(0,0);
        cout<<an;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define arr array
#define _min(a) *min_element(a.begin(), a.end());
#define _max(a) *max_element(a.begin(), a.end());
#define _sort(x) sort(x.begin(), x.end())
#define _rsort(x) sort(x.rbegin(), x.rend())
#define _reverse(x) reverse(x.begin(), x.end())
#define _debug(x) cout << #x << " = " << x << endl;
#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;
#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()
#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()
typedef long long ll;
using namespace std;

void solve() {	
	int n, k; cin >> n >> k;
	vector<int> a(n), dp(n, 0); for (auto &u : a) cin >> u;
	for (int i = 1; i < n; ++i) {
		int t = i - k;
		dp[i] = INF;
		if (i - k < 0) t = 0;
		for (int j = t; j < i; ++j) {
			dp[i] = min(dp[i], abs(a[i] - a[j]) + dp[j]);
		}
	}
	cout << dp[n - 1] << endl;
}   

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

    // int t; cin >> t;
    // while(t--) 
        solve();
}

Measured memory_bytes: 3948
import java.util.Scanner;

public class Main {
	Scanner scanner = new Scanner(System.in);

	int a = scanner.nextInt();
	int b = scanner.nextInt();
	public static void main(String[] args){
		Main aa = new Main();
		System.out.println(aa.num(aa.a,aa.b));
	}
	String num(int a, int b){
		if((double)a*b/2-Math.floor((double)a*b/2) == 0){
			return "No";
		}else{
			return "Yes";
		}
	}
}

Measured memory_bytes: 21716
#include <cstdio>

template <class T>
T abs(T a) { return (a < 0 ? -a : a); }

int main() {
    long long n, m, mod = 1000000007;
    scanf("%lld%lld", &n, &m);
    if (abs(n - m) <= 1) {
        auto ret = 1ll;
        for (auto i = 2ll; i <= n; i++) ret = (ret * i) % mod;
        for (auto i = 2ll; i <= m; i++) ret = (ret * i) % mod;
        if (n == m) ret = (ret * 2) % mod;
        printf("%lld\n", ret);
    } else {
        printf("0\n");
    }

    return 0;
}

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

int main(int argc, const char * argv[]) {
    int a,b;
    char op;
    do{
        cin >> a >> op >> b;
        switch( op ){
            case '+':
                cout << a + b << endl;
                break;
                
            case '-':
                cout << a - b << endl;
                break;
                
            case '*':
                cout << a * b << endl;
                break;
                
            case '/':
                cout << a / b << endl;
                break;
                
            default:
                break;
        }
    }while(op != '?');
    return 0;
}



Measured memory_bytes: 3096
import java.util.ArrayList;
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ");
		int dotCount = Integer.parseInt(line[0]);
		int dimCount = Integer.parseInt(line[1]);
		
		ArrayList<String[]> list = new ArrayList();
		for(int i = 0;i<dotCount;i++) {
			list.add(sc.nextLine().split(" "));
		}
		
		int result = 0;
		for(int i = 0;i<dotCount;i++) {
			for(int j = i+1;j<dotCount;j++) {
				
				double distatnFrom1to2 = 0d;
				String[] strArray1 = list.get(i);
				String[] strArray2 = list.get(j);
				for(int x = 0;x<dimCount;x++) {
					int tmp = Math.abs(Integer.parseInt(strArray1[x]) 
							- Integer.parseInt(strArray2[x]));
					distatnFrom1to2 += tmp*tmp;
				}
				
				double checkDouble = Math.sqrt(distatnFrom1to2);
				if(checkDouble == (int)checkDouble) {
					result++;
				}
				
				
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n;
  cin >> n;
  
  int res=0;
  int b=0,a=0,ab=0;
  string s;
  for(int i=0;i<n;i++){
 cin >> s;
  for(int j=0;j<s.length()-1;j++){
   if(s.substr(j,2)=="AB"){
     res++;
   }
  } 
   if(s[0]=='B'&&s[s.length()-1]=='A'){
    ab++;
   }
   else if(s[0]=='B'&&s[s.length()-1]!='A'){
    b++;
   }
   else if(s[0]!='B'&&s[s.length()-1]=='A'){
    a++;
   }
  }  
 
   res+=min(a,b);
   if(a==0&&b==0&&ab!=0){
   ab--;
   }
   res+=ab;
  
 cout << res <<endl;

}


Measured memory_bytes: 888
a=str(input())
if a=='SUN':
    print(7)
elif a=='MON':
    print(6)
elif a=='TUE':
    print(5)
elif a=='WED':
    print(4)
elif a=='THU':
    print(3)
elif a=='FRI':
    print(2)
elif a=='SAT':
    print(1)

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

double distance(double px,double py,double qx,double qy){
    return sqrt(pow(py-qy,2)+pow(px-qx,2));
}

int main(){
    int n;
    
    struct data1{
        double x,y,r;
    } circle1;
    
    struct data2{
        double x,y,r;
    } circle2;
    
    cin >> n;
    while(n--){
        cin >> circle1.x >> circle1.y >> circle1.r;
        cin >> circle2.x >> circle2.y >> circle2.r;
        
        double d = distance(circle1.x,circle1.y,circle2.x,circle2.y);
        
        if(circle1.r + circle2.r < d) cout << "0" << endl;
        else if(circle2.r + d < circle1.r) cout << "2" << endl;
        else if(circle1.r + d < circle2.r) cout << "-2" << endl;
        else cout << "1" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1224
N,M=map(int,input().split())
li=[0]*N
for i in range(M):
    si,ci=map(int,input().split())
    if li[si-1] != 0 and li[si-1] !=ci:
        print(-1)
        exit(0)
    if si==1 and ci==0:
        if N>1:
            print(-1)
            exit(0)
    li[si-1]=ci
if N>1 and li[0]==0:
    li[0]=1
for i in range(N):
    print(li[i],end="")


Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    _ <- getLine
    -- スペース区切り整数の入力
    l <- map strToInt . words <$> getLine
    let xs = filter ((>= 2) . length) $ group $ sort l
    -- 出力
    putStrLn . show . solve $ reverse xs

solve :: [[Int]] -> Int
solve xs
    | (length xs) >= 2 = if (length $ head xs) >= 4 then foldl1 (*) (take 2 $ head xs) else foldl1 (*) (map head $ take 2 xs)
    | (length xs) == 1 = if (length $ head xs) >= 4 then foldl1 (*) (take 2 $ head xs) else 0
    | otherwise = 0


Measured memory_bytes: 51580