akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

int main() {
  string S;
  vector<long long> v;
  cin >> S;
  long long N = S.size();
  long long key = 0;
  char k[2] = {'R', 'L'};
  rep(i, N) {
    if(S[i] == k[key]) continue;
    else {
      v.push_back(i-1);
      key = key ^ 1;
    }
  }
  v.push_back(N-1);
  long long ans[100000] = {0};
  rep(i, v.size()) {
    if(i % 2 == 1) continue;
    if(i == 0) {
      ans[v[i]] += (v[i] + 2) / 2;
      ans[v[i]] += (v[i+1]-v[i]) / 2;
      ans[v[i]+1] += (v[i] + 1) / 2;
      ans[v[i]+1] += (v[i+1]-v[i]+1) / 2;
    } else {
      ans[v[i]] += (v[i]-v[i-1]+1) / 2;
      ans[v[i]] += (v[i+1]-v[i]) / 2;
      ans[v[i]+1] += (v[i]-v[i-1]) / 2;
      ans[v[i]+1] += (v[i+1]-v[i]+1) / 2;
    }
  }
  rep(i, N) {
    cout << ans[i];
    if(i != N-1) cout << " ";
    else cout << endl;
  }
  return 0;
}

Measured memory_bytes: 5000
import numpy as np
a, b, x = map(int, input().split())
init = x / pow(a, 2)

if pow(a, 2) * b == x:
    print(0)
    exit()

tan = (2 * b - (2 * x) / pow(a, 2)) / a
if 0 < b - a * tan < init:
    ans = np.rad2deg(np.arctan(tan))
    print(ans)
    exit()
    
tan = pow(b, 2) * a / (2 * x)
if 0 < b / tan <= a:
    ans = np.rad2deg(np.arctan(tan))
    print(ans)
    exit()

print(90)

Measured memory_bytes: 12484
A = [0]*3
nums = set([])
for i in range(3):
    A[i] = list(map(int,input().split()))
    for j in A[i]:
        nums.add(j)
N = int(input())

for i in range(N):
    b = int(input())
    if b in nums:
        for i in range(3):
            try:
                ind = A[i].index(b)
                A[i][ind] = 0
            except ValueError:
                continue

ans = 0
for i in range(3):#行ベクトル
    if sum(A[i]) == 0:
        ans += 1

for j in range(3):#列ベクトル
    tmp = 0
    for k in range(3):
        tmp += A[k][j]
    if tmp == 0:
        ans += 1

tmp = 0
tmp2 = 0
for m in range(3):
    tmp += A[m][m]
    tmp2 += A[m][-m-1]
if tmp == 0:
    ans += 1
if tmp2 == 0:
    ans += 1

if ans > 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n,q = gets.chomp.split.map(&:to_i)
s = gets.chomp
qs = q.times.map{gets.chomp.split.map(&:to_i)}
array = Array.new(s.size,0)
count = 0
1.upto(s.size-1) do |i|
  if s[i-1..i] == "AC"
    count += 1
    array[i] = count
  else
    array[i] = count
  end
end

qs.each do |l,r|
  puts array[r-1] - array[l-1]
end


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

int main(){
	int N,W;
	cin>>N>>W;

	int v[1000],w[1000];
	for(int i=0;i<N;i++)
		cin>>v[i]>>w[i];

	static int DP[101][10001];
	for(int i=0;i<=N;i++)
		DP[i][0]=0;
	for(int j=0;j<=W;j++)
		DP[0][j]=0;

	for(int i=1;i<=N;i++){
		for(int j=0;j<=W;j++){
			if(j<w[i-1])
				DP[i][j]=DP[i-1][j];
			else{
				if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1])
					DP[i][j]=DP[i-1][j];
				else
					DP[i][j]=DP[i-1][j-w[i-1]]+v[i-1];
			}
		}
	}
	
	cout<<DP[N][W]<<endl;
	
	return 0;
}

	

