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

#define fi first
#define se second
#define ll long long

const int N = 200200;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int le;
long long C;
long long d[N];
long long b[N];
long long k[N];
vector < int > v;

long double inter(int x, int y)
{
        return (long double)(b[x] - b[y]) / (k[y] - k[x]);
}

void add(int x)
{
        while(le > 1 && inter(v[le - 2], v[le - 1]) > inter(v[le - 2], x)){
                v.pop_back();
                le -= 1;
        }
        le += 1;
        v.push_back(x);
}

int now = 0;

long long get(long long x)
{
        int l = 0, r = le - 1;
        while(l < r){
                int m = (l + r) / 2;
                if(inter(v[m], v[m + 1]) < (long double)x){
                        l = m + 1;
                }
                else{
                        r = m;
                }
        }
        return x * k[v[l]] + b[v[l]];
}

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n >> C;
        for(int i = 1; i <= n; i++){
                long long x;
                cin >> x;
                if(i == 1){
                        k[i] = -2 * x;
                        b[i] = x * x;
                        add(i);
                        continue;
                }
                d[i] = get(x) + x * x + C;
                k[i] = -2 * x;
                b[i] = d[i] + x * x;
                add(i);
        }
        cout << d[n] << "\n";
}


Measured memory_bytes: 6008
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int m=0,n,aa[1100][1100],a,b,cnt=0;
pair<int,int> p[220000];
string s,ss[110000];
char c;
signed main(){
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2;
}

Measured memory_bytes: 1152
n = int(input())
s = input()

array = list(s)
r = len(s.replace('W', ''))
w = n - r
ans = min(r,w)

i = 0
j = len(array)-1
count = 0
for i in range(r):
  if array[i] == 'W':
    count += 1
  
print(min(count, ans))

Measured memory_bytes: 73336
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <stdio.h>
#include <iterator>

#include <string.h>
using namespace std;

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORD(i,a,b) for(int i=(a);i>(b);i--)
#define scn(a)  scanf("%d",&a)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vecout(vec) for(int i=0;i<vec.size();i++){cout<<vec[i]<<" ";} 
#define cont continue
typedef long long ll;


const ll mod =1e9 +7;
int main(){
    fastio
    int n;
    cin>>n;
    
    if(n>=30) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
    
    
    
    return 0;
}


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

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

    int a, b;
    char op;

    while (1) {
        cin >> a >> op >> b;
        if (op == '?') {
            break ;
        } else if (op == '+') {
            cout << a + b << '\n';
        } else if (op == '-') {
            cout << a - b << '\n';
        } else if (op == '*') {
            cout << a * b << '\n';
        } else if (op == '/') {
            cout << a / b << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int num[maxn],ans[maxn];
int fa[maxn];

int father(int u)
{
	if(fa[u]==u) return u;
	else return fa[u]=father(fa[u]);
}
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		fa[i]=i;
		num[i]=1;
	}
	int a,b;
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		int fax=father(a);
		int fay=father(b);
		fa[fax]=fay;
		if(fax!=fay) num[fay]+=num[fax];
		
		ans[a]--;
		ans[b]--;
	}
	for(int i=1;i<=n;i++){
		int kk=father(i);
//		cout<<i<<" "<<kk<<" "<<num[kk]<<endl;
		ans[i]+=num[kk]-1;
	}
	for(int i=1;i<=k;i++){
		cin>>a>>b;
		if(father(a)==father(b)){
			ans[a]--;
			ans[b]--;
		}
	}
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<" ";
	}
}

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

