akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

typedef bitset<625> bt;

void Gauss_elim(vector<bt> &b) {
	int le = 0;
	rep(j, 625) {
		Rep(i, le, b.size()) {
			if (b[i][j]) {
				swap(b[le], b[i]);
				rep(k, b.size()) {
					if (k == le)continue;
					if (b[k][j]) {
						b[k] ^= b[le];
					}
				}
				le++; break;
			}
		}
	}
}
int mp[25][25];
int w, h, d;
void solve() {
	rep(i, h) {
		rep(j, w) {
			cin >> mp[i][j];
		}
	}
	vector<bt> b(h*w);
	rep(i, h) {
		rep(j, w) {
			rep(k, h) {
				rep(l, w) {
					int dist = abs(k - i) + abs(l - j);
					if (dist == d || dist == 0) {
						b[i*w + j][k*w + l] = true;
					}
				}
			}
		}
	}
	Gauss_elim(b);
	/*rep(i, b.size()) {
		rep(j, h*w)cout << b[i][j];
		cout << endl;
	}*/
	bt goal;
	rep(i, h)rep(j, w)if (mp[i][j]) {
		//cout << i << " " << j << endl;
		goal[i*w + j] = true;
	}
	/*rep(j, h*w)cout << goal[j];
	cout << endl;*/
	rep(i, b.size()) {
		rep(j, 625) {
			if (b[i][j]) {
				if (goal[j]) {
					goal ^= b[i];
				}
				break;
			}
		}
	}
	//cout << "ans is ";
	if (goal.count() == 0) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(7);
	//init();
	while (cin >> w>>h>>d, w) {
		solve();
	}
	//stop
	return 0;
}




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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N, M;
    ll L;
    cin >> N >> M >> L;
    ll dist[N][N] = {};
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            if(j != i)
                dist[i][j] = INF;
    for(int i = 0; i < M; i++) {
        int A, B;
        ll C;
        cin >> A >> B >> C;
        if(C <= L) {
            A--;
            B--;
            dist[A][B] = dist[B][A] = C;
        }
    }
    for(int k = 0; k < N; k++) {
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                if(dist[i][k] != INF && dist[k][j] != INF)
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++)
            if(i != j) {
                dist[i][j] = dist[i][j] <= L ? 1 : INF;
            }
    }
    for(int k = 0; k < N; k++) {
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                if(dist[i][k] != INF && dist[k][j] != INF)
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    int Q;
    cin >> Q;
    while(Q--) {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        ll ans = dist[s][t] == INF ? -1 : dist[s][t] - 1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((d<=a  )|| (c>=b )) cout  << 0 << endl;
    else if((a>=c&&b>=d&&d>=a)||(b>=d && d>= a && a >= c))   cout<< d-a<<endl;
    else if(a<=c&&b>=d)   cout <<  d-c<<endl;
    else if((d>=b&&a<=c&&b>=c)||(d<=c && c <= b && b <= d))   cout << b-c << endl;
    else if(d >= b && a >= c) cout << b-a << endl;
    return 0;
}

Measured memory_bytes: 256
Array.prototype.rjust = function(dig) {
  var pre = '';
  for (var i = 0; i < dig; i++) { pre += ' '; }
  return this.map(function(m) { return (pre + m).slice(-dig); });
};
Array.prototype.sum = function() {
  return this.reduce(function(m, n) { return +n + m; }, 0);
};

var d = require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n');
while (d[0] !== '0') {
  var lc = +d.shift();
  var sums = [];
  var lastLine = [];
  for (var i = 0; i < lc; i++) {
    var nums = d.shift().split(' ');
    nums.push(nums.sum());
    sums.push(nums);
    console.log(nums.rjust(5).join(''));
  }
  for (var i = 0, max = lc+1; i < max; i++) {
    lastLine.push(sums.map(function(n) { return n[i]; }).sum());
  }
  console.log(lastLine.rjust(5).join(''));
}

Measured memory_bytes: 10124
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int main(void){
    long long int n,sum;
    cin>>n;
    vector<long long int> a(n);
    rep(i,n){cin>>a.at(i);}
    sum=0;
    rep(i,n-1){
        if(a.at(i)>a.at(i+1)){sum=sum+a.at(i)-a.at(i+1); a.at(i+1)+=a.at(i)-a.at(i+1);}
    }
    
    cout<<sum<<endl;
}


Measured memory_bytes: 4760
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long

int jg(int a) {
    int X = a / 2;
    return X;
}

int main(void) {
    int n;
    cin >> n;
    int a[110];
    vector<int> cc;
    int cnt = 1;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (i >= 2 && a[i] == a[i - 1])cnt++;
        else if (i >= 2) {
            cc.push_back(cnt);
            cnt = 1;
        }
   }
    cc.push_back(cnt);
    int ans = 0; rep(i, cc.size())ans += cc[i] / 2;
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
// const int INF=1e9;
void solve(){
	int n,w;cin>>n>>w;
    vector<int>wt(n),val(n);
    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    int dp[n][w+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=0;
    dp[0][wt[0]]=val[0];
    for(int i=1;i<n;i++){
        for(int j=0;j<=w;j++){
            if(j>=wt[i])
            dp[i][j]=max(dp[i][j],dp[i-1][j-wt[i]]+val[i]);
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
        }
    }
    int maxx=-1;
    for(int j=0;j<=w;j++){
        maxx=max(maxx,dp[n-1][j]);
    }
    cout<<maxx;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 81572
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    uint N, M; cin >> N >> M;
    vector<int> vX(M);
    for(uint i=0; i<M; ++i){ cin >> vX[i]; }
    sort(vX.begin(), vX.end());
    
    vector<int> vD(M-1);
    for(uint i=0; i<M-1; ++i){ vD[i] = vX[i+1]-vX[i]; }
    sort(vD.begin(), vD.end(), greater<int>());
    
    int sum=vX[ vX.size()-1 ] - vX[0];
    for(uint i=0; i<min(N-1, M-1); ++i){
        sum -= vD[i];
    }
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    ll ans=1;
    for(ll i=1;i*i<=m;i++){
        if(m%i==0){
            if(m>=i*n){
                ans =max(ans,i);
            }
            if(i>=n){
                ans=max(ans,m/i);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    char c[4]={'A','C','T','G'};
    char b;
    cin>>b;
    REP(i,4){
        if(b==c[i]){
            OUT(c[(i+2)%4]);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[n],b[n];
  rep(i,n) cin >> a[i] >> b[i];
  ll dp[m+1];
  fill(dp,dp+m+1,-MAXL);
  dp[0]=0;
  rep(i,n) {
    rrep(j,m) {
      if(j+a[i]<=m) dp[j+a[i]]=max(dp[j+a[i]],dp[j]+b[i]);
    }
  }
  ll ans=0;
  rep(i,m+1) ans=max(ans,dp[i]);
  pr(ans);
}

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


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
int main(){
    int n;
    int a[3001];
    int masterko[100001]={};
    
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
//         int tem=a[i];
//         int ko[100001]={};
//         for(int s=2;tem>1;){
//             if(tem%s==0){
//                 tem/=s;
//                 ko[s]++;
//                 cout<<s<<endl;
//                 if(masterko[s]<ko[s])masterko[s]=ko[s];
//             }else{
//                 s++;
//             }
//         }
//     }
//     cout<<"ans"<<endl;
//     int mm=1;
//     for(int i=2;i<=100000;i++){
//         if(masterko[i]!=0){
//             mm*=pow(i,masterko[i]);
//         }
//     }
//     mm--;
//     cout<<mm<<endl;
//     int ans=0;
//         for(int i=1;i<=n;i++){
//             ans+=mm%a[i];
//         }
    
//     cout<<ans<<endl;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=a[i]-1;
    }
    cout<<ans<<endl;
}

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

int main() {
   int a,m;
   cin >> a >> m;
   vector<int> e(m);
  rep(i,m) cin >> e[i];
   int cnt = 0;
   rep(i,m){
       cnt+=e[i];
   }
   string ans;
   if(cnt>a) cout << -1 << endl;
   else cout << (a-cnt) << endl;
   return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <set> 
# include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n; cin>>n;
    vector<ll> v(n);
    REP(i,n)cin>>v[i];
    sort(ALL(v));
    vector<ll> sides;
    vector<ll> list;
    map<ll,ll> mp;
    REP(i,n){
        ll a=v[i];
        if(mp.find(a)!=mp.end()){
            mp.at(a)++;
            list.push_back(a);
        }else{
            mp.insert(make_pair(a,1));
        }
    }
    REP(i,SIZE(list)){
        ll s=list[i];
        while(mp.at(s)/=2){
            sides.push_back(s);
        }
    }
    ll ans;
    if(SIZE(sides)<2){
        ans=0;
    }else{
        sort(ALL(sides),greater<>());
        ans=sides[0]*sides[1];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 10320
/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 1000000007
#define yes cout << "Yes\n"
#define no cout << "No\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    take;
    ll sum = 0, ans = 0;
    for(int i = 0; i < n; i++) {
        ans += (sum * a[i]);
        sum += a[i];
        sum %= mod;
        ans %= mod;
    }
    cout << ans << '\n';
    return;
}

int main() {
    /*int tc;
    cin >> tc;
    while(tc-- > 0)*/
    solve();
    return 0;
}


Measured memory_bytes: 4844
# import math
# import copy
# import fractions
# import numpy as np
#
# # ===FUNCTION===
#
# def getInputNum():
#     inputNum = int(input())
#     return inputNum
#
# def getInputListInt():
#     outputoData = []
#     inputData = input().split()
#     outputData = [int(n) for n in inputData]
#
#     return outputData
#
# def getSomeInputInt(n):
#     outputDataList = []
#     for i in range(n):
#         inputData = int(input())
#         outputDataList.append(inputData)
#
#     return outputDataList
#
# def getSomeInputListInt(n):
#     inputDataList = []
#     outputDataList = []
#     for i in range(n):
#         inputData = input().split()
#         inputDataList = [int(n) for n in inputData]
#         outputDataList.append(inputDataList)
#
#     return outputDataList
#
# # ===CODE===
#
# num = getInputListInt()
#
# a = num[0]
# b = num[1]
# c = num[2]
# d = num[3]
#
# c_modzero = math.floor(b/c) - math.floor((a-1)/c)
# d_modzero = math.floor(b/d) - math.floor((a-1)/d)
#
# cd = c / fractions.gcd(c, d) *d
#
# cd_modzero = math.floor(b/cd) - math.floor((a-1)/cd)
#
# ans = b - a + 1 - (c_modzero + d_modzero - cd_modzero)
#
# print(int(ans))

import copy



# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

def GCD(x, y):
    return x if y == 0 else GCD(y, x % y)


def LCM(x, y):
    return x // GCD(x, y) * y


A, B, C, D = map(int, input().split())

S = B - A + 1

canC = B // C - (A - 1) // C
canD = B // D - (A - 1) // D
canCD = B // LCM(C, D) - (A - 1) // LCM(C, D)

print(S - (canC + canD) + canCD)

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

int main(void){
  int n;
  scanf("%d",&n);
  
  long int a[n];
  int i, j=0;
  double m=0, k=0;
  long int ans=1;
  for(i=0; i<n; i++){
    scanf("%ld", &a[i]);
    if(a[i]==0){
      k++;
    }
    m+=log10(a[i]);
    ans*=a[i];
  }
  
  if(k!=0){
    printf("0\n");
    return 0;
  }
  
  if(m>18 || ans>1000000000000000000){
    printf("-1\n");
    return 0;
  }
  
  printf("%ld\n",ans);
  
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,T;
	cin >> N >> T;
	vector<ll> A(N);
	FOR(i,0,N)cin>>A[i];
	ll ans=0;
	ll maxsub=0;
	ll minA=A[0];
	FOR(i,1,N){
		if(maxsub==(A[i]-minA)){
			ans++;
		}else if(maxsub<(A[i]-minA)){
			ans=1;
			maxsub = A[i]-minA;
		}
		if(minA>A[i])minA=A[i];
	}
	cout << ans << endl;
}

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

bool is_increase(int N, vector<int> &p){
	for(int i = 1; i < N; i++){
		if(p[i - 1] > p[i]){
			return false;
		}
	}
	return true;
}

int main(){
	int N, i, j;
	scanf("%d", &N);
	vector<int> p(N);
	for(i = 0; i < N; i++){
		scanf("%d", &p[i]);
	}
	for(i = 0; i < N; i++){
		for(j = 0; j < N; j++){
			swap(p[i], p[j]);
			if(is_increase(N, p)){
				printf("YES\n");
				return 0;
			}
			swap(p[i], p[j]);
		}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int a,b,c[105];
int main()
{
    scanf("%d",&b);
    for(int i=1;i<=b;i++){
    	scanf("%d",&a);
    	for(int j=i;j<=b;j++) c[j]+=a;
	}
	for(int i=1;i<=b;i++){
    	scanf("%d",&a);
    	for(int j=1;j<=i;j++) c[j]+=a;
	}
    for(int i=1;i<=b;i++) a=max(a,c[i]);
    printf("%d\n",a);
}

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

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

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

	if (n >= 400 && n < 600) {
		cout << "8" << endl;
	}
	else if (n < 800) {
		cout << "7" << endl;
	}
	else if (n < 1000) {
		cout << "6" << endl;
	}
	else if (n < 1200) {
		cout << "5" << endl;
	}
	else if (n < 1400) {
		cout << "4" << endl;
	}
	else if (n < 1600) {
		cout << "3" << endl;
	}
	else if (n < 1800) {
		cout << "2" << endl;
	}
	else if (n < 2000) {
		cout << "1" << endl;
	}


	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    ll n,k;
    cin >> n >> k;

    ll m=n%k;

    ll ans = min(m,abs(m-k));

    cout << ans << endl;

    return 0;
}


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

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


Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        final List<Integer> list = IntStream.range(0, n)
            .mapToObj(i -> scanner.nextInt())
            .collect(Collectors.toList());

        for (int i = k; i < n; i++) {
            if (list.get(i) > list.get(i - k)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 65376
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010,mod=998244353;
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int a,b,t;
int main(){
	a=read();b=read();t=read();
	printf("%d\n",t/a*b);
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n, a, b;
  cin >> n;
  for(int k=0; k<n; ++k){
    int x=0, y=0, d=0, x_=0, y_=0, d_=0;
    while(1){
      cin >> a >> b;
      if(!a && !b) break;
      x_+=a, y_+=b, d_=x_*x_+y_*y_;
      if(d_>d || (d_==d && x_>x)) x=x_, y=y_, d=d_;
    }
    cout << x << " " << y << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define N 5001
#define INF 1e9
using namespace std;
int n,m;
int G[N][N];
int C[N],R[N];
vector<int> g[N];
typedef pair<int,int> P;

vector<int> bfs(int start){
  vector<int>res,D(N,R[start]+1);
  queue<int> Q;
  Q.push(start);
  D[start]=0;
  while(!Q.empty()){
    int pos = Q.front();Q.pop();
    for(int i=0;i<g[pos].size();i++) {
      int nx=g[pos][i];
      if(D[nx]>D[pos]+1){
	Q.push(nx),D[nx]=D[pos]+1;
	res.push_back(nx);
      }
    }
  }
  return res;
}

int dijkstra(){
  vector<int>D(N,INF); 
  priority_queue<P,vector<P>,greater<P> > Q;
  Q.push(P(0,0));
  D[0] = 0;
  while(!Q.empty()){
    P t=Q.top();Q.pop();
    int pos=t.second;
    int cost=t.first;
    if(pos==n-1) return cost;
    vector<int> nx=bfs(pos);

    for(int i=0;i<nx.size();i++){
      int npos=nx[i];
      int ncost=cost+C[pos];
      if(D[npos]>ncost){
	Q.push(P(ncost,npos));
	D[npos] = ncost;
      }
    }
  }
  return -1;
}


int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>C[i]>>R[i];
  
  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  
  cout<<dijkstra()<<endl;
  return 0;
}

Measured memory_bytes: 3768
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,k,m,n;
	cin>>a>>b>>c;
	cin>>k;
	if(a>b)
	{
		if(a>c)
		{
			m=a;n=b+c;
		}
		else
		{
			m=c;n=a+b;
		}
	}
	else
	{
		if(b>c)
		{
			m=b;n=a+c;
		}
		else
		{
			m=c;n=a+b;
		}
	}
	while(k--)
	{
		m*=2;
	}
	cout<<m+n;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	int n,d;
	//freopen("inp.in","r",stdin);
	cin >> n >> d;
	int cnt = 0;

	while(n--)
	{
		double x,y;
		cin >> x >> y;
		double p = sqrt((x*x)+(y*y));
		if(p<=d)cnt++;

	}
	cout << cnt << "\n";
	
	return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    long long int n;
    cin>>n;
    vector<long long int> vec(n);
    long long int sum=0,ans=0,x,center,center2;
    rep(i,n){
        cin>>x;
        sum+=x;
        vec[i]=sum;
    }
    vector<long long int> vec2(n);
    rep(i,n){
        vec2[i]=abs(sum-2*vec[i]);
    }
    sort(all(vec2));
    cout<<vec2[0]<<endl;
}


Measured memory_bytes: 3328
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   long N = sc.nextLong();
   long[] Xi = new long[5];
   for(int i =0;i<5;i++)
   {
     Xi[i] = sc.nextLong();
   }
	Arrays.sort(Xi);
   double cc = Math.ceil((double)N/(double)Xi[0]);
   long ans = (long)cc+4;
   System.out.println(ans);
 }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
const long long OO = (long long) 1e9+7;
#define lp(i,a,n) for(long long i = a ; i < n ; ++i)
#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define PI acos(-1.0)
#define vec(a,b)                ((b)-(a))
#define length(a)               (hypot((a).imag(), (a).real()))
#define EPS 1e-9
#define INF 1e9
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define ff first
#define ss second
typedef vector<int> vi ;
typedef   long long ll;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<int,int> pii;


using namespace std;
ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m


int h,w ,ans,xx[]={0,0,1,-1},yy[]={1,-1,0,0};
vpii nxt;
char grid[25][25];
bool vstd[25][25];
int dist[25][25];
bool valid(int x,int y){
    return x>=0&&y>=0&&x<h&&y<w && grid[x][y] =='.';
}
void bfs(int x, int y){
    int tmx = 0,mxx=x,mxy=y;
    queue<pii> q;
    q.push({x,y});
    vstd[x][y] = 1;
    dist[x][y] = 0;
    while(!q.empty()) {
        pii  p =q.front();
        q.pop();
        lp(i,0,4){
            int tx = p.ff+xx[i] , ty = p.ss+yy[i];
            if(!valid(tx,ty) ) continue;
            if ( !vstd[tx][ty] )
                q.push({tx,ty}), dist[tx][ty] = dist[p.ff][p.ss] + 1;
            vstd[tx][ty] = 1;
            if(dist[tx][ty] > tmx) tmx = dist[tx][ty] , mxx=tx,mxy=ty;
        }
    }

    if(tmx!=0) nxt.push_back({mxx,mxy}) , ans=max(ans,tmx);
}




int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
  //    freopen( "output.txt" , "w" , stdout ) ;
  //  freopen( "input.txt" , "r" , stdin ) ;

   cin>>h>>w;
   lp(i,0,h)lp(j,0,w) cin>>grid[i][j];
   lp(i,0,h)lp(j,0,w)if(!vstd[i][j]){
        bfs(i,j);
   }
   int tn= nxt.size();
   lp(i,0,tn){
      // cout << nxt[i].ff<< " "<<nxt[i].ss<<endl;
        lp(k,0,25)lp(j,0,25) vstd[k][j] = 0;
        bfs(nxt[i].ff,nxt[i].ss);
   }
    cout<<ans;



    return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=1e6+5,L=1e6;
bitset<N>vis;int p[N],mu[N],cnt[N],a[N],st[N],c[N],s[N],top,n,m,res;
void init(int n=L){
	mu[1]=1;
	fp(i,2,n){
		if(!vis[i])p[++m]=i,mu[i]=-1;
		for(R int j=1;j<=m&&i*p[j]<=n;++j){
			vis[i*p[j]]=1;
			if(i%p[j]==0)break;
			mu[i*p[j]]=-mu[i];
		}
	}
	fp(i,1,n)upd(mu[i],P);
	fp(i,1,n)for(R int j=i;j<=n;j+=i)upd(s[j],mul(i,mu[i]));
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n);
	init();
	fp(i,1,n)scanf("%d",&a[i]),++cnt[a[i]];
//	fp(d,1,233)fp(i,1,n)if(a[i]%d==0)fp(j,1,n)if(a[j]%d==0)fp(t,1,233)
//		if((a[i]/d)%t==0&&(a[j]/d)%t==0)upd(res,mul(mu[t],mul(d,mul(a[i]/d,a[j]/d))));
//	fp(d,1,233)fp(i,1,n)if(a[i]%d==0)fp(j,1,n)if(a[j]%d==0)
//		if(__gcd(a[i]/d,a[j]/d)==1)upd(res,mul(d,mul(a[i]/d,a[j]/d)));
//	fp(T,1,233)fp(i,1,n)if(a[i]%T==0)fp(j,1,n)if(a[j]%T==0)
//		upd(res,1ll*a[i]/T*a[j]/T%P*T%P*s[T]%P);
	fp(T,1,L){
		R int sum=0;
		for(R int j=T;j<=L;j+=T)upd(sum,mul(j/T,cnt[j]));
		sum=mul(sum,sum),sum=mul(sum,mul(T,s[T]));
		upd(res,sum);
	}
	fp(i,1,n)res=dec(res,a[i]);
	res=mul(res,(P+1)>>1);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 18816
-- Try AtCoder
-- author: Leonardone @ NEETSDKASU
 
 
 
main = print . solve . map read . tail . words=<< getContents

cost a b = (b - a) ^ 2

solve xs = ans where
    min = minimum xs
    max = maximum xs
    g f = sum $ map f xs
    ans = minimum . map g $ map cost [min .. max]
    

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

int main() {
    int N;cin >> N;
    string S[N] = {};
    for (int i = 0;i < N;i++){
        cin >> S[i];
    }
    sort(S,S + N);
    int res = 1;
    string X = S[0];
    for (int i = 1;i < N;i++){
        if (S[i] == X) continue;
        else {
            X = S[i];
            res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 9864
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

int
main() {
  int n,k;
  vector<int> w;

  cin >> n >> k;
  for (int i=0;i<n;++i) {
    int t;
    cin >> t;
    w.push_back(t);
  }

  // naive algorithm;
  // increment p ...
  uint64_t m = accumulate(begin(w), end(w), 0);
  auto est_p = (m / k);
  // cout << "est_p " << est_p << endl;
  
  auto calc = [](vector<int> & xs, int k, int p) -> bool{
    int wi=0;
    int i=0;
    for (; i<k; ++i) {
      int v = p;
      // cout << "wi = " << wi << " v = " << v << endl;
      while ( v - xs[wi] >= 0) {

	v -= xs[wi];
	wi++;
	if (wi == xs.size()) return true;
	// cout << "v = " << v << endl;
      }
    }
    return false;
  };

  auto ap = est_p;
  do {
    if (calc(w, k, ap)) {
      break;
    }
    ap++;
  } while (true);
  cout << ap << endl;
  
  return 0;
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
#define MEM(a,num) memset(a,num,sizeof(a))
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=2e5+100;
typedef long long ll;
bool check(ll v,ll u){return (u^v)==(u+v);}
ll l[maxn];
int a[maxn];
int main()
{
	int N,v=0;
	scanf("%d",&N);
	rep(i,1,N)scanf("%d",&a[i]);
	l[0]=1;
	rep(i,1,N)
	{
		l[i]=l[i-1];
		int j=l[i];
		while(j<=N&&check(v,a[j++]))
			l[i]++,v+=a[j-1];
		v-=a[i];
	}
	ll ans=0;
	rep(i,1,N)
		ans+=(l[i]-i);
	printf("%lld\n",ans);
}

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

using namespace std;
// #define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
// #define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main(){
  long double a;
  long double b;
  cin >> a >> b;

  // long double ans = a * b;
  // long long res = floor(ans);
  long long res = floor(a*b);
  // cout << (long long)ans << endl;
  // cout << (long long)ans << endl;
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3720
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#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>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n;
	cin >> n;
	map<string, int> mp;
	string s[110];
	rep(i, n) {
		cin >> s[i];
		mp[s[i]]++;
		if (mp[s[i]] > 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	rep(i, n - 1) {
		int k = s[i].size();
		if (s[i][k - 1] != s[i + 1][0]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
k=int(input())
l=[1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]
print(l[k-1])

Measured memory_bytes: 9376
from collections import deque

diffs = [(-1, 0), (0, -1), (0, 1), (1, 0)]

h, w = map(int, input().split())
start_point = tuple(map(lambda x: int(x) - 1, input().split()))
goal_point = tuple(map(lambda x: int(x) - 1, input().split()))
maze = [input() for _ in range(h)]

counts = [[-1] * w for _ in range(h)]

counts[start_point[0]][start_point[1]] = 0
point_queue = deque([start_point])

while point_queue:
    connected_queue = deque()
    while point_queue:
        curr_h, curr_w = point_queue.pop()
        connected_queue.append((curr_h, curr_w))

        for diff_h, diff_w in diffs:
            next_h = curr_h + diff_h
            next_w = curr_w + diff_w

            if not (0 <= next_h < h and 0 <= next_w < w):
                continue

            if maze[next_h][next_w] == '#':
                continue

            if (next_h, next_w) == goal_point:
                print(counts[curr_h][curr_w])
                exit(0)

            if counts[next_h][next_w] != -1:
                continue

            counts[next_h][next_w] = counts[curr_h][curr_w]
            point_queue.append((next_h, next_w))
            connected_queue.append((next_h, next_w))

    while connected_queue:
        curr_h, curr_w = connected_queue.pop()
        for diff_h in range(-2, 3):
            for diff_w in range(-2, 3):
                next_h = curr_h + diff_h
                next_w = curr_w + diff_w

                if not (0 <= next_h < h and 0 <= next_w < w):
                    continue

                if maze[next_h][next_w] == '#':
                    continue

                if (next_h, next_w) == goal_point:
                    print(counts[curr_h][curr_w] + 1)
                    exit(0)

                if counts[next_h][next_w] != -1:
                    continue

                counts[next_h][next_w] = counts[curr_h][curr_w] + 1
                point_queue.append((next_h, next_w))

print(-1)


Measured memory_bytes: 84880
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;
        string s;
        cin >> s;

        int ret = 0;
        int len = 0;
        for(int i=0; i<m+1; ++i){
            if(i < m && !((len % 2 == 0) ^ (s[i] == 'I'))){
                ++ len;
            }else{
                -- len;
                len /= 2;
                if(len >= n)
                    ret += len - n + 1;
                if(i < m && s[i] == 'I')
                    len = 1;
                else
                    len = 0;
            }
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll l(n*2) ;
	for(auto &i:l) cin >> i ;
	mysort(l) ;
	ll ans = 0 ;
	for(int i=0;i<2*n;i+=2){
		ans += l.at(i) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll x, y;
    cin >> n >> x >> y;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    // dp[何枚取ったか][次が先手=0, 後手=1]
    vector<vector<ll>> dp(n + 10, vector<ll>(2));
    for(int i = n - 1; i >= 0; i--) {
        dp[i][0] = -1;
        ll pre = (i == 0 ? y : a[i - 1]);
        chmax(dp[i][0], llabs(pre - a[n - 1]));
        for(int j = i + 1; j < n; j++) {
            chmax(dp[i][0], dp[j][1]);
        }
        dp[i][1] = LLINF;
        pre = (i == 0 ? x : a[i - 1]);
        chmin(dp[i][1], llabs(pre - a[n - 1]));
        for(int j = i + 1; j < n; j++) {
            chmin(dp[i][1], dp[j][0]);
        }
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 384
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val (a, b, h, m) = (sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt())

  val PerMinutes = 1.0 / (12.0 * 60.0)

  val hourRadian = (2 * Math.PI) * (h / 12.0 + m * PerMinutes)
  val minutesRadian = 2 * Math.PI * m / 60.0

  val radian = Math.abs(hourRadian - minutesRadian)
  val resSquare = (a * a) + (b * b) - 2 * a * b * Math.cos(radian)
  println(Math.sqrt(resSquare))
}


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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//const double pi=3.14159265359;
//###################################################################
int main() {

    int n=D();
    if(n>=30)puts("Yes");
    else puts("No");
    
}

Measured memory_bytes: 3668
# 2015/10/11
# WA 13/20
s=STDIN.gets.split
n = s[0].to_i
q = s[1].to_i
int_max=2**31-1
ar  = Array.new(100001,(int_max))
ar2 = Array.new(1001  ,(int_max))

1.upto(q) {
s=STDIN.gets.split
com = s[0].to_i
x   = s[1].to_i
y   = s[2].to_i
#printf(":%d %d %d\n",com,x,y)
if(com==0)
  x1=x/100
  if ar2[x1] > y then
    ar[x]=y
    ar2[x1]=y 
  elsif ar2[x1] == ar[x] then
    ar[x]=y
    min_=int_max
    floor=x1*100
    ceil =floor+99
    floor.upto(ceil){|i| min_ = ar[i]  if min_ > ar[i] }
    ar2[x1]=min_
  else
    ar[x]=y
  end
elsif (com==1)
  min_=int_max
  x1=x/100
  y1=y/100
  #printf(":x1y1=%d %d\n",x1,y1) if x==110 && y==430
  #printf(":ar2 =%d %d\n",ar2[2],ar2[3]) if x==110 && y==430
  if(x1==y1 || x1+1==y1)
    x.upto(y){|i|
      min_ = ar[i] if min_ > ar[i]
    }
  else
    if (x % 100) > 0 then
      x.upto(x1*100+99){|i| min_ = ar[i]  if min_ > ar[i] }
      (x1+1).upto(y1-1){|i| min_ = ar2[i] if min_ > ar2[i]  }
    else
      x1.upto(y1-1){|i| min_ = ar2[i] if min_ > ar2[i]      }
    end
    (y1*100).upto(y){|i|
      min_ = ar[i] if min_ > ar[i]
    } if (y % 100)>0
  end
  puts min_
end
}

Measured memory_bytes: 9596
program test
implicit none

integer(8) :: i,j,a,b,k,ans,count

read(*,*) a,b,k

count = 0
do i=min(a,b),1,-1
	if(mod(a,i)==0 .and. mod(b,i) ==0) then
		count = count + 1
		if(count == k) then
			ans = i 
			goto 100
		endif
	endif
enddo
100 continue
write(*,*) ans

























contains
subroutine heapsort_down(n,y1,y2)
 
	implicit none
	integer(8),intent(in) :: n
	integer(8),intent(inout) :: y1(1:n)
	integer(8),intent(inout) :: y2(1:n)
	integer(8) :: i,k,j,l
	integer(8) :: t1,t2
	
	l = n/2+1
	k = n
 
	do while (k /= 1)
		 if(l > 1) then
				l = l-1
				t1 = y1(l)
				t2 = y2(l)
				
		 else
				t1 = y1(k)
				t2 = y2(k)
				y1(k) = y1(1)
				y2(k) = y2(1)
				k = k-1
				if(k == 1) then
					 y1(1) = t1
					 y2(1) = t2
					 exit
				endif
		 endif
 
		 i = l
		 j = l+l
 
		 do while(j <= k)
				if(j < k) then
					 if(y1(j) > y1(j+1)) j = j+1
				endif
				
				if (t1 > y1(j)) then
					 y1(i) = y1(j)
					 y2(i) = y2(j)
					 i = j
					 j = j+j
				else
					 j = k+1
				endif
		 
		 enddo
		 
		 y1(i) = t1
		 y2(i) = t2
	
	enddo
	return
 
end subroutine heapsort_down
 
subroutine heapsort_up(n,y1,y2)
 
	implicit none
	integer(8),intent(in) :: n
	integer(8),intent(inout) :: y1(1:n)
	integer(8),intent(inout) :: y2(1:n)
	integer(8) :: i,k,j,l
	integer(8) :: t1,t2
	
	l = n/2+1
	k = n
 
	do while (k /= 1)
		 if(l > 1) then
				l = l-1
				t1 = y1(l)
				t2 = y2(l)
				
		 else
				t1 = y1(k)
				t2 = y2(k)
				y1(k) = y1(1)
				y2(k) = y2(1)
				k = k-1
				if(k == 1) then
					 y1(1) = t1
					 y2(1) = t2
					 exit
				endif
		 endif
 
		 i = l
		 j = l+l
 
		 do while(j <= k)
				if(j < k) then
					 if(y1(j) < y1(j+1)) j = j+1
				endif
				
				if (t1 < y1(j)) then
					 y1(i) = y1(j)
					 y2(i) = y2(j)
					 i = j
					 j = j+j
				else
					 j = k+1
				endif
		 
		 enddo
		 
		 y1(i) = t1
		 y2(i) = t2
	
	enddo
	return
 
end subroutine heapsort_up
 
end program

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		int[] num = new int[6];
		Scanner sc = new Scanner(System.in);
		int count;
		Slot s;
		
		while(true){
			count = 0;
			for(int i=0;i<6;i++){
				num[i] = sc.nextInt();
				count += num[i];
			}
			
			if(count == 0){
				break;
			}
			
			s = new Slot(num);
			System.out.println(s.getCoin());
		}
	}
}

class Slot{
	int[] gameResult;
	int coin;
	
	Slot(int[] num){
		gameResult = num;
		coin = 100;
	}
	
	private void reflectResult(){
		coin += 15*6*gameResult[0];
		coin += 15*4*gameResult[1];
		coin += 7*gameResult[2];
		coin += 2*gameResult[3];
		coin -= (3*(gameResult[5]-gameResult[4])-5*gameResult[0]-3*gameResult[1]);
	}
	
	public int getCoin(){
		reflectResult();
		return coin;
	}
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

vii adj;
vi seen;
int N, M;

void dfs(int v){
    seen[v]=true;
    for(auto nv : adj[v]){
        if(seen[nv]) continue;
        dfs(nv);
    }
    return;
}

int main(){
    cin >> N >> M;
    adj.resize(N);
    seen.assign(N, 0);
    for(int i=0; i<M; i++){
        int a, b; cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int ans=0;
    for(int i=0; i<N; i++){
        if(seen[i]) continue;
        dfs(i);
        ans++;
    }
    ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9572
#include <iostream>

using namespace std;

int N;
int maxL, currentL;

int main()
{
    int last, current;

    cin >> N >> last;
    maxL = currentL = 1;

    for(int i = 2; i <= N; i++)
    {
        cin >> current;

        if(current <= last)
            {
                currentL++;
                maxL = max(maxL, currentL);
            }
        else
            currentL = 1;

        last = current;
    }

    cout << maxL - 1 << '\n';
    return 0;
}


Measured memory_bytes: 256