akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;

		boolean[][] table = new boolean[21][21];
		for (int i=0; i<n; i++) {
			int x = in.nextInt();
			int y = in.nextInt();
			table[y][x] = true;
		}

		int m = in.nextInt();
		int cy = 10, cx = 10, cnt = 0;
		while (m-- > 0) {
			char d = in.next().charAt(0);
			int s = in.nextInt();

			switch (d) {
				case 'N':
					while (s-- > 0) {
						cy++;
						if (table[cy][cx]) {
							table[cy][cx] = false;
							cnt++;
						}
					}
					break;
				case 'E':
					while (s-- > 0) {
						cx++;
						if (table[cy][cx]) {
							table[cy][cx] = false;
							cnt++;
						}
					}
					break;
				case 'S':
					while (s-- > 0) {
						cy--;
						if (table[cy][cx]) {
							table[cy][cx] = false;
							cnt++;
						}
					}
					break;
				case 'W':
					while (s-- > 0) {
						cx--;
						if (table[cy][cx]) {
							table[cy][cx] = false;
							cnt++;
						}
					}
					break;
			}
		}

		out.println(cnt == n ? "Yes" : "No");

		return true;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		while(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 41164
n,m = map(int,input().split())
graph = {i:[] for i in range(1,n+1)}

for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
if len(set(graph[1]).intersection(set(graph[n]))) > 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

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

int main()
{
	char clsnam[11][20] = { "light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy" } ;

	double CLASS[10] = { 48.00, 51.00, 54.00, 57.00, 60.00, 64.00, 69.00, 75.00, 81.00, 91.00 } ;
	double get ;

	while( cin >> get )
	{
		for( int i = 9 ; i >= 0 ; i -- )
		{
			if( get <= CLASS[i] )
			{
				if( i == 0 ){ cout << clsnam[0] << endl ; }
			}
			else
			{
				cout << clsnam[i+1] << endl ;
				break ;
			}
		}
	}

	return 0 ;
}

Measured memory_bytes: 1220
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 1000010;
const int MAXM = 30010;
const int MAXK = 16;
const int MAXQ = 200010;

string s[8] = {"", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string x;
    cin >> x;
    FOR(i,1,7)
        if (x == s[i]) {
            cout << i;
            return 0;
        }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    vector<vector<LL>> dp(n+2, vector<LL>(3, -1e+15));
    dp[0][0] = 0;
    dp[1][1] = 0;
    for(LL i = 0; i < n; ++i){
        for(LL j = 0; j < 3; ++j){
            // use a[i]
            dp[i+2][j] = max(dp[i+2][j], dp[i][j] + a[i]); 
            // not use a[i]
            if(j+1 < 3){
                dp[i+2][j+1] = max(dp[i+2][j+1], dp[i+1][j]);                  
            }
        }
    }
    LL ans = 0;
    if(n % 2 == 0){
        ans = dp[n+1][1];
    }else{
        ans = dp[n+1][2];
    }
    //cerr << dp << endl;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 15292
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n,k;
  cin >> n >> k;
  Vi tr(n);
  rep(i,0,n) cin >> tr[i];
  sort(ALL(tr));
  
  Vi d(n-k+1);
  rep(i,0,n-k+1){
    d[i] = -tr[i] + tr[i+k-1];
  }
  
  cout << *min_element(ALL(d)) << endl;
  
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using i64 = long long;

template <class T = long long int>
class Bit {
    private:
    unsigned len;
    T init;
    std::vector<int> arr;

    public:
    Bit(unsigned length, T initialValue = 0): len(length), init(initialValue), arr(len + 1, init) {}
    void update(unsigned a, T newval) {
        for (unsigned x = a; x <= len; x += x & -x) arr[x] += newval;
    }
    T query(unsigned a) const {
        T ret = init;
        for (unsigned x = a; x > 0; x -= x & -x) ret += arr[x];
        return ret;
    }
};

int main() {
    constexpr int inf = std::numeric_limits<int>::max();
    int n;
    std::cin >> n;
    std::vector<int> a(n), b(n);
    for (auto &e : a) std::cin >> e;
    for (auto &e : b) std::cin >> e;

    int ret = inf;
    for (int bit = 0; bit < (1 << n); bit++) {
        std::map<int, std::vector<std::pair<int, int>>> v;
        for (int i = 0; i < n; i++) {
            int f = (bit & (1 << i)) > 0;
            // f == 1 -> reversed, odd
            // f == 0 -> otherwise
            v[f ? b[i] : a[i]].emplace_back(i, f);
        }

        int pos = 0, s = 0;
        bool flg = true;
        std::vector<int> perm;
        for (auto &e : v) {
            auto &q = e.second;
            int cnt = q.size();
            std::set<int> odd, even;
            for (int i = 0; i < cnt; i++) {
                if ((q[i].first % 2) ^ q[i].second) odd.insert(q[i].first);
                else even.insert(q[i].first);
            }

            for (int i = 0; i < cnt; i++) {
                if (pos % 2) {
                    if (odd.empty()) {
                        flg = false;
                        break;
                    }
                    auto j = odd.begin();
                    s += abs(pos - *j);
                    perm.push_back(*j);
                    odd.erase(j);
                } else {
                    if (even.empty()) {
                        flg = false;
                        break;
                    }
                    auto j = even.begin();
                    s += abs(pos - *j);
                    perm.push_back(*j);
                    even.erase(j);
                }
                pos++;
            }
        }

        Bit<> bb(60);
        s = 0;
        for (int i = 0; i < perm.size(); i++) {

            s += i - bb.query(perm[i] + 1);
            bb.update(perm[i] + 1, 1);
        }

        if (flg) ret = std::min(ret, s);
    }

    std::cout << (ret == inf ? -1 : ret) << std::endl;

    return 0;
}


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

#ifdef LOCAL
#define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define dbg(...) 17;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) { return os << "(" << p.first << ", " << p.second << ")"; }
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) { bool f = true; os << "{"; for (const auto &x : c) { if (!f) os << ", "; f = false; os << x; } return os << "}"; }
template<typename T> void debug(string s, T x) { cerr << s << " = " << x << "\n"; }
template<typename T, typename... Args> void debug(string s, T x, Args... args) { cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...); }

