akhauriyash/Code-Regression huggingface dataset:
<?php
define('MAX', pow(10, 5));
fscanf(STDIN, "%d %d", $N, $M);
$a = [1];
for ($i = 1; $i <= sqrt($M); $i++) {
    if ($M % $i === 0) {
        $x = intdiv($M, $i);
        if ($x >= $N) {
            $a[] = $i;
        }
        if ($i >= $N) {
            $a[] = $x;
        }
    }
}
printf("%d", max($a));


Measured memory_bytes: 4604
#include <iostream>
typedef long long int ll;
typedef long double ld;

int main(void){
	int K, i = 0;
	int a[1000000];
	std::cin >> K;
	a[0] = 7 % K;
	if(a[0] == 0){
		std::cout << i+1 << std::endl;
		return 0;
	}
	for(i = 1; i <= K; i++){
		a[i] = (a[i-1]*10 + 7) % K;
		if(a[i] == 0){
			std::cout << i+1 << std::endl;
			return 0;
		}
	}
	std::cout << -1 << std::endl;

	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,K;
  cin>>N>>K;
  int ans=INT_MAX;
  for(int i=0;i<=N;i++){
    int num=1;
    int j=N-i;
    for(int k=0;k<i;k++)num*=2;
    for(int k=0;k<j;k++)num+=K;
    ans=min(ans,num);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int K;
  string S;
  cin >> K >> S;
  int L = S.size();
  
  if (L <= K) {
    cout << S;
  }
  else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "...";
  }
  
}

Measured memory_bytes: 3632
n=int(input())
li = list(map(int,input().split()))

count=0
for i in range(n-2):
  ext=[]
  for k in range(3):
    ext.append(li[i+k])
    
  ext.sort()
  if ext[1]==li[i+1]:
    count+=1
    
print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, ai, aj;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i != n; ++i) cin >> a[i];
  sort(begin(a), end(a));
  ai = a.back();
  auto j = upper_bound(begin(a), end(a), ai / 2) - begin(a);
  if (j == 0) {
    aj = a[0];
  } else if (j == n - 1) {
    aj = a[n - 2];
  } else {
    aj = 2*a[j] - ai < ai - 2*a[j-1] ? a[j] : a[j-1];
  }
  cout << ai << " " << aj << endl;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n,s) for (int i=a;s>0?i<n:i>n;i+=s)
#define rep(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int inf = 1e9+10, mod = 1e9+7; const long long llinf = 1e18;
// head


int main(){
  int x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<long long> A(x),B(y),C(z);
  rep(i,x)cin >> A[i];
  rep(i,y)cin >> B[i];
  rep(i,z)cin >> C[i];
  vector<long long >data;
  rep(i,x)rep(j,y) data.push_back(A[i]+B[j]);
  sort(all(data));
  reverse(all(data));
  vector<long long > ans;
  rep(i,min(int(data.size()),k))rep(j,z) ans.push_back(data[i]+C[j]);
  sort(all(ans));
  reverse(all(ans));
  rep(i,k) cout << ans[i] << endl;
  
}

Measured memory_bytes: 43112
import java.util.*;

// UVa 11504

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		char[] c1 = in.next().toCharArray();
		char[] c2 = in.next().toCharArray();
		char[] c3 = in.next().toCharArray();
		
		char turn = 'a';
		int ai = 0;
		int bi = 0;
		int ci = 0;

		while (true) {
			if (turn == 'a') {
				if (ai == c1.length) {
					System.out.println("A");
					break;
				} else {
					turn = c1[ai];
					ai++;
				}
			}
			if (turn == 'b') {
				if (bi == c2.length) {
					System.out.println("B");
					break;
				} else {
					turn = c2[bi];
					bi++;
				}
			}
			if (turn == 'c') {
				if (ci == c3.length) {
					System.out.println("C");
					break;
				} else {
					turn = c3[ci];
					ci++;
				}
			}
		}
	}
}

Measured memory_bytes: 22484
#include<iostream>
#include<string>

#include<cstring>
#include<map>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<utility>
#include<sstream>
#include<stack>
using namespace std ;

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



#define pb push_back
#define all(x) x.begin(),x.end()
#define distSqr(x1,y1,z1,x2,y2,z2) (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2)
#define dist(x1,y1,x2,y2) sqrt(distSqr(x1,y1,x2,y2))
#define Set(x,v) memset(x,v,sizeof x)
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b) __gcd(a,b)
#define pi acos(-1)
#define mp make_pair
#define error 1e-12
#define mod 1000007
#define For(i,n) for(i=0;i<n;i++)
#define inf 1e5

typedef long long ll;
typedef unsigned int ui;

typedef pair<ui,ui> puu;
typedef double db;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,db> pid;
typedef vector<int> VI;
typedef pair<char,char> pcc;