int main(){
  string N;
  cin >> N;
  if(N.at(0)=='7'){
    cout << "Yes" << endl;  
  }
  else if(N.at(1)=='7'){
    cout << "Yes" << endl;
  }
  else if(N.at(2)=='7'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    string n;
    cin>>n;
    if(n[n.size()-1]=='0'){
        cout<<"pon";
    }else if(n[n.size()-1]=='1'){
        cout<<"pon";
    }else if(n[n.size()-1]=='2'){
        cout<<"hon";
    }else if(n[n.size()-1]=='3'){
        cout<<"bon";
    }else if(n[n.size()-1]=='4'){
        cout<<"hon";
    }else if(n[n.size()-1]=='5'){
        cout<<"hon";
    }else if(n[n.size()-1]=='6'){
        cout<<"pon";
    }else if(n[n.size()-1]=='7'){
        cout<<"hon";
    }else if(n[n.size()-1]=='8'){
        cout<<"pon";
    }else if(n[n.size()-1]=='9'){
        cout<<"hon";
    }

    return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define hahahahahahahahahahahah ios_base::sync_with_stdio(0);
using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{

	hahahahahahahahahahahah;
	cin.tie(0);
	string s;
	cin>>s;
	int n = (int)s.size();
	for(int i =0;i<n;i++)cout<<"x";
	cout<<endl;


	
	return 0;
}

Measured memory_bytes: 764
from collections import Counter

def get_prime_factors(x):
    out = []
    if x < 1:
        return out
    while not x%2:
        out.append(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.append(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.append(x)
    return out
    
def main():
    n = int(input())
    primes = Counter(get_prime_factors(n))
    ans = 0
    for k, v in primes.items():
        num = 1
        while v >= num:
            v -= num
            ans += 1
            num += 1
    print(ans)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 65764
#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{	string s;
	int n,k=0,m=0;
	cin>>s;
	cin>>n;
   	if(n>1)
	for(int i=0;i<s.length();i++)
	{ if(n==1)
	{cout<<s[i]<<endl;
	return 0;}
	if(s[i]=='1')
		n-=1;
	if(s[i]!='1')
	{cout<<s[i]<<endl;
	return 0;}
	}
	else if(n==1)
	cout<<s[0]<<endl;
	return 0;
}

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

int main() {
    char c;
    cin >> c;
    if ((c == 'a')||(c == 'i')||(c == 'u')||(c == 'e')||(c == 'o')) {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
set<int> atcoder;
signed main()
{
	int t;for(register int i(0);i^3;i++){scanf("%d",&t);if(!(atcoder.count(t))){atcoder.insert(t);}}
	printf("%d",atcoder.size());atcoder.clear();
	return putchar(10),0;
}

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

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

  if (N%10==3){
    cout << "bon" << endl;
  }else if(N%10==0 || N%10==1 || N%10==6 || N%10==8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i32 N;
    cin >> N;
    i32 i;
    for (i = 1; i <= 10; i++) {
        if (N - i * 1000 <= 0) break;
    }
    cout << i * 1000 - N << endl;
}


Measured memory_bytes: 3648
#pragma region def
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

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

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
using pint = pair<int, int>;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long llINF = 1e18;
#pragma endregion

int main () {
    string s;
    cin >> s;
    if (s[0] == 'A' && s[1] == 'A' && s[2] == 'A' ||
    s[0] == 'B' && s[1] == 'B' && s[2] == 'B') {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
    return 0;
}

Measured memory_bytes: 256
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 52;

int n, p;

int a[N_MAX];

int cnt[2];

ll p2[N_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> p;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= n; i++)
        cnt[(a[i] & 1)]++;
    p2[0] = 1;
    for(int i = 1; i <= n; i++)
        p2[i] = p2[i - 1] * 2;
    if(cnt[1] == 0)
    {
        if(p == 0)
            cout << p2[cnt[0]] << "\n";
        else
            cout << "0\n";
        return 0;
    }
    cout << 1LL * p2[cnt[0]] * p2[cnt[1] - 1] << "\n";
    return 0;
}


Measured memory_bytes: 3608
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author verytable
 */

#include <iostream>
#include <fstream>

#include <iostream>

class TaskB {
public:
	void solve(std::istream& in, std::ostream& out) {
        std::string s;
        in >> s;

        std::string res = "";
        res.reserve(s.size());
        for (int i = 0; i < s.size(); ++i) {
            if (i % 2 == 0) {
                res += s[i];
            }
        }

        out << res;
	}
};


int main() {
	TaskB solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N, M;
	cin >> N >> M;
	int F[300][300];

	fx(N) {
		fy(M) {
			cin >> F[x][y];
		}
	}
	set<int> a;
	fx(M) {
		a.insert(x + 1);
	}
	int ans = N;
	fx(M) {
		int num[301] = { 0, };
		int maxi = 0;
		int j = 0;
		fy(N) {
			fz(M) {
				if (a.count(F[y][z])) {
					num[F[y][z]]++;
					if (maxi<num[F[y][z]]) {
						j = F[y][z];
						maxi = num[F[y][z]];
					}
					break;
				}
			}
		}

		if (ans > maxi) {
			ans = maxi;
		}
		//else {
			a.erase(j);
		//}
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 640
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p,y=input().split()
    l[int(p)-1].append(y.zfill(10)+str(i).zfill(6))
for i in range(n):
    l[i].sort()
s=[0]*m
for i in range(n):
    for j in range(len(l[i])):
        s[int(l[i][j][10:16])]=str(i+1).zfill(6)+str(j+1).zfill(6)
for i in s:
    print(i)


Measured memory_bytes: 30472
#include <bits/stdc++.h>
#define MAX (ll)(1e4 + 4)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	int h, n;
	cin >> h >> n;
	pair<int, int> ar[n];
	for (int i = 0; i < n; i++) {
		cin >> ar[i].first >> ar[i].second;
	}
	int dp[MAX];
	fill (dp, dp + MAX, MOD);
	dp[0] = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < n; j++) {
			dp[min (h, ar[j].first + i)] = min (dp[min (h, ar[j].first + i)], dp[i] + ar[j].second);
		}
	}
	cout << dp[h] << "\n";
}


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

int main(void)
{
    int h,w,i,j,vanishi[100]={0},vanishj[100]={0};
    char a[100][100];

    scanf("%d %d\n",&h,&w);
    for ( i = 0; i < h; i++)
    {
        for ( j = 0; j < w; j++)
        {
            scanf("%c",a[i]+j);
        }
        scanf("\n");
    }

    for ( i = 0; i < h; i++)
    {
        vanishi[i]=1;
        for ( j = 0; j < w; j++)
        {
            if(a[i][j]=='#') vanishi[i]=0;
        }
    }

    for ( j = 0; j < w; j++)
    {
        vanishj[j]=1;
        for ( i = 0; i < h; i++)
        {
            if(a[i][j]=='#') vanishj[j]=0;
        }
    }

    for ( i = 0; i < h; i++)
    {
        if(vanishi[i]==0)
        {
            for ( j = 0; j < w; j++)
            {
                if(vanishj[j]==0) printf("%c",a[i][j]);
            }
            printf("\n");
        }
    }
    

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
 int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(abs(a-c)>d)
       {if(abs(a-b)<=d && abs(b-c)<=d )
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
       }
       else
       {
           printf("Yes");
       }
return 0;
}

Measured memory_bytes: 1708
N, W = map(int, input().split())
value = list()
weight = list()

for j in range(N):
  v, w = map(int, input().split())
  value.append(v)
  weight.append(w)

dp = [0] * (W+1)

for k in range(1,W+1):
  dpk = 0
  for m in range(N):
    if(k-weight[m] >= 0):
      tmp = dp[k-weight[m]] + value[m]
      if(tmp > dpk):
        dpk = tmp
  dp[k] = dpk

print(dp[W])


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

int main()
{
int A,B,M;scanf("%d %d %d",&A,&B,&M);
int ans=300000,an=300000;
vector<int> a(A);vector<int> b(B);
for(int i=0;i<A;i++){scanf("%d ",&a[i]);an=min(an,a[i]);}
for(int i=0;i<B;i++){scanf("%d ",&b[i]);ans=min(an+b[i],ans);}
vector<int> x(M);vector<int> y(M);vector<int> c(M);
for(int i=0;i<M;i++){scanf("%d %d %d",&x[i],&y[i],&c[i]);ans=min(ans,a[x[i]-1]+b[y[i]-1]-c[i]);}
printf("%d\n",ans);
}

Measured memory_bytes: 2176
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX_N 100
#define MAX_W 10000
#define NIL -1

int dp[MAX_N + 1][MAX_W + 1];
int N, W;
int v[MAX_N], w[MAX_W];

void solve() {
    for (int i = N - 1; i >= 0; --i) {
        for (int j = 0; j <= W; ++j) {
            if (j < w[i])
                dp[i][j] = dp[i + 1][j];
            else
                dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
        }
    }

    return;
}

int main() {
    scanf("%d%d", &N, &W);

    for (int i = 0; i < MAX_N + 1; ++i) {
        fill_n(dp[i], MAX_W + 1, 0);
    }

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

    solve();

    printf("%d\n", dp[0][W]);
}

Measured memory_bytes: 6688
#include<bits/stdc++.h>
using namespace std;
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long
const int M=1e9+7;

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

int expo(int x, int y) {int res=1;x=x%M;while(y>0){if(y&1)res=(1ll*res*x)%M;
	y=y>>1;x=(1ll*x*x)%M;} return res;}
	

signed main(){
	gearup;
	int t = 1;
	//cin >> t;
	while(t--){
		int n, ans;
		cin >> n;
		ans = (n / 500) * 1000;
		ans += (((n % 500) / 5 ) * 5);
		cout << ans ; 
	}
	return 0;
}

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

using namespace std;

int main() {
	long long int N, M;
	cin >> N >> M;
	vector<string>A( N ), B( M );
	for( size_t i = 0; i < N; i++ ) {
		cin >> A[i];
	}
	for( size_t i = 0; i < M; i++ ) {
		cin >> B[i];
	}
	for( size_t i = 0; i <= N - M; i++ ) {
		for( size_t j = 0; j <= N - M; j++ ) {
			bool f = true;
			for( size_t a = 0; a < M; a++ ) {
				for( size_t b = 0; b < M; b++ ) {
					if( A[i + a][j + b] != B[a][b] ) {
						f = false;
					}
				}
			}
			if( f ) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    uint64_t ans=1;
    set<int> NUM;
    while(1){
        if(NUM.count(s)) break;
        NUM.insert(s);
        if(s%2) s=s*3+1;
        else s/=2;
        ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();

            int[][] A = new int[2][N];
            for (int r = 0; r < 2; r++) {
                for (int c = 0; c < N; c++) {
                    A[r][c] = in.nextInt();
                }
            }

            int max = 0;
            for (int c = 0; c < N; c++) {
                int count = 0;
                for (int c2 = 0; c2 < N; c2++) {
                    if (c2 < c) {
                        count += A[0][c2];
                    } else if (c2 == c) {
                        count += A[0][c2];
                        count += A[1][c2];
                    } else {
                        count += A[1][c2];
                    }
                }
                max = Math.max(max, count);
            }
            System.out.println(max);
        }
    }
}


Measured memory_bytes: 21972
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        String line=s.nextLine();
        String[] SNum=line.split(" ");
        int[] num=new int[SNum.length];
        for(int i=0;i<SNum.length;i++){
            num[i]=Integer.parseInt(SNum[i]);
        }

        int sum;
        if(num[3]<=num[0]){
            sum=num[3];
        }else if(num[3]<=num[1]){
            sum=num[0];
        }else{
            sum=num[0]-(num[3]-num[0]-num[1]);
        }

        System.out.println(sum);
    }
}

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

string ans[51];
int main(){
    int r;cin>>r;
    cout<<(int)r*r<<endl;
    return 0;
}

Measured memory_bytes: 384
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
import bisect #二部探索
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化
INF = 10**9 + 7
mod = 10**9 + 7

def main():
    n = int(input())
    data = [input().split() for _ in range(n)]
    #print(data)
    flag = False
    for i in range(n-2):
        if data[i][0] == data[i][1] and data[i+1][0] == data[i+1][1] and data[i+2][0] == data[i+2][1]:
            flag = True
    if flag:
        print('Yes')
    else:print('No')
    return 0

if __name__ == "__main__":
    main()

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

int main(int, char**) {
        std::string S;
        std::cin >> S;
        int Q;
        std::cin >> Q;
        int T;
        bool reverse = false;
        std::string L = "";
        std::string R = "";
        for (int i=0; i<Q; i++) {
                std::cin >> T;
                if (T == 1) {
                        reverse = !reverse;
                } else {
                        int F;
                        std::string C;
                        std::cin >> F >> C; 
                        bool flag = (F == 1 & !reverse) || (F == 2 & reverse);
                        if (flag) { 
                                L = L + C;
                        } else {
                                R = R + C;
                        }
                }
        }
        std::reverse(L.begin(), L.end());
        S = L + S + R;
        if (reverse) {
                std::reverse(S.begin(), S.end());
        }
        std::cout << S << std::endl;
        return 0;
}


Measured memory_bytes: 1596
import java.util.*;

class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int iin = sc.nextInt();
        int iik = sc.nextInt();
        int iis = 0;
        int irt = 0;
        TreeMap<Integer,Integer> ihm = new TreeMap<Integer,Integer>();
        for(int i=0;i<iin;i++){
            iis = sc.nextInt();
            if(ihm.containsKey(iis)){
                int iat = ihm.get(iis);
                iat++;
                ihm.put(iis, iat);
            }
            else{
                ihm.put(iis, 1);
            }
        }
        
        for(int i=ihm.size();i>iik;){
            int j=1;
            for(;;j++){
                if(ihm.containsValue(j)){
                    break;
                }
            }
            for(int k=ihm.firstKey();i>iik;k=ihm.higherKey(k)){
                int ike = ihm.get(k);
                if(j==ike){
                    irt += ihm.remove(k);
                    i--;
                    if(i==iik){
                        break;
                    }
                }
                if(ihm.higherKey(k)==null){
                	break;
                }
            }
        }
        System.out.println(irt);
    }
}


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

int main(){
  long long N;
  cin>>N;
  int cnt,a,num;
  cnt=0;
  num=1;
  for(int i=0;i<N;i++){
    cin>>a;
    if(a==num){
      cnt++;
      num++;
    }
  }
  if(cnt==0) cout<<"-1";
  else cout<<N-cnt;    
}

    


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library
//

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n; cin >> n;
    vector<P> ba(n);
    for(int i = 0; i < n; ++i){
        P tmp;
        cin >> ba[i].second >> ba[i].first ;
    }
    sort(ba.begin(), ba.end());

    ll now = 0;
    string ans = "Yes";
    for (int i = 0; i < n; ++i){
        now += ba[i].second;
        if(now > ba[i].first){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	double a,b,c,d,e,f;
	while(cin >> a >> b >> c >> d >> e >> f){
		double x = (c*e-b*f)/(a*e-b*d);
		double y = (c*d-a*f)/(b*d-a*e);
		if(x==0) x = 0;
		if(y==0) y = 0;
		printf("%.3f %.3f\n", x, y);
	}
}

Measured memory_bytes: 1236
N = int(input())
ratios = [[i for i in map(int,input().split())] for j in range(N)]

ans_a = 0
ans_t = 0
ratio = ratios.pop(0)
ans_a = ratio[0]
ans_t = ratio[1]

for ratio in ratios:
  i = max(ans_a // ratio[0], ans_t // ratio[1])
  while True:
    temp_a = ratio[0]*i
    temp_t = ratio[1]*i
    if temp_a >= ans_a and temp_t >= ans_t:
      ans_a = temp_a
      ans_t = temp_t
      break
    i += 1
    
print(ans_a + ans_t)

Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
 
		int n = sc.nextInt();
    if(n==1){
    System.out.println("Hello World");
    }else{
      int a = sc.nextInt();
      int b = sc.nextInt();
    System.out.println(a+b);
    }
    
    }}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
    public static void debug(String str){
        boolean debug = false;
        if(debug != true){
            return;
        }
        System.out.println(str);
    }
    public static void scanArray(Scanner sc ,int[] array, int num){
        for(int i =0;i<num;i++){
            array[i] = sc.nextInt();
        }
    }
    public static void main(String[] args) {

        int N;
        int L;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            L = sc.nextInt();

        }
        int min = L;
        int sum = 0;
        for(int i = 0 ;i < N;i++){
            int d = L + i;
            sum += d;
            if(Math.abs(min) > Math.abs(d)){
                min = d;
            }
        }
        System.out.println(sum -min);
    }
}


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

