akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int n;
    cin >> n;
    int a[2][n];
    for (int i = 0; i < n; i++) {
        cin >> a[0][i];
    }
    for (int i = 0; i < n; i++) {
        cin >> a[1][i];
    }

    // 2 行ぶんの累積和をつくる
    int s[2][n+1] = {0};
    bool not_yet = true;
    for (int i = 0; i < n+1; i++) {
        if (not_yet) {
            not_yet = false;
            continue;
        }
        s[0][i] = s[0][i-1] + a[0][i-1];
        s[1][i] = s[1][i-1] + a[1][i-1];
    }
    // どの列で下に移動すれば最大値が得られるかしらべる
    int max = 0;
    for (int i = 1; i < n+1; i++) {
        int tmp = s[0][i] + (s[1][n] - s[1][i-1]);
        if (max < tmp) {
            max = tmp;
        }
    }

    cout << max << endl;
}

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

int main(){
  string s;
  cin >> s;
  int fx=0, x=stoi(s);
  for(int i=0; i<s.length(); i++) fx += s[i]-'0';
  if(x%fx==0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

int main(){
  int n,x,ans;
  cin >> n >> x;
  vector<int> m(n);
  rep(i,n){
    cin >> m[i];
    x -= m[i];
  }
  ans = n + (x/(*min_element(m.begin(),m.end())));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
X = int(input())
if(X%2 == 1 and X >= 6):
  for i in range(10000):
    j = 0
    while((X + 2*i) % (j+3) != 0 and (X + 2*i) > 2*(j+3)):
        j += 2
    if((X + 2*i) % (j+3) != 0):
        print(X + 2*i)
        break

elif(X == 2):
  print(2)

elif(X == 3):
  print(3)

elif(X == 4):
  print(5)

elif(X == 5):
  print(5)

else:
  for i in range(10000):
    j = 0
    while((X + 2*i + 1) % (j+3) != 0 and (X + 2*i + 1) > 2*(j+3)):
        j += 2
    if((X + 2*i + 1) % (j+3) != 0):
        print(X + 2*i + 1)
        break

Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long n=gl();
	    long m=gl();
	    
	    //System.out.println(ans);
	    if(n==m) {
	    	long ans=2;
	    	long i=n;
	    	while(i>0) {
	    		ans*=i;
	    		ans=ans%1000000007;
	    		i--;
	    	}
	    	i=m;
	    	while(i>0) {
	    		ans*=i;
	    		ans=ans%1000000007;
	    		i--;
	    	}
	        System.out.println(ans);
	    } else if(Math.abs(n-m)==1) {
	    	long ans=1;
	    	long i=n;
	    	while(i>0) {
	    		ans*=i;
	    		ans=ans%1000000007;
	    		i--;
	    	}
	    	i=m;
	    	while(i>0) {
	    		ans*=i;
	    		ans=ans%1000000007;
	    		i--;
	    	}
	        System.out.println(ans);
	    } else {
	    	System.out.print(0);
	    }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35624
def 解():
    iN,iT = [int(_) for _ in input().split()]
    aA = [int(_) for _ in input().split()]
    iL = len(aA)

    aMaxD = [0]
    iMin = aA[0]
    iV = 0

    def checkMax(aMaxD,iMaxD):
        if aMaxD[0] < iMaxD:
            aMaxD = [iMaxD]
        elif aMaxD[0] == iMaxD:
            aMaxD.append(iMaxD)
        return aMaxD

    iB = aA[0]
    for iN in aA[1:]:
        if iB - iN > 0:
            if iV >= 0:
                aMaxD = checkMax(aMaxD,iB-iMin)
            iV = -1
        elif iB - iN < 0:
            if iV <= 0:
                iMin = min(iB,iMin)
            iV = 1
        iB = iN
    aMaxD = checkMax(aMaxD,aA[-1] - iMin)
    print( len(aMaxD) )
解()


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int l[101];
  int li;
  int ans = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> li;
    l[i] = li;
  }
 if(n <= 2){
   cout << 0 << endl;
   return 0;
 }
  for(int i = 0; i < n-2; i++){
    for(int j = i+1; j < n-1; j++){
      if(i>=j || l[i]==l[j])continue;

      for(int k = j+1; k < n; k++){
        if(j>=k || l[j] == l[k] || l[i] == l[k])continue;
          if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]){
            ans++;
          }

      }
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

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

	double sum = 0;
	for(int i = 0; i < N; i++)
	{
		sum += (double)(1.0 / A[i]);
	}

	sum = (double)(1.0 / sum);
	
	cout << setprecision(10) << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n, k;
		cin >> n >> k;
		n = n % k;
		n = min(n, k - n);
		cout << n << '\n';
	}
	return 0;
}