bool chk(int n,int pos) {return n&(1<<pos);}
void set(int& n,int pos) {n=n|(1<<pos);}
void reset(int& n,int pos) {n=n&~(1<<pos);}

int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)==2)
    {
        printf("%d\n",gcd(a,b));
    }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
   lli A,B,C,L,R,N,M,K,sum=0,num=0,flag=1;
   cin >> A >> B >> C;
   if(A%2==0||B%2==0||C%2==0)Out(0);
   else Out(min(A*B,min(B*C,C*A)));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
ll cnt[N],n,ans,a[N];
struct Tree
{
	ll l,r;
	ll dat,sum;
	#define l(x) t[x].l
	#define r(x) t[x].r
	#define dat(x) t[x].dat
	#define sum(x) t[x].sum
}t[N<<2];
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
inline void build(int p,int l,int r)
{
	l(p)=l;r(p)=r;
	if(l==r) 
	{
		dat(p)=cnt[l];
		sum(p)=dat(p)*(dat(p)-1)/2;
		return;
	}
	int mid=l+r>>1;
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	sum(p)=sum(p<<1)+sum(p<<1|1);
}
inline void ask(int p,int x)
{
	if(l(p)==r(p)) return;
	int mid=l(p)+r(p)>>1;
	if(x<=mid) ans+=sum(p<<1|1),ask(p<<1,x);
	else       ans+=sum(p<<1),ask(p<<1|1,x);
}
int main()
{
	//freopen("1.in","r",stdin);
	n=read();
	for(int i=1;i<=n;++i) 
	{
		a[i]=read();
		cnt[a[i]]++;
	}
	build(1,1,n); 
	for(int i=1;i<=n;++i)
	{
		ans=(cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
		ask(1,a[i]);
		printf("%lld\n",ans);
	}
	return 0;
}


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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n;
int a[101];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;
#endif
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] == a[i]) {
      a[i] = 10000;
      ans++;
    }
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
//mint
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
//BIT
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
};
//combination
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
//gcd and lcm
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
//prime
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

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

  int dp[h+1];
    rep(j,h+1){
    dp[j]=100000000;
    }

  dp[0]=0;
  rep(i,n){
  cin >> a >>b;
    rep(j,h+1){
      int nj=min(j+a,h);
      dp[nj]=min(dp[nj],dp[j]+b);
    
    }
   }
	cout <<dp[h]<<endl;
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    bool flag = true;
    if(S[2] != S[3]) flag = false;
    if(S[4] != S[5]) flag = false;
    if(flag == true) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define endl '\n'
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

ll n, k, dist[101010];
vpi adj[101010];
bool vis[202020];

void djikstra(int s){

    rep(i, 0, k){
    dist[i] = inf;
    }
    priority_queue<pi> q;
    dist[s]=0;
    q.push({0, s});

    while(!q.empty()){

        int a, b;
        tie(a, b) = q.top();
        q.pop();

        if(vis[b])continue;
        vis[b]=true;

        for(auto  t: adj[b]){

            if(dist[t.f] >= dist[b]+t.ss ){

            dist[t.f] = min(dist[t.f], dist[b]+t.ss );
            q.push({-dist[t.f], t.f });

            }
        }

    }


}

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

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


cin >> k;

rep(i, 0, k){
    adj[i].pb({(i+1)%k, 1});
    adj[i].pb({(i*10)%k, 0});
}

djikstra(1);


cout << dist[0]+1 << endl;






return 0;}
///....