int main() {
  int n = 0;
  int m = 0;
  int a[9], am[9];
  fill_n(a, 9, 0);
  fill_n(am, 9, 0);
  int amap[9];
  amap[0] = 2; // 1
  amap[1] = 5; // 2
  amap[2] = 5; // 3
  amap[3] = 4; // 4
  amap[4] = 5; // 5
  amap[5] = 6; // 6
  amap[6] = 3; // 7
  amap[7] = 7; // 8
  amap[8] = 6; // 9

  cin >> n;
  cin >> m;
  for(int i=0; i<m; ++i){
    cin >> a[i];
    am[i] = amap[a[i]-1];
  }

  // 0: 本
  // 1: 桁
  // 2: 数
  unsigned long int dp[10010][3];
  fill_n(dp[0], 10010*3, 0);
  
  vector<vector<int>> vv = vector<vector<int>>(10010);
  for(int i=0; i<=n; ++i){
    for(int j=0; j<m; ++j){
      if (i - am[j] >= 0) {
        unsigned long int prev[3] = { dp[i-am[j]][0], dp[i-am[j]][1], dp[i-am[j]][2] };
        if (prev[0] + am[j] <= n) {
          if (prev[0] + am[j] > dp[i][0] ||
              (prev[0] + am[j] == dp[i][0] && prev[1] + 1 > dp[i][1]) ||
              (prev[0] + am[j] == dp[i][0] && prev[1] + 1 == dp[i][1] && a[j] > dp[i][2])
              ){
            dp[i][0] = prev[0] + am[j];
            dp[i][1] = prev[1] + 1;
            dp[i][2] = a[j];
            vv[i] = vv[i-am[j]];
            vv[i].push_back(a[j]);
          }
        }
      }
    }
  }

//  for(int i=0; i <= n; ++i) {
//    cout << i << ": " << dp[i][0] << ", " << dp[i][1] << ", " << dp[i][2] << " : ";
//    for(auto itr = vv[i].begin(); itr != vv[i].end(); ++itr){
//      cout << *itr;
//    }
//    cout << endl;
//  }
  
  vector<int> v;
  for(int i=n; i>=0; --i){
    if (!vv[n].empty()) {
      v = vv[n];
      break;
    }
  }
  
  sort(v.begin(), v.end(), greater<int>());
  for (auto itr = v.begin(); itr != v.end(); ++itr) {
    cout << *itr;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 146560
N = int(input())
S = str(input())
X = [0] * N

Sum1 = 0
Sum2 = 0
Sum3 = 0

for i in range(N):
    if S[i] == "R":
        X[i] = 1
        Sum1 += 1
    elif S[i] == "G":
        X[i] = 2
        Sum2 += 1
    elif S[i] == "B":
        X[i] = 4
        Sum3 += 1

Sum = Sum1 * Sum2 * Sum3

for i in range(N):
    for j in range(1, N):
        if i - j < 0 or N <= i + j:
            break
        else:
            if (X[i] + X[i - j] + X[i + j]) == 7:
                Sum -= 1

print(Sum)

Measured memory_bytes: 68260
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
//to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {

	string s;
	cin >> s;
	int ans = 0, cnt = 0;
	rep(i, s.size()) {
		if (s[i] == 'A' || s[i] == 'C' ||
			s[i] == 'T' || s[i] == 'G') {
			cnt++;
			ans = max(ans, cnt);
		}
		else {
			cnt = 0;
		}
	}
	cout << ans << rt;

	please AC;
}
//参考：---;

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int s = scan.nextInt();
		int count = 0;

		for(int x = 0; x <= k; x++){
			for(int y = 0; y <= k; y++){
				int z = s - x - y;
				if(0 <= z && z <= k){
					count ++;
				}
			}
		}
		System.out.println(count);
	}
}


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