int main() {
    const ll INF = 1e16;
    int n; cin >> n;
    vector<ll> a(n + 1);
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
    }
    auto fail = [&]() {
        cout << -1 << '\n';
        exit(0);
    };
    vector<ll> post(n + 1);
    for (int i = n; i >= 0; i--) {
        if (i == n) post[i] = a[i];
        else post[i] = post[i + 1] + a[i];
    }
    ll ans = 0;
    ll level = 1;
    for (int i = 0; i <= n; i++) {
        ans += min(level, post[i]);
        level -= a[i];
        if (level < 0) {
            fail();
        }
        level *= 2;
        level = min(level, INF);
    }
    cout << ans << '\n';
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
vector<T> GetListOfDivisor(T N){
    vector<T> res;
    vector<T> res2;
    for(long long i=1; i*i<=N; i++){
        if(N%i!=0) continue;
        res.push_back(i);
        res2.push_back(N/i);
    }
    reverse(res2.begin(), res2.end());
    if(res.back() == res2.front()) res.pop_back();
    res.insert(res.end(), res2.begin(), res2.end());
    return res;
}

int main()
{
    ll N, M;
    cin >> N >> M;

    auto divisors = GetListOfDivisor(M);
    auto res = M / *lower_bound(divisors.begin(), divisors.end(), N);
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()

signed main() {
  int n,k; cin >> n >>k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  auto ok = [&](int x) {
    int kk = k;
    rep(i,n) kk -= (a[i] + x-1) / x - 1;
    return kk >= 0;
  };

  int l = 0, r = *max_element(ALL(a));
  while(r-l>1) {
    int m = l + (r-l) / 2;
    if(ok(m)) r = m;
    else l = m;
  }
  cout << r << endl;
}


Measured memory_bytes: 4012
#include<iostream>
using namespace std;
int uppernum(int x){
  if(x%10==0) return x;
  else{
    int r; r=x%10;
    return x-r+10;
  }
}

int main() {
  int sum=0,ans=999;
  int a[5];
  for(int i=0;i<5;i++){
    cin >> a[i];
    sum += uppernum(a[i]);
  }
  for(int i=0;i<5;i++){
    int ssum = sum-uppernum(a[i])+a[i];
    if(ssum<=ans) ans = ssum;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;

int a[N];
ll sum[N];

int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	sum[0] = 0;
	for(int i = 1;i <= n;++i) scanf("%d",&a[i]),sum[i] = sum[i-1]+a[i];
    
	double ans = 0;
	for(int i = 1;i+k-1 <= n;++i){
		double t = (double)(sum[i+k-1]-sum[i-1]+k)/2.0;
		ans = max(ans,t);
	}
	printf("%.12lf\n",ans);
	return 0;
}

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

int main() {
  int N,a=0;
  string S;
  cin >>N >>S;
  vector<int> b(N+1);
  for (int i=0;i<N;i++){
  if (S.at(i)=='I'){
  a++;
  }
  else if (S.at(i)=='D'){
  a--;
  }
  b.at(i)=a;
  }
  b.at(N)=0;
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  cout << b.at(0) << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define in(x) freopen(x,"r",stdin)
#define out(x) freopen(x,"w",stdout)
#define N 100500
#define oo ll(1e16)
#define P pair<ll,ll>
#define F first
#define S second
#define pb push_back
#define el '\n'
#define elf endl
#define base ll(1e9+7)
#define MM 4294967296
#define re return
#define nins 4294967295
using namespace std;
typedef long long ll;
void ok() {cout<<"Yes";}
void no() {cout<<"No";}
void oke() {cout<<"Yes"; exit(0);}
void noe() {cout<<"No"; exit(0);}
string s;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin>>s;
    for(int i=0;i<sz(s);i+=2)
        if(s[i]=='L') noe();
    for(int i=1;i<sz(s);i+=2)
        if(s[i]=='R') noe();
    oke();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char*) { cerr << endl; }
template <class T, class... U> void my_dmp(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; my_dmp(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type>
ostream& operator<<(ostream& os, T const& v) { os << "{"; for (auto const& x : v) os << " " << x; return os << " }"; }
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct my_Init { my_Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } my_init;

template <class T, size_t d, class = typename enable_if<(d == 0)>::type> constexpr auto make_v(T const& x = {}) { return x; }
template <class T, size_t d, class... U, class = typename enable_if<(d > 0)>::type> constexpr auto make_v(size_t n, U... x) { auto val = make_v<T,d-1>(x...); return vector<decltype(val)>(n, move(val)); }
template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> constexpr bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> constexpr bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> constexpr auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
const ll INF = (1LL<<62)-1; // ~ 4.6e18
////////////////////////////////

int32_t main() {
    int n; cin >> n;
    vector<int> v(110);
    rep1 (i,9) rep1 (j,9) v[i*j] = 1;
    cout << (v[n] ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
const int MAX_N = 100005;
int n, m;
char s[MAX_N];
VI v;
void input() {
    RI(n, m);
    scanf("%s", s);
}

int main( int argc, char *argv[] ) {
    input();    
    REP(i, n+1) if(s[i]=='0') v.PB(i);
    VI path;
    int i = n;
    path.PB(i);
    while(i > 0) {
        int x = *lower_bound(v.begin(), v.end(), i-m);
        if(x == i) {
            printf("-1\n");
            return 0;
        }
        path.PB(x);
        i = x;
    }
    reverse(ALL(path));

    // cout << path << endl;
    for(int i=0; i<(int)path.size()-1; i++) {
        if(i>0) printf(" ");
        printf("%d", path[i+1]-path[i]);
    } printf("\n");
    return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s;
  cin >> s;

  int cnt = 0;
  rep(i, s.length()-1){
    if(s[i] != s[i+1]){
      cnt++;
    }
  }

  cout << cnt << endl;



  return 0;
}


Measured memory_bytes: 512
#coding:utf-8

n,m = map(int, input().split())
itv = []
for i in range(m):
    si,ti = map(int, input().split())
    itv.append([ti, si])
itv.sort()

ans = 0
t = 0
for i in range(m):
    if itv[i][1] >= t:
        ans += 1
        t = itv[i][0]

print(ans)

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

int main() {
  int dp[100010];
  int N;
  cin >> N;
  for(int n = 1;n <= 100000;n++){
    dp[n] = 100000;
    int p6 = 1,p9 = 1;
    while(n >= p6){
      dp[n] = min(dp[n],dp[n-p6]+1);
      p6 *= 6;
    }
    while(n >= p9){
      dp[n] = min(dp[n],dp[n-p9]+1);
      p9 *= 9;
    }
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 640
while True:
    n, x = (int(i) for i in input().split())

    if n == 0 and x == 0:
        break
    
    nums = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    nums += 1
    print(nums)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1e9+1;

/*
奇数数列および偶数数列をソートして、最大個数要素および次に多い要素のペアを確保する
*/

void solve(){
    int n;
    cin >> n;
    vector<int> v1, v2;
    bool odd = true;
    rep(i,n){
        int tmp;
        cin >> tmp;
        if(odd) {
            v1.emplace_back(tmp);
            odd = false;
        }
        else{
            v2.emplace_back(tmp);
            odd = true;
        }
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    int pointer=0;
    int p2 = 0;
    int s = v1.size();
    vector<pair<int,int>> a1,a2;
    a1.emplace_back(make_pair(1,v1[0]));
    while(pointer<s-1){
        if(v1[pointer]!=v1[pointer+1]){
            a1.emplace_back(make_pair(1, v1[pointer+1]));
            p2++;
        }
        else{
            a1[p2].first++;
        }
        pointer++;
    }
    pointer = 0;
    p2 = 0;
    a2.emplace_back(make_pair(1,v2[0]));
    while(pointer<s-1){
        if(v2[pointer]!=v2[pointer+1]){
            a2.emplace_back(make_pair(1, v2[pointer+1]));
            p2++;
        }
        else{
            a2[p2].first++;
        }
        pointer++;
    }
    //cout << a1[0].first << " " << a1[0].second << endl;
    //cout << a2[0].first << " " << a2[0].second << endl;

    sort(a1.rbegin(), a1.rend());
    sort(a2.rbegin(), a2.rend());
    //cout << a1[0].first << " " << a1[0].second << endl;
    //cout << a2[0].first << " " << a2[0].second << endl;

    if(a1.size()!=1 && a2.size()!=1){
        if(a1[0].second!=a2[0].second){
            cout << n-(a1[0].first+a2[0].first) << endl;
        }
        else{
            cout << n - max(a1[0].first+a2[1].first, a1[1].first+a2[0].first) << endl;
        }
    }
    else{
        if(a1.size()!=1){
            if(a1[0].second!=a2[0].second){
                cout << n-(a1[0].first+a2[0].first) << endl;
            }
            else{
                cout << n - a1[1].first+a2[0].first << endl;
            }
        }
        else if(a2.size()!=1){
            if(a1[0].second!=a2[0].second){
                cout << n-(a1[0].first+a2[0].first) << endl;
            }
            else{
                cout << n - a1[0].first+a2[1].first << endl;
            }
        }
        else{
            if(a1[0].second!=a2[0].second){
                cout << n-(a1[0].first+a2[0].first) << endl;
            }
            else{
                cout << n/2 << endl;
            }
        }
    }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

using namespace std;

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int main() {
  int n, m;
  fscanf(stdin, "%d%d ", &n, &m);
  vector<pair<int,int>> v;
  REP(i,m) {
    int a, b;
    fscanf(stdin, "%d%d ", &a, &b);
    v.pb(mp(b,a));
  }
  sort(all(v));
  int res = 0, s, e;
  tie(e,s) = v[0];
  FOR(i,1,v.size()) {
    int l, u;
    tie(u,l) = v[i];
    s = max(l,s); e = min(u,e);
    if (s >= e) {
      res++;
      s = l; e = u;
    }
  }
  if (s < e) res++;
  fprintf(stdout, "%d\n", res);
  return 0;
}


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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const MOD: i64 = 1000000007;

fn main(){
    input!{
        N: i32,
    }

    let mut f: Vec<i64> = Vec::new();

    for i in 0..N+1 {
        f.push(0);
    }

    for i in 1..N+1 {
        let mut t: i32 = i;
        let mut j: i32 = 2;
        while j * j <= t {
            while t % j == 0 {
                f[j as usize] += 1;
                t /= j;
            }
            j += 1;
        }
        if t > 1 {
            f[t as usize] += 1;
        }
    }

    let mut ans: i64 = 1;
    for x in f.iter() {
        ans = ans * (x + 1) % MOD;
    }

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

Measured memory_bytes: 2156
import math
n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]
point = []
r = 0
for i in range(n-1):
    x1,y1=xy[i]
    for j in range(i+1,n):
        x2,y2=xy[j]
        d = ((x1-x2)/2)**2+((y1-y2)/2)**2
        if r**2 > d:
            if y1-y2 != 0:
                a = -(x1-x2)/(y1-y2)
                x = math.sqrt((r**2-d)/(a**2+1))//10**(-6)*10**(-6)
                point.append([(x1+x2)/2+x,(y1+y2)/2+a*x])
                point.append([(x1+x2)/2-x,(y1+y2)/2-a*x])
            else:
                x = math.sqrt(r**2-d)//1//10**(-6)*10**(-6)
                point.append([(x1+x2)/2,(y1+y2)/2+x])
                point.append([(x1+x2)/2,(y1+y2)/2-x])
        elif r**2 == d:
            point.append([(x1+x2)/2,(y1+y2)/2])

r_o = 800
r_i = 0
while r_o-r_i > 10**(-8):
    judge = 0
    while point:
        x,y = point.pop()
        c = 0
        for i,j in xy:
            if (x-i)**2+(y-j)**2 > r**2:
                c = 1
                break
        if c == 0:
            judge = 1
            break
            
    if judge == 1:
        r_o = r
    else:
        r_i = r
    r = (r_o+r_i)/2
    point = []
    for i in range(n-1):
        x1,y1=xy[i]
        for j in range(i+1,n):
            x2,y2=xy[j]
            d = ((x1-x2)/2)**2+((y1-y2)/2)**2
            if r**2 > d:
                if y1-y2 != 0:
                    a = -(x1-x2)/(y1-y2)
                    x = math.sqrt((r**2-d)/(a**2+1))//10**(-6)*10**(-6)
                    point.append([(x1+x2)/2+x,(y1+y2)/2+a*x])
                    point.append([(x1+x2)/2-x,(y1+y2)/2-a*x])
                else:
                    x = math.sqrt(r**2-d)//10**(-6)*10**(-6)
                    point.append([(x1+x2)/2,(y1+y2)/2+x])
                    point.append([(x1+x2)/2,(y1+y2)/2-x])
            elif r**2 == d:
                point.append([(x1+x2)/2,(y1+y2)/2])
    
print(r)

Measured memory_bytes: 3440
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map> // STL
#include <set>
#include <string> 
#include <vector>
#include <queue>
#include <stack>
#define mpr make_pair
#define debug() puts("okkkkkkkk")

using namespace std;

typedef long long LL;

const int inf = 1 << 26;

int n, mx = -inf;
int a[200005];

int check(int x) {
	int ans = 0;
	for ( int i = 0; i < n; i ++ ) {
		if(abs(a[i]-x) <= 1) ++ ans;
	}
	
	return ans;
}

set<int> S;

inline int read(){
	int x = 0, f = 1;
	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar())
		if(ch == '-') f = -f;

	for(; ch >= '0' && ch <= '9'; ch = getchar())
		x = x*10+ch-'0';

	return x*f;
}

int cal[200005];
map<int, int> mp, mp2;

int main(){
	n = read();
	for ( int i = 0; i < n; i ++ ){ a[i] = read();}
	
	int ans = -inf;
	sort(a, a+n);
	for ( int i = n-1; i >= 0; i -- ) mp[a[i]] = i;
	for ( int i = 0; i < n; i ++ ) mp2[a[i]] = i;
	for ( int i = 0; i < n; i ++ ) {
		int tmp = a[i];
		if(mp.count(tmp+2)) {
			ans = max(ans, mp2[tmp+2]-mp[tmp]+1);
		} else if(mp.count(tmp+1)) {
			ans = max(ans, mp2[tmp+1]-mp[tmp]+1);
		} else ans = max(ans, mp2[tmp]-mp[tmp]+1);
	}
	
	printf("%d\n", ans); 

	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const 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;
}

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 / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n;
cin>>n;
ll a;
ll max=-infll;
ll min=infll;
for(int i=0;i<n;i++){
    cin>>a;
    chmax(max,a);
    chmin(min,a);
}
cout<<max-min<<endl;
}












Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
// #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef int ll;
const ll MAXN = 5e5+5;
const ll MAX = 1e5+5;
inline ll max(ll a,ll b){return a>b?a:b;}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll powmod(ll a,ll b,ll mod){ll ret=1;while(b>0){if(b&1)ret=ret*a%mod;b>>=1;a=a*a%mod;}return ret;}
inline ll multi(ll a,ll b,ll mod){ll ret=0;while(b){if(b&1)ret=(ret+a)%mod;b>>=1;a<<=1;a%=mod;}return ret;}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll d=exgcd(b,a%b,x,y);ll tmp=x;x=y;y=tmp-a/b*x;return d;}
inline ll inverse(ll a,ll b){ll x,y;ll d=exgcd(a,b,x,y);if(d!=1)return -1;return (x%b+b)%b;}
int main(){
	ll k,sum=0;
	scanf("%d",&k);
	for(ll a=1;a<=k;++a){
		for(ll b=1;b<=k;++b){
			ll d=gcd(a,b);
			for(ll c=1;c<=k;++c){
				sum+=gcd(d,c);
			}
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

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

int main() {
	int n;
	cin >> n;
	while(n--) {
		ll money;
		cin >> money;
		int y, k;
		cin >> y >> k;
		ll maxi = 0;
		rep(i, k) {
			ll m = money;
			int z, mpy;
			double r;
			cin >> z >> r >> mpy;
			ll res = 0;
			if(z==0) {
				ll add = 0;
				rep(j, y) {
					add += r * m;
					m -= mpy;
				}
				res = add + m;
			} else {
				res = m;
				rep(j, y) {
					res += r * res - mpy;
				}
			}
			maxi = max(maxi, res);
		}
		cout << (ll)maxi << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (auto &&i : s) {
        i = (i - 'A'+n)%26+'A';
    }
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

// dp[i+1][j+1] := s[i], t[j] まで見たときの LCS(longest common subsequence) の長さ
int dp[3005][3005];
// 遷移前の状態を復元用に保持しておく。
vector<P> pre[3005][3005];

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

    string s, t;
    cin >> s >> t;
    int n1 = s.length();
    int n2 = t.length();
    for(int i = 0; i < n1; ++i){
        for(int j = 0; j < n2; ++j){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
                pre[i+1][j+1].push_back(P(i, j));
            }
            else{
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
                if(dp[i+1][j] > dp[i][j+1]){
                    pre[i+1][j+1].push_back(P(i+1, j));
                }
                else if(dp[i+1][j] < dp[i][j+1]){
                    pre[i+1][j+1].push_back(P(i, j+1));
                }
                else{
                    pre[i+1][j+1].push_back(P(i+1, j));
                    pre[i+1][j+1].push_back(P(i, j+1));
                }
            }
        }
    }
    for(int i = 0; i < n1; ++i){
        pre[i+1][0].push_back(P(i, 0));
    }
    for(int i = 0; i < n2; ++i){
        pre[0][i+1].push_back(P(0, i));
    }
    P now = P(n1, n2);
    string res;
    while(now != P(0, 0)){
        int x = now.first, y = now.second;
        now = pre[x][y][0];
        int nx = now.first, ny = now.second;
        if(x - nx == 1 && y - ny == 1){
            res += s[nx];
        }
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
}

Measured memory_bytes: 528640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;
ll arr[N];
int main()
{
    FIO
    ll x = 0;
    int n; cin>>n;
    for(int i = 0 ; i<n ; i++)
    {
        cin>>arr[i];
        x ^= arr[i];
    }
    for(int i = 0 ; i<n ; i++)
        cout<< (arr[i]^x) <<" ";
    return 0;

}

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

using namespace std;
typedef long long ll;

int n;
ll a[100];

inline void chkmin(ll &x, ll y) { x = x < y ? x : y; }

ll dfs(int l, int r, int x, int y) {
	if (l + 2 > r) return 0;
	ll res = LLONG_MAX;
	for (int i = l + 1; i < r; ++i)
		chkmin(res, dfs(l, i, x, x + y) + dfs(i, r, x + y, y) + a[i] * (x + y));
	return res;
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	cout << dfs(1, n, 1, 1) + a[1] + a[n] << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;

const int MAX_N = 1e2 +6;

int mp[MAX_N][MAX_N];
int cnt[MAX_N*MAX_N];

int main () {
	int n,m;
	scanf("%d %d",&n,&m);
	int tot;
	scanf("%d",&tot);
	for (int i=1;tot>=i;i++) {
		scanf("%d",&cnt[i]);
	}
	memset(mp,-1,sizeof(mp));
	for (int i=1;n>=i;i++) {
		for (int j=1;m>=j;j++) {
			mp[i][j] = 0;
		}
	}
	int dx[4] = {1,0,-1,0},dy[4]={0,1,0,-1};
	int id=1;
	int x=1,y=1;
	while (id != tot+1) {
		mp[x][y] = id;
		cnt[id]--;
		if (!cnt[id]) id++;
		for (int k=0;4>k;k++) {
			int tx=x+dx[k],ty=y+dy[k];
			if (mp[tx][ty] == 0) {
				x=tx;
				y=ty;
				break;
			}
		}
	}
	for (int i=1;n>=i;i++) {
		for (int j=1;m>=j;j++) {
			if (j!=1) printf(" ");
			printf("%d",mp[i][j]);
		}
		puts("");
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N; cin>>N;
    vec A(N);
    int sum = 0;
    REP(i,N){
        cin>>A[i];
        sum += A[i];
    }
    Sort(A);
    if(sum%10!=0) Out(sum);
    else{
      bool X = true;
        REP(i,N){
            if(A[i]%10!=0){
              X = false;
                Out(sum-A[i]);
                break;
            }
        }
      if(X) Out(0);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int x,y;
  cin>>x>>y;
  int ans=0;
  if(x==3)ans+=100000;
  if(x==2)ans+=200000;
  if(x==1)ans+=300000;
  if(y==3)ans+=100000;
  if(y==2)ans+=200000;
  if(y==1)ans+=300000;
  if(x==1&&y==1)ans+=400000;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	x := scanString()

	memo := make([]int, n+1)
	for i := 0; i < n; i++ {
		c := 0
		for b := i + 1; b != 0; b >>= 1 {
			if b&1 == 1 {
				c++
			}
		}
		memo[i+1] = memo[(i+1)%c] + 1
	}

	cn := 0
	for _, s := range x {
		if s == '1' {
			cn++
		}
	}

	a1, a2 := 0, 0
	p1, p2 := 1, 1
	for i := 0; i < n; i++ {
		if x[n-1-i] == '1' {
			if cn != 1 {
				a1 = (a1 + p1) % (cn - 1)
			}
			a2 = (a2 + p2) % (cn + 1)
		}
		if cn != 1 {
			p1 = p1 * 2 % (cn - 1)
		}
		p2 = p2 * 2 % (cn + 1)
	}

	ans := make([]int, n)
	p1, p2 = 1, 1
	for i := 0; i < n; i++ {
		c := cn
		if x[n-1-i] == '1' {
			if cn != 1 {
				c--
				ans[n-1-i] = memo[(a1-p1%c+c)%c] + 1
			} else {
				ans[n-1-i] = 0
			}
		} else {
			c++
			ans[n-1-i] = memo[(a2+p2%c)%c] + 1
		}
		if cn != 1 {
			p1 = p1 * 2 % (cn - 1)
		}
		p2 = p2 * 2 % (cn + 1)
	}

	for i := 0; i < n; i++ {
		fmt.Fprintln(wr, ans[i])
	}
}


Measured memory_bytes: 7144
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int d = sc.nextInt();

		double ans = 1;

		if (d == 0) {
			ans *= n;
		} else {
			ans *= 2 * (n - d);
		}

		while (m != 2) {
			ans = ans * (m - 1) / (m - 2);
			m--;
		}

		ans /= (long) Math.pow(n, 2);

		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#058-C
n=int(input())
s=[]
for i in range(n):
    s.append(list(input()))
l=''
for i in range(26):
    t=n+2
    for j in range(n):
        t=min(t,s[j].count(chr(97+i)))
    for j in range(t):
        l=l+chr(97+i)
print(l)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> ans(n+1, 0);
    int i, j, k;
    for (i = 1; i * i < n; i++) {
        int ii = i * i;
        for (j = 1; j * j + ii < n; j++) {
            int jj = j * j;
            for (k = 1; k * k + ii + jj < n; k++) {
                int target = ii + jj + k * k + i * j + j * k + k * i;
                if (target <= n) ans[target]++;
            }
        }
    }
    xrep(i, 1, n+1) {
        cout << ans[i] << endl;
    }
    cout << endl;
}


Measured memory_bytes: 3528
#include<iostream> 
#include<stdio.h>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<functional>
#include<string.h>
#define debug(a)	cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef unsigned long long ull;
ll a[100005], sum[100005];
ll n, m;
ll check(ll x)
{
	ll num = 0;
	for (int i = 0; i < n; i++)
	{
		num += lower_bound(a, a + n + 1, x - a[i] - 1, greater<ll>()) - a;
	}
	return num;
}
ll lowerbound(ll l,ll r, ll target){
	ll x = r;
        while(l<r){
            ll m = (l+r)/2;
            if(check(x - m) >= target) r = m;
            else    l = m + 1;
        }
        return x - l;
}
ll get(ll x)
{
	ll num = 0, s = 0;
	for (int i = 0; i < n; i++)
	{
		ll f = lower_bound(a, a + n + 1, x - a[i] - 1, greater<ll>()) - a;
		s += f;
		num += sum[f - 1] + f * a[i];
	}
	return num + x * (m - s);
}
int main()
{	
	while (~scanf("%lld%lld", &n, &m))
	{
		for (int i = 0; i < n; i++)
		{
			scanf("%lld", a + i);
		}
		sort(a, a + n, greater<ll>());
		a[n] = -10000000;
		sum[0] = a[0];
		for (int i = 1; i < n; i++)
		{
			sum[i] = sum[i - 1] + a[i];
		}
		//debug(lowerbound(0, 500000, m));
		ll ans = get(lowerbound(0, 250000, m));
		printf("%lld\n", ans);
	}
} 



Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    X = MI()
    for i, x in enumerate(X):
        if x == 0:
            print(i+1)
            return


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9104
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            int N = Integer.parseInt(br.readLine());
            
            while(true){
                N = N - 1000;
                
                if(N <= 0){
                    break;
                }
            }
            
            System.out.println(Math.abs(N));
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 32484