akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

vector<int> memo(50,0);

int fibo(int n){
  if(memo[n]!=0){return memo[n];}
  memo[n]=fibo(n-1)+fibo(n-2);
  return memo[n];

}

signed main(){
  int N;cin>>N;
  memo[0]=memo[1]=1;
  int ans =fibo(N);
  print(ans)



}



Measured memory_bytes: 3224
N = int(input())
L = [1]
for i in range(N):
	if 6**(i+1) <=N:
		L.append(6**(i+1))
	if 9**(i+1) <= N:
		L.append(9**(i+1))
	if 6**(i+1) >N:
		break
L.sort(reverse =True)
dp = []
dp = [float("inf")]*(N+1)

dp[0] = 0

for i in range(N+1):
	for l in L:
		if i+l <= N:
			dp[i+l] = min(dp[i+l], dp[i]+1)

print(dp[N])


Measured memory_bytes: 3828
// 2014/07/29 Tazoe

#include <iostream>
#include <string>
using namespace std;

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

	int t = 0;
	int h = 0;

	for(int i=0; i<n; i++){
		string s1, s2;
		cin >> s1 >> s2;

		if(s1>s2){
			t += 3;
		}
		else if(s1<s2){
			h += 3;
		}
		else{
			t += 1;
			h += 1;
		}
	}

	cout << t << ' ' << h << endl;

	return 0;
}

Measured memory_bytes: 1208
//                               //
    // author : samars_diary //
    // 16-09-2020 │ 23:37:05 //
//                               //

#include <iostream>
using namespace std;

void solve(){
    long long int a;
    cin>>a;
    cout<<1-a;
}

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

    //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif

    int t = 1;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#define F(i)for(int i=0;i<=9;i++)