using namespace std;

#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define UL 100000007
#define ret return
#define f(dt,i,a,b) for(dt i=a;i<b;i++)
#define pb push_back
#define sq(a) (a)*(a)
#define PI 3.14159

typedef vector<long long int> vlli;
typedef vector<int> vi;
typedef long long int lli;  //  e-18 to e18

int main(){
    fastIO();
    int n,a,tmp;
    cin>>n;
    lli s=0;
    map<int,int> m;
    for(int i=0;i<n-1;i++){
        cin>>a;
        m[a]++;
    }
        for(int i=1;i<=n;i++){
            if(m[i])    cout<<m[i] <<endl;
            else  cout<<0<<endl;
        }

return 0;

}       

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;


    vector<int> A, B;

    for(int i = 0; i <= 300; i++){
        for(int j = 0; j <= 300; j++)
            if(100 * a * i + 100 * b * j <= f && 100 * a * i + 100 * b * j > 0)
                A.Pb(100 * a * i + 100 * b * j);
    }

    for(int i = 0; i <= 3000; i++){
        for(int j = 0; j <= 3000; j++)
            if(c * i + d * j <= f)
                B.Pb(c * i + d * j);
    }

    int la = A.size(), lb = B.size();

    int I = 0, J = 0;
    DD ans = 0.;
    for(int i = 0; i < la; i++){
        for(int j = 0; j < lb; j++){
            if(A[i] + B[j] <= f){
                DD x = (100. * B[j]) / (DD)A[i];
                if(x > (DD)e)
                    continue;

                if(x > ans)
                    ans = x, I = i, J = j;
            }
        }
    }

    cout << A[I] + B[J] << ' ' << B[J] << '\n';
    return 0;
}