Measured memory_bytes: 7292
unittest
{
	assert( [ "5", "5 2 3 4 1" ].parse.expand.solve == "YES" );
	assert( [ "5", "2 4 3 5 1" ].parse.expand.solve == "NO" );
	assert( [ "7", "1 2 3 4 5 6 7" ].parse.expand.solve == "YES" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto ps = input.front.split.to!( long[] );
	return tuple( ps );
}

auto solve( long[] ps )
{
	auto r = 0L;
	foreach( i, p; ps )
	{
		r += ( i + 1 != p );
	}
	return ( r <= 2 ) ? "YES" : "NO";
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

#pragma region Debug
void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cout << H << " ";
	debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
#pragma endregion

// コンパイル時、エイリアス「debug」を使用 --> マクロが使えるように

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	int n,k;
	cin >> n >> k;

	vi p(n),c(n), start_pts(n+1, 0);

	rep(i,n){
		cin >> p[i];
		p[i]--;
	}
	rep(i,n){
		cin >> c[i];
	}

	int ans = -1e18;
	// 始点を決める
	rep(s,n){
		int ptr = s;
		vi course; // 初期化できる?
		ll total = 0;
		// あるサイクルを周回する
		while(1){
			ptr = p[ptr];
			course.eb(c[ptr]);
			total += c[ptr];	// 1周分を集計
			if(ptr == s) break;
		}
		// そのサイクルについて終点を全探索
		int l = course.size();
		ll temp = 0;
		rep(i,l){
			temp += course[i];
			if(i+1 > k) break;
			ll now = temp;
			if(total > 0){
				ll rounds = (k-(i+1))/l;
				now += total * rounds;
			}
			ans = max(ans, now);
		}
	}

	cout << ans << endl;

}

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

Measured memory_bytes: 3824
using System;
//using System.Collections.Generic;
//using System.Text;
using System.Linq;

class AtCoder{
  public static void Main(){

    string s = Console.ReadLine();
    char[] c = s.ToCharArray();
    
    char[] c2 = c.Distinct().ToArray();
    
    if(c.Length == c2.Length) Console.WriteLine("yes");
    else Console.WriteLine("no");
  }
}


Measured memory_bytes: 13268
h,w = map(int,input().split())
g=[input() for _ in range(h)]

def cost(x):
    v=[[0]*w for _ in range(h)]
    v[x[1]][x[0]]=1
    que = [x]
    ans=-1
    while que:
        newque = []
        for X,Y in que:
            for x,y in ((0,-1),(-1,0),(0,1),(1,0)):
                if 0<=X+x<w and 0<=Y+y<h and g[Y+y][X+x]=='.' and v[Y+y][X+x]==0:
                    v[Y+y][X+x] = 1
                    newque.append((X+x,Y+y))
        ans+=1
        que = newque
    return ans

ans = 0
for i in range(w):
    for j in range(h):
        if g[j][i]=='.':
            ans = max(ans,cost((i,j)))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

using ll = long long;
using namespace std;

bool exist(const vector<int> A) {
    int N = A.size();
    if (N % 2 == 1) {
        if (A[0] != 0)return false;
        for (int i = 1; i < N; i++) {
            int k = i;
            if (i % 2 == 1)k++;
            if (A[i] != k)return false;
        }
    }
    else {
        for (int i = 0; i < N; i++) {
            int k = i;
            if (i % 2 == 0)k++;
            if (A[i] != k)return false;
        }
    }
    return true;
}

int main() {
    int mod = 1'000'000'007;
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N)cin >> A[i];

    sort(A.begin(), A.end());
    if (!exist(A)) {
        cout << "0" << endl;
        return 0;
    }

    int e = N / 2;
    int ans = 1;
    for (int i = 0; i < e; i++) {
        ans *= 2;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>

int main(){
  int N,K,X,Y,i,val;
  val=0;
  scanf("%d",&N);
  scanf("%d",&K);
  scanf("%d",&X);
  scanf("%d",&Y);

  for(i=1;i<=N;i++){
    if(i<=K){
      val+=X;
  }else{
      val+=Y;
    }
  }
  printf("%d",val);
  return 0;
}

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

using namespace std;


const int N=1e6+7;

int n,arr[N],st=2,en,mid,frq[N];
int can(){}
int main() {

    int a , b , c , d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b) + min(c,d) << endl;
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> u1(n);
  vector<int> u2(n);
  vector<int> u3(n);
  vector<int> a1(101,0);
  vector<int> a2(101,0);
  vector<int> a3(101,0);
  for(int i=0;i<n;i++){
    cin>>u1[i]>>u2[i]>>u3[i];
    a1[u1[i]]++;
    a2[u2[i]]++;
    a3[u3[i]]++;
  }
  long long int ans=0;

  for(int i=0;i<n;i++){
    ans=0;
    if(a1[u1[i]]==1)ans+=u1[i];
    if(a2[u2[i]]==1)ans+=u2[i];
    if(a3[u3[i]]==1)ans+=u3[i];
    cout<<ans<<endl;
  }

}



Measured memory_bytes: 3056
def solve():
    N, X = map(int,input().split())
    A = [0] + list(map(int, input().split()))
    ans = 0
    #A =[]*N個、for i in range(N-1)でやると、初項がXより大きい場合に対応できない。
    #より正確にいうと、A =[3, 3, 2] X = 1のようなケース。 A1>A3かつ A1+A2>X かつ　A2+A3 > Xのとき
    for i in range(N):
        diff = A[i] + A[i+1] - X
        if diff > 0:
            A[i+1] -= diff
            ans += diff
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 14252
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int x[101];
int y[101];
int h[101];

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i] >> h[i];
	int H = 1;
	bool flag = false;
	int X;
	int Y;
	
	for (int i = 0; i <= 100; i++) 
	{
		int cx = i;
		X = cx;
		vector<int>ans;
		vector<int>idx;
		for (int j = 0; j <= 100; j++) 
		{
			int cy = j;
			Y = cy;
			for (int t = 0; t < n; t++)
			{
				int q = abs(X - x[t]) + abs(Y - y[t]);
				if (h[t] != 0) {
					ans.push_back(h[t] + q);
				}
				if (h[t] == 0) {
					idx.push_back(t);
				}
			}
			ans.erase(unique(ans.begin(), ans.end()), ans.end());
			if (ans.size() == 1) {
				int h = ans[0];
				bool flag = true;
				for (int m = 0; m < idx.size(); m++) {
					int q = abs(X - x[idx[m]]) + abs(Y - y[idx[m]]);
					if (h > q)
						flag = false;
				}
				if (flag) {
					cout << X << ' ' << Y << ' ' << h;
					return 0;
				}
			}
			ans.clear();
			idx.clear();

		}
	}
}



