akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

//bitset<5010> left_field[5010], right_field[5010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, K; cin >> N >> K;
	vector<int>a(N); rep(i, 0, N)cin >> a[i];
	sort(all(a));
	int ans;

	//left_field[0][0] = right_field[0][0] = 1;
	//rep(i, 1, N + 1) {
	//	left_field[i] = left_field[i - 1];
	//	if (a[i] >= K)continue;
	//	rrep(j, 0, K - a[i]) {
	//		if (left_field[i][j]) {
	//			left_field[i][j + a[i]] = 1;
	//		}
	//	}
	//}
	//rep(i, 1, N + 1) {
	//	right_field[i] = right_field[i - 1];
	//	if (a[N + 1 - i] >= K)continue;
	//	rrep(j, 0, K - a[i]) {
	//		if (right_field[i][j]) {
	//			right_field[i][j + a[i]] = 1;
	//		}
	//	}
	//}

	//rep(i, 1, N + 1) {
	//	if (a[i] >= K) {
	//		ans--;
	//		continue;
	//	}
	//	// left_field[i-1]  right_field[N-i]
	//	rep(j, 0, K - a[i]) {
	//		// left_field[i-1][j] right_field[N-i][K-a[i]-j]
	//		bool f(false);
	//		rep(k, K - a[i] - j, K - j) {
	//			if (left_field[i - 1][j] && right_field[N - i][K - a[i] - j]) {
	//				f = true;
	//				break;
	//			}
	//		}
	//		if (f) {
	//			ans--;
	//			break;
	//		}
	//	}
	//}

	bool f[5010];
	int l(-1), r(N);
	while (r - l > 1) {
		int mid = (l + r) / 2;
		rep(i, 0, 5010)f[i] = 0;
		f[0] = true;
		if (a[mid] >= K) {
			r = mid;
			continue;
		}
		rep(j, 0, N) {
			if (mid == j)continue;
			rrep(k, a[j], K + 10) {
				f[k] = f[k - a[j]] || f[k];
			}
		}
		bool g(false);
		rep(k, K - a[mid], K)g = f[k] || g;

		if (g) r = mid;
		else l = mid;


		//rep(i, 0, K + 100)cout << i << (i == K + 100 - 1 ? '\n' : ' ');
		//rep(i, 0, K + 100)cout << f[i] << (i == K + 100 - 1 ? '\n' : ' ');
	}
	dump(l, r);
	cout << l+1  << endl;

	return 0;
}

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

typedef pair<int, int> pii;

pii A[100010];

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

	cin >> N;
	for(int i = 0; i < N; i++) cin >> A[i].first;

	for(int i = 0; i < N; i++) A[i].second = i + 1;
	sort(A, A + N);

	for(int i = 0; i < N; i++) cout << A[i].second << " ";
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    if(n == 3) {
        cout << "2 5 63\n";
        return 0;
    }
    if(n == 4) {
        cout << "2 5 20 63\n";
        return 0;
    }

    vector<ll> v00;
    for(ll i=2; i<29990; i+=6) v00.push_back(i);
    for(ll i=4; i<29992; i+=6) v00.push_back(i);
    v00.push_back(29990);
    v00.push_back(29992);
    v00.push_back(6);
    v00.push_back(29996);
    v00.push_back(29998);
    v00.push_back(12);
    vector<ll> v0, v3;
    REP(i, 7500) v0.push_back(v00[i]);
    FOR(i, 7500, 10002) v3.push_back(v00[i]);
    vector<ll> v1;
    for(ll i=3; i<30000; i+=6) v1.push_back(i);
    vector<ll> v2;
    for(ll i=18; i<=30000; i+=6) v2.push_back(i);

    dump(v0.size());
    dump(v1.size());
    dump(v2.size());
    dump(v3.size());

    REP(i, 20) cerr << v0[i] << " ";
    cerr << endl;
    REP(i, 20) cerr << v1[i] << " ";
    cerr << endl;
    REP(i, 20) cerr << v2[i] << " ";
    cerr << endl;
    REP(i, 20) cerr << v3[i] << " ";
    cerr << endl;

    vector<ll> ans;
    ll idx0 = 0, idx1 = 0;
    ll lim = min(2500LL, n/5);
    REP(i, lim) {
        ans.push_back(v0[idx0++]);
        ans.push_back(v0[idx0++]);
        ans.push_back(v0[idx0++]);
        ans.push_back(v1[idx1++]);
        ans.push_back(v1[idx1++]);
    }
    n -= lim*5;

    ll idx3 = 0;
    lim = min(834LL, n/3);
    dump(n, lim);
    REP(i, lim) {
        ans.push_back(v3[idx3++]);
        ans.push_back(v3[idx3++]);
        ans.push_back(v3[idx3++]);
    }
    n -= lim*3;

    ll idx2 = 0;
    dump(n);
    REP(i, n) ans.push_back(v2[idx2++]);

    REP(i, ans.size()) cout << ans[i] << (i+1==ans.size() ? '\n' : ' ');

    return 0;
}