Measured memory_bytes: 4100
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


signed main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int x,y;
    cin >> x >> y;
    cout << x+y/2 << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        p: [usize; n],
    }
    let mut p = p;
    p.sort();
    let mut total = p.pop().unwrap() / 2;
    // eprintln!("{}", total);
    for x in p {
        total += x;
    }
    println!("{}", total)
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}


template<int d> int nearest(vector<INT> &l, INT pos)
{
	int begin = 0, end = l.size() - 1;

	while (1) {
		int half = (begin + end) / 2;
		if (pos < l[half])
		{
			end = half;
		}
		else
		{
			begin = half;
		}
		if (end - begin < 2)
		{
			if (d == 0)
			{
				return pos - l[begin] > l[end] - pos ? end : begin;
			}
			else if(d == 1)
			{
				return begin;
			}
			else
			{
				return end;
			}
		}
	}
}

int main()
{
	char c;
	cin >> c;

	if (c == 'A')
	{
		cout << 'T' << endl;
		return 0;
	}
	if (c == 'T')
	{
		cout << 'A' << endl;
		return 0;
	}
	if (c == 'G')
	{
		cout << 'C' << endl;
		return 0;
	}
	if (c == 'C')
	{
		cout << 'G' << endl;
		return 0;
	}


	return 0;
}


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