Measured memory_bytes: 256
S = str(input())
Y = int(str(S[0]) + str(S[1]))
M = int(str(S[2]) + str(S[3]))
if Y <= 12 and 1 <= Y and M <= 12 and 1 <= M:
    print("AMBIGUOUS")
elif M <= 12 and 1 <= M:
    print("YYMM")
elif Y <= 12 and 1 <= Y:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long




int32_t main(){
	int s = 0;
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i = 0;i<n;i++){
		cin>>v[i];
		s+=v[i];
		if(i) v[i] += v[i-1];
	}
	int resp = (int) 1e19;
	for(int i = 0;i<n-1;i++){
		resp = min(resp , abs(2*(v[i]) -s));
	}
	cout<<resp<<endl;
}

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

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

	vector<int> a(M), b(M);
	vector<vector<int>> table(N, vector<int>(N, 0));
	for(int i=0; i<M; i++){
		cin >> a.at(i) >> b.at(i);
		table.at(a.at(i)-1).at(b.at(i)-1) = 1;
		table.at(b.at(i)-1).at(a.at(i)-1) = 1;
	}

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

	int ans = 0;

	do{
		if(v.at(0) == 1){
			bool flg = true;
			for(int i=0; i<N-1; i++){
				if(table.at(v.at(i)-1).at(v.at(i+1)-1) == 0){
					flg = false;
					exit;
				}
			}
			if(flg) ans++;
		}
	}while(next_permutation(v.begin(), v.end()));

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
std::vector<int> vc;
int main()
{
    LL N,K;
    std::cin >> N >> K;
    LL cnt = 0;
    while (N)
    {
        cnt++;
        N/=K;
    }
    std::cout<<cnt<<'\n';
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N, M, sum = 0, P, X;
  int T[100000] = {0};
  cin >> N;
  for(int i = 1;i <= N;i++){
    cin >> T[i];
    sum += T[i];
  }



  cin >> M;
  for(int i = 1;i <= M;i++){
    cin >> P >> X;
    cout << sum - T[P] + X << endl;
  }

  return 0; 
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
     
    int N,M;
    long x[2000],y[2000],z[2000], w[2000];
     
    int main(){  
      //freopen("ABC049C_in.txt", "r", stdin);
     
      scanf("%d %d\n",&N,&M);
      for(int i=1;i<=N;i++){
        scanf("%ld %ld %ld\n",&x[i], &y[i], &z[i]);
      }
      
      long ans=0;

      for(int bit=0; bit<(1<<3); bit++){
        long a=(bit&(1<<0)) ? 1 : -1;
        long b=(bit&(1<<1)) ? 1 : -1;
        long c=(bit&(1<<2)) ? 1 : -1;
        for(int i=1;i<=N;i++){
            w[i]=a*x[i]+b*y[i]+c*z[i];
        }
        partial_sort(w+1, w+1+M, w+1+N,  std::greater<long>());
        long cur=0;

        for(int i=1;i<=M;i++){
            cur+=w[i];  
        }      
        if(cur>ans){ans=cur;}  
      }

     
      printf("%ld\n",ans);
      return 0;
    }

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = 100000;

        var sosu = new int[n + 1];

        for (int i = 2; i <= Math.Sqrt(n);) {
            if (sosu[i] == 0) {
                var x = 2 * i;
                while (x <= n) {
                    sosu[x] = 1;
                    x += i;
                }
            }
            i += i == 2 ? 1 : 2;
        }

        var li = new List<int>();
        var hash = new HashSet<int>();

        for (int i = 2; i <= n;) {
            if (sosu[i] == 0) {
                hash.Add(i);
            }
            i += i == 2 ? 1 : 2;
        }

        for (int i = 3; i <= n; i += 2) {
            if (sosu[i] == 0) {
                var x = (i + 1) / 2;
                if (hash.Contains(x))
                    li.Add(i);
            }
        }

        var q = int.Parse(input.ReadLine());
        for (int i = 0; i < q; i++) {
            var spl = input.ReadLine().Split(' ');
            var l = int.Parse(spl[0]);
            var r = int.Parse(spl[1]);
            var c = li.Count(x => l <= x && x <= r);
            Console.WriteLine(c);
        }
        return null;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 18740
#include<stdio.h>



int main()
{
	int n ,m ;
	scanf( "%d %d" ,&n ,&m ) ;


	n += m ;


	if( n < 0 )
	{
		puts( "-1" ) ;
	}

	else if( n > 0 )
	{
		puts( "1" ) ;
	}

	else
	{
		puts( "0" ) ;
	}


	return 0 ;
}

Measured memory_bytes: 1820
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int d[300003] = {};

void dijkstra(int s, int n, graph g)
{
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;

  fill(d, d + n, INT_MAX);
  d[s] = 0;
  q.push(make_pair(0, s));

  while (!q.empty())
  {
    auto p = q.top();
    q.pop();

    int v = p.second;
    if (d[v] < p.first)
      continue;
    REP(i, g[v].size())
    {
      auto e = g[v][i];
      if (d[e.to] > d[v] + e.cost)
      {
        d[e.to] = d[v] + e.cost;
        q.push(make_pair(d[e.to], e.to));
      }
    }
  }
}

int main()
{

  int n, m;
  cin >> n >> m;

  graph g(3 * (n + 1));

  REP(i, m)
  {
    int u, v;
    cin >> u >> v;
    g[3 * u].push_back({3 * v + 1, 1});
    g[3 * u + 1].push_back({3 * v + 2, 1});
    g[3 * u + 2].push_back({3 * v, 1});
  }

  int s, t;
  cin >> s >> t;

  dijkstra(3 * s, 3 * (n + 1), g);

  if (d[3 * t] == INT_MAX)
  {
    cout << -1 << endl;
  }
  else
  {
    cout << d[3 * t] / 3 << endl;
  }
  return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  deque<ll> v;
  rep(i,n){
    auto itr=lower_bound(all(v),a[i]);
    if(itr==v.begin()){
      v.push_front(a[i]);
    }else{
      ll j=itr-v.begin()-1;
      v[j]=a[i];
    }
  }
  cout<<v.size()<<endl;
}


Measured memory_bytes: 1920
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())