int main() {
	int n;
	while(scanf("%d",&n)!=EOF) {
		int count=0;
		F(i)F(j)F(k)F(l) {
			if((i+j+k+l)==n) count++;
		}
		printf("%d\n",count);
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
#include<set>
#include<iomanip>
#include<bitset>

using namespace std;

/************************************************/

int main(void) {
	string s;
	cin >> s;
	cout << s[0];
	int count = 0;
	for (int i = 1; i < s.size() - 1; i++) {
		if (s[i] != NULL) {
			count++;
		}
	}
	cout << count;
	cout << s[s.size() - 1];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    LL a[7];
    REP(i,7)cin>>a[i];
    LL ai=a[0],ao=a[1],aj=a[3],al=a[4];
    LL res1=ao,res2=ao;
    res1+=(ai/2LL)*2LL;
    res1+=(aj/2LL)*2LL;
    res1+=(al/2LL)*2LL;
    if(ai%2&&aj%2&&al%2){
        res1+=3;
    }
    if(ai>0&&aj>0&&al>0){
        res2+=3;ai--;aj--;al--;
    }
    res2+=(ai/2LL)*2LL;
    res2+=(aj/2LL)*2LL;
    res2+=(al/2LL)*2LL;
    cout<<max(res1,res2)<<endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::input;
fn main() {
    input! {
        total: usize,
        foots: usize,
    }
    let cranes: f32 = 2.0 * (total as f32) - (foots as f32) / 2.0;
    let turtles: f32 = (foots as f32) / 2.0 - total as f32;
    if (cranes.round() == cranes) && (turtles.round() == turtles) && (cranes >= 0.0) && (turtles >= 0.0) { println!("Yes") }
    else { println!("No") }
    
}


Measured memory_bytes: 2544
#include<iostream>
#include<iomanip>
#include<sstream>
#include<stack>
#include<string>
#include<cstdlib>

double calc( char op, double a, double b )
{
	switch( op )
	{
		case '+':
			return a + b;
		case '-':
			return a - b;
		case '*':
			return a * b;
		case '/':
			return a / b;
	}
}

int main()
{
	std::string str;
	while( std::getline( std::cin, str ) )
	{
		std::stack<double> s;
		std::istringstream iss( str );
		std::string item;

		while( iss >> item )
		{
			if( item == "+" || item == "-" || item == "*" || item == "/" )
			{
				double b = s.top(); s.pop();
				double a = s.top(); s.pop();

				s.push( calc( item[0], a, b ) );
			}
			else
				s.push( atof( item.c_str() ) );
		}

		std::cout << std::fixed << std::setprecision( 6 ) << s.top() << std::endl;
	}

	return 0;
}

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

int main(){
  int n,o=0;
  cin >> n;
  for(int i=0;i<n;i++){
    int tem;
    cin >> tem;
    if(tem%2) o++;
  }
  if(o%2) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

 class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i = 1;
		int x;
		while(true){
			x = scan.nextInt();
			if(x == 0)break;
			System.out.println("Case " + i + ": " + x);
			i++;
		}
	}
}

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

typedef long long ll;

int n, p;
string s;
int cnt[10001];

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

    cin >> n >> p >> s;

    ll res;
    if (p == 2 || p == 5) {
        for (int i = 0; i < n; ++i) {
            if ((s[i] - '0') % p == 0)
                res += i + 1;
        }
    } else {
        ll base = 1;
        ll sum = 0;
        cnt[0] = 1;
        for (int i = n - 1; i >= 0; --i) {
            sum = ((s[i] - '0') * base + sum) % p;
            res += cnt[sum];
            cnt[sum]++;
            base = base * 10 % p;
        }
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 720
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,K,count=0;
  scanf("%d %d",&N,&K);
  int num[N];
  //for(int i=0;i<N;i++) scanf("%d ",&num[i]);
  count =  (N-K)/(K - 1) + 1;
  if((N - K)%(K - 1) != 0)count ++;
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
def permutation(n,x,mod=10**9+7):
    tmp=1
    for i in range(n,n-x,-1):
        tmp=(tmp*i)%mod
    return tmp

import itertools
n=int(input())
lst=[list(map(int,input().split())) for _ in range(n)]
patlen=permutation(n,n)
patlst=list(itertools.permutations(lst,n))
kyori=0
for i in patlst:
    for j in range(n-1):
        kyori+=((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2)**0.5
        
print(kyori/patlen)        

Measured memory_bytes: 45168
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n;
char s[111111];

int calc(char ch) {
	int l = 0, r = n-1, res = 0;
	if (s[l] != ch) {
		res++;
		while(l<=r && s[l]!=ch) l++;
	}
	if (l<=r && s[r] != ch) {
		res++;
		while(l<=r && s[r]!=ch) r--;
	}
	for(int i=l;i<r;i++)
		if (s[i]==ch && s[i+1] != ch) res+=2;
	return res;
}

int main() {
	scanf("%s", s);
	n = strlen(s);
	printf("%d\n", min(calc('B'), calc('W')));
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372037ll;

void solve()
  {
   int n;
   cin>>n;
   map<int,int> mp;
   loop(i,1,101)
    loop(j,1,101)
     loop(k,1,101)
       {
        int lhs = i*i + j*j + k*k + i*j + i*k + j*k;
        mp[lhs]++;
       }
   loop(i,1,n+1)
    cout<<mp[i]<<END;
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 6028
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
typedef pair<int, int> pair;
double rad(double a) {return a * 180 / PI;}

//dpTable
int dp[100050];

vector<ll> rsk(100050);

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    cout << ((B - A + 1) % 2 == 0 ? "Borys" : "Alice") << endl;
    return 0;
}

Measured memory_bytes: 3868
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: i32 = s.next().unwrap().parse().unwrap();
	let a: Vec<i32> = s.take(n).map(|a| a.parse().unwrap()).collect();
	let sum: i32 = a.iter().sum();
	let ans = divisors(sum).fold(1, |r, x| {
		let mut sum = 0;
		let mut a: Vec<i32> = a.iter().map(|a| a % x).inspect(|a| sum += a).collect();
		let m = (sum / x) as usize;
		a.sort();
		let cnt: i32 = a[0..n - m].iter().sum();
		if cnt <= k {
			x
		} else {
			r
		}
	});
	println!("{}", ans);
}

pub fn divisors<T>(n: T) -> impl std::iter::Iterator<Item = T>
where
	T: num::PrimInt,
{
	let n = if n < T::zero() { T::zero() - n } else { n };
	let mut d = T::one();
	let mut divs = vec![];
	std::iter::from_fn(move || {
		while d * d <= n {
			if n % d == T::zero() {
				let r = d;
				if d != n / d {
					divs.push(n / d);
				}
				d = d + T::one();
				return Some(r);
			}
			d = d + T::one();
		}

		divs.pop()
	})
}


Measured memory_bytes: 2180
#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; }
const ll INF=1LL<<60;
int main(){
    ll a,b;cin >> a >> b;
    if(a==1||b==1){
        cout << 1 << endl;
    }
    else{
        cout << (a*b+1)/2 << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
a=[int(x) for x in input().split()]
ruiseki=[0]
for i in range(1,n+1):
  ruiseki.append(ruiseki[i-1]+a[i-1])

ruiseki=ruiseki[1:]
mod=10**9+7
ma=max(ruiseki)
ans=0
for i in range(len(a)):
  ans+=((ma-ruiseki[i])*a[i])%mod
print(ans%mod)



Measured memory_bytes: 31688
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll n;
vi A;
vvi E(222222);
vi deg(222222);
vi dp(222222,llINF);
vi ans(222222);
void dfs(ll now,ll par){
  for(auto e:E[now]){
    if(e == par)continue;
    auto lb = lower_bound(ALL(dp),A[e]);
    ll po = lb-dp.begin();
    ll num = dp[po];
    *lb = A[e];
    ans[e] = (lower_bound(ALL(dp),llINF)-dp.begin());
    dfs(e,now);
    dp[po] = num;
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  A.resize(n);
  for(auto &a:A)cin>>a;
  for(int i=0;i<n-1;i++){
    ll a,b;cin>>a>>b;
    E[--b].pb(--a);
    E[a].pb(b);
  }
  dp[0] = A[0];
  ans[0] = 1;
  dfs(0,-1);
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 33028
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
int INF = 1000000000;

int main() {
  string s, t; cin >> s >> t;
  int cnt = 0;
  rep(i, 3) {
    if (s[i] == t[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;
  vll as(n);
  rep(i, n) cin >> as[i];

  vll dp(k + 1, 0);
  rep(i, k + 1) {
    dp[i] = 0;
    rep(j, n) {
      if (i - as[j] >= 0 && dp[i - as[j]] == 0) {
        dp[i] = 1;
        break;
      }
    }
  }
  string ans = dp[k] == 1 ? "First" : "Second";

  cout << ans << endl;

  return 0;
}


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

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

    int res0 = 0;
    int resN = 0;
    int Ai;
    for (int i = 0; i < M; i++)
    {
        cin >> Ai;
        if (Ai < X)
        {
            res0++;
        }
        if (Ai > X)
        {
            resN++;
        }
    }
    cout << min(res0, resN) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
  ll a=lD(),b=lD(),x=lD(),sum=0;
  sum=(b/x)-(a/x);
  if(a%x==0)
    sum++;
  cout<<sum<<endl;
}




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

int main()
{
    int s, ans = 1; cin >> s;
    while(!(s == 4 || s == 2 || s == 1)){
        if(s % 2) s = 3 * s + 1;
        else s = s / 2;

        ans++;
    }
    cout << ans + 3 << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  string s;cin>>s;
  ll k;cin>>k;
  ll n=s.size();

  ll c=0;
  string a=s;
  vector<ll>v(10,0);
  rep(i,0,a.size()-1){
    if(a[i]==a[i+1])c++;
    else {v[0]+=(c+1)/2;c=0;}
  }
  v[0]+=(c+1)/2;
  c=0;
  a+=s;
  rep(i,0,a.size()-1){
    if(a[i]==a[i+1])c++;
    else {v[1]+=(c+1)/2;c=0;}
  }
  v[1]+=(c+1)/2;
  c=0;
  a+=s;
  rep(i,0,a.size()-1){
    if(a[i]==a[i+1])c++;
    else {v[2]+=(c+1)/2;c=0;}
  }
  v[2]+=(c+1)/2;

  ll p=v[2]-v[1],q=v[1]-v[0];

  // rep(i,0,3)out(v[i]);

  if(p==q){
    out(v[0]+q*(k-1));
  }else{
    if(k%2)out(v[1]*(k/2)+v[0]);
    else out(v[1]*(k/2));
  }



  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
t = input()

if s == t:
  print(n)
  exit()

ans = ''
for i in range(n):
  ss = s[n-i-1:]
  tt = t[:i+1]
  if ss == tt:
    ans = s[:n-i-1]+ss+t[i+1:]
if len(ans) == 0:
  print(len(s+t))
else:
  print(len(ans))
  

Measured memory_bytes: 3060
#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int rad = 0;
  f80 x = 0, y = 0;
  while (true) {
    int a, b;
    char c;
    cin >> a >> c >> b;
    if (a == 0) break;

    x += cos((double) rad * M_PI / 180) * a;
    y += sin((double) rad * M_PI / 180) * a;
    rad += b;
  }
  cout << (int) y << '\n';
  cout << (int) x << '\n';
}



Measured memory_bytes: 3476
n, q = map(int, input().split())
s = input()
t = [0]*(n + 1)

for i in range(n):
    if s[i: i + 2] == "AC":
        t[i + 1] = t[i] + 1
    else:
        t[i + 1] = t[i]

for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])

Measured memory_bytes: 51316
#include<bits/stdc++.h>
#include<math.h>
#define rep(i, n, k) for(int i=k; i<n; ++i)
#define drep(i, n, k) for(int i=k; i>=n; --i)
using namespace std;

int main(){
  long long int a, b;
  cin >> a >> b;
  long long int k;
  if((a+b) % 2 == 0) k = (a+b)/2;
  else{
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  cout << k << endl;
  return 0;
}

Measured memory_bytes: 256
//Wrong answer on test inf.
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
#define y1 y1___
using namespace std;
char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
ll read(){
	char ch=gc();ll x=0;int op=1;
	for (;!isdigit(ch);ch=gc()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=gc()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
int main(){
	int n=read(),k=read();
	printf("%d\n",(n-1-1)/(k-1)+1);
	return 0;
}

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

Measured memory_bytes: 596
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M, X = getlist()
	L = []
	for i in range(N):
		CA = getlist()
		L.append(CA)

	ans = INF
	for i in range(1 << N):
		money = 0
		algo = [0] * M
		for j in range(N):
			if ((i >> j) & 1) == 1:
				money += L[j][0]
				for k in range(M):
					algo[k] += L[j][k + 1]

		judge = "Yes"
		for j in range(M):
			if algo[j] < X:
				judge = "No"

		if judge == "Yes":
			ans = min(ans, money)

	if ans == INF:
		print(-1)
	else:
		print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 68624
#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>
#include <functional>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;
int main()
{
	int N;
	cin >> N;
	for (int f = 0; f * 4 <= 100; f++) {
		for (int s = 0; s * 7 <= 100; s++) {
			if (N == f * 4 + s * 7) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}



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

using namespace std;

int main(){
    long long int X;
    cin >> X;

    for(long double i=-1000;i<=1000;i++){
        for(long double j=-1000;j<=1000;j++){
            if(i*i*i*i*i+j*j*j*j*j==X){
                cout << i << " " << -j << endl;
                return 0;
            }else if(i*i*i*i*i-j*j*j*j*j==X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3788
n = int(input())
s = input()
max_sep = 0
for i in range(n):
  s1 = s[:i]
  set1 = set(list(s1))
  s2 = s[i:]
  set2 = set(list(s2))
  set_all = set1 & set2
  max_sep = max(max_sep, len(set_all))

print(max_sep)

Measured memory_bytes: 3064
<?php
  list($n, $d) = explode(" ", trim(fgets(STDIN)));

  $x = [];
  for ($i=0; $i<$n; $i++) {
    $x[] = explode(" ", trim(fgets(STDIN)));
  }

  $ans = 0;
  for ($i=0; $i<$n; $i++) {
    for ($j=$i+1; $j<$n; $j++) {
      $distance = 0;
      for ($k=0; $k<$d; $k++) {
        $distance += pow($x[$i][$k] - $x[$j][$k], 2);
      }
      $a = ceil(sqrt($distance));
      if(($a * $a) == $distance){
        $ans++ ;
      }
    }
  }
    
  echo $ans;

Measured memory_bytes: 4984
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using Graph = vector<vector<int>>;

int main()
{
    int n;
    string x;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i, n) {
        cin >> s[i] >> t[i];
    }
    cin >> x;

    int pos = 0;
    rep(i, n) {
        if (x == s[i]) {
            pos = i;
            break;
        }
    }

    if (pos + 1 == n) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    for (int i = pos  + 1; i < n; i++) {
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}

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

int a[100000];
int b[100000];
int pos[100000];
int cnt[100000];
int diff[100000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> a[i];
		a[i]--;
		pos[a[i]] = i;
	}
	for(int i = 0; i < N; i++){
		cin >> b[i];
		b[i]--;
		cnt[b[i]]++;
	}

	bool flag = 0;
	for(int i = 0; i < N; i++){
		if(cnt[i] == 0){
			diff[pos[i]] = 1;
			flag = 1;
		}
	}

	if(flag){
		cout << "No" << endl;
		for(int i = 0; i < N; i++){
			cout << i + 1;
			if(i != N - 1) cout << " ";
		}
		cout << endl;

		for(int i = 0; i < N; i++){
			if(diff[i]){
				cout << (i + 1) % N + 1;
			}
			else{
				cout << i + 1;
			}
			if(i != N - 1) cout << " ";
		}
		cout << endl;
	}
	else{
		cout << "Yes" << endl;
	}
}



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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
    }
    sort(all(p));
    int ans = 0;
    rep(i, k) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

template <class T>
inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}


Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector <int> v(n);
	for (int i=0;i<n;++i){
		cin>>v[i];
	}
	sort(v.begin(),v.end(),greater <int> ());
	long long int ans = 0;
	int id = 0;
	for (int i=0;i<n-1;++i){
		ans += (long long int) v[id];
		if (i%2 == 0){
			++id;
		}
	}
	cout << ans << endl;
}

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

int n,l[1000],sum,ma;

int main(){
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>l[i];
        sum+=l[i];
        if(l[i]>ma)ma=l[i];
    }
    sum-=ma;

    if(sum>ma){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

m = 0
su = 0
mi = 10 ** 10
for ai in A:
    if ai < 0:
        m += 1
    mi = min(mi, abs(ai))
    su += abs(ai)

if m % 2 == 1:
    print(su - 2 * mi)
else:
    print(su)

Measured memory_bytes: 14332
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int h[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) cin >> h[i];

  int ans = 0;
  int sum = 0;
  int ma = h[0];
  FOR(i, 1, n) {
    if(ma >= h[i]) {
      sum++;
      ans = max(ans, sum);
    } else {
      sum = 0;
    }
    ma = h[i];
  }

  cout << ans << endl;
}


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

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double epsilon = 1e-9;        // Add epsilon when casting double to int to avoid rounding pitfall issues, eg, 0.94*8178 in int
const int maxn = 1e6+10;

void solve()
{
    ll n;
    cin >> n;

    vector<pair<ll, ll> > a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i].first;
        a[i].second = i;    
    }

    sort(a.begin(), a.end());
    for(auto i: a)
        cout << i.second+1 << " ";
    
}

int main()
{
   
    int t = 1;
    //cin >> t;
    while(t--)
        solve();

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 4848
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  while (true) {
    int h, w; cin >> h >> w;
    if (h == 0 && w == 0) break;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
	cout << '#';
      }
      cout << endl;
    }
      cout << endl;
  }
  return 0;
  
}

Measured memory_bytes: 1152
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(input())
L = [int(input()) for _ in range(N)]
ans = 0
prev = 0
for a in L:
    if a == 0:
        prev = 0
        continue

    a += prev
    ans += a//2
    prev = a % 2
print(ans)


Measured memory_bytes: 7200
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 55;
const int MAXM = 1010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    int sum = 0;
    FOR(i,1,n)
        FOR(j,i+1,n) sum += a[i] * a[j];
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n; cin >> n;
    long long min = n;
    for(long long i=1;i<=sqrt(n);++i){
        long long b;
        if(n%i != 0) continue;
        b = n/i;
        if(min > b) min = b;
    }
    string s = to_string(min);
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 100005;

int n, m, v, p;
int a[MAXN];

bool trial(int x){
	auto idx = upper_bound(a, a + n, a[x]) - a;
	lint tmp = 1ll * (v - idx - p + 1) * m;
	for(int i=idx; i<n-p+1; i++){
		if(a[x] + m < a[i]) return 0;
		tmp -= a[x] + m - a[i];
	}
	return tmp <= 0;
}

int main(){
	scanf("%d %d %d %d",&n,&m,&v,&p);
	for(int i=0; i<n; i++) scanf("%d",&a[i]);
	sort(a, a + n);
	int s = 0, e = n;
	while(s != e){
		int m = (s+e)/2;
		if(trial(m)) e = m;
		else s = m + 1;
	}
	cout << n - s << endl;
}


Measured memory_bytes: 640
def func(n):
  return int((n / 2) if n % 2 == 0 else (3 * n + 1))

s = int(input())

A = [s]
i = 0
while A[i] not in A[:i]:
  A.append(func(A[i]))
  i += 1
print(i + 1)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int gcd(int x, int y) { return x&&y? gcd(y%x,x): x+y; }
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto &x: a) cin >> x;
  vector<int> lg(n), rg(n);
  lg[0]=0;
  for(int i=1;i<n;++i) lg[i]=gcd(lg[i-1],a[i-1]);
  rg[n-1]=0;
  for(int i=n-2;i>=0;--i) rg[i]=gcd(rg[i+1],a[i+1]);
  
  int answer = max(lg[n-1],rg[0]);
  FOR(i,1,n-1) answer = max(answer, gcd(lg[i],rg[i]));
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1408
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int[] count = new int[3];

        int[] array = new int[n];
        for(int i = 0;i < n;i++){
            int temp = sc.nextInt();
            if(temp <= a){
                count[0] ++;
            }else if(temp <= b){
                count[1] ++;
            }else{
                count[2] ++;
            }
        }

        System.out.println(Math.min(count[0],Math.min(count[1],count[2])));


    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}//ここまで

Measured memory_bytes: 21712
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<ll> p(n);
    REP(i, n) cin >> p[i];

    vector<ll> rank(n);
    iota(ALL_OF(rank), 0LL);
    sort(ALL_OF(rank), [&](ll i, ll j) {
        return p[i] < p[j];
    });
    ll cand = 1;
    ll coans = 1;
    RANGE(i, 1, n-1) {
        if (rank[i-1] < rank[i]) {
            ++cand;
        } else {
            cand = 1;
        }
        chmax(coans, cand);
    }
    cout << n - coans << endl;
    
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int dp[81][81][6400 * 2 + 2];
int find_it(int dif_sum , int i , int j , int &n , int &m , vector<vector<pair<int , int>>> & matrix){
    if(i == n - 1 && j == m - 1){
        return min(abs(dif_sum + matrix[i][j].first - matrix[i][j].second) , abs(dif_sum + matrix[i][j].second - matrix[i][j].first));
    }
    if(dp[i][j][dif_sum + 6401] != -1){
        return dp[i][j][dif_sum + 6401];
    }
    int minvalue = INT_MAX;
    int ff = dif_sum + matrix[i][j].first - matrix[i][j].second;
    int ss = dif_sum + matrix[i][j].second - matrix[i][j].first;
    if(i + 1 < n){
        minvalue = min(minvalue , find_it(ff , i + 1 , j , n , m , matrix));
        minvalue = min(minvalue , find_it(ss , i + 1 , j , n , m , matrix));

    }
    if(j + 1 < m){
        minvalue = min(minvalue , find_it(ff , i , j + 1 , n , m , matrix));
        minvalue = min(minvalue , find_it(ss , i , j + 1 , n , m , matrix));
    }
    return dp[i][j][dif_sum + 6401] = minvalue;

}
int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n , m;
    cin >> n >> m;
    vector<vector<pair<int , int> > > matrix(n , vector<pair<int , int>> (m));

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cin >> matrix[i][j].first;
        }
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cin >> matrix[i][j].second;
        }
    }
    memset(dp , -1 , sizeof(dp));
    cout << find_it(0 , 0 , 0 , n , m , matrix);


return 0;
}


Measured memory_bytes: 328448
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){
    int n;cin >> n;
    int k ;cin >> k;
    int q;cin >> q;
    int a[q];
    int b[n];
    
    for(int i=0;i<n;i++){
        b[i] = 0;
    }
    for(int i=0;i<q;i++){
        cin >> a[i];
        a[i]--;
        b[a[i]]++;
     }
    for(int i=0;i<n;i++){
        if(k-q+b[i] > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
import sys
N,Y=map(int,input().split())
count=0
n=N+1
for x in range(n):
  i=10000*x
  if i>Y:
    break
  for y in range(n):
    j=5000*y
    if j>Y:
      break
    z=N-x-y
    if z<0:
      continue
    if i+j+1000*z==Y:
      print(x,y,z)
      sys.exit()
print(-1,-1,-1)

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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

vector< bool > prime_table(int 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(){
  //cout.precision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll Q;
  cin >> Q;
  
  int N = 100000;
  
  auto vec = prime_table(N);
  
  vector<ll> sum(N);
  sum[0] = 0;
  
  REP(i,N-1){
    sum[i] = sum[i-1];
    if(vec[i] && vec[(i+1)/2]) sum[i]++;
  }

  rep(i,Q){
    int l,r;
    cin >> l >> r;
    cout << sum[r] - sum[l-1] << endl;
  }
}
  
  

Measured memory_bytes: 1408
#include <iostream>

bool check(const int& D, const int& T, const int& S)
{
    // 間に合わない場合
    if(D > T*S)
    {
        return false;
    }

    return true;
}

int main()
{
    int D,T,S;// D[m], T[min], S[m/min]
    std::cin >> D >> T >> S;
    if(
        (D < 1 && 10000 < D ) 
        || (T < 1 && 10000 < T ) 
        || (S < 1 && 10000 < S ) 
    )
    {
        std::cout << "input error";
        return -1;
    }


    bool canArrive = check(D, T,S);
    if(canArrive)
    {
        std::cout << "Yes";
    }
    else
    {
       std::cout << "No";
    }
    
    return 0;
}

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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  for(int i =0; A>0 && C>0; i++){
    C -= B;
    if(C <=0)
      break;
    A -= D;
  }
  if(C>A)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}



Measured memory_bytes: 3632
# import sympy

# 約数の列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

def main():
    N = int(input())
    table = num_divisors_table(N)
    ans = 0
    for c in range(1, N):
        #ab = make_divisors(N-c)
        #ab = sympy.divisors(N-c)
        ab = table[N-c]
        ans += ab
    print(ans)
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 16520
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int P,Q,R;
	cin>>P>>Q>>R;
	cout<<(min(P+Q,min(Q+R,R+P)));
  return 0;
}


Measured memory_bytes: 256