const int mod = 1e9 + 7;

struct matrix {
	int n;
	vector<vector<ll>> mat;
	matrix() {}
	matrix(int m, int p) {
		n = m;
		mat.resize(m, vector<ll> (m, 0));
		if (p == 1) {
			for (int i = 0; i < m; i++) {
				mat[i][i] = 1;
			}
		}
	}
	matrix multiply(matrix& b) {
		matrix p = matrix(n, 0);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					p.mat[i][j] = (p.mat[i][j] + mat[i][k] * b.mat[k][j]) % mod;
				}
			}
		}
		return p;
	}
	matrix expo(ll pow) {
		matrix exp = matrix(n, 1);
		while (pow > 0) {
			if (pow & 1) {
				exp = exp.multiply(*this);
			}
			*this = multiply(*this);
			pow = pow >> 1;
		}
		return exp;
	}
};

int main() {
	ios_base::sync_with_stdio(false);

	int N;
	ll K;
	cin >> N >> K;
	matrix g = matrix(N, 0);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> g.mat[i][j];
		}
	}
	matrix answer = g.expo(K);
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans = (ans + answer.mat[i][j]) % mod;
		}
	}
	cout << ans;

	return 0;
}

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	
	if((a==b && a!=c) || (b==c && b!=a) || (a==c && b!=c))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		
	return 0;
		
} 

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define pb push_back
#define ff first
#define ss second
#define SIZE 200001
#define INF 2e9 + 9
#define BIG_INF 1e18 + 9
#define acmpIN "input.txt"
#define acmpOUT "output.txt"