Measured memory_bytes: 7052
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 30001
int first[10]; //0 ~ 9
int last[10]; // 0 ~ 9
bool syutugen[10];
int main() {
    int n;
    string s;
    cin >> n >> s;
    memset(syutugen, false, sizeof(syutugen));
    for (int i = 0; i < n; i++) {
        if (!(syutugen[s[i] - '0'])) {
            first[s[i] - '0'] = i;
        }
        syutugen[s[i] - '0'] = true;
        last[s[i] - '0'] = i;
    }
    int count = 0;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            for (int k = 0; k <= 9; k++) {
                if ((syutugen[i]) && (syutugen[k]) && (syutugen[j])) {
                    bool ok = false;
                    for (int l = first[i] + 1; l <= last[k] - 1; l++) {
                        if (s[l] - '0' == j) {
                            ok = true;
                        }
                    }
                    if (ok) {
                        count++;
                    }
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {1, 0}, dy[] = {0, 1};
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int add(int a, int b){return  a + b > mod ? a + b - mod : a + b;}
int mul(int a, int b){return a * b >= mod ? a * b % mod : a * b;} 
int main(){
    //FL;
    FIN;
    int n;
    cin >> n;
    map<string, int> m;
    w(n){
        string str;
        cin >> str;
        m[str]++;
    }
    cout << "AC" << " x " << m["AC"] << '\n';
    cout << "WA" << " x " << m["WA"] << '\n'; 
    cout << "TLE" << " x " << m["TLE"] << '\n';
    cout << "RE" << " x " << m["RE"] << '\n'; 
    EjecuteTime;
    return 0;
}       

Measured memory_bytes: 3848
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n1,n2,minv,maxv,i;
  while(cin >> n1){
    cin >> n2;
    minv=min(n1,n2);
    maxv=1;
    for(i=1;i<=minv;i++){
      if(n1%i==0&&n2%i==0) maxv=max(maxv,i);
    }
    cout << maxv << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn = 1e9 + 7;

int n, k;

int main() {
  cin >> n >> k;
  if(k > (n + 1)/ 2) {
    cout << "NO";
  }
  else 
    cout << "YES";
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)












 
int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    REP(i, n){
        ll h;
        cin >> h;
        if(h >= k) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
int main(void) {
  int N;
  cin >> N;
  
  int d = 1000000007;
  vector<int64_t> B(N+1,0);
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
    B[i+1] = B[i] + A[i];
  }
  
  int64_t ans = 0;
  for(int i=0; i<N; i++){
    int64_t sum = (B[N]-B[i+1])%d;
    ans += sum*A[i];
    ans %= d;
  }
  
  cout << ans << endl;
  
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

typedef array<ll,4> tile;

void normalize(tile &t) {
	tile rt = t;
	FOR(dir,0,4) {
		t = min(t,rt);
		rotate(begin(rt),begin(rt)+1,end(rt));
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vector<tile> c(n);
	map<tile,ll> cnt;
	FOR(i,0,n) {
		FOR(j,0,4) cin >> c[i][j];
		normalize(c[i]);
		cnt[c[i]]++;
	}

	ll res = 0;
	FOR(i,0,n) {
		cnt[c[i]]--;
		FOR(j,i+1,n) {
			cnt[c[j]]--;
			FOR(dir,0,4) {
				tile t[4];
				t[0] = {c[i][0],c[i][3],c[j][0],c[j][3]};
				t[1] = {c[i][3],c[i][2],c[j][1],c[j][0]};
				t[2] = {c[i][2],c[i][1],c[j][2],c[j][1]};
				t[3] = {c[i][1],c[i][0],c[j][3],c[j][2]};
				map<tile,ll> ccnt;
				ll cur = 1;
				FOR(k,0,4) {
					normalize(t[k]), ccnt[t[k]]++;
					tile rt = t[k];
					ll rot = 0;
					FOR(dir2,0,4) {
						if (rt == t[k]) rot++;
						rotate(begin(rt),begin(rt)+1,end(rt));
					}
					cur *= rot;
				}
				for (const auto &p: ccnt) {
					ll have = has(cnt,p.xx) ? cnt[p.xx] : 0, need = p.yy;
					FOR(k,0,need) cur *= have-k;
				}
				res += cur;
				rotate(begin(c[j]),begin(c[j])+1,end(c[j]));
			}
			cnt[c[j]]++;
		}
	}
	cout << res << endl;
}



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

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef vector<vector<int>> graph;

inline bool check(const vector<pair<int, int>> &range1, const vector<pair<int, int>> &range2) {
	const int m = range1.size();
	for(int i = 0; i < m; ++i) {
		if(range1[i].second < range2[i].first) return true;
	}
	return false;
}

bool find_loop(const graph &G) {
	const int n = G.size();

	vector<int> in_degree(n, 0);
	for(int v = 0; v < n; ++v) {
		for(const auto &to : G[v]) {
			++in_degree[to];
		}
	}

	queue<int> que;
	for(int v = 0; v < n; ++v) {
		if(in_degree[v] == 0) que.push(v);
	}

	int cnt = 0;
	while(!que.empty()) {
		const int v = que.front();
		que.pop();

		++cnt;

		for(const auto &to : G[v]) {
			if(--in_degree[to] == 0) que.push(to);
		}
	}

	return cnt < n;
}

bool solve() {
	int n, m;
	cin >> n >> m;

	vector<vector<pair<int, int>>> range(n, vector<pair<int, int>>(m, pair<int, int>(0, 100)));

	for(int i = 0; i < n; ++i) {
		int k;
		cin >> k;

		for(int j = 0; j < k; ++j) {
			int a, b;
			string s;
			cin >> a >> s >> b;

			if(s[0] == '>') {
				chmax(range[i][a - 1].first, b);
			}
			else {
				chmin(range[i][a - 1].second, b);
			}
		}

		for(int j = 0; j < m; ++j) {
			if(range[i][j].first > range[i][j].second) return false;
		}
	}

	graph G(n);
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			if(i == j) continue;
			if(check(range[i], range[j])) G[i].emplace_back(j);
		}
	}

	return !find_loop(G);
}

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

	cout << (solve() ? "Yes" : "No") << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1360
import java.util.Scanner;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		for(;num > 1000;) {
			num -= 1000;
		}
		System.out.println(1000-num);
	}
}

Measured memory_bytes: 35392
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct edge{
    int to;
    int cost;
};
vector<vector<edge>> g;

void dijkstra(int s,vector<int> &d) {
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> que;
    for(int &x : d) x = INF;
    d[s] = 0;
    que.push(make_pair(0, s));
    
    while(!que.empty()) {
        pair<int,int> p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        
        rep(i,g[v].size()) {
            edge e = g[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
}

int main(){
    int n;
    cin>>n;
    g.resize(n);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        edge x = {b,1};
        edge y = {a,1};
        g[a].push_back(x);
        g[b].push_back(y);
    }
    
    vector<int> fennec(n);
    dijkstra(0,fennec);
    vector<int> snuke(n);
    dijkstra(n-1,snuke);
    
    int f=0,s=0;
    rep(i,n){
        if(fennec[i]<=snuke[i]) f++;
        if(fennec[i]>snuke[i]) s++;
    }
    if(f>s)  cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
    
    //cout<<f<<" "<<s<<endl;
}


Measured memory_bytes: 7364
import java.io.*;
import java.math.BigDecimal;
import java.util.*;


// 2011/10/22

//0216@¹¿à
public class Main {

	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		int[] ir = readIntArray();
		int w = ir[0];
		if (w == -1)
			return false;

		int r;
		if (w > 30) {
			r = 1150 + 1250 + 1400+ (w-30)*160;
		}
		else if (w > 20) {
			r = 1150 + 1250 + (w-20)*140;
		}
		else if (w > 10) {
			r = 1150 + (w-10)*125;
		}
		else {
			r = 1150;
		}
		
		
		// ðÌ\¦
		System.out.printf("%d\n", 4280 - r);
		
		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "29:0:";

			inputStr = inputStr.replace(":", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		//int N = readIntArray()[0];

		for(int i = 0; /*i < N*/; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌXy[XæØèÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {
		
		String s = reader.readLine();
		if (s == null)
			return null;
		String[] sp = s.split(" ");
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[201];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1,a2,a3,a4;
    //float f,g,h;
    //char now,pre;
    string s,s1;
    cin>>a1>>a2;
    m=a2;
    while(m>0)
    {
        a1*=10;
        m/=10;
    }
    a1+=a2;
    a2=(int)sqrt(a1);
    if(a2*a2==a1) cout<<"Yes";
    else cout<<"No";
    return 0;
}



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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int n,k;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> k;

  double p = 0.0;

  for (int i = 1; i <= n; i++) {
    double temp = 1.0/n;
    if (i < k) {
      int point = i;
      while (point < k) {
        point *= 2;
        temp *= 0.5;
      }
    }
    p += temp;
  }

  printf("%.15f\n", p);


  return 0;
}


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

int main(void)
{
  int n, k, height, count=0;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> height;
    if (height >= k) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
#define endl "\n" 
//#pragma GCC optimize(2)
using namespace std;
//typedef complex<double>C;
//const double PI(acos(-1.0));
//const double eps(1e-8);
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int s=0;while(x){s+=BIT[x];x-=x&-x;}return s;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
const int N=1e5+10;
const int M=1e9+7;
int n;
deque<PII>q;
int main(){Accel
    cin>>n;
    q.push_front(MP(1,1));
    bitset<N>s;
    while(SZ(q)){
		int cst=q.front().S;
		int num=q.front().F;
		q.pop_front();
		if(s[num])continue;
		s[num]=1;
		if(!num){
			cout<<cst<<endl;return 0;
		}
		q.push_front(MP(num*10%n,cst));
		q.push_back(MP((num+1)%n,cst+1));
	}
}


Measured memory_bytes: 1152
#include <cstdio>

inline int min(const int &a, const int &b) {
	return a < b ? a : b;
}

#define siz 10000000

char buf[siz], *bit = buf;

inline int nextInt(void) {
	register int ret = 0;
	register int neg = false;
	
	for (; *bit < '0'; ++bit)
		if (*bit == '-')neg ^= true;
	
	for (; *bit >= '0'; ++bit)
		ret = ret * 10 + *bit - '0';
	
	return neg ? -ret : ret;
}

#define inf 2147483647

int n, m, mini[400005];

int find(int t, int l, int r, int x, int y) {
	if (x <= l && r <= y)
		return mini[t];
	int mid = (l + r) >> 1;
	if (y <= mid)
		return find(t << 1, l, mid, x, y);
	if (x > mid)
		return find(t << 1 | 1, mid + 1, r, x, y);
	else
		return min(
			find(t << 1, l, mid, x, mid),
			find(t << 1 | 1, mid + 1, r, mid + 1, y)
		);
}

void update(int t, int l, int r, int x, int y) {
	if (l == r)mini[t] = y;
	else {
		int mid = (l + r) >> 1;
		if (x <= mid)
			update(t << 1, l, mid, x, y);
		else
			update(t << 1 | 1, mid + 1, r, x, y);
		mini[t] = min(mini[t << 1], mini[t << 1 | 1]);
	}
}

signed main(void) {
	fread(buf, 1, siz, stdin);

	n = nextInt();
	m = nextInt();

	for (int i = 0; i <= (n << 2); ++i)mini[i] = inf;

	for (int i = 1; i <= m; ++i) {
		int c = nextInt();
		int x = nextInt();
		int y = nextInt();
		if (c)	// find(x, y)
			printf("%d\n", find(1, 1, n, x + 1, y + 1));
		else	// update(x, y)
			update(1, 1, n, x + 1, y);
	}

//	system("pause");
}

Measured memory_bytes: 5568
#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() {
  string s,t;cin>>s>>t;
  rep(i,s.size()){
    s=s.substr(1)+s[0];
    if(s==t){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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

int main (){
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    if(x==7 or x==5 or x==3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
int n,x;ll a[yuzu|10];
int main(){
int i;ll ans=0;
n=read(),x=read();
for (i=1;i<=n;++i) a[i]=read();
if (a[1]>x) ans+=a[1]-x,a[1]=x;
for (i=2;i<=n;++i){
  if (a[i]+a[i-1]>x) ans+=a[i]+a[i-1]-x,a[i]-=a[i]+a[i-1]-x;
  if (a[i]<0) ans+=a[i],a[i]=0;
  } 
write(ans);
}

Measured memory_bytes: 1024
n = int(input())
s = list(input())
r = 0
g = 0
b = 0


for i in range(n):
    if s[i] == 'R':
        r += 1
    elif s[i] == 'G':
        g += 1
    else:
        b += 1

ans = r * g * b

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = 2 * j - i
        if k < n:
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1


print(ans)


Measured memory_bytes: 68168
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();

		List<String> lines1 = Arrays.asList(line1.split(" "));

		Integer K = Integer.parseInt(lines1.get(0));
		Integer S = Integer.parseInt(lines1.get(1));
/*
		Integer a = S / K;
		int res = 0;

		if (3 == a) {
			res = 1;
		} else if (2 <= a) {
			res = 9;
		} else if (1 < a) {
			res = (S-K) * 3;
		}else if (1 == a) {
			res = 3;
		}
*/

		int res = 0;

		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				int z = S-x-y;
				if(0 <= z && z <= K) {
					res++;
				}
			}
		}

		System.out.println(res);
	}

}

Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#define oo 987654321
#define INT long long
using namespace std;

int n, a[100010], t, ans = 1, d, c;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ )
    {
        cin>>t;
        if( i == 0 ) a[c++] = t;
        else
        {
            if( a[c-1] != t ) a[c++] = t;
        }
    }
    if( n <= 2 ) return cout<<1<<endl, 0;
    n = c;
    for(int i = 0 ; i < n-2 ; i++ )
    {
        if( a[i] > a[i+1] and a[i+1] < a[i+2] ) ans++, i++;
        else if( a[i] < a[i+1] and a[i+1] > a[i+2] ) ans++, i++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
void main(){
	string[] s = inln!string();
	string ans;
	foreach(elm; s)ans ~= elm[0];
	ans.writeln();
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;
int N, K;
double P[MAX_N];

signed main()
{

  cin >> N >> K;
  REP(n,N) {
    cin >> P[n];
  }

  double tmp = 0;
  REP(n,K) {
    tmp += (1+P[n])/2;
  }
  double ans = tmp;

  FOR(n,K,N) {
    tmp += (1+P[n])/2 - (1+P[n-K])/2;
    ans = max(ans, tmp);
  }

  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 1792
a,b,c=map(int,input().split())

if c-a-b<0:
    print("No")
elif 4*a*b<(c-a-b)**2:#式変形桁落ちはわかっていたが式変形のかんがえかたがなかった
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>
#include <fstream>

using namespace std;

long long mod = 998244353;
vector<long long> fact(1000001);
vector<long long> invFact(1000001);

long long binpow(long long x, long long k)
{
    if (k == 0)
    {
        return 1LL;
    }
    long long temp = binpow(x, k / 2);
    if (k % 2 == 1)
    {
        return (((temp * temp) % mod) * x) % mod;
    }
    else
    {
        return (temp * temp) % mod;
    }
}

long long modular_inverse(long long x)
{
    return binpow(x, mod - 2);
}

void initFact()
{
    for (int i = 0; i <= 1000000; i++)
    {
        fact[i] = (i == 0) ? 1 : (i * fact[i - 1] % mod);
        invFact[i] = modular_inverse(fact[i]);
    }
}

int binomial(int n, int k)
{
    return ((fact[n] * invFact[k]) % mod * invFact[n - k]) % mod;
}

int main()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie();
    cout.tie();
    // ifstream cin("in.txt");
    // ofstream cout("out.txt");
    
    
    // int t;
    // cin >> t;
    // for (int qwe = 0; qwe < t; qwe++)
    // {
    //     cout << "Case #" << qwe + 1 << ": ";
    // }


    initFact();
    long long n, m, k;
    cin >> n >> m >> k;
    long long curr = m, rez = 0;
    for (int i = 0; i < n - k - 1; i++)
    {
        (curr *= (m - 1)) %= mod;
    }
    for (int i = k; i >= 0; i--)
    {
        // cout << n << " " << i << " " << binomial(n - 1, i) << " " << curr << '\n';
        rez += binomial(n - 1, i) * curr;
        rez %= mod;
        curr *= (m - 1);
        curr %= mod;
    }
    cout << rez << '\n';


    return 0;
}


Measured memory_bytes: 18200
#include<cstdio>
#include<algorithm>
using namespace std;
const int mod=1e9+7,inv2=5e8+4;
int n,ans,a[200010],b[200010],dp[4010][4010],fac[8010],invfac[8010];
int Add(int a,int b){
	return a+b>=mod?a+b-mod:a+b;
}
int Minus(int a,int b){
	return a<b?a-b+mod:a-b;
}
int C(int n,int m){
	return 1ll*fac[n]*invfac[m]%mod*invfac[n-m]%mod;
}
int qpow(int x,int n){
	int ret=1;
	while(n){
		if(n&1)
			ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;
		n>>=1;
	}
	return ret;
}
void init(){
	fac[0]=1;
	for(int i=1;i<=8000;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	invfac[8000]=qpow(fac[8000],mod-2);
	for(int i=7999;~i;i--)
		invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
	return;
}
int main(){
	scanf("%d",&n);
	init();
	for(int i=1;i<=n;i++){
		scanf("%d%d",a+i,b+i);
		dp[2000-a[i]][2000-b[i]]++;
		ans=Minus(ans,C((a[i]<<1)+(b[i]<<1),a[i]<<1));
	}
	for(int i=0;i<=4000;i++)
		for(int j=0;j<=4000;j++){
			if(i)
				dp[i][j]=Add(dp[i][j],dp[i-1][j]);
			if(j)
				dp[i][j]=Add(dp[i][j],dp[i][j-1]);
		}
	for(int i=1;i<=n;i++)
		ans=Add(ans,dp[2000+a[i]][2000+b[i]]);
	printf("%d",1ll*ans*inv2%mod);
	return 0;
}

Measured memory_bytes: 64640
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#endif

using namespace std;


typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
  stringstream ss;
  ss << f;
  ss >> t;
}

vector<string> split(const string &str, char delim) {
  vector<string> res;
  size_t current = 0, found;
  while ((found = str.find_first_of(delim, current)) != string::npos) {
    res.push_back(string(str, current, found - current));
    current = found + 1;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}

#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb push_back


#define MOD 1000000007LL
#define EPS 1e-8


int main() {
  int N;
  cin >> N;
  vint A(N);
  rep(i, N) {
    int t;
    cin >> t;
    A[t]++;
  }
  LL res = 1;

  if (N & 1) {
    if (A[0] != 1) {
      cout << 0 << endl;
      return 0;
    }
    for (int j = 2; j < N; j += 2) {
      if (A[j] != 2) {
        cout << 0 << endl;
        return 0;
      }
      (res *= 2) %= MOD;
    }
  } else {
    for (int j = 1; j < N; j += 2) {
      if (A[j] != 2) {
        cout << 0 << endl;
        return 0;
      }
      (res *= 2) %= MOD;
    }
  }

  cout << res % MOD << endl;
  return 0;
}

Measured memory_bytes: 640
require 'date'
loop do
    y1,m1,d1,y2,m2,d2 = gets.split.map{|i| i.to_i}
    if y1==-1 || m1==-1 || d1==-1 || y2==-1 || m2==-1 || d2==-1 then break end
    date1 = Date.new(y1,m1,d1)
    date2 = Date.new(y2,m2,d2)
    puts date2-date1
end

Measured memory_bytes: 23000
X, Y, A, B, C = [int(_) for _ in input().split()]
P = [int(_) * 3 for _ in input().split()]
Q = [int(_) * 3 + 1 for _ in input().split()]
R = [int(_) * 3 + 2 for _ in input().split()]
S = sorted(P + Q + R)
cnt = [0, 0, 0]
ans = [0, 0, 0]
limit = [X, Y, 10**10]
while S:
    s = S.pop()
    q, r = divmod(s, 3)
    if cnt[r] >= limit[r]:
        continue
    cnt[r] += 1
    ans[r] += q
    if sum(cnt) == X + Y:
        print(sum(ans))
        exit()


Measured memory_bytes: 31148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int m,i,j,big,k;
		int count = 0;
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		int array[] = new int[n];

		for(m=0;m<n;m++)array[m] = Integer.parseInt(in.next());

	for (i=0; i<n-1; i++){               //???????????????????????????????????°i
		for (j=n-1; j>=i+1; j--){        //?????????????°?????????£??\????´???¨??????????????????????????°j
			if (array[j] < array[j-1]){
				big = array[j-1];        //??§???????????????????´????????????????????????????????????°big
				array[j-1] = array[j];   //??????????????§??\???????????????
				array[j] = big;
				count++;                 //???????????\??????????????°?????????????????????
			}
		}
	}
	for(k = 0;k<n-1;k++){
		System.out.print(array[k]+" ");
	}
    if(k==(n-1))System.out.println(array[k]);
			System.out.println(count);
	}
}

Measured memory_bytes: 26152
package main

import "fmt"

var N, M int

func main() {
	fmt.Scan(&N, &M)
	var a, b int
	result := make([]int, N)
	for i := 0; i < N; i++ {
		result[i] = 0
	}
	for i := 0; i < M; i++ {
		fmt.Scan(&a, &b)
		result[a-1] += 1
		result[b-1] += 1
	}

	for i := 0; i < N; i++ {
		fmt.Println(result[i])
	}

}


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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];
    ll ans = 0;
    rep(i, N - 1) {
        for (int j = i + 1; j < N; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def main():
        x, n = map(int, input().split())
        if n == 0:
            return x
        else:
            p = list(map(int, input().split()))


            cur = 0
            if x not in p:
                return x
            
            while True:
                if x-cur not in p:
                    return x-cur
                if x+cur not in p:
                    return x+cur

                cur+=1
    print(main())


resolve()

Measured memory_bytes: 61796
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(string, "s", long, "p");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto s = sread();
    if (s[0 .. $ - 1].all_eq() || s[1 .. $].all_eq())
        writeln("Yes");
    else
        writeln("No");
}

bool all_eq(string s)
{
    auto t = s[0];
    foreach (e; s)
    {
        if (e != t)
            return false;
    }
    return true;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2576
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	ans := 0
	s := getNextString(scanner)
	t := getNextString(scanner)
	for i := 0; i < 3; i++ {
		if s[i] == t[i] {
			ans++
		}
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mk_pii(a,b,c) make_pair((a),make_pair((b),(c)))
using namespace std;
int main(){
        vector<pair<int,pair<int,int>>> v;
        for(int i=1;i<150;i++){
                for(int j=1;j<150;j++){
                        if(i < j){
                                v.emplace_back(mk_pii(i*i+j*j,i,j));
                        }
                }
        }
        sort(v.begin(),v.end());
        int h,w;
        while(cin >> h >> w,h || w){
                int x = h*h+w*w;
                for(int unsigned i = 0;i<v.size();i++){
                        if(v[i].first > x || (v[i].first == x && v[i].second.first > h)){
                                cout << v[i].second.first << " " << v[i].second.second << endl;
                                break;
                        }
                }
        }

        return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 1000000007;
 
int main() {
  ll n;
  cin >> n;
  vector<ll>a(n),b(n),c(n);
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++) cin >> b[i];
  for(int i=0; i<n; i++) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  
  
  ll ans = 0;
  ll a_count = 0;
  ll b_count = n;
  for(int i=0; i<n; i++){
    for(int j=a_count; j<n; j++){
      if(a[j]>=b[i]) break;
      a_count++;
    }
    
    for(int j=n-b_count; j<n; j++){
      if(c[j]>b[i]) break;
      b_count--;
    }
    
    ans+=a_count*b_count;
    
  }
  
  cout << ans << endl;
  
  return 0;
  
}

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

int main() {
  vector<string> S(3);
  for (int i = 0; i < (int)3; ++i) cin >> S[i];

  function<int(int)> winner = [&](int i) {
    if (S[i].size() == 0) return i;
    int ni = S[i][0] - 'a';
    S[i] = S[i].substr(1);
    return winner(ni);
  };

  cout << char(winner(0) + 'A') << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
	a = {"SUN" : 0,
	"SAT" : 6,
	"FRI" : 5,
	"THU" : 4, 
	"WED" : 3,
	"TUE" : 2,
	"MON" : 1}
	s = input()
	print(7-a[s.strip()])
	
main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

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

  int n;
  cin >> n;
  vector<int> h(n), dp(n);
  for(auto &x:h) cin >> x;
  
  dp[1] = abs(h[1] - h[0]);
  
  for(int i = 2; i < n; ++i)
  {
  	dp[i] = min(
      	dp[i-2] + abs(h[i] - h[i-2]),
      	dp[i-1] + abs(h[i] - h[i-1])
    );
  }
  
  cout << dp[n-1] << endl;
  
}


Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
int n1=0,n2 = 0;
scanf("%d %d",&n1,&n2);
if(n1<n2)
printf("a < b\n");
else if(n1>n2)
printf("a > b\n");
else
printf("a == b\n");

return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 2 * 100000 + 10;
inline int add(int x, int y)
{
    return (x + y) % MOD;
}
inline int sub(int x, int y)
{
    return add(x, MOD - y);
}
inline int mul(int x, int y)
{
    return (x * 1ll * y) % MOD;
}
int binpow(int x, int n)
{
    int res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}
int fact[N];
int inv(int x)
{
    return binpow(x, MOD - 2);
}
int C(int n, int k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    fact[0] = 1;
    for (int i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
    int ans = 0;
    for (int i = 0; i <= k; i++)
        ans = add(ans, mul(m, mul(C(n - 1, i), binpow(m - 1, n - 1 - i))));
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4420
queue=[]
N,M=map(int,input().split())
NE=9223372036854775807
mp=[NE]*(N+1)
lst=[[] for _ in range(N+1)]
for _ in range(M):
    L,R,D = map(int, input().split())
    lst[L].append((L,R,D))
    lst[R].append((L,R,D))

def check(L, R, D):
    if mp[L] == NE:
        mp[L] = mp[R]-D
    elif mp[R] == NE:
        mp[R] = mp[L]+D
    else:
        if mp[L]+D != mp[R]:
            print("No")
            exit()

def check_list(ls, checking):
    while len(ls):
        L,R,D = ls.pop()
        check(L,R,D)
        nx = R if L == checking else L
        if len(lst[nx]): queue.append(nx)

for i in range(1, N+1):
    if mp[i] == NE: mp[i] = 0
    check_list(lst[i], i)

    while(len(queue) > 0):
        num = queue.pop()
        check_list(lst[num], num)
print("Yes")
 

Measured memory_bytes: 105888
s = input()
tiles = list(map(int, list(s)))

kouho0 = [i % 2 == 0 for i in range(len(tiles))]
kouho1 = [i % 2 != 0 for i in range(len(tiles))]

kekka0 = 0
kekka1 = 0
for i in range(len(tiles)):
    if tiles[i] != kouho0[i]:
        kekka0 += 1
    if tiles[i] != kouho1[i]:
        kekka1 += 1

if kekka0 < kekka1:
    print(kekka0)
else:
    print(kekka1)


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s;
  for (int i = 0; i < 3; ++i){
  	cin>>s;
  	cout<<s[i];
  }
  cout<<endl;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using P   = pair<int, int>;
using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    int ans = 0;
    for(int i=0;i<n;i++){
        int l, r;cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
(defmacro input []
  '(list (read-line) (read-line)))

(defn TwoAnagrams [[s t]]
  (if (neg?
        (compare
          (apply str (sort s))
          (apply str (reverse (sort t)))))
    "Yes"
    "No"))

(-> (input)
  TwoAnagrams
  println)

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

/*
5
aba
ab
*/

int main() {
int l,n,m;
string s,t,f;
cin>>l>>s>>t;

if(s+t<=t+s){
    f=s;
    s=t;
}else{
    f=t;
}

n=f.length();
m=s.length();
t="";
for(int i=0;i*m<=l;i++){
    if((l-i*m)%n==0){
        int k=(l-i*m)/n;
        string u="";
        for(int j=0;j<k;j++){
            u+=f;
        }
        cout<<u+t<<endl;
        return 0;
    }
    t+=s;
}
	return 0;
}

Measured memory_bytes: 1544
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]" << endl;  return os;  }
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

int main() {
  int n, k; cin >> n >> k;
  string s; cin >> s;
  vector<int> A;
  if (s[0] == '0') A.push_back(0);
  char prev = ' ';
  for (auto &&c: s) {
    if (prev != c) {
      A.push_back(0);
      prev = c;
    }
    A[A.size()-1]++;
  }
  if (s[n-1] == '0') A.push_back(0);
  int m = A.size();
  vector<int> acc(m+1, 0);
  loop(i,0,m) acc[i+1] = acc[i] + A[i];
  int len = min(2*k+1, m);
  int max_ = 1;
  for (int l=0; l+len<=m; l++) {
    if (l%2==1) continue;
    max_ = max(max_, acc[l+len] - acc[l]);
  }
  cout << max_ << endl;
  return 0;
}


Measured memory_bytes: 4104
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int main(){
	int n, x;
	vector<int> p;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> x;
		p.push_back(x);
	}
	sort(p.begin(), p.end(), greater<int>());
	p[0] = p[0]/2;
	cout << accumulate(p.begin(), p.end(), 0) << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[10000];
    int l=0,i,k;
    cin>>s;
    k = strlen(s);
    for(i=0;i<k;i++)
    {
        if(s[i]=='7')
            l++;
    }
    if(l>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238


#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 1e5 + 1;
vector<pair<ll,ll>> adj[N];
ll color[N];
bool visited[N];
void dfs(ll a, ll dist){
    visited[a] = true;
    for(auto u : adj[a]){
        if(!visited[u.ff]){
            ll bc;
            bc = dist + u.ss;
            if(bc % 2 == 0){
                color[u.ff] = 0;
            }
            else{
                color[u.ff] = 1;
            }
            dfs(u.ff, bc);
        }
    }
}
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    
    //cin >> T;
    while (T--) {
        ll n;
        ll a ,b, c;
        cin >> n;
        for(i = 0; i < n - 1; i++){
            cin >> a >> b >> c;
            adj[a].pb({b, c});
            adj[b].pb({a, c});
        }
        color[1] = 0;
        dfs(1, 0);
        for(i = 1; i <= n; i++){
            cout << color[i] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 13352
/*
 * Contents   : AOJ DPL 1 A
 * Author     : KitauraHiromi
 * LastUpdate : 20180611
 * Since      : 20180611
 */
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int N, M;
int dp[21][50001]; // dp[m][i]: m種類目までのコインをi円集めたときの最小枚数を保持
int value[21];
int main(void){
    cin >> N >> M;
    memset(dp, 50001, sizeof(dp));
    for(int m=0; m<M; ++m) cin >> value[m];
    for(int m=0; m<=M; ++m) dp[m][0] = 0;
    for(int m=0; m<M; ++m){
        for(int i=0; i<=N; ++i){
            if(i >= value[m]) dp[m+1][i] = min(dp[m+1][i-value[m]] + 1, dp[m][i]);
            else dp[m+1][i] = dp[m][i];
        }
    }
    cout << dp[M][N] << endl;
}


Measured memory_bytes: 7192