broken = set([int(readline()) for i in range(M)])

dp = [0] * (N + 1)
dp[0] = 1
if 1 not in broken:
  dp[1] = 1
  
DIV = 10 ** 9 + 7

for i in range(2, N + 1):
  if i in broken:
    continue
  dp[i] = dp[i - 2] + dp[i - 1]
  dp[i] %= DIV
  
print(dp[N])

Measured memory_bytes: 19020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i,j,A,B,n1,n2,n3,n4,n5 ,count;
  count = 0;
  cin >> A >> B;
  
  for(i=A,j=0;i<=B;i++){
  	n1 = i / 10000;
    n2 = (i - n1 * 10000) / 1000;
    n3 = (i - n1 * 10000 - n2 * 1000) / 100;
    n4 = (i - n1 * 10000 - n2 * 1000 - n3 * 100) / 10;
    n5 = (i - n1 * 10000 - n2 * 1000 - n3 * 100 - n4 * 10);
    j = n5 * 10000 + n4 * 1000 + n3 * 100 + n2 * 10 + n1;
    if(i-j == 0) count++;
  }
  cout << count << endl;
}



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

Vert = N-X
Hor = X
Fin = False
while not Fin:
    if Vert < Hor:
        if Hor % Vert == 0:
            TotalLength += (2 * (Hor//Vert) - 1) * Vert
            Fin = True
        else:
            TotalLength += 2 * (Hor//Vert) * Vert
            Hor %= Vert
    else:
        if Vert % Hor == 0:
            TotalLength += (2 * (Vert//Hor) - 1) * Hor
            Fin = True
        else:
            TotalLength += 2 * (Vert//Hor) * Hor
            Vert %= Hor
print(TotalLength)

Measured memory_bytes: 3064
use std::io::*;//Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let n:i32 = read();
    let a:i32 = read();
    let b:i32 = read();
    let mut ans = 0;
    for i in 1..n + 1 {
        let mut k = i;
        let mut sum = 0;
        while k > 0 {
            sum += k % 10;
            k /= 10;
        }
        if a <= sum && sum <= b {
            ans += i;
        }
    }
    println!("{}",ans);
}

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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-18;

using namespace std;

int h,w;
int m;
set<int> target;

int hsum[300001];
int wsum[300001];

vector<int> hmax,wmax;

int res;

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int x,y;

    cin>>h>>w>>m;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        x--;
        y--;
        target.insert(x*MOD+y);
        hsum[x]++;
        wsum[y]++;
    }

    res=-1;

    int Max=-INF;
    for(int i=0;i<h;i++){
        Max=max(Max,hsum[i]);
    }
    for(int i=0;i<h;i++){
        if(hsum[i]==Max){
            hmax.push_back(i);
        }
    }
    res+=Max;

    Max=-INF;
    for(int i=0;i<w;i++){
        Max=max(Max,wsum[i]);
    }
    for(int i=0;i<w;i++){
        if(wsum[i]==Max){
            wmax.push_back(i);
        }
    }
    res+=Max;

    bool flag=0;
    for(int i=0;i<hmax.size();i++){

        for(int j=0;j<wmax.size();j++){

            if( target.find( hmax[i]*MOD+wmax[j] ) == target.end() ){
                res++;
                flag=1;
                break;
            }

        }

        if(flag==1){
            break;
        }

    }

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 30288
A, B, C, K = gets.split(" ")

if K.to_i < A.to_i
  puts(K)
elsif K.to_i < A.to_i + B.to_i
  puts(A)
else
  puts(A.to_i + (K.to_i - (A.to_i + B.to_i)) * (-1))
end

Measured memory_bytes: 14188
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];

    ll ans=0;
    ll max_count = 60;
    sort(A.rbegin(),A.rend());
    while (max_count >= 0)
    {
        ll tmp = 1LL << max_count;
        ll count = 0;
        for(int i=0;i<N;i++){
            if(A[i]>=tmp){
                count++;
                A[i]-=tmp;
            }
        }
        cerr << tmp << " ";
        cerr << ans << endl;
        ll num = (count*(N-count))%MOD;
        ans = (ans + ((num*(tmp%MOD))%MOD))%MOD;
        max_count--;
    }
    
    cout << ans << endl;

    return 0;
}

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

vector<pair<int, int>> most_common(vector<int> nums){
    map<int, int> frequency;
    for (auto n : nums){
        frequency[n]++;
    }
    vector<pair<int, int>> freq_key;
    for (auto item: frequency){
        freq_key.push_back(make_pair(item.second, item.first));
    }
    sort(freq_key.begin(), freq_key.end(), greater<pair<int, int>>());
    vector<pair<int, int>> output;
    if (freq_key.size() == 1){
        output.push_back(freq_key[0]);
    } else {
        output.push_back(freq_key[0]);
        output.push_back(freq_key[1]);
    }
    return output;

}

int main(){
    int n;cin>>n;
    vector<int> even;
    vector<int> odd;
    for (int i=0;i<n;i++){
        int temp;cin>>temp;
        if (i % 2 == 0){
            even.push_back(temp);
        } else {
            odd.push_back(temp);
        }
    }
    auto most_common_even_pair = most_common(even);
    auto most_common_odd_pair = most_common(odd);

    if (most_common_even_pair[0].second == most_common_odd_pair[0].second){
        if (most_common_even_pair.size() == 2 && most_common_odd_pair.size() == 2){
            if (most_common_even_pair[0].first + most_common_odd_pair[1].first < most_common_even_pair[1].first + most_common_odd_pair[0].first){
                cout << n - most_common_even_pair[1].first - most_common_odd_pair[0].first << endl;
            } else {
                cout << n - most_common_even_pair[0].first - most_common_odd_pair[1].first << endl;
            }
        } else {
            if (most_common_even_pair.size() == 1 && most_common_odd_pair.size() == 2){
                cout << n - most_common_even_pair[0].first - most_common_odd_pair[1].first << endl;
            } else if (most_common_even_pair.size() == 2 && most_common_odd_pair.size() == 1){
                cout << n - most_common_even_pair[1].first - most_common_odd_pair[0].first << endl;
            } else {
                cout << n - most_common_even_pair[0].first << endl;
            }
        }

    } else {
        cout << n - most_common_even_pair[0].first - most_common_odd_pair[0].first << endl;
    }
    return 0;
}

Measured memory_bytes: 4084
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n;
    cin >> n;
    ll ans = 1e18;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ans = min(i-1+(n/i-1), ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys


def main(argv=sys.argv):
  week = {'MON':6, 'TUE':5 , 'WED':4 , 'THU':3, 'FRI':2, 'SAT':1, 'SUN':0}
  
  day = input()
  
  if day == 'SUN':
    print(7)
    
  else:
    print(week[day])

  return 0


if __name__ == '__main__':
  sys.exit(main())

Measured memory_bytes: 2940
fun main(args: Array<String>) {
    val  A = readLine()!!.map { it - 'a' }
    val  B = readLine()!!.map { it - 'a' }
    val  C = readLine()!!.map { it - 'a' }
    val abc = listOf(A, B, C)
    val cnt = Array(3) { 0 }
    var turn = 0
    while (abc[turn].getOrNull(cnt[turn]) != null) {
        val nextTurn = abc[turn].get(cnt[turn])
        cnt[turn]++
        turn = nextTurn
    }
    println('A' + turn)
}


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

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    ll tmp = min(a, k);
    a -= tmp;
    k -= tmp;
    b -= min(k, b);
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  switch((A+B>C+D)-(A+B<C+D)){
    case 1:cout << "Left" << endl;break;
    case 0:cout << "Balanced" << endl;break;
    case -1:cout << "Right" << endl;break;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma optimize("Ofast")
using namespace std;

using ll = long long;
const int N = 2e5+5;

vector<ll> a(N),l(N),r(N);
int main()
{
    ios_base::sync_with_stdio(0);

    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    for(int i = 1; i <= n; ++i)
        l[i] = l[i-1]^a[i];
    for(int i = n; i >= 1; --i)
        r[i] = r[i+1]^a[i];
  
    for(int i = 1; i <= n; ++i)
        cout << (l[i-1] ^ r[i+1]) << ' ';
    return 0;
}


Measured memory_bytes: 7876
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll n, k;
pair<ll, ll> a[5000];
bool solve(pair<ll, ll> domey, pair<ll, ll> mid){
    bool dp[k + 1] = {1};
    for(ll i = 0; i < n; i++){
        if(i == mid.second) continue;
        bool nextdp[k + 1];
        for(ll j = 0; j <= k; j++) nextdp[j] = dp[j];
        for(ll j = a[i].first; j <= k; j++) nextdp[j] |= dp[j - a[i].first];
        for(ll j = 0; j <= k; j++) dp[j] = nextdp[j];
    }
    bool ret = 0;
    for(ll i = max<ll>(0, k - mid.first); i < k; i++) ret |= dp[i];
    return ret;
}
int main(){
    cin >> n >> k;
    ll sum = 0;
    for(ll i = 0; i < n; i++) cin >> a[i].first;
    sort(a, a + n);
    for(ll i = 0; i < n; i++) a[i].second = i;
    auto po = upper_bound(a, a + n, pair<ll, ll>(0, 0), solve);
    cout << po - a << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> P;

int ss[55][55];
int x[55], y[55];
P point[55];

int query(int x1, int y1, int x2, int y2){
    return ss[x2][y2] - ss[x2][y1] - ss[x1][y2] + ss[x1][y1];
}

lint solve(int x1, int y1, int x2, int y2){
    return 1LL * (x[x2-1]-x[x1]) * (y[y2-1]-y[y1]);
}

int main(){
    int n, k; cin >> n >> k;
    for(int i=0;i<n;i++){
        int xx, yy; cin >> xx >> yy;
        x[i] = xx; y[i] = yy;
        point[i] = P(xx, yy);
    }

    sort(x, x+n), sort(y, y+n);

    for(int i=0;i<n;i++){
        int posx, posy; P p = point[i];
        posx = distance(x, lower_bound(x, x+n, p.first));
        posy = distance(y, lower_bound(y, y+n, p.second));
        ss[posx+1][posy+1]++;
    }

    for(int i=0;i<=n;i++)
        for(int j=0;j<n;j++) ss[i][j+1] += ss[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<=n;j++) ss[i+1][j] += ss[i][j];

    lint ans = 1e20;
    for(int x1=0;x1<=n;x1++){
        for(int x2=x1+1;x2<=n;x2++){
            for(int y1=0;y1<=n;y1++){
                for(int y2=y1+1;y2<=n;y2++){
                    if(k<=query(x1, y1, x2, y2)) ans = min(ans, solve(x1, y1, x2, y2));
                }
            }
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define inf 1e9+1
struct item
{
    int wt;
    int val;
};

int solve(vector<item> ar, int n, int W)
{
    int maxval = n*1000;
    long long dp[n+1][maxval+1];
    for(int val = 0;val<=maxval;val++)
    {
        dp[1][val]=inf;
    }
    dp[1][0]=0;
    dp[1][ar[1].val] = ar[1].wt;
    for(int i=2;i<=n;i++)
    {
        for(int v=0;v<=maxval;v++)
        {
            dp[i][v] = dp[i-1][v];
            if(ar[i].val>v)
            {
                continue;
            }
            dp[i][v] = min(dp[i][v],ar[i].wt+dp[i-1][v-ar[i].val]);
        }
    }
    int ans = 0;
    for(int x = 0;x<=maxval;x++)
    {
        if(dp[n][x]<=W)
        {
            ans = x;
        }
    }
    return ans;

}
 
int main()
{
    int n,w;
    cin>>n>>w;
    vector<item> ar(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>> ar[i].wt>>ar[i].val;
    }
    cout<<solve(ar,n,w);
}

Measured memory_bytes: 81736
#include <stdio.h>

int main(void)
{
int m, f, r;
int a = 1;

while(a == 1){

scanf("%d %d %d", &m, &f, &r);

if(m == -1 && f == -1 && r == -1)
break;

if(m == -1 || f == -1 || m + f < 30)
 printf("F\n");
else if(m + f >= 80)
 printf("A\n");
else if(m + f >= 65 && m+f < 80)
 printf("B\n");
else if(m + f >= 50 && m + f < 65 || r >= 50)
 printf("C\n");
else if(m + f >= 30 && m + f < 50)
 printf("D\n");

}

return 0;

}




Measured memory_bytes: 2012
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
//const ll mod = 1000000007LL;
const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222



ll a[MAX];


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


  double x = 1;
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) x *= a[i];
  double y = 0;
  rep(i, n) y += x / a[i];  
  cout.precision(6);
  cout << fixed << double(x) / y << endl;


  return 0;
}


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

int main(){
    string S;
    cin >> S;

    int a_count = 0;
    int b_count = 0;
    int c_count = 0;

    for(int i = 0; i < 3; i++){
        if(S[i] == 'a') a_count++;
        if(S[i] == 'b') b_count++;
        if(S[i] == 'c') c_count++;
    }

    if(a_count == 1 && b_count == 1 && c_count == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
      static List<string> a = new List<string>();
    static decimal result;
static StringBuilder sb = new StringBuilder();
static int N,M,K;
    static void Main()
    {
Read1();
      Read5();
     //中のABを集計
      for(int i=0;i<N;i++){
      for(int j=0;j<a[i].Length-1;j++){
      if(a[i][j]=='A' && a[i][j+1]=='B'){result++;}
      }
      }
      int count,count2,count3;
      count=0;count2=0;count3=0;
      //A末尾Bスタートを集計
      for(int i=0;i<N;i++){
      if(a[i][a[i].Length-1]=='A'){count++;}
        if(a[i][0]=='B'){count2++;}
        if(a[i][a[i].Length-1]=='A' && a[i][0]=='B'){count3++;}
      }
      if(count3==count && count3==count2 && count3>0){result+=count3 - 1;}
      else if(count2>=count){result+=count;}else{result+=count2;}
                    Console.WriteLine(result.ToString());

    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
for(int i=0;i<N;i++){
a.Add(Console.ReadLine());
}
 
    }


}

Measured memory_bytes: 13780
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] m = new int[n];
		int ans = n, min = 1000, sum = 0;
		
		for (int i = 0; i < n; i++) {
			m[i] = sc.nextInt();
			sum += m[i];
			if (m[i] < min) {
				min = m[i];
			}
		}

		ans += (x - sum)/min;

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
using namespace std;
int main(void){
	int n;
		cin >> n;
	vector<int> V;
	V.push_back(n);
	int ans=0;
	int c=0;
	while(1){
		c++;
		int l=(n%2?3*n+1:n/2);
		for(int i=0;i<V.size();i++){
			if(l==V[i]){
				ans=c+1;
				break;
			}
		}
		if(ans)
			break;
		V.push_back(l);
		n=l;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<string>
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 1e4+5;

int main(){
	int a,b,c; cin >> a >> b >> c;
	int sum = a+b+c;
	if(sum >= 22) puts("bust");
	else puts("win");
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = inputs[0];
        var k = inputs[1];

        Modint result = 0;

        for (long i = k; i <= n + 1; i++)
        {
            result += i * (n - i + 1) + 1;
        }

        Console.WriteLine(result.Value);
    }

    /// <summary>
    /// モジュラス数学 割り算をしたときの余りのみ注目
    /// </summary>
    public struct Modint
    {
        private const int M = 1000000007;

        public long Value { get; }

        private static readonly List<int> _factorialCache = new List<int> { 1 };

        public Modint(long value) { Value = value; }

        public static implicit operator Modint(long a)
        {
            var m = a % M;
            return new Modint((m < 0) ? m + M : m);
        }

        public static Modint operator +(Modint a, Modint b)
            => a.Value + b.Value;

        public static Modint operator -(Modint a, Modint b)
            => a.Value - b.Value;

        public static Modint operator *(Modint a, Modint b)
            => a.Value * b.Value;

        // フェルマーの小定理
        public static Modint operator /(Modint a, Modint b)
            => a * Pow(b, M - 2);

        /// <summary>
        /// a^n (繰り返し２累乗法)
        /// </summary>
        public static Modint Pow(Modint a, int n)
        {
            if (n == 0) return 1;
            if (n == 1) return a;

            var p = Pow(a, n / 2);
            return p * p * Pow(a, n % 2);
        }

        /// <summary>
        /// 階乗 n!
        /// </summary>
        public static Modint Fac(int n)
        {
            for (int i = _factorialCache.Count; i <= n; i++)
            {
                _factorialCache.Add((int)(Math.BigMul(_factorialCache.Last(), i) % M));
            }
            return _factorialCache[n];
        }

        public static Modint nCr(int n, int r)
            => (n < r) ? 0 :
               (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r));
    }
}

Measured memory_bytes: 19020