//#pragma GCC optimize("Ofast")
//



string s;
int a[SIZE], t;

ll n;



int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen(acmpIN, "r", stdin);
//    freopen(acmpOUT, "w", stdout);

    cin >> n;
    ll ans = n / 500;
    ans *= 1000;

    n %= 500;

    ans += (n / 5 * 5);


    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N; ll K;
ll consumption[200005];
ll difficulty[200005];

ll trainingSets(ll m){
    ll cont = 0;
    for (int i=1; i<=N; i++){
        ll newIdx = m / difficulty[i];
        if (newIdx < consumption[i]) cont += consumption[i] - newIdx;
    }
    return cont;
}

int main() {
    scanf("%d %lld", &N, &K);
    for (int i=1; i<=N; i++){
        scanf("%lld", &consumption[i]);
    }
    for (int i=1; i<=N; i++){
        scanf("%lld", &difficulty[i]);
    }
    sort(consumption+1, consumption+1+N);
    sort(difficulty+1, difficulty+1+N, greater<ll>());
    ll l = 0, r = -1, m;
    for (int i=1; i<=N; i++) r = max(r, consumption[i]*difficulty[i]);
    while (r - l > 1LL){
        m = (l+r)/2LL;
        if (trainingSets(m) > K) l = m;
        else r = m;
    }
    if (l == 0){
        if (trainingSets(0) <= K) l--;
    }
    printf("%lld\n", ++l);
    return 0;
}

