akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll p[100];

int main() {
  std::cin >> N;

  rep( i, N )
    std::cin >> p[i];

  bool fl2 = true;

  rep( k, N-1 )
    fl2 &= p[k] < p[k+1];

  bool ans = false;

  if( fl2 )
    ans = true;

  rep( i, N ) rep( j, i ) {
    std::swap(p[i], p[j]);

    bool fl = true;

    rep( k, N-1 )
      fl &= p[k] < p[k+1];

    if( fl )
      ans = true;

    std::swap(p[i], p[j]);
  }

  puts( ans ? "YES" : "NO" );

  return 0;
}

Measured memory_bytes: 3620
def multiple(n):
    a = []
    for i in range(1,int(n**.5)+1):
        a.append(i*i)
    return a
n = int(input())
a = multiple(n)
ans = 10**18
for i in a:
    if n-i < 0:
        continue
    ans = min(ans,abs(n-i))
print(n-ans)

Measured memory_bytes: 10236
n = int(input())
a = list(map(int,input().split()))
c = 1
d = 0
for i in range(n-1):
  if a[i] == a[i+1]:
    pass
  elif a[i] < a[i+1]:
    if d < 0:
      d = 0
      c += 1
    else:
      d += 1
  else:
    if d > 0:
      d = 0
      c += 1
    else:
      d -= 1
print(c)

Measured memory_bytes: 14252
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,k,arr[105];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }    
    sort(arr+1,arr+n+1);
    int x=k;
    for(int i=1;i<=n;i++){
        if(x<arr[i]){
            cout<<i-1<<endl;
            return 0;
        }
        x-=arr[i];
    }
    if(x>0) cout<<n-1<<endl;
    else cout<<n<<endl;

}

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

class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
			
			char[] field = kb.readLine().toCharArray();
			int len = field.length;
			int[] areas = new int[10000];
			int cnt, found, total;
			
			cnt = total = found = 0;
            for( int i=0; i<len; i++ ) {
            	found = findPool( field, i, len );
            	if( 0 < found ) {
            		areas[cnt] = getArea( field, i, found );
            		total += areas [cnt++];
            		i = found;
            		found = 0;
            	}
            }
            
            StringBuilder output = new  StringBuilder( );
            output.append( total ).append( "\n" );
            output.append( cnt ).append( " " );
           	for( int i=0; i<cnt; i++ ) {
           		output.append( areas[i] ).append( " " );
         	}
         	output.deleteCharAt( output.lastIndexOf( " " ) );
         	System.out.println( output );

	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	}
	public static int getArea( char[] field, int start, int end )
	{
		int i, area, cnt, s, t;
		area = cnt = s = t = 0;
		for( i=start; i<=end; i++ ) {
            if( '\\'== field[i] ) {
            	cnt++;
            	t++;
            	area += cnt;
            } else if( 0 < cnt && '/' == field[i] ) {
            	area += cnt;
            	cnt--;
            } else if( '_' == field[i]  ) {
            	s += cnt;
            }
		}
		area = ( area - t + s );
		
		return area;
	}
	public static int findPool( char[] field, int start, int end )
	{
		int cnt, i;
		cnt = 0;
		for( i=start; i<end; i++ ) {
            if( '\\'== field[i] ) {
            	cnt++;
            } else if( 0 < cnt && '/' == field[i] ) {
            	cnt--;
            	if( 0 == cnt ) { break; }
            }
		}
		if( end == i ) { i = 0; }
		return i;
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n;
	cin >> n;

	if(n == 1){
		cout << "Hello World" << endl;
	}else{
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

ll comb(ll n, ll k){
    ll numerator = 1;
    k = min(k, n-k);
    for(ll i = n; i > n-k; --i) numerator *= i;

    ll denominator = 1;
    for(ll i = 1; i <= k; ++i) denominator *= i;

    ll ret = numerator / denominator;
    return ret;
}

int main(){

    ll n, p;
    cin >> n >> p;
    vector<ll> a(n);

    ll odd = 0;
    rep(i, n) {
        cin >> a[i];
        if(a[i]%2) ++odd;
    }

    ll even = n - odd;
    ll res = 0;
    if(p){
        ll max_odd = (odd+1)/2*2-1; // max odd number not greater than <odd>
        for(ll i = 1; i <= max_odd; i+=2){
            res += comb(odd, i);
        }
    }

    else{
        ll max_even = odd/2*2; // max even number not greater than <even>
        for(ll i = 0; i <= max_even; i+=2){
            res += comb(odd, i);
        }
    }

    cout << res * (1LL<<even) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,c,d;/*0~9の範囲*/
	int n;/*50以下*/
	int count;

	while(scanf("%d",&n) != EOF)
	{
		if(n<0 || n>50)
			continue;

		count = 0;/*リセット*/
		for(a=0;a<=9;a++)
		{
			for(b=0;b<=9;b++)
			{
				for(c=0;c<=9;c++)
				{
					d=n-(a+b+c);
					if(d >= 0 && d <= 9)
						count++;
				}
			}
		}

		printf("%d\n",count);
	}

	return 0;
}

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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
    }
    println!("{}", n*n*n);
}
//nを入力後ctrl+Z