Measured memory_bytes: 3620
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    bool f; char ch; f=0; x=0; ch=getchar();
    while(ch<'0' || ch>'9') {if(ch=='-') f=1; ch=getchar();}
    while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    if(f) x=-x;
}

template< typename T > inline void Max(T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min(T &a, T b) {if(b<a) a=b;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double pi=(double) acos(-1.0);
const int MOD=(int) 1e9+7;
const int INF=(int) 0x3f3f3f3f;
const LL  LINF=(LL) INF<<32|INF;
const int SINF=(uint) ~0>>1;
const LL  SLINF=(ULL) (-1)>>1;
const double DINF=(double) 1e50;
const double eps=(double) 1e-8;
const int maxn=(int) 2000+20;
const int maxm=(int) 1e6+20;
const int maxk=(int) 5e2+20;

inline int sig(double x) {return x<-eps?-1:x>eps;}

//--------------start------------------

void work()
{
    int n; LL k;
    cin >>n >>k;
    LL ans=1;
    while(n--)
    {
        if(ans>k) ans+=k;
        else ans<<=1;
    }
    cout <<ans <<endl;
}

//--------------end--------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
#define PI acos(-1.0)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

int main()
{
    
    int n, i, j, a[105];
    cin>>n;
    vi v;
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n-1;i++){
    	for(j=i+1;j<n;j++){
    		v.pb(abs(a[i]-a[j]));
    	}
    }
    sort(v.begin(),v.end());
    cout<<v.back()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a * b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//“Failure is unimportant. It takes courage to make a fool of yourself.”
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
#define int long long int
#define P 1000000007
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define b(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 1000
#define PI 3.14159265359
#define inf LLONG_MAX
using namespace __gnu_pbds;
using namespace std;


signed main() {
    teevra_gati
    
    ll n,k;
    cin>>n>>k;
    vl a(n+1), cost(n+1, inf);
    f(i,1,n+1) cin>>a[i];
    f(i,1,min(k+1,n+1)) cost[i] = abs(a[i]-a[1]);

    f(i,k+1,n+1){
        f(j,1,k+1){
            cost[i] = min(cost[i], cost[i-j] + abs(a[i]-a[i-j]));
        }
    }
    cout<<cost[n];
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define modulo N
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000005



int main(){
	
	string S,T;
	cin>>S>>T;
	
	T.pop_back();
	
	if(S==T)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll x=pow(2,n);
    multiset <ll> a;
    for(ll i=0;i<x;i++)
    {
        ll y;
        cin>>y;
        a.insert(y);
    }
    multiset <ll> b;
    auto y=a.end();
    y--;
    b.insert(*y);
    a.erase(y);
    for(ll i=1;i<=n;i++)
    {
        vector <ll> l;
        for(ll j:b)
        {
            auto p=a.lower_bound(j);
            if(p==a.begin())
            {
                cout<<"No\n";
                return 0;
            }
            p--;
            l.pb(*p);
            a.erase(p);
        }
        for(ll j=0;j<l.size();j++)
        {
            b.insert(l[j]);
        }
    }
    cout<<"Yes\n";
}


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

#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;

int const N=1e6+100;
ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();
int const BN = 31;

ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}

ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}

ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll ans=n*(n-1)/2;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
from itertools import accumulate as acc

H, W, K = map(int, input().split())
S = [list(map(int, list(input()))) for _ in range(H)]

acc_list = [list(acc([0] + s)) for s in S]

def solve(l, x, limit):
    part_num = len(l)-1
    ok, ng = x, W+1
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        score = 0
        for i in range(part_num):
            s = 0
            for j in range(l[i], l[i+1]):
                # print(i, j, mid)
                s += acc_list[j][mid] - acc_list[j][x]
            score = max(s, score)
        if score <= limit:
            ok = mid
        else:
            ng = mid
    return ok

min_num = 10**18
for i in range(1<<(H-1)):
    l = []
    for j in range(H-1):
        if (i>>j)&1:
            l.append(j+1)
    h_split_num = len(l)
    l = [0] + l + [H]
    x = solve(l, 0, K)
    w_split_num = 0
    flag = True
    while x < W:
        w_split_num += 1
        r = solve(l, x, K)
        if x == r:
            flag = False
            break
        x = r
    if flag:
        split_num = w_split_num + h_split_num
        min_num = min(split_num, min_num)

print(min_num)


Measured memory_bytes: 75012
A, B, C, X, Y = map(int, input().split())

ans = 10 ** 18
for i in range(0, 2 * max(X, Y) + 1, 2):
    tmpx = X - (i // 2)
    if tmpx <= 0:
        tmpx = 0
    tmpy = Y - (i // 2)
    if tmpy <= 0:
        tmpy = 0
    ans = min(ans, (i * C) + (tmpx * A) + (tmpy * B))

print(ans)

Measured memory_bytes: 9104
// Danielxlr
// https://atcoder.jp/contests/abc174/tasks/abc174_e
// greedy
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=2e6+1;
int n,k;
ll a[N];
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k;
	ll l=1,r;
	for(int i=1; i<=n ;i++){
		cin >> a[i];
		r=max(r,a[i]);
	}
	while(l!=r){
		ll mid=(l+r)/2;
		ll s=0;
		for(int i=1; i<=n ;i++){
			s+=(a[i]-1)/mid;
		}
		if(s<=k) r=mid;
		else l=mid+1;
	}
	cout <<l << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    for(int i=1;i<n;i++){
        a.at(i)=__gcd(a.at(i),a.at(i-1));
    }
    cout << a.at(n-1) << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

const float INF = 1e7;
const float EPS = 1e-7;

int main()
{
	int L;
	float dp[1<<12][12];
	while(scanf("%d", &L) != EOF){
		char c;
		vi rs;
		while(scanf("%c", &c), c==' '){
			int r;
			scanf("%d", &r);
			rs.push_back(r);
		}
		int n = rs.size();
		
		rep(i, 1<<n) rep(j, n)
			dp[i][j] = INF;
		rep(i, n){
			dp[1<<i][i] = rs[i]*2.0f;
		}
		rep(i, 1<<n){
			rep(j, n){
				if(!(i&(1<<j)))
					continue;
				rep(k, n){
					if(j == k || !(i&(1<<k)))
						continue;
					dp[i][j] = min(dp[i][j], dp[i^(1<<j)][k] + 2.0f*(float)sqrt(rs[j]*rs[k])+rs[j]-rs[k]);
				}
			}
		}
		
		float best = INF;
		rep(i, n)
			best = min(best, dp[(1<<n)-1][i]);
		puts(best-EPS < L ? "OK" : "NA");
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n, t;
  cin >> n >> t;
  if(t%2==1) t--;
  vector<int> a(n);

  for(int i=0; i<n; i++) cin >> a[i];
  int p = a[0];
  int d = 0;
  map<int, int> mp;
  for(int i=0; i<n; i++){
    if(p > a[i]){
      p = a[i];
    }
    d = max(a[i]-p, d);
    mp[a[i]-p]++;
    cerr << a[i]-p << " " << mp[a[i]-p] << endl;
  }
  cerr << d << endl;
  int r = d * t/2;

  cout << mp[d] << endl;

  return 0;
}



//


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

int main() {
  vector<pair<int, int>> AB;
  int a, b;
  cin >> a >> b; AB.push_back(make_pair(a-1, b-1));
  cin >> a >> b; AB.push_back(make_pair(a-1, b-1));
  cin >> a >> b; AB.push_back(make_pair(a-1, b-1));
  sort(AB.begin(), AB.end());

  do {
    vector<int> used(4, 0);
    int s = AB[0].first, g; used[s]++;
    bool ok; ok = true;
    for (auto ab : AB) {
      if (ab.first == s) g = ab.second;
      else if (ab.second == s) g = ab.first;
      else ok = false;
      if (0 < used[g]) ok = false;
      used[g]++; s = g;
    }
    if (ok) {
      cout << "YES" << endl;
      return 0;
    }

    ok = true;
    used[0] = 0; used[1] = 0; used[2] = 0; used[3] = 0;
    s = AB[0].second; used[s]++;
    for (auto ab : AB) {
      if (ab.first == s) g = ab.second;
      else if (ab.second == s) g = ab.first;
      else ok = false;
      if (0 < used[g]) ok = false;
      used[g]++; s = g;
    }
    if (ok) {
      cout << "YES" << endl;
      return 0;
    }
  } while (next_permutation(AB.begin(), AB.end()));
  cout << "NO" << endl;
}

Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))

s = []
for _ in range(D):
    s.append(list(map(int, input().split())))

# last(d, i)を計算するためのメモ
# new_dp = [[0] * 26 for _ in range(D)]
dp = [0] * 26


def dec(d, dp):
    # d日の終わりに起こる満足度の減少計算の関数
    s = 0
    for j in range(26):
        s += c[j] * (d - dp[j])

    return s


# d日目に開催するコンテストを決める
v = 0
for d in range(D):
    a = 0
    b = 0
    for i in range(26):
        old = dp[i]
        dp[i] = (d + 1)
        if (a <= s[d][i] - dec(d + 1, dp)):
            a = max(s[d][i] - dec(d + 1, dp), a)
            b = i
        dp[i] = old
    v += a
    dp[b] = d + 1
    print(b + 1)


Measured memory_bytes: 9520
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


#define MAX_V 100010

struct edge { int to; long long cost; };
int V;

vector<edge> tree_yen[MAX_V];
vector<edge> tree_snu[MAX_V];
ll d_yen[MAX_V];
ll d_snu[MAX_V];
int N;

void dijkstra(int s, ll d[MAX_V], vector<edge> tree[MAX_V]) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + N, LINF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) { continue; }
        for (int i = 0; i < tree[v].size(); i++) {
            edge e = tree[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

ll snuuk[100010];

int main(){
    cin >> N >> V;
    int s, t;
    cin >> s >> t;
    s--, t--;
    rep(i, V){
        int p, q, a, b;
        cin >> p >> q >> a >> b;
        p--, q--;
        tree_yen[p].push_back(edge{q, a});
        tree_yen[q].push_back(edge{p, a});
        tree_snu[p].push_back(edge{q, b});
        tree_snu[q].push_back(edge{p, b});
    }

    dijkstra(s, d_yen, tree_yen);
    dijkstra(t, d_snu, tree_snu);
    

    rep(i, N){
        // cout << d_yen[i] << " " << d_snu[i] << endl;
        snuuk[i] = 1e15 - (d_yen[i] + d_snu[i]);
    }

    rrep(i, N - 1){
        snuuk[i] = max(snuuk[i], snuuk[i+1]);
    }

    rep(i, N) cout << snuuk[i] << endl;

    return 0;
}

Measured memory_bytes: 19140
n,w=map(int,input().split())
weight,value=[0]*110,[0]*110
dp = [[0 for _ in range(100100)] for _ in range(110)]
for i in range(n):
    weight[i],value[i] = map(int,input().split())
for i in range(n):
    sum_w =0
    while sum_w <= w:
        #i番目の品物を選ぶ
        if(sum_w - weight[i] >=0):
            dp[i+1][sum_w] =max(dp[i+1][sum_w], dp[i][sum_w - weight[i]]+ value[i])
        #選ばない場合
        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])
        sum_w +=1
print(dp[n][w])

Measured memory_bytes: 181640
#include<bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 13;
int n, m, sz[maxN], ans;
bool can[maxN];
int main () {
    cin >> n >> m;
    fill(sz, sz + n + 1, 1);
    can[1] = 1;
    for (int i = 0; i < m; i++) {
	int x, y;
	cin >> x >> y;
	if (can[x])
	    can[y] = 1;
	sz[x]--;
	sz[y]++;
	if (sz[x] == 0)
	    can[x] = 0;
    }
    for (int i = 1; i <= n; i++)
	ans += can[i];
    cout << ans << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <string>
#include <memory.h>
#include <bitset>
#include <stack>
#include <assert.h>
using namespace std;
#define ll long long
#define ppi pair<int, int>
#define mp make_pair
#define inf 2e16
const int N = 2e5 + 11, K = 20 , S = 1e3 + 11;
const int mod = 1e9 + 7;
int dp[3011][3011], n, m;
int main()
{
#ifndef ONLINE_JUDGE
	//freopen("inp.txt", "r", stdin);
#endif
	string a, b;
	cin >> a >> b;
	n = a.size(), m = b.size();
	for (int i = n - 1 ; i >= 0 ; i--)
	{
		for (int j = m - 1; j >= 0; j--)
		{
			dp[i][j] = max(dp[i + 1][j] , dp[i][j + 1]);
			if (a[i] == b[j])
			{
				dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + 1);
			}
		}
	}
	int j = 0;
	for (int i = 0; i < n; i++)
	{
		while (j < m)
		{
			if (dp[i][j] == dp[i + 1][j]) break;
			else if (a[i] == b[j] && dp[i][j] == dp[i + 1][j + 1] + 1)
			{
				printf("%c", b[j++]);
				break;
			}
			else j++;
		}
	}
	return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

long long MOD = 1000000007;

long long ketawa(long long n, long long b){
  long long ret = 0;
  if(b > n) return n;
  else return ketawa(n/b, b) + (n%b);
}

int main(){
  long long n,s;
  cin>>n>>s;

  if(n < s){
    cout<<"-1"<<endl;
    return 0;
  }

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

  long long nn = sqrt(n)+1LL;
  for(int i=2;i<=nn;i++){
    if(ketawa(n,i) == s){
      cout<<i<<endl;
      return 0;
    }
  }

  long long tmp = (n-s);
  long long tt = sqrt(tmp)+1LL;

  for(int i=tt;i>=1;i--){
    if((tmp % i) == 0){
      long long b = (tmp/i) + 1LL;

      if(b <= i) continue;
      if(b*i > n) continue;
      if(i > s) continue;
      if((n-b*i) != (s-i)) continue;
      if((n-b*i) >= b) continue;

      cout<<((tmp/i)+1LL)<<endl;
      return 0;
    }
  }

  cout<<"-1"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  int k; cin >> k;
  sort(a.begin(), a.end());
  for(int i = 0; i < k; i++){
    a[2] *= 2;
  }
  int ans = 0;
  rep(i,3) ans += a[i];
  cout << ans << endl;
  return 0;
}


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

int main(){
    ll n;cin >> n;
    vector<ll> ap,am,a;
    rep(i,n){
        ll temp;cin >> temp;
        if(temp < 0){
            am.push_back(temp);
        }
        // else if(temp == 0){
        //     az.push_back(temp);
        // }
        else{
            ap.push_back(temp);
        }
        a.push_back(temp);
    }
    vector<ll> x(n-1),y(n-1);
    sort(ap.begin(),ap.end());
    sort(am.begin(),am.end(),greater<ll>());
    if(n > 2){
        if(am.size() == 0){
            x[0] = ap[0];
            y[0] = ap[1];
            // ap.erase(ap[0]);
            // ap.erase(ap[1]);
            ap.erase(ap.begin());
            ap.erase(ap.begin());
            am.push_back(x[0] - y[0]);
        }
        else if(ap.size() == 0){
            x[0] = am[0];
            y[0] = am[1];
            am.erase(am.begin());
            am.erase(am.begin());
            ap.push_back(x[0] - y[0]);
        }
        else if(ap.size() > 1){
            x[0] = am.back();
            y[0] = ap.back();
            ap.pop_back();
            am.pop_back();
            am.push_back(x[0] - y[0]);
        }
        else{
            x[0] = ap.back();
            y[0] = am.back();
            ap.pop_back();
            am.pop_back();
            ap.push_back(x[0] - y[0]);
        }
        ll i = 1;
        while(ap.size() > 1){
            x[i] = am.back();
            y[i] = ap.back();
            ap.pop_back();
            am.pop_back();
            am.push_back(x[i] - y[i]);
            i++;
            // cout << i << "m";
        }
        while(am.size() > 1){
            x[i] = ap.back();
            y[i] = am.back();
            ap.pop_back();
            am.pop_back();
            ap.push_back(x[i] - y[i]);
            i++;
            // cout << i <<"p";
        }
        // cout << i << endl;
        x[i] = ap[0];
        y[i] = am[0];
        ll ans = x[i]-y[i];
        i++;
        cout << ans << endl;
        rep(j,n-1) cout << x[j] << " " << y[j] << "\n";
        return 0;
    }
    else{
        x[0] = max(a[0],a[1]);
        y[0] = min(a[0],a[1]);
        ll ans = x[0] - y[0];
        cout << ans << endl;
        rep(j,n-1) cout << x[j] << " " << y[j] << "\n";
        return 0;
    }

    return 0;
}

Measured memory_bytes: 5356
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while(n--) {
    string s;
    getline(cin,s);
    int f = 0;
    for (int a=0;f==0;a++) {
      string buf(s);
      REP(b,26) {
        REP(i,s.length()) {
          if (s[i]!=' ') {
            buf[i] = ((s[i]-'a')*a+b)%26 + 'a';
          }
        }
        if (buf.find("that")!=-1||buf.find("this")!=-1) {
          cout << buf << endl;
          f = 1;
          break;
        }
      }
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;

bool valid(int i,int j,int h,int w){
    return i>=0 && i<h && j>=0 && j<w;
}
int main(){
    int h,w;
    cin>>h>>w;
    string grid[h];
    for(int i=0;i<h;i++){
        cin>>grid[i];
    }
    ll path[h][w];
    memset(path,0,sizeof(path));
    path[0][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(grid[i][j]=='.'){
                 if(valid(i,j-1,h,w)){
                    path[i][j]+=path[i][j-1];
                }
                if(valid(i-1,j,h,w)){
                    path[i][j]+=path[i-1][j];
                }
            }
            if(path[i][j]>=mod){
                path[i][j]-=mod;
            }
            //cout<<path[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<path[h-1][w-1];
}


Measured memory_bytes: 13344
#define MYDEBUG
/*
 * A.cpp
 *
 *  Created on: 2018/07/10 14:18
 *      Author: jln
 */

#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	out << endl;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
	out << "{" << p.first << "," << p.second << "}";
	return out;
}
struct edge {
	int from, to, cost;
	edge(int f, int t, int c) {
		from = f;
		to = t;
		cost = c;
	}
	edge() {
		from = -1;
		to = -1;
		cost = -1;
	}
	bool operator<(const edge& e) const {
		return cost < e.cost;
	}
};
struct vertex {
	int id, val1, val2;
	vertex(int id_, int val1_, int val2_) {
		id = id_;
		val1 = val1_;
		val2 = val2_;
	}
	vertex() {
		id = 0;
		val1 = val2 = 0;
	}
};
ostream& operator<<(ostream& out, const edge& e) {
	out << "(";
	out << e.from << "->" << e.to << ": ";
	out << e.cost;
	out << ")";
	return out;
}
ostream& operator<<(ostream& out, const vertex& v) {
	out << "<";
	out << v.id << ": ";
	out << v.val1 << ", "; //なにかの要素，値
	out << v.val2; //なにかの要素，値
	out << ">";
	return out;
}
typedef struct edge edge;
typedef struct vertex vertex;
int N;
vector<int> a;
void solve() {
	cin >> N;
	a = vector<int>(N);
	rep(i,0,N)
	{
		cin >> a[i];
	}
	int ans = 0;
	rep(i,0,N)
	{
		rep(j,0,N)
		{
			ans = max(ans, abs(a[i] - a[j]));
		}
	}
	cout << ans << endl;
}
int main() {
	solve();
}


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

cnt=0
fl=0

for i in range(N):
    if S[i]=='a' and cnt<A+B:
        print('Yes')
        cnt+=1
    elif S[i]=='b' and cnt<A+B and fl<B:
        print('Yes')
        cnt+=1
        fl+=1
    else:
        print('No')

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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 int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	int n;
	cin >> n;
	rep(i,n){
		int a;
		cin >> a;
		if(a&1){
			cout << "first";
			return 0;
		}		
	}
	cout << "second";
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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 long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

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

	s[3] = '8';
	Ans(s);
}


Measured memory_bytes: 256
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

using namespace std;

const int INF = 1<<29;        // 十分大きい値にする, INT_MAX にしないのはオーバーフロー対策

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************
//方針：好きなだけ隣接２要素の符号反転をしてよいのである異なる２点の組を定めて、その組のみ符号反転させることが可能
//したがって負の要素があっても２つずつ正にしていくことができる
//最終的には負の要素が偶数の時は全て正、奇数の時は1つを残してすべて正にできる
//したがって偶数なら全絶対値合計、奇数なら負の数の絶対値最小のものを負にすることで総和を最大化できる
//今回は教育のためＤＰをつかって全てを探索していく

//i ∈ {0, 1, ..., N}, j ∈ {0, 1} に対して dp(i, j) を、A1, A2, ..., Ai を確定し、j = 1 なら i を選んで反転した
//場合 (すなわち Ai+1 の符号が反転している状態) の A1 + A2 + ... + Ai の最大値と定義します。
//dp[N][2]としてすべての要素を使う必要があるので答えはdp[N][0]である

//dp(i,0 or 1)がA1, A2, ..., Ai+1  と区間の総和最大値を表すことに注意

int main(void){

    int n,i;
    
    scanf("%d",&n);

    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    long long dp[n][2];//dp[i][0]はA[i]の反転無し,dp[i][1]は-A[i]としたときの総和
    dp[0][0]=0;//要素なしの区間総和
    dp[0][1]=-INF;//存在しない

    for(i=0;i<n;i++)
    {
        dp[i+1][0]=max(dp[i][0]+A[i],dp[i][1]-A[i]);
        dp[i+1][1]=max(dp[i][0]-A[i],dp[i][1]+A[i]);
    }


    cout<<dp[n][0]<<endl;  
    return 0;
}

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

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int long_dis = a[0] + k - a[n - 1];
    rep(i, n - 1) {
        int tmp = a[i + 1] - a[i];
        if (long_dis < tmp) {
            long_dis = tmp;
        }
    }

    cout << k - long_dis << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1e9 + 100;

int main() {
	int N;
	scanf("%d", &N);
	priority_queue<PII> pq;
	int Xs = INF, Xm = 0;
	int Ys = INF, Ym = 0;
	for(int i = 0; i < N; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		if(x > y) swap(x, y);
		pq.push(MP(y, x));
		Xs = min(Xs, x);
		Ys = min(Ys, y);
		Xm = max(Xm, x);
		Ym = max(Ym, y);
	}
	ll ans = 1ll * (Xm - Xs) * (Ym - Ys);
	while(!pq.empty()) {
		PII u = pq.top(); pq.pop();
		if(u.S >= u.F) break;
		Xm = max(Xm, u.F);
		Ys = min(Ys, u.S);
		swap(u.F, u.S);
		pq.push(u);
		debug("%lld %lld -- %lld %lld\n", Xm, Xs, pq.top().F, Ys);
		ans = min(ans, 1ll * (Xm - Xs) * (pq.top().F - Ys));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2420
def main():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))

    ans = float('inf')
    for i in range(N-K+1):
        L = x[i]
        R = x[i+K-1]
        if R < 0:
            ans = min(ans, abs(L))
        elif L <= 0 <= R:
            ans = min(2*abs(R)+abs(L), 2*abs(L)+abs(R), ans)
        elif 0 < L:
            ans = min(ans, abs(R))
        else:
            continue
    
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#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;
const int MAX = 10000000;
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;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

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

	int tr = n*a;
	int ta = b;
	cout << min(tr,ta) << endl;

  return 0;
}


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

using namespace std;

int main() {
    int n;
  	vector<int> v;  
  
  	cin >> n;
  
  	int tmp;
  	for (int i = 0; i < n; i++) {
    	cin >> tmp;
      	v.push_back(tmp);
    }
  
  	sort(v.begin(), v.end());
  
  	double ans = v[0];
  	for (int i = 1; i < n; i++) {
      	ans = (ans + v[i]) / 2.0;
    }
  
  	cout << setprecision(20) << ans << endl;
  
    return 0;
}


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

int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {	//最大公約数
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int min(int a, int b ) {
	if (a < b) {
		return a;
	}
	else
		return b;
}
int max(int a, int b) {
	if (a < b)
		return b;
	else
		return a;
}
int main(void)
{
	int l, r, d, ans = 0;
	scanf("%d%d%d",&l,&r,&d);
	for (int i = l; i <= r; i++) {
		if (i%d == 0)
			ans++;
	}
	printf("%d",ans);
	return 0;
}//pd pdp

Measured memory_bytes: 1724
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int a, b;
	vector<int> cities(5, 0);
	for (int i = 0; i < 3; i++) {
		cin >> a >> b;
		cities[a]++;
		cities[b]++;
	}

	int maxi = 0;
	for (int x: cities) {
		maxi = max(maxi, x);
	}

	cout << (maxi < 3 ? "YES" : "NO") << endl;
	return 0;
}


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

using namespace std;

#define all(a) begin(a), end(a)
#define MOD 1000000007
#define PII pair<int, int>
#define complete_unique(a) a.erase(unique(begin(a), end(a)), end(a))
#define mst(x, a) memset(x, a, sizeof(x))
typedef vector<int> VI;
typedef long long ll;

ll quick_pow(ll a, ll b) {
    long long res = 1;
    while (b) {
        if (b & 1)
            res = a * res;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll gcd(ll a, ll b) {
    a = abs(a), b = abs(b);
    while (b != 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

bool is_prime(int n) {
    if (n == 0) return false;
    if (n == 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    int j = sqrt(n);
    for (int i = 2; i <= j; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}

ll reverse_num(ll n) {
    ll x = 0, t = n;
    while (t != 0) {
        x = x * 10 + t % 10;
        t /= 10;
    }
    return x;
}


const int N = 1e6 + 100;
int n, q;
int nums[N], res[N], visited[N], tree[N];
struct Query {
    int l, r;
    int pos;
} ask[N];

bool cmp(Query q1, Query q2) {
    return q1.r < q2.r;
}

int lowbit(int x) {
    return x & -x;
}

void add(int i, int val) {
    while (i <= n) {
        tree[i] += val;
        i += lowbit(i);
    }
}

int query(int r) {
    int result = 0;
    while (r) {
        result += tree[r];
        r -= lowbit(r);
    }
    return result;
}

int query(int l, int r) {
    return query(r) - query(l);
}

void solve() {
    //    freopen("C:\\Users\\26019\\Downloads\\P1195_4.in", "r", stdin);
    //    fclose(stdin);
    cin >> n >> q;
    for (int i = 1; i <= n; ++i) {
        cin >> nums[i];
    }
    for (int i = 1; i <= q; ++i) {
        cin >> ask[i].l >> ask[i].r;
        ask[i].pos = i;
    }
    sort(ask + 1, ask + 1 + q, cmp);
    int next = 1;
    for (int i = 1; i <= q; ++i) {
        for (int j = next; j <= ask[i].r; ++j) {
            if (visited[nums[j]]) {
                add(visited[nums[j]], -1);
            }
            add(j, 1);
            visited[nums[j]] = j;
        }
        next = ask[i].r + 1;
        res[ask[i].pos] = query(ask[i].l - 1, ask[i].r);
    }
    for (int i = 1; i <= q; ++i) {
        cout << res[i] << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 17400
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int A,B;
    cin>>A>>B;
    if(A<=8&&B<=8){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int M = 1000000007;

long long powmod(long long x,long long y){
    long long res =1 ;
    for(long long i=0;i<y;i++){
        res = res * x % M;
    }
    return res;
}

int main(){
    int N;
    cin >> N;
    long long ans = powmod(10, N) - powmod(9, N) - powmod(9, N) + powmod(8, N);
    ans %= M;
    ans = (ans + M) % M;
    cout << ans << endl;
}

Measured memory_bytes: 3604
#define judge
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int ninf = 0xcfcfcfcf;
const double pi = acos(-1.0);
map<string, int> m;
int n;
int res = ninf;
int main() {
#ifndef judge
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    m[s]++;
    res = max(res, m[s]);
  }

  for (auto it : m) {
    if (it.second == res) cout << it.first << endl;
  }
  return 0;
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
const int N = 1e5 + 5, INF = 1e18;
using namespace std;
int n, dp[N][3], arr[N];
char c[N];
signed main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            dp[i][j]=-INF;
        }
        int mult = 1;
        if (i)
        {
            cin >> c[i];
            if (c[i] == '-') mult = -1;
        }
        cin >> arr[i];
        arr[i] *= mult;
    }
    dp[0][0] = arr[0];
    for(int i = 1; i < n; i++)
    {
        dp[i][0]=dp[i-1][0] + arr[i];
        dp[i][1]=dp[i-1][1] - arr[i];
        if(c[i] == '-') dp[i][1] = max(dp[i][1], dp[i-1][0] + arr[i]);
        dp[i][2]=dp[i-1][2] + arr[i];
        if(c[i] == '-') dp[i][2] = max(dp[i][2], dp[i-1][1] - arr[i]);
        dp[i][1]=max(dp[i][1], dp[i][2]);
        dp[i][0]=max(dp[i][0], dp[i][1]);

    }
    cout << dp[n-1][0];
}

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

int main(){

int a,b;
cin>>a>>b;
if(a+b >= a-b && a+b >= a*b){
  cout<<a+b<<endl;
}else if(a-b >= a+b && a-b >= a*b){
  cout<<a-b<<endl;
}else{
  cout<<a*b<<endl;
}
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
l = []
cnt = 0
i = 0
for a in A:
  l.append((a,B[a-1]))
  i += 1
j = A[0]
for i in range(len(l)):
  cnt += l[i][1]
  a = l[i][0]-1
  if l[i][0] == j+1:
    cnt += C[a-1]
  j = l[i][0]
print(cnt)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    //OJ;
   // FIO;
    int x;
    cin>>x;
    if(x>=400 and x<=599){
        cout<<8<<endl;
    }
    else if(x>=600 and x<=799){
        cout<<7<<endl;
    }
    else if(x>=800 and x<=999){
        cout<<6<<endl;
    }
    else if(x>=100 and x<=1199){
        cout<<5<<endl;
    }
    else if(x>=1200 and x<=1399){
        cout<<4<<endl;
    }
    else if(x>=1400 and x<=1599){
        cout<<3<<endl;
    }
    else if(x>=1600 and x<=1799){
        cout<<2<<endl;
    }
    else if(x>=1800 and x<=1999){
        cout<<1<<endl;
    }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,p,w,g,y;
  string s;
  cin >> N;
  p=0;w=0;g=0;y=0;
	for(int i= 0; i<N;i++){
	cin>>s;
	if(s=="P"){
		p =1;
	}
	if(s=="W"){
		w =1;
	}
	if(s=="G"){
		g =1;
	}
	if(s=="Y"){
		y =1;
	}
	}
	if(p+w+g+y==4){
      cout<<"Four";
    }
  if(p+w+g+y==3){
    cout<<"Three";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  priority_queue<int, vector<int>, less<int>> pq;
  for (int i = 0; i < N; i++) {
    pq.push(A.at(i));
  }
 
  while(M--){
    int t=pq.top();
    pq.pop();
    pq.push(t/2);
  }
    
  long ans=0;
  for(int i=0;i<N;i++){
    int t=pq.top();
    ans+=t;
    pq.pop();
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1276