Measured memory_bytes: 3328
N = int(input())
for h in range(1,3500):
    for n in range(1,3500):
        flg = False
        try:
            w = (N*h*n)/(4*h*n-N*n-N*h)
            if w >= 0 and w.is_integer():
                flg = True
        except:
            pass
        if flg:
            print(h,n,int(w))
            exit(0)

Measured memory_bytes: 73732
N, M = list(map(int, input().split()))

if N == 1 and M == 1:
  print(1)
  exit()

if N <= 2 and M <= 2 or N == 2 or M == 2:
  print(0)
  exit()

if N == 1:
  print(M - 2)
  exit()
if M == 1:
  print(N - 2)
  exit()

print((N - 2) * (M - 2))

Measured memory_bytes: 3064
// Created by the_solver...
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];

void fastio()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


void solve()
{
	
	int n,k;cin>>n>>k;
	int a[n],dp[n+1];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<=n;i++)dp[i] = mod;
	dp[0] = 0;
	// dp[1] = abs(a[1]-a[0]);
	// dp[2] = min((dp[1]+abs(a[2]-a[1])),abs(a[2]-a[0]));
	int i,j;
	for(int i=1;i<n;i++)
	{
		for(i-k<0?j=0:j=i-k;j<=i;j++){
		dp[i] = min((dp[j]+abs(a[j]-a[i])),dp[i]);
		}
	}
	cout<<dp[n-1]<<endl;
}


int32_t main()
{
    
    //fastio();
    // int t;cin>>t;
    // while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>
#include<bits/stdc++.h>
#include<map>
#include<utility>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define vecl vector<long>
#define vecll vector<long long>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
#define rep1e(i, n) for(int i=1; i <= (int)(n); i++)
#define rep1ne(i, n) for(int i=1; i < (int)(n); i++)

#define MAX 100010

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;

  veci point;
  veci cl;
  
  rep(i, N) {
    point.push_back(K - Q);
  }

  rep(i, Q) {
    int q;
    cin >> q;
    cl.push_back(q - 1);
  }

  rep(i, Q) {
    point[cl[i]]++;
  }

  rep(i, N) {
    if(point[i] <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 1528
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    long long n,i,aa=0,bb=0,cnt,sum=0;
    vector <long long> a(n,0),b(n,0);
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<n;i++)
    {
        cin>>b[i];
        bb+=b[i];
    }
    for(i=0;i<n;i++)
    {
        aa+=a[i];
        if(i!=0) bb-=b[i-1];
        cnt=aa+bb;
        if(cnt>sum) sum=cnt;
        cnt=0;
    }
    cout<<sum;
    system ("pause"); 
    return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    string s;
    cin >> n >> s;
    int l = 0;
    int r = n - 1;
    int ans = 0;
    while (l < r) {
        while (l < n && s[l] == 'R') {
            ++l;
        }
        while (r >= 0 && s[r] == 'W') {
            --r;
        }
        if (l < r) {
            swap(s[l], s[r]);
            ++ans;
        }
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3740