Measured memory_bytes: 5032
n =  int(input())
ac = 0
tle = 0
re = 0
wa = 0
for i in range(n):
    string = input()
    if string == "AC":
        ac += 1
    if string == "WA":
        wa += 1
    if string == "TLE":
        tle += 1
    if string == "RE":
        re += 1
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))


Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;
int main()
{
  ios_base :: sync_with_stdio(false) , cin.tie(0), cout.tie(0);

  int  n , kount =0 ;
  cin>>n;

  int arr[n], arr2[n];

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

  for(int i=0 ; i<n ; i++)

    cin>>arr2[i];

  for(int i=0 ; i<n ; i++)
  {
      if(arr[i]>arr2[i])
        kount+=(arr[i] - arr2[i]);
  }

  cout<<kount<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
#include <queue>
#include <unordered_map>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main(){
  ll N;
  cin >> N;
  string s[100005];
  rep(i,N) cin >> s[i];

  ll ans = 0;
  unordered_map<string, int> mp;
  
  rep(i, N){
    sort(s[i].begin(), s[i].end());
    auto itr = mp.find(s[i]);
    if(itr != mp.end()){
      mp[s[i]]++;
    }else{
      mp[s[i]]=1;
    }
  }
  
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    ll tmp = itr->second;
    if(tmp>1){
      ans+=tmp*(tmp-1)/2;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 17572
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; ++i) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n, k; cin >> n >> k;
	ll po[200001] = {};
	for(ll i = 0; i < n; ++i){
		ll a; cin >> a;
		++po[--a];
	}
	vector<ll> v;
	for(ll i = 0; i < 200001; ++i){
		if(po[i]) v.push_back(po[i]);
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	for(ll i = 0; v.size() - i > k; ++i){
		ans += v[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3956
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int A[3];
    int K;
    rep(i,3) cin >> A[i];
    cin >> K;
    rep(i,K){
        *max_element(A,A+3)=*max_element(A,A+3)*2;
    }
    cout << accumulate(A,A+3,0) << endl;
}

Measured memory_bytes: 256
N = int(input())
dp = [0]*(N+10)

for i in range(N+1):
    if i == 0:
        dp[i] = 2
        continue
    if i == 1:
        dp[i] = 1
        continue
    dp[i] = dp[i-1]+dp[i-2]

print(dp[N])

Measured memory_bytes: 3060
def main():
    """
    a % d + c % d = (a + c) % dだよね
    整数の余りを取るのと，整数の各桁の余りを取るのが同じこともあった　→　Digits Parade
    """
    N = int(input())
    X = input()
    t = X.count("1")
    x1, x2 = int(X, 2) % (t+1), int(X, 2) % (t-1) if t != 1 else 0
    for i in range(N):
        ans = 1
        x = 0
        if X[i] == "0":
            # 反転してt+1
            p = pow(2, N-i-1, t+1)
            x = x1 + p
            x %= t+1
        elif t != 1 and X[i] == "1":
            p = pow(2, N-i-1, t-1)
            x = x2 - p
            x %= (t-1)
        else:
            # t == 1 かつ その"1"を反転するとき
            # 当然X_iは0になる，答えも0
            ans = 0
        while x > 0:
            x %= "{:0b}".format(x).count("1")
            ans += 1
        print(ans)


if __name__ == '__main__':
    main()


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

L = [ i+1+A[i] for i in range(N) ]
R = [j+1-A[j] for j in range(N) ]

Ld = {}
Rd = {}

for i in range(N):
    if R[i] in Rd.keys():
        Rd[R[i]] += 1
    else:
        Rd[R[i]] = 1

ans = 0
for i in range(N):
    if L[i] in Rd.keys():
        ans += Rd[L[i]]
    if L[i] == R[i]:
        ans -= 1
        
print(ans)

Measured memory_bytes: 50176
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
	string n,right,left;     //n=n枚のカード
	int num;      //num=シャッフル回数
	int num2 = 0; //num2=シャッフル枚数

	while (1){
		cin >> n;
		cin >> num;
		if (n == "-")break;
		for (int i = 0; i < num; i++){
			cin >> num2;
			left = n.substr(0, num2);
			right = n.substr(num2, n.size());
			n = right + left;
		}
		cout << n << endl;
	}
	return 0;
}



Measured memory_bytes: 3148
def solve(string):
    n, m, *abc = map(int, string.split())
    a = sorted(abc[:n])
    cb = sorted(list(zip(*[iter(abc[n:][::-1])] * 2)))
    i = ans = 0
    for c, b in cb[::-1]:
        start = i
        while i < n and a[i] < c and b > 0:
            i += 1
            b -= 1
            ans += c
        if start == i:
            break
    ans += sum(a[i:]) if i < n else 0
    return str(ans)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m + 1)])))