Measured memory_bytes: 960
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  string s;
  int n;
  cin>>s;
  n=s.size();
  stack<char>st;
  int cnt=0;
  rep(i,n) {
    char a=s[i];
    if(a=='S') st.push('S');
    else {
      if(!st.empty()) {
        if(st.top()=='S') {
          st.pop();
        }
        else {
          st.push('T');
        }
      }
      else {
        st.push('T');
      }
    }
  }
  while(!st.empty()) {
    cnt++;
    st.pop();
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 644
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

void solve(){
  int n,C;
  cin>>n>>C;
  vector<vector<int>>g(1e5+100);
  vector<int>imos(1e5+100);
  set<pair<int,int>>st;
  vector<int>s(n),t(n),c(n);
  rep(i,n){
    cin>>s[i]>>t[i]>>c[i];
    st.emplace(t[i],c[i]);
  }
  rep(i,n){
    if(st.count({s[i],c[i]}))imos[s[i]]++;//同じチャンネルを連続で観ることができるかどうか
    else imos[s[i]-1]++;
    imos[t[i]]--;
  }
  int ans=1;
  rep(i,1e5+10)imos[i+1]+=imos[i],chmax(ans,imos[i+1]);
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <queue>

using namespace std;

int main() {
	int n; cin >> n;
	char a, b, t;
	queue<char> p;
	for (int i = 0; i < n; ++i) {
		cin >> t;
		p.push(t);
		if (p.size() == 2) {
			a = p.front(); p.pop(); b = p.front(); p.pop();
			if (a == 'T' && b == 'F') p.push('F');
			else p.push('T');
		}
	}
	cout << p.front() << endl;

	return 0;
}


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

  int N;
  string S;

int input(){
  cin>>N;
  cin>>S;
  return 0;
}
  
int main(){
  input();
  int ans=0;
  for (int i=0;i<1000;i++){
    string t=to_string(i);
    while(t.size()<3){
      t.insert(t.begin(),'0');
    }
    int n=0;
    for (int j=0;j<N;j++){

      if(t.at(n)==S.at(j)){
        n++;
      }
      if(n==3){
        ans++;
        //cout<<t<<endl;
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

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

    vector<vector<char>>a(n,vector<char>(n));
    vector<vector<char>>b(m,vector<char>(m));

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];

    for(int i=0;i<m;i++)
        for(int j=0;j<m;j++)
            cin>>b[i][j];
            
    bool ans=false;
    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++){
            bool flag=true;
            for(int k=0;k<m;k++){
                for(int l=0;l<m;l++){
                    if(a[k+i][l+j]!=b[k][l])
                        flag=false;
                }
            }
            if(flag)
                ans=true;
        }
    }

    ans?cout<<"Yes":cout<<"No";
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
l=int(input())
ans=[]
now=1
while l:
  if l%2==1:
    if l==1:break
    ans.append((now,20,l-1))
    l-=1
  if l==0:break
  ans.append((now,now+1,0))
  ans.append((now,now+1,l//2))
  now+=1
  l//=2
if now!=20:
  ans.append((now,20,0))
print(20,len(ans))
for a in ans:
  print(' '.join(map(str,a)))


Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13)
    cout<<b;
    else if(a>5 && a<13)
    cout<<b/2;
    else
    cout<<0;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
cin >> N;
set<string> S;
vector<string> vec(N);
bool ans = true;
string ab;
cin >> ab;
S.insert(ab);
char a = ab.at(ab.size()-1);
for (int i = 1;i < N;i++) {
    cin >> ab;
    if (S.count(ab)) ans = false;
    else if (ab.at(0) != a) ans = false;
    else {
        S.insert(ab);
        a = ab.at(ab.size()-1);
    }
}



if (ans == true) cout << "Yes" << endl;
else cout << "No" << endl;


return 0;
}


Measured memory_bytes: 256
N = int(input())
count = 0
TF = False
for i in range(N):
    Ds = list(map(int, input().split()))
    if  Ds[0] == Ds[1]:
        count += 1
    else:
        count = 0
    if count == 3:
        TF = True
        break

if TF:
    print('Yes')
else:
    print('No')


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

int main() {
  int n;
  cin >> n;
  if(n % 1000 == 0) {
    cout << 0 << endl;
  }else {
    cout << (n / 1000 + 1) * 1000 - n << endl;
  }

  return 0;
}


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

using namespace std;

int main() {
	int n;

	cin >> n;

	vector<string> s1(n);
	vector<int> v1(n);


	for (int i = 0;i < n;i++) {
		cin >> s1[i] >> v1[i];
	}

	vector<bool> s(13, false);
	vector<bool> h(13, false);
	vector<bool> c(13, false);
	vector<bool> d(13, false);

	for (int j = 0; j < n;++j) {
		if (s1[j] == "S") {
			s[v1[j] - 1] = true;
		}
		else if (s1[j] == "H") {
			h[v1[j] - 1] = true;
		}
		else if (s1[j] == "D") {
			d[v1[j] - 1] = true;
		}
		else if (s1[j] == "C") {
			c[v1[j] - 1] = true;
		}
	}

	for (int i = 0; i < 13; ++i) {
		if (s[i] == false) {
			cout << "S " << i + 1 << endl;
		}
	}

	for (int i = 0; i < 13; ++i) {
		if (h[i] == false) {
			cout << "H " << i + 1 << endl;
		}
	}

	for (int i = 0; i < 13; ++i) {
		if (c[i] == false) {
			cout << "C " << i + 1 << endl;
		}
	}

	for (int i = 0; i < 13; ++i) {
		if (d[i] == false) {
			cout << "D " << i + 1 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
int main(){
  long double a,b,h,m;
  cin>>a>>b>>h>>m;
//  h+=m/60;
  long double A=(h+m/60)/12*2*PI,B=m/60*2*PI;
  
  
   // float ans=sqrt(a*a+b*b-2*a*b*cos(A-B));
//   cout<<fixed<<setprecision(30)<<sqrt(a*a+b*b-2*a*b*cos(B-A))<<endl;
  
  
    // float ans=sqrt(a*a+b*b-2*a*b*cos(B-A));
   cout<<fixed<<setprecision(30)<<sqrt(a*a+b*b-2*a*b*cos(B-A))<<endl;
    

}


Measured memory_bytes: 4164
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int l[201];

int main(void){
	scanf("%d",&n);
	int res=0;
	for(int i=0;i<n*2;i++){
		scanf("%d",&l[i]);
	}
	sort(l,l+n*2);
	for(int i=0;i<n*2;i+=2){
		res+=l[i];
	}
	printf("%d\n",res);
	return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(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++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int n, k;
int r, s, p;
bool f[N + 1];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    //ms(f, -1);
    string t;
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;
    ll res = 0;
    FOR(i, 0, n - 1)
    {
        if(f[i] == 0)
        {
            char ch = t[i];
            int j = i;
            int d = 0;
            while(j < n && ch == t[j] && f[j] == 0)
            {
                d++;
                f[j] = 1;
                j += k;
            }
            f[i] = 1;
            if(ch == 'p') res += ((d + 1) / 2) * s;
            if(ch == 'r') res += ((d + 1) / 2) * p;
            if(ch == 's') res += ((d + 1) / 2) * r;
           // cout << d << " " << res << endl;
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int qmin(int a, int b){
	return (a < b) ? a : b;
}

int A, B, M;
int a[100100], b[100100];
int x, y, c;
int mn1 = 0x3f3f3f3f, mn2 = 0x3f3f3f3f;
int ans = 0x3f3f3f3f;

int main(){
	scanf("%d%d%d", &A, &B, &M);
	rep(i, A){
		scanf("%d", &a[i]);
		mn1 = qmin(mn1, a[i]);
	}
	rep(i, B){
		scanf("%d", &b[i]);
		mn2 = qmin(mn2, b[i]);
	}
	ans = mn1 + mn2;
	rep(i, M){
		scanf("%d%d%d", &x, &y, &c);
		x--, y--;
		ans = qmin(ans, a[x] + b[y] - c);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (k, x) = get!(i32, i32);
    let start = std::cmp::max(-1000000, x - k + 1);
    let goal = std::cmp::min(x + k - 1, 1000000);
    // eprintln!("{}", start);
    // eprintln!("{}", goal);
    let mut ans = String::new();
    for i in start..goal + 1 {
        ans += &i.to_string();
        ans += &" ".to_string();
    }
    ans.pop();
    println!("{}", ans);
}


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

int main() {

  int N , M ;
  cin >> N >> M ;
  if( N >= 10) cout << M <<endl ;
  else cout << 100*(10 - N ) + M << endl;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  int M = max(max(a, b), c);
  if(M == a){
    cout << a*10 + b + c << endl;
  }else if(M == b){
    cout << M*10 + a + c << endl;
  }else{
    cout << M*10 + a + b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     cin>>n;
     ll sum=0;
     for(i=1;i<=n;i++)
     {
      for(j=1;j<=n;j++)
      {
        for(k=1;k<=n;k++)
        {
          sum+=__gcd(i,__gcd(j,k));
        }
      }
     }
     cout<<sum;
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 3788
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
max = a.max
num = Array.new(max+1,0)
ans = 0
n.times do |i|
  if a[i] != max
    num[a[i] + 1] += 1
    ans = num[a[i]+1] if ans < num[a[i]+1]
  end
  if a[i] != 0
    num[a[i] - 1] += 1
    ans = num[a[i]-1] if ans < num[a[i]-1]
  end
  num[a[i]] += 1
  ans = num[a[i]] if ans < num[a[i]]
end
puts ans

Measured memory_bytes: 21920
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
int a[100005];
bool upflag = false;
bool downflag = false;
int ans = 1;
int pre;
/**********************************************/

int main(){
    cin >> n;
    REP(i, n){
        cin >> a[i];
    }
    
    pre = a[0];
    FOR(i, 1, n){
        if(!upflag && !downflag){
            if(pre < a[i]) upflag = true;
            else if(pre > a[i]) downflag = true;
        }else if(upflag){
            if(pre > a[i]){
                upflag = false;
                ans++;
            }
        }else{
            if(pre < a[i]){
                downflag = false;
                ans++;
            }
        }
        pre = a[i];
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
from sys import stdin
from sys import maxsize


def two_div(l):
    divs = []
    if l == 2:
        return [(1,1)]
    if l == 3:
        return [(2,1)]
    preL = 0
    for m in range(l-1,l//2 -1,-1):
        if preL == l-m:
            break
        divs.append((m,l-m))
        preL = m
    return divs


def three_div(mmm):
    if mmm == 3:
        return[(1,1,1)]
    if mmm == 4:
        return[(2,1,1)]
    divs = []
    rest = 1
    for m in range(mmm-2,mmm//3 -1,-1):
        rest += 1
        two_c = two_div(rest)
        for t in two_c:
            if m < t[0]:
                continue
            c = (m,t[0],t[1])
            divs.append(c)
    return divs

def triple(x,y,z):
    v = x*x + y*y + z*z + x*y + y*z + z*x
    return v

def main():
    n = int(input())
    # n = 10000
    ans = [0] * (n+1)
    for goukei in range(3,300):
        mini = maxsize
        factors = three_div(goukei)
        # print("================")
        for x,y,z in factors:
            # print(x,y,z)
            v = triple(x,y,z)
            # print("=>"+str(v))

            if x == y and y == z and v <= n:
                # print("1")
                # print(x,y,z)
                ans[v] += 1
            elif x!=y and y!=z and z!=x and v <= n:
                # print("6")
                # print(x,y,z)
                ans[v] += 6  
            elif v <= n:
                # print("3")
                # print(x,y,z)
                ans[v] += 3

            if mini > v:
                mini = v
        if mini >= n:
            break

    for i in range(1,n+1):
        # print(str(i) + ":" +str(ans[i]))
        print(ans[i])
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  ll a,b;cin>>a>>b;
  for(int i=1;i<=b;i++){
    if((a*i)%b==0){
      cout<<a*i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>M;
    mat G(N, vec(N, 0));
    rep(i,M){
        cin>>A>>B;
        --A, --B;
        G[A][B] = G[B][A] = 1;
    }
    vec ord(N - 1);
    rep(i,N-1) ord[i] = i + 1;
    ll ans = 0;
    do{
        ll v = 0;
        bool ok = true;
        for(ll to : ord){
            ok = ok & G[v][to];
            v = to;
        }
        ans += ok;
    }while(next_permutation(ALL(ord)));
    cout<<ans<<endl;
}

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

ll an[100001];

int main(){
	int n;
	scanf("%d", &n);
	priority_queue<pair<int, int> > q;
	q.push(make_pair(0, 0));
	f(i, 1, n + 1){
		int t;
		scanf("%d", &t);
		q.push(make_pair(t, i));
	}
	int l = q.top().first, v = q.top().second, s = 1;
	q.pop();
	while (!q.empty()){
		int d = l - q.top().first;
		an[v] += (ll)d * s;
		++s;
		l = q.top().first;
		v = min(v, q.top().second);
		q.pop();
	}
	f(i, 1, n + 1)printf("%lld\n", an[i]);
}


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

int main(){
    string a,b;
    cin >> a >> b;
    string c = a + b;
    int ans = stoi(c);
    for(int i=0; i < 400 ;i++){
        if(i*i == ans){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int answer=0;
    if(a==b){
      answer=c;
    }else if(a==c){
      answer=b;
    }else{
      answer=a;
    }
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int A[3][3];
bool marked[3][3];

int main(){
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> A[i][j];
            marked[i][j] = false;
        }
    }

    int N;
    cin >> N;

    vector<int> b(N);
    for (int i = 0; i < N; i++){
        cin >> b.at(i);
    }

    for (int k = 0; k < N; k++){
        for (int i = 0; i < 3; i++){
            for (int j = 0; j < 3; j++){
                if (A[i][j] == b[k]){
                    marked[i][j] = true;
                }
            }
        }
    }

    string ans = "No";
    for (int i = 0; i < 3; i++){
        if ((marked[i][0] && marked[i][1] && marked[i][2]) || (marked[0][i] && marked[1][i] && marked[2][i]))
            ans = "Yes";
    }

    if ((marked[0][0] && marked[1][1] && marked[2][2]) || (marked[2][0] && marked[1][1] && marked[0][2])){
        ans = "Yes";
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b) {
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

int main() {
  int a, b, c, tmp;
  scanf("%d %d %d", &a, &b, &c);
  if (a > b) swap(&a, &b);
  if (b > c) swap(&b, &c);
  if (a > b) swap(&a, &b);
  printf("%d %d %d\n", a, b, c);
  return 0;
}



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

using namespace std;

int p[10];

int main () {
    cin >> p[0] >> p[1] >> p[2];
    sort(p, p + 3);
    if (p[0] == 5 && p[1] == 5 && p[2] == 7) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
import math
class Point:
	def __init__(self,x,y):
		self.x=x
		self.y=y
	def __str__(self):
		return str(self.x)+' '+str(self.y)
	
def koch(n,a,b):
	if n==0: return
	s=Point(0,0)
	t=Point(0,0)
	u=Point(0,0)
	th=math.pi*60/180
	s.x=(2*a.x+1*b.x)/3
	s.y=(2*a.y+1*b.y)/3
	t.x=(1*a.x+2*b.x)/3
	t.y=(1*a.y+2*b.y)/3
	u.x=(t.x-s.x)*math.cos(th)-(t.y-s.y)*math.sin(th)+s.x
	u.y=(t.x-s.x)*math.sin(th)+(t.y-s.y)*math.cos(th)+s.y
	
	koch(n-1,a,s)
	print(s)
	koch(n-1,s,u)
	print(u)
	koch(n-1,u,t)
	print(t)
	koch(n-1,t,b)

n=int(input())
a=Point(0,0)
b=Point(100,0)
print(a)
koch(n,a,b)
print(b)



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

int main() {
  
  string s;
  cin >> s;
  
  int a = 0;
  int b = 0;
  
  for(int i = 0; i < 3; i++){
    
    if(s.at(i) == 'A') a++;
    if(s.at(i) == 'B') b++;

  }
  
  if(a == 3 || b == 3){
    cout << "No" <<endl;
  }
  else{
    cout << "Yes" << endl;
  }
}



Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007LL;

int main(void) {
    string S;
    cin >> S;
    int Y, M, flag = 0;
    Y = (S[0]-'0')*10 + (S[1]-'0');
    M = (S[2]-'0')*10 + (S[3]-'0');
    if (Y <= 12 && Y >= 1) flag |= 2;
    if (M <= 12 && M >= 1) flag |= 1;
    if ((flag & 3) == 3) cout << "AMBIGUOUS" << endl;
    else if (flag & 2) cout << "MMYY" << endl;
    else if (flag & 1) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    rep(i, 0, n+3){
        mp[i] = 1;
    }
    mp[n+1] = 0;
    mp[n+2] = 0;
    rep(i, 0, m){
        int k;
        cin >> k;
        mp[k] = 0;
    }
    ll mod = 1000000007;
    for(int i = n-1; i >= 0; i--){
        if(mp[i] == 0 && mp[i-1] == 0){
            cout << 0 << endl;
            return 0;
        }
        else if(mp[i]){
            mp[i] = (mp[i+1] + mp[i+2]) % mod;
        }
    }
    cout << mp[0] << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


ll h,w,k; 
ll dp[105][10];
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN

    ll n,t;cin>>n>>t;
    ll mn = mod;
    REP(i,n){
        ll c, tt;cin>>c>>tt;
        if (t>=tt){
            mn = min(mn,c); 
        }
    }
    if(mn == mod) {
        cout<<"TLE"<<endl;
        return 0;
    }
    cout<<mn<<endl;
    return 0;

}

Measured memory_bytes: 256
/*
   Author: Shivam Shukla
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();

    int n; cin >> n;
    vl a(n), cnt(n); 
    repa(i, n) cin >> a[i], cnt[a[i] - 1]++;
    
    ll s = 0;
    repa(i, n)
       s += (cnt[i] * (cnt[i] - 1)) >> 1;
    
    repa(i, n) 
      cout << (s - cnt[a[i] -  1] + 1) << endl;
    
    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
}

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

typedef pair<int, int> P;
typedef long long ll;


#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPTO(i, n) for(int i = 0; i <= n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定

int strlen(char *s)
{
	int i = 0;
	while(s[i] != '\0'){
		i++;
	}
	return i;
}

int main(){
    char S[20];
    char T[20];
    cin >> S >> T;
    int ans=0;
    for(int i=0; i<strlen(S);i++){
        if(S[i]==T[i]){
        }
        else{
            ans = 1;
        }
    }
    if(ans==0){
        if(strlen(T)-strlen(S)==1){
                cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        cout << "No" << endl;
    }



  
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N =2 * 1e5 + 123;
int n , a[N] , p[40] , ans;
map < int , int > cnt;
multiset < int > st;
main(){
	scanf("%lld" , &n);
	p[0] = 1;
	for(int i = 1 ; i <= 33 ; i++)
		p[i] = p[i - 1] * 2ll;
	for(int i = 1 ; i <= n ; i++){
		scanf("%lld" , &a[i]);
		st.insert(a[i]);
	}
	
	while(!st.empty()){
		int x = *st.rbegin();
		st.erase(st.find(x));
		int id = 0;
		while(p[id] <= x)
			++id;
		auto it = st.find(p[id] - x);
		if(it != st.end()){
			++ans;
			st.erase(it);
		}
	}
	cout << ans ;
	return 0;
}

Measured memory_bytes: 11136
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll INF=1e18;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    pll m=make_pair(-1,-1);
    rep(i,n){
        cin >> a[i];
        if(a[i]>m.fi){
            m.fi=a[i];
            m.se=i;
        }
    }
    pll diff=make_pair(INF,-1);
    rep(i,n){
        if(i==m.se) continue;
        if(abs(m.fi-2*a[i])<diff.fi){
            diff.fi=abs(m.fi-2*a[i]);
            diff.se=i;
        }
    }
    cout << m.fi << " " << a[diff.se] << endl;
} 


Measured memory_bytes: 1024
program main
implicit none
character(len=10) :: c, s
integer :: nlen, nsum, nslen
integer :: i, j, k,m
integer, allocatable :: nc(:,:)
read(*,*) c
nlen = len_trim(c)
!nsum = nlen*(nlen+1)/2
allocate(nc(nlen,nlen))

do i = 1, nlen
   do j = i, nlen
      s = c(i:j)
     nslen=len_trim(s)
      nc(i,j) = 0
      do k = 1, nslen
         if ( s(k:k) == 'A'.or.s(k:k) == 'T'.or.s(k:k) == 'C'.or.s(k:k) == 'G') then
            nc(i,j) = nc(i,j)+1
         else 
            nc(i,j) = 0
         end if
      end do
   end do
end do

m = 0
do i = 1, nlen
do j = i, nlen
    if( nc(i,j) >= m) then
       m = nc(i,j)
    end if
end do
end do

write(*,'(i0)') m

end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//FILE *fi = freopen("1.txt", "r", stdin);
//FILE *fo = freopen("1", "w", stdout);
string s;
int main()
{
    cin >> s;
    int cur = 0;
    int ans = 0;
    for (auto x : s)
    {
        if (x == 'R')
            cur++;
        else
        {
            cur = 0;
        }
        ans = max(ans, cur);
    }
    cout << ans;
    return 0;
}

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

int main() {
  
  int a=0, b=0, c=0, d=0, e=0, k=0;
  
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> k;
  
  int l = e-a;
  
  if(k<l) {
    
    cout << ":(" << endl;
    
  } else if(l<=k) {
    
    cout << "Yay!" << endl;
    
  }
  
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j * i <= n; j++) {
            int k = n - i * j;
            if (k > 0) ++ans;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,W; cin >> n >> W;
    vl v(n),w(n);
    rep(i,n) cin >> v[i] >> w[i];
    ll dp[n+1][W+1] = {};
    rep(i,n){
        rep(j,W+1){
            dp[i+1][j] = dp[i][j];
            if(j-w[i]>=0) dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i]);
        }
    }
    cout << dp[n][W] << endl;
}


Measured memory_bytes: 10980
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld\n",x)
#define print2(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 333333

ll x[111], y[111], h[111];

int main(void) {
  cin >> n;
  ll xx, yy, hh;
  rep(i, n) cin >> x[i] >> y[i] >> h[i];
  rep(i, 101) {
	rep(j, 101) {
	  rep(k, n) if (h[k]) {
		hh = h[k] + abs(x[k] - i) + abs(y[k] - j);
	  }
	  ok = true;
	  rep(k, n) {
		if (h[k] == max(hh - abs(x[k] - i) - abs(y[k] - j), 0LL))  continue;
		ok = false;
	  }
	  if (!ok) continue;
	  xx = i;
	  yy = j;
	  if (ok) break;
	}
	if (ok) break;
  }
  cout << xx << " " << yy << " " << hh << endl;

  return 0;
}

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

int main(void)
{
    int n = 0;
    cin >> n;
    int tmp = 0;
    int countMinus = 0;
    unsigned long long sum = 0;
    int min = 1000000001;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        if (tmp < 0)
        {
            countMinus++;
        }
        tmp = abs(tmp);
        sum += tmp;
        if(min > tmp) {
            min = tmp;
        }
    }


    if(countMinus & 1) {
        cout << sum - min * 2 << endl;
    }
    else {
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 256
///                ..:: In The Name Of God ::..
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define endl    'n'
#define INF 2e9
#define int ll
#define vi          vector<int>
#define de          deque<int>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()//全範囲指定を簡略化
typedef long long ll;
using namespace std;
int l,i=0,a[10];
//配列の要素数は　sizeof(ar)/sizeof(ar[0]) で求める
signed main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    while(cin>>l){
        a[i] = l;
        i++;
    }
    if(a[3]==1){
        cout << 1;
    }
    else{
        cout << 0;
    }
}

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

ans = N

for k in range(50):
    left, right = 1, int(pow(N, 1/(k+1))) + 1
    while left + 1 < right:
        mid = (left + right) >> 1
        if mid ** (k+1) >= N:
            right = mid
        else:
            left = mid
    for i in range(k+1):
        if ((right - 1) ** i) * (right ** (k+1 - i)) >= N:
            ans = min(ans, A * k + i * (right - 1) + (k+1 - i) * right)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll  long long int
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
const int inf=1e9+5;
ll n,k;
const int N = 1e5+5;
ll ar[N];
/*bool vis[N];
ll a[N];*/
/*bool sortinrev(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
     return (a.f>b.f);
}*/
void solve()
{   ll m,y,x,res=0,l,r,cnt0=0,z,sum1=0,cnt1=0,h,res1,ans=0,sum=0;
    scanf("%d", &n);
    scanf("%d", &k);
    //cin>>n>>k;
    rep(i,0,n) scanf("%d", &ar[i]);
    vector<ll> dp(n,inf);
    dp[0]=0;
    //dp[1]=abs(ar[0]-ar[1]);
    for(ll i=0;i<n;++i)
    {
        for(ll j=i+1;j<=i+k;++j)
            if(j<n)
            dp[j]=min(dp[i]+abs(ar[i]-ar[j]),dp[j]);
    }
    printf("%d",dp[n-1]);
    //cout<<dp[n-1];
}
int main()
{   //speed_up
    ll t;
   //cin>>t;
    t=1;
    while(t--)
        solve();

}


Measured memory_bytes: 1792
($N,$M,$K)=glob<>;
map$s+=$_,@X=glob<>;
@Y=glob<>.$K;
$i=$N;
until($i<0){$s+=$Y[$j++]until$Y[$j]+$s>$K;$s>$K||($\+=$-=$i+$j-$\);$s-=$X[--$i]}
print

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

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		int[] in=new int[10];
		for(int i=0;i<10;i++)
			in[i]=Integer.parseInt(reader.readLine());
		Arrays.sort(in);
		System.out.println(in[9]);
		System.out.println(in[8]);
		System.out.println(in[7]);
	
	}
}

Measured memory_bytes: 17016
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;

void init() {
}

char strbuf[100];
vector<string> S;
void solve(int n) {
    S.resize(n);
    for (int i = 0; i < n; i++) {
        scanf("%s", strbuf);
        S[i] = strbuf;
    }
    for (int i = 0; i < n; i++) {
        int dot = 0;
        while (dot < S[i].length() && S[i][dot] == '.') ++dot;
        if (dot) {
            if (dot > 1) S[i] = string(dot - 1, ' ') + "+" + S[i].substr(dot);
            else S[i] = "+" + S[i].substr(dot);
        }
    }
    //for (string s : S) cout<<s<<endl;cout<<endl;
    for (int i = 0; i < n; i++) {
        int plus = 0;
        while (plus < S[i].length() && S[i][plus] != '+') ++plus;
        if (plus == S[i].length()) continue;
        for (int j = i - 1; j >= 0; j--) {
            if (S[j][plus] != ' ') {
                //DEBUG(S[j][plus])
                //assert(S[j][plus] == '+');
                break;
            }
            S[j][plus] = '|';
        }
    }
    for (string s : S) {
        printf("%s\n", s.c_str());
    }
    S.clear();
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    init();
    while (cin >> n, n) {
        solve(n);
    }
}

Measured memory_bytes: 3920
#include <stdio.h>
int main(void){
	int n, a, b;
	scanf("%d", &n);
	b = n % 100;
	a = (n - b) / 100;
	if(1 <= a && a <= 12 && (b == 0 || b >= 13)){
		printf("MMYY\n");
	}else if(1 <= b && b <= 12 && (a == 0 || a >= 13)){
		printf("YYMM\n");
	}else if(1 <= a && a <= 12 && 1 <= b && b <= 12){
		printf("AMBIGUOUS\n");
	}else{
		printf("NA\n");
	}
	return 0;
}

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

int a(int input){
	int yakushiroyo = 1;
	if(ceil(sqrt(input))!=floor(sqrt(input))){
		for(int i = 2;i <= ceil(sqrt((int)input));i++){
			if(input%i==0){
				yakushiroyo+=2;
			}
		}
	}
	yakushiroyo++;
	return yakushiroyo;
}

int main() {
	int n,c;
	c=0;
	cin >> n;
	for(int i = 5;i<= n;i=i+2){
		if(a(i)==8){
			c++;
		}
	}
	cout << c << endl;
	return 0;
}

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

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

  if (a * b % 2 == 1) {
    cout << "Odd" << endl;
  }  
  if (a * b % 2 == 0) {
    cout << "Even" << endl; 
  }
}



Measured memory_bytes: 256