Measured memory_bytes: 40204
#include<iostream>
#include<algorithm>
#include<vector>
 using namespace std;
 typedef long long ll;
 int main()
 {
 	int a,b;
 	cin>>a>>b;
 	for(int i=1;i<=2000;i++){
 		if((int)(i*0.08)==a&&(int)(i*0.1)==b){
 			cout<<i<<endl;
 			return 0;
		 }
	 } 
	cout<<-1<<endl;
  } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 2;

vector<ll> dijkstra(int s, WeightedGraph & G){
  using P = pair<ll, int>;
  int n=G.size();
  vector<ll> ds(n,INF64);
  vector<ll> bs(n,-1);
  priority_queue<P, vector<P>, greater<P> > pq;
  ds[s]=0;
  pq.emplace(ds[s],s);
  while(!pq.empty()){
    P p=pq.top();pq.pop();
    int v=p.second;
    if(ds[v]<p.first) continue;
    for(auto& e:G[v]){
      int u=e.first;
      ll c=e.second;
      if(ds[u]>ds[v]+c){
        ds[u]=ds[v]+c;
        bs[u]=v;
        pq.emplace(ds[u],u);
      }
    }
  }
  return bs; // 経路
  //return ds;
}


void solve() {
    ll N, M; cin >> N >> M;
    WeightedGraph G(N);
    for(int i = 0; i < M; ++i){
        ll A, B; cin >> A >> B;
        --A; --B;
        G[A].push_back({B,1});
        G[B].push_back({A,1});
    }
    auto b = dijkstra(0, G);
    for(int i = 1; i < N; ++i)
    {
        if(b[i] == -1){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < N; ++i)
    {
        cout << b[i]+1 << endl;
    }
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 19372
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a,b;scanf("%d%d",&a,&b);
	long long ret=0;
	for(int i=b;i<=a+1;i++){
		long long L=(long long)(i-1)*i/2;
		long long R=(long long)(a*2-i+1)*i/2;
		ret=(ret+R-L+1)%mod;
	}
	ret%=mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <math.h>
using namespace std;

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b){
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}

bool sosu(ll p){
    bool ans = true;
    double psqrtd = pow(p, 0.5);
    ll psqrt = psqrtd;
    for(ll i = 2; i <= psqrt; i++){
        if(p%i==0)ans = false;
    }
    if(p==1)ans = false;
    return ans;
}

vector< bool > prime_table(ll n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main(void){
    ll n;
    string s;
    cin >> n;
    ll ans = n;
    cin >> s;
    for(ll i=1;i<n;i++){
        if(s.at(i-1)==s.at(i))ans--;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 512
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()
    a.sort()

    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10 ** 18:
            print(-1)
            exit(0)

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
	int n;
	long long a;
	long long minValue = 1000000;
	long long maxValue = -1000000;
	long long sum = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a < minValue) minValue = a;
		if (a > maxValue) maxValue = a;
		sum += a;
	}

	cout << minValue << " " << maxValue << " " << sum << endl;

	return 0;
}


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

int main(){
  string S, T;
  cin >> S >> T;
  int result = 1500;
  for(int i = 0; i < S.length()+1-T.length(); i++){
    string tmp = S.substr(i, T.length());
    int tmpint = 0;
    for(int i = 0; i < T.length(); i++){
      if(tmp[i] != T[i]){
        tmpint ++;
      }
    }
    if(tmpint < result){
      result = tmpint;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int table[10][10];
int cnt,check,flag,tmp_flag;
queue<pair<int,int> > que;
int search(int y,int x){
    que.push(pair<int,int>(y,x));
    cnt++;
    x++;
    if(x < 5){
        if(table[y][x] == check) search(y,x);
    }
    if(cnt >= 3) {
        tmp_flag = true;
        return cnt;
    }
    else return 0;
}
int main(){
    int n;
    while(cin >> n,n){
        rep(i,n){
            rep(j,5){
                cin >> table[i][j];
            }
        }
        int point = 0;
        flag = true;
        while(flag){
            flag = false;
            rep(i,n){
                rep(j,5) {
                    if(table[i][j] == 0) continue;
                    tmp_flag = false;
                    cnt = 0;
                    check = table[i][j];
                    point += check*search(i,j);
                    if(tmp_flag){
                        flag = true;
                        while(!que.empty()){
                            pair<int,int> tmp = que.front();
                            que.pop();
                            table[tmp.first][tmp.second] = 0;
                        }
                    }
                    else while(!que.empty()) que.pop();
                }
            }
            if(!flag) continue;
            for(int i=n-1; i>=1; i--){
                for(int j=4; j>=0; j--){
                    if(table[i][j] != 0) continue;
                    for(int k=i; k>=0; k--){
                        if(table[k][j] == 0) continue;
                        swap(table[i][j],table[k][j]);
                        break;
                    }
                }
            }
        }
        cout << point << endl;
    }
    return 0;
}



Measured memory_bytes: 3152
//sucannerクラス使うためにインポート
import java.util.*;

class Main{
	//プログラムのエントリポイント
	public static void main(String[] args){
		//入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		while (true) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			if (x == 0 && y == 0 ){
				break;
			}else if (x < y){
				System.out.println( x + " " + y);
			} else {
				System.out.println( y + " " + x);
			}
			
		}
	}
}

Measured memory_bytes: 27288
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long l,r;
  cin>>l>>r;
  long long ans=1e10;
  if(l-r>2019){
    cout<<"0";return 0;
  }
  else{
    for(long long i=l;i<=r;i++){
      for(long long j=i+1;j<=r;j++){
        ans=min(ans,((i%2019)*(j%2019))%2019);
        if(ans==0){cout<<"0";return 0;}
      }
    }
    cout<<ans;
  }
  return 0;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int a_s = 0;
    int b_s = 0;
    while(c > 0){
        c =  c - b;
        a_s++;
    }
    while(a > 0) {
        a = a - d;
        b_s++;
    }
    if(a_s < b_s) cout << "Yes" << endl;
    else if(a_s > b_s) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<int> p(n),q(n);
  rep(i,n){
    cin >> p[i];
  }
  rep(i,n){
    cin >> q[i];
  }
  vector<int> r(n);
  r=p;
  sort(r.begin(),r.end());
  int pn=0,qn=0,cnt=0;
  do{
    if(r==p){pn=cnt;}
    if(r==q){qn=cnt;}
    cnt++;
  }while(next_permutation(r.begin(), r.end()));
  

  cout << abs(pn-qn) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define M 1000000007

using namespace std;

const int mxN=100,mxX=1e9;
string s,t;
int dp[3001][3001];

int main()
{
    cin>>s>>t;
    int m = s.length();
    int n = t.length();
    memset(dp,0,sizeof(dp));
    for(int i = 1; i<=m; i++)
    {
        for(int j = 1; j<=n; j++)
        {
            if(s[i-1] == t[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans = "";
    int i = m,j = n;
    while(i && j)
    {
        if(s[i-1] == t[j-1])
        {
            ans+=s[i-1];
            i--;
            j--;
        }
        else if(dp[i][j-1] > dp[i-1][j])
            j--;
        else
            i--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

Measured memory_bytes: 38672
l, r = map(int, input().split())
if l//2019<r//2019:
    print(0)
else:
    ans = 2019
    for ll in range(l, r):
        for rr in range(ll+1, r+1):
            ans = min(ans, (ll*rr)%2019)
    print(ans)

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


int main() {
    int A,B,C,D;
    cin>>A>>B>>C>>D;

    int Alice[105]={0}, Bob[105]={0};
    for(int i=A; i<B; i++) Alice[i]=1;
    for(int i=C; i<D; i++) Bob[i]=1;

    int ans=0;
    for(int i=0; i<100; i++) ans+=Alice[i]*Bob[i];

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / b;
	printf("%d %d %f\n", d, r, f);
	return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>
#include<iostream>

using namespace std;
int main(){
    int a,b,c;
    int max;
    cin>>a>>b>>c;
    if(a==b&&b==c){
        cout<<a+b;
    }
    else{
        max = a;
        if(max<b)max=b;
        if(max<c)max=c;
        cout<<a+b+c-max;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
 char N[1001];
 int T[1000]={0};
 int i,j,k;
 int num;


 
/*????????????????????????*/
 for(j=0;j>=0;j++){

  scanf("%s",N);

  for(i=0;N[i]!='\0';i++){
   num=N[i]-'0';
   T[j]+=num;
   if(N[i]=='\0'){
    break;
   }
  }
  
  if(T[j]==0){
   k=j;
   break;
  }

 }

 for(j=0;j<k;j++){
  printf("%d\n",T[j]);
 }
 

return 0;
}

  

Measured memory_bytes: 540
#include <iostream>

using namespace std;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    const int w = tx - sx;
    const int h = ty - sy;

    // 1周目
    for (int i = 0; i < w; i++)
        cout << "R";
    for (int i = 0; i < h; i++)
        cout << "U";
    for (int i = 0; i < w; i++)
        cout << "L";
    for (int i = 0; i < h; i++)
        cout << "D";

    // 2周目
    cout << "D";
    for (int i = 0; i < w + 1; i++)
        cout << "R";
    for (int i = 0; i < h + 1; i++)
        cout << "U";
    cout << "LU";
    for (int i = 0; i < w + 1; i++)
        cout << "L";
    for (int i = 0; i < h + 1; i++)
        cout << "D";
    cout << "R" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,a,b,c,d,e,f,g,h,j,k,l;
	scanf("%d",&a);
	for(i=1;i<=a;i++){
		scanf("%d %d %d %d",&b,&c,&d,&e);
		if(d>=5 && e>=2){
			f=b*d;
			g=c*e;
			h=(f+g)*8/10;
			printf("%d\n",h);
		}
		if(d<5 && e<2){
			f=b*d;
			g=c*e;
			h=f+g;
			printf("%d\n",h);
		}
		else if(d<5){
			f=b*d;
			g=c*e;
			h=f+g;
			j=b*5;
			k=c*e;
			l=(k+j)*8/10;
				if(h<l){
					printf("%d\n",h);
				}
				else{
					printf("%d\n",l);
				}
		}
		else if(e<2){
			f=b*d;
			g=c*e;
			h=f+g;
			j=b*d;
			k=c*2;
			l=(k+j)*8/10;
				if(h<l){
					printf("%d\n",h);
				}
				else{
					printf("%d\n",l);
				}
		}
	}
	return 0;
}

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

int main(){
    int N,M,C;
    cin >> N >> M >> C;
    int B[M];
    for(int i=0; i<M; i++){
        cin >> B[i];
    }
    int A;
    int correct=0;
    double sum;
    for(int i=0; i<N; i++){
        sum=0;
        for(int j=0; j<M; j++){
            cin >> A;
            sum+=A*B[j];
        }
        sum+=C;
        if(sum>0){
            correct++;
        }
    }
    cout << correct << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n, m[2];
long a[45][2];
long c[45];
long dp[45][405][405];

int main(){
    scanf("%ld%ld%ld", &n, &m[0], &m[1]);
    for(int i = 1; i <= n; i++){
        scanf("%ld%ld%ld", &a[i][0], &a[i][1], &c[i]);
    }
    for(int j = 0; j <= 400; j++){
        for(int k = 0; k <= 400; k++){
            dp[0][j][k] = LINF;
        }
    }
    dp[0][0][0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= 400; j++){
            for(int k = 0; k <= 400; k++){
                dp[i][j][k] = dp[i-1][j][k];
                if(j-a[i][0] >= 0 && k-a[i][1] >= 0){
                    dp[i][j][k] = std::min(dp[i][j][k], dp[i-1][j-a[i][0]][k-a[i][1]] + c[i]);
                }
            }
        }
    }
    /*
    for(int j = 0; j <= 10; j++){
        for(int k = 0; k <= 10; k++){
            if(dp[n][j][k] == LINF){
                printf(" LINF");
            }else{
                printf(" %4ld", dp[n][j][k]);
            }
        }
        printf("\n");
    }
    //*/
    long ans = LINF;
    for(int i = 1; std::max(m[0], m[1]) * i <= 400; i++){
        ans = std::min(ans, dp[n][m[0]*i][m[1]*i]);
    }
    if(ans == LINF){
        printf("-1\n");
    }else{
        printf("%ld\n", ans);
    }
}


Measured memory_bytes: 53504
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define usll                    unordered_set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
//	inp_out();
	ll w,s;
	cin>>s>>w;
	if(w>=s)	cout<<"unsafe";
	else cout<<"safe";

	return 0;
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**6)
n = int(input())
adjacent_list = [[] for i in range(n+1)]
for i in range(n-1):
    a,b = map(int, input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)
finished = set()
inf = 10**9
dist = [inf for i in range(n+1)]
def dfs(node):
    finished.add(node)
    for i in adjacent_list[node]:
        if i not in finished:
            dist[i] = dist[node]+1
            dfs(i)
dist[1] = 0
rem_1 = [i+1 for i in range(n) if (i+1) % 3 == 1]
rem_2 = [i+1 for i in range(n) if (i+1) % 3 == 2]
rem_0 = [i+1 for i in range(n) if (i+1) % 3 == 0]
index_0 = 0
index_1 = 0
index_2 = 0
dfs(1)
ans = []
count_even = 0
count_odd = 0
for i in range(1,len(dist)):
    if dist[i] % 2 == 0:
        count_even += 1
    else:
        count_odd += 1

#場合分け
if count_even > n/3 and count_odd > n/3:
    #この場合、普通にやる
    for i in range(1,len(dist)):
        if dist[i] % 2 == 1:
            if index_2 < len(rem_2):
                ans.append(rem_2[index_2])
                index_2 += 1
            else:
                ans.append(rem_0[index_0])
                index_0 += 1
        else:
            if index_1 < len(rem_1):
                ans.append(rem_1[index_1])
                index_1 += 1
            else:
                ans.append(rem_0[index_0])
                index_0 += 1
elif count_even <= n/3:
    #1からの距離が偶数のところが全体の1/3を閉めない場合
    #そこに全部3の倍数を入れてしまえば、題意を満たす
    li = rem_1 + rem_2
    index = 0
    for i in range(1,len(dist)):
        if dist[i] % 2 == 0:
            ans.append(rem_0[index_0])
            index_0 += 1
        else:
            if index < len(li):
                ans.append(li[index])
                index += 1
            else:
                ans.append(rem_0[index_0])
                index_0 += 1
else:
    ##1からの距離が奇数のところが全体の1/3を閉めない場合
    #そこに全部3の倍数を入れてしまえば、題意を満たす
    li = rem_1 + rem_2
    index = 0
    for i in range(1,len(dist)):
        if dist[i] % 2 == 1:
            ans.append(rem_0[index_0])
            index_0 += 1
        else:
            if index < len(li):
                ans.append(li[index])
                index += 1
            else:
                ans.append(rem_0[index_0])
                index_0 += 1
for i in ans:
    print(i, end=" ")



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

/*
R8BH3W
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//*/

#define y1 wwgp
#define endl '\n'
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound

#define mp  make_pair
#define pb  push_back
#define read(x) freopen(x".in","r",stdin);
#define write(x) freopen(x".out","w",stdout);
#define   sz(x)  (int)x.size()
#define  all(x)  x.begin(), x.end()
#define  bit(x)  __builtin_popcountll(x)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = int(2e5)+666, maxn2 = int(1e6)+666;
int inf = LONG_MAX; ll linf = LLONG_MAX;
int mod = 69;
int kob (int x, int y) { return ((ll)x * 1ll * y) % mod; } 
int aza (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int kos (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
/// --------------------------@MAIN THEME-----------------------------------

int h[maxn], d[maxn];

main () { ios_base::sync_with_stdio(0); cin.tie(0);
	#ifdef ez
		read ("")
	#endif
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i) {
		cin >> h[i];
		if (i == 1) {
			d[i] = 0;
			continue;
		}
		if (i == 2) {
			d[i] = abs (h[i] - h[1]);
			continue;
		} else {
			d[i] = min (d[i-1] + abs (h[i] - h[i-1]), d[i-2] + abs (h[i] - h[i-2]));
			continue;
		}

	}


	cout << d[n];
	return 0;	
}

Measured memory_bytes: 1024
from functools import reduce

def mycmb(n,r,p):
    r = min(r,n-r)
    if r == 0:
        return 1
    over = reduce(lambda x,y:x*y%p,range(n,n-r,-1))
    under = reduce(lambda x,y:x*y%p,range(1,r+1))
    return (over * pow(under,p-2,p))%p


mod = 10**9+7

x,y = map(int, input().split())
n = (2*x-y) // 3
m = (2*y-x) //3

if (x+y) % 3 != 0:
    print(0)
    exit()

if n < 0 or m < 0:
    print(0)
    exit()

print(mycmb(n+m,n,mod))

Measured memory_bytes: 9560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,ans=0,ans1=inf;
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		ans+=x;
		if(x%10!=0){
			ans1=min(ans1,x);
		}
	}
	cout <<(ans%10!=0? ans:max(ll(0),ans-ans1));
	// your code goes here
	return 0;
}

Measured memory_bytes: 384
def isprime(x):
    if x == 2:
        return True
    if x < 2 or x%2==0:
        return False
    i = 3
    while i <= x**(1/2):
        if x%i==0:
            return False
        i = i + 2
    return True
n=int(input())
count=0
for i in range(n):
    x=int(input())
    if isprime(x)==True:
        count+=1
print(count)


Measured memory_bytes: 5664
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

// ll n,k,a,b,c,d,x,y,z,m,l;
// ll ans;
// vecl arr(N);
// ll dp[509][509];
// ll pre[N];



void test_case() {
	
    int  h,n;
    cin>>h>>n;

    vec d(n), b(n);

    rep(i,n) {
        cin>>d[i]>>b[i];
    }

    int dp[N];

    for(int i=0; i<N; i++) {
        dp[i] = LONG_MAX;
    }


    

    dp[0] = 0;

    int ans = INT64_MAX;

    for(int i=1; i<=10*h; i++) {
        
        for(int j=0; j<n; j++) {
            if(i- d[j] >=0 && dp[i - d[j]] != LONG_MAX) {
                dp[i] = min(dp[i], dp[i-d[j]] + b[j]);
                if(i>=h) {
                    ans=min(ans, dp[i]);
                }
            }
        }
    }

    // for(int i=1; i<=h; i++) {
    //     cout<<dp[i]<<" ";
    // }
    // cout<<endl;

    cout<<ans<<endl;




}


signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}

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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e17 + 5
#define ll long long
#define int long long
#define pow poww

const int N = 1e5 + 5;
int n , k;
int dp[N] , h[N];

main()
{
    //freopen("B.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    FOR(i , 1 , n)
    {
        dp[i] = oo;
        cin >> h[i];
    }
    dp[1] = 0;
    FOR(i , 2 , n)
    {
        FORD(j , i - 1 , max((ll)1 , i - k))
            dp[i] = min(dp[i] , dp[j] + abs(h[i] - h[j]));
    }
    cout << dp[n];
}



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

#define int long long int
#define MOD 1000000007

void solve()
{
    int n ;
    cin >> n ;
    cout << n * n << endl ;
}

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

    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        solve() ;
    }
    return 0 ;
}

Measured memory_bytes: 256
from operator import itemgetter
n=int(input())
data=[]
for i in range(n):
    a = list(input().split())
    a[1] = int(a[1])
    a.append(i+1)
    data.append(a)
data = sorted(data, key=itemgetter(1), reverse=True)
data = sorted(data, key=itemgetter(0), reverse=False)
for i in data:
    print(i[2])

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	if(a>=13)
	{
		cout<<b;
		return 0;
	}
	if(a<=5)
	{
		cout<<0;
		return 0;
	}
	cout<<b/2;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
int main(){
  string s;
  cin>>s;
  cout<<700+count(s.begin(),s.end(),'o')*100<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define MOD 1000000007
using namespace std;
typedef long long ll;
const int MAXN = 2000005;
int fac[MAXN],inv[MAXN],n,x[9],y[9];
inline int ksm(int x,int k)
{
    ll ret=1;
    while(k){
        if(k&1)ret=(ll)ret*x%MOD;
        x=(ll)x*x%MOD;
        k>>=1;
    }
    return ret;
}
inline void init()
{
    fac[0]=1;
    for(int i=1;i<=2000000;++i)
        fac[i]=(ll)fac[i-1]*i%MOD;
    inv[2000000]=ksm(fac[2000000],MOD-2);
    for(int i=1999999;i>=0;--i)
        inv[i]=(ll)inv[i+1]*(i+1)%MOD;
}
inline int C(int n,int m)
{
//    cout<<n<<" "<<m<<" "<<(ll)fac[m]*inv[m-n]%MOD*inv[n]%MOD<<endl;
    return (ll)fac[m]*inv[m-n]%MOD*inv[n]%MOD;
}
inline int C(int X,int Y,int k)
{
    int rx1,rx2,ry1,ry2;
    if(k==0){
        rx1=X-x[2],rx2=X-x[1],ry1=Y-y[2],ry2=Y-y[1];
    }else{
        rx1=x[5]-X,rx2=x[6]-X,ry1=y[5]-Y,ry2=y[6]-Y;
    }
//    cout<<((C(rx2+1,rx2+ry2+2)-C(rx2+1,ry1+rx2+1)+MOD)%MOD-C(ry2+1,rx1+ry2+1)+MOD)%MOD+C(rx1,rx1+ry1)%MOD<<endl;
    return (((C(rx2+1,rx2+ry2+2)-C(rx2+1,ry1+rx2+1)+MOD)%MOD-C(ry2+1,rx1+ry2+1)+MOD)%MOD+C(rx1,rx1+ry1))%MOD;
}
inline void add(int &x,int a){
    x+=a;
    if(x>=MOD)x-=MOD;
}
int main()
{
    for(int i=1;i<=6;++i)scanf("%d",x+i);
    for(int i=1;i<=6;++i)scanf("%d",y+i);
    init();
    int ans=0;
    for(int i=x[3];i<=x[4];++i){
        add(ans,(ll)C(i,y[3]-1,0)*C(i,y[3],1)%MOD*(MOD-(i+y[3]))%MOD);
        add(ans,(ll)C(i,y[4],0)*C(i,y[4]+1,1)%MOD*(i+y[4]+1)%MOD);
    }
    for(int i=y[3];i<=y[4];++i){
        add(ans,(ll)C(x[3]-1,i,0)*C(x[3],i,1)%MOD*(MOD-(x[3]+i))%MOD);
        add(ans,(ll)C(x[4],i,0)*C(x[4]+1,i,1)%MOD*(x[4]+i+1)%MOD);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15872
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007


char S[100],T[100];

signed main(){
    scanf("%s",S);scanf("%s",T);
    if(strncmp(S,T,strlen(S))==0&&strlen(T)==strlen(S)+1){
        printf("Yes\n");
    }else{
         printf("No\n");
    }
   
    return 0;
}


Measured memory_bytes: 1684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int n,a[105],b[105],flag;
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read(),b[i]=read();
		if(i>2){
			if(a[i]==b[i]&&a[i-1]==b[i-1]&&a[i-2]==b[i-2]) flag=1;
		}
	}
	if(flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 3632