akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 

using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> p;
typedef pair<double,double> dop;
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


signed main()
{

int n,k;
std::cin >> n >> k;
std::vector<int> tr(n,0);
for(int i = 0; i < n; i++){
    int temp;
    std::cin >> temp;
    tr[i] = temp;
}
std::sort(all(tr),std::greater<int>());
int mi = tr[k - 1];
int ma = tr[0];
int d = ma - mi;
for(int i = k; i < n; i++){
    mi = tr[i];
    ma = tr[i - k + 1];
    if(ma - mi < d){
        d = ma - mi;
    }
}
std::cout <<  d << std::endl;
return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int H,N; cin>>H>>N;
    vi v(N);
    rep(i,N) {
        cin>>v[i];
    }
    int sum=0;
    rep(i,N) {
        sum+=v[i];
    }
    if(sum>=H) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 640
fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let ans = if (a * b) % 2 == 0 { "Even" } else { "Odd" };
    println!("{}", ans);
}

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long a = in.nextLong(), b = in.nextLong(), n = in.nextLong();
		long x = Math.min(n, b-1);
		System.out.println((a*x/b) - a*(x/b));
	}
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> a(n), b(n); cin >> a >> b;
    vector<ll> Sa(n+1, 0), Sb(n+1, 0);
    rep(i, n) Sa[i+1] = Sa[i] + a[i];
    rep(i, n) Sb[i+1] = Sb[i] + b[i];
    ll ans = 0;
    rep(i, n) {
        chmax(ans, Sa[i+1] + Sb[n] - Sb[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int a[200010]={};
	int sum[200010]={};
	vector<int> ans;

	cin >> N;
	for(int i=1;i<=N;i++)
		cin >> a[i];
	
	for(int i=N;i>0;i--)
	{
		int Sum=0;
		for(int j=i;j<=N;j+=i)
			Sum+=sum[j];
		if(Sum%2!=a[i])
		{
			sum[i]=1;
			ans.push_back(i);
		}
	}
	
	cout << ans.size() << endl;
	for(int i=0;i<ans.size();i++)
	{
		cout << ans[i];
		if(i==ans.size()-1)
			cout << endl;
		else 
			cout << " ";
	}
	return 0;
}


Measured memory_bytes: 3320
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
Mindif = x[1]-x[0]
import math
for i in range(1,N):
    Mindif = math.gcd(Mindif,x[i+1]-x[i])
print(Mindif)

Measured memory_bytes: 19884
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define inf 0x3f3f3f3f
#define eps 1e-20
ll read()
{
	ll tmp=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())tmp=tmp*10+c-'0';
	return tmp*f;
}
using namespace std;
int x[100010],y[100010];
int sumb[2010][2010],suml[2010][2010];
int n,k;
int getsumb(int u,int l,int d,int r){return sumb[d][r]-sumb[u-1][r]-sumb[d][l-1]+sumb[u-1][l-1];}
int getsuml(int u,int l,int d,int r){return suml[d][r]-suml[u-1][r]-suml[d][l-1]+suml[u-1][l-1];}
int main()
{
	int i,j;
	n=read(); k=read();
	for(i=1;i<=n;i++){
		x[i]=read(); y[i]=read();
		char c=getchar();
		if(c=='B')++sumb[x[i]%(2*k)+1][y[i]%(2*k)+1];
		else ++suml[x[i]%(2*k)+1][y[i]%(2*k)+1];
	}
	for(i=1;i<=2*k;i++)
		for(j=1;j<=2*k;j++){
			sumb[i][j]+=sumb[i-1][j]+sumb[i][j-1]-sumb[i-1][j-1];
			suml[i][j]+=suml[i-1][j]+suml[i][j-1]-suml[i-1][j-1];
		}
	int ans=0;
	for(i=1;i<=k;i++)
		for(j=1;j<=k;j++){
			int cntb=getsumb(1,1,i-1,j-1)+getsumb(1,j+k,i-1,2*k)+getsumb(i+k,1,2*k,j-1)+getsumb(i,j,i+k-1,j+k-1)+getsumb(i+k,j+k,k*2,k*2);
			int cntl=getsuml(1,j,i-1,j+k-1)+getsuml(i,1,i+k-1,j-1)+getsuml(i,j+k,i+k-1,2*k)+getsuml(i+k,j,2*k,j+k-1);
			ans=max(ans,cntb+cntl);
		}
	for(i=1;i<=k;i++)
		for(j=1;j<=k;j++){
			int cntl=getsuml(1,1,i-1,j-1)+getsuml(1,j+k,i-1,2*k)+getsuml(i+k,1,2*k,j-1)+getsuml(i,j,i+k-1,j+k-1)+getsuml(i+k,j+k,k*2,k*2);
			int cntb=getsumb(1,j,i-1,j+k-1)+getsumb(i,1,i+k-1,j-1)+getsumb(i,j+k,i+k-1,2*k)+getsumb(i+k,j,2*k,j+k-1);
			ans=max(ans,cntb+cntl);
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 32384
#include <iostream>
#include <complex>

using namespace std;

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

	int a;
	cin >> a;
	a = abs(a - s);

	for (int i = 1; i < n; ++i) {
		int b;
		cin >> b;
		b = abs(b - s);

		int joyo;
		joyo = a % b;
		while (joyo) {
			a = b;
			b = joyo;
			joyo = a % b;
		}

		a = b;
	}

	cout << a << endl;


	return 0;
}


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

int main() {
  int ans = 0;
  int num;
  cin >> num;

  for (int i = 0; i < num; i++) {
    int v;
    cin >> v;
    ans += v - 1;
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<functional>


using namespace std;

class Main{
public:
  void input();
  void run();

private:
  int N;
  vector<string> s;
  vector<int> c;
  vector<int> front;
  vector<int> back;
};


void Main::input(){
  cin >> N;
  s.resize(N);
  c.resize(N, -1);
  for( int i = 0; i < N; ++i ){
    cin >> s[i];
    int pos = -1;
    do{
      ++c[i];
      pos=s[i].find("AB", pos+1);
    }while( pos != string::npos );
    if( s[i].front() == 'B' ){
      front.emplace_back(i);
    }
    if( s[i].back() == 'A' ){
      back.emplace_back(i);
    }
  }
  return;
}

void Main::run(){
  int ans = 0;
  for( const auto &x : c ){
    ans += x;
  }
  int min = (front.size() < back.size() ? front.size() : back.size());
  int max = (front.size() < back.size() ? back.size() : front.size());
  ans += min;
  if( (front==back) && (max>0) ){
    --ans;
  }
  cout << ans << endl;
  return;
}






int main(){
  Main m;
  m.input();
  m.run();
  return 0;
}



Measured memory_bytes: 896
import java.util.*;

public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int counter=0;
		int N= sc.nextInt();
		int K= sc.nextInt();
		int h=0;
		for(int i =1; i <=N; i++){
			h=sc.nextInt();
			if(h>=K){
				 counter++;
			 }
		 }
		 System.out.println(counter);


	}
}


Measured memory_bytes: 47868
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
const int MN=2e5+5;
int N,a[MN],Xor,Sum;
ll ans;
int main()
{
	N=read();
	reg int i,l,r;
	for(i=1;i<=N;++i) a[i]=read();
	for(l=1,r=1;l<=N;++l)
	{
		while((Xor^a[r])==(Sum+a[r])&&r<=N)
			Xor^=a[r],Sum+=a[r++];
		ans+=r-l;
		Xor^=a[l];Sum-=a[l];
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

ll a[100010],b[100010];
int n,ans;
map<ll,int>mp;


ll pw(ll x)
{
	return x*x;
}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		ll x;
		scanf("%lld",&x);
		for(ll j=2; j*j*j<=x; j++)
			while(x%(j*j*j)==0)
				x/=j*j*j;
		mp[x]++;
		a[i]=x;
		ll y=1;
		for(ll j=2; j*j*j<=x; j++)
			if(x%j==0)
			{
				y*=(x%(j*j)==0)?j:j*j;
				while(x%j==0)x/=j;
			}
		if(pw((ll)sqrt(x))==x)y*=(ll)sqrt(x);
		else y*=x*x;
		b[i]=y;
	}
	if(mp[1])ans++,mp[1]=0;
	for(int i=1; i<=n; i++)
	{
		ans+=max(mp[a[i]],mp[b[i]]);
		mp[a[i]]=mp[b[i]]=0;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 14336
#include <stdio.h>


// キューの構造体
typedef struct {
    char name[11];
    int time;
} Queue;


int main()
{
    //入力
    int n, q;
    scanf("%d%d", &n, &q);

    int size = 2 * n; //キューのサイズ
    Queue Queue[size];
    int pre = 0, rear = 0, cnt = 0; //pre:enqueue, rear:inqueue, cnt:経過時間
    for( rear = 0; rear < n; ++rear )
        scanf("%s %d", Queue[rear].name, &Queue[rear].time);


    //処理と出力
    while( pre != rear ){
        if( Queue[pre].time <= q ){ // if( Queue[pre].time == q ){ inqueueしない }
            cnt += Queue[pre].time;
            printf("%s %d\n", Queue[pre].name, cnt);
        } else {
            cnt += q;
            Queue[pre].time -= q;
            Queue[rear] = Queue[pre]; //inqueue
            rear = (rear + 1) % size; //次のinqueue先
        }

        //次のdequeue先
        pre = (pre + 1) % size;
    }


    return 0;
}


Measured memory_bytes: 3348
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll N, K;
    cin >> N >> K;
    ll a = 0;
    ll b = 0;
    
    if(K % 2 != 0){
        for(ll i = 1; i <= N; i++){
            if(i % K == 0) a++;
        }
    } else{
        for(ll i = 1; i <= N; i++){
            if(i % K == 0) a++;
            if(i % K == K/2) b++;
        }
    }
    
    cout << a*a*a + b*b*b << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;

int main()
{
    int k; cin >> k;
    int j=0;
    ll n,m;
    queue<ll> que;
    for(int i=1;i<=9;i++) que.push(i);
    for(int i=0;i<k;i++){
        j++;
        n=que.front();
        que.pop();
        m=10*n+(n%10);
        if(n%10!=0) que.push(m-1);
        que.push(m);
        if(n%10!=9) que.push(m+1);
    }
    cout << n << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	VI a, b;
	while (true) {
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		a.PB(x);
		b.PB(y);
	}
	rep(i, SZ(a)) {
		int x = a[i], y = b[i];
		if (x < y)cout << x << " " << y;
		else cout << y << " " << x;
		cout << "\n";
	}
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[3];
    for(int i=0;i<3;++i){
        a[i]=n%10;
        if(a[i]==9)a[i]=1;
        else if(a[i]==1)a[i]=9;
        n/=10;
    }
    for(int i=2;i>=0;--i)cout<<a[i];
    cout<<endl;

}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    string t;
    cin>>t;

    int siz=t.length();
    rep(i,siz){
        if(t[i]=='?')t[i]='D';
    }

    cout<<t<<"\n";

    return 0;

}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int result = 0;
    for(int i = 0; i < s.length(); i++)
    {
        for(int j = i; j < s.length(); j++)
        {
            bool f = true;
            for(int k = i; k <= j; k++)
            {
                if(!((s[k] == 'A')||(s[k] == 'T')||(s[k] == 'G')||(s[k] == 'C')))
                {
                    f = false;
                    break;
                }
            }
            if(f)
            {
                result = max(result, j-i+1);
            }
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	string s;
	while (getline(cin, s))
	{
		stack<double> v;
		stringstream ss;
		string a;
		ss << s;
		while (ss >> a)
		{
			if (a == "+")
			{
				long double x = v.top();
				v.pop();
				long double y = v.top();
				v.pop();
				v.push(y + x);
			}
			else if (a == "-")
			{
				long double x = v.top();
				v.pop();
				long double y = v.top();
				v.pop();
				v.push(y - x);
			}
			else if (a == "*")
			{
				long double x = v.top();
				v.pop();
				long double y = v.top();
				v.pop();
				v.push(y * x);
			}
			else if (a == "/")
			{
				long double x = v.top();
				v.pop();
				long double y = v.top();
				v.pop();
				v.push(y / x);
			}
			else
			{
				v.push(stod(a));
			}
		}
		printf("%6f\n", v.top());
	}
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e6 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;
    return 0;   
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
  int a = 0, b = 0, t = 0;
  cin >> a >> b >> t;
  int sum = 0;
  if(t < a) {
    cout << sum << endl;
  } else {
    sum = (t / a) * b;
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        int max = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
            if(max < h[i]) max = h[i];
            if(max <= h[i]) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 36176
import sys
input=sys.stdin.readline

def main():
    W,H,N = map(int, input().split())
    x0 = 0
    y0 = 0
    x1 = W
    y1 = H
    for _ in range(N):
        x,y,a = map(int, input().split())
        if a == 1:
            x0 = max(x0, x)
        if a == 2:
            x1 = min(x1, x)
        if a == 3:
            y0 = max(y0, y)
        if a == 4:
            y1 = min(y1, y)
    w = max(0, x1-x0)
    h = max(0, y1-y0)
    print(w*h)

if __name__ == '__main__':
    main()


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

int main(){
    string s;
    cin >> s;
    if (s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int len = s.length(); //A12345
    vector<int> indx;
    int counter = 0;
    for (int i = 2; i < len - 1; i++){
        if(s[i] == 'C') {
            indx.push_back(i);
            counter += 1;
        }
    }
    if (counter != 1) {
        cout << "WA" << endl;
        return 0;
    }

    for (int i = 0; i < len; i++){
        if (i == 0 || i == indx[0]) continue;
        else {
            if(isupper(s[i])) {
                cout << "WA" << endl;
                return 0;
            }
        }
    }
    cout << "AC" << endl;
}

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

#define ll long long
const ll _ = 1e6 + 7 , MOD = 998244353 , INV2 = (MOD + 1) / 2;
int N , inv[_] , prm[_] , mu[_] , sum[_] , cnt; bool nprm[_];
int sum1[_] , sum2[_]; vector < int > ys[_];

void init(){
	mu[1] = 1;
	for(int i = 2 ; i <= 1e6 ; ++i){
		if(!nprm[i]){prm[++cnt] = i; mu[i] = -1;}
		for(int j = 1 ; prm[j] * i <= 1e6 ; ++j){
			nprm[prm[j] * i] = 1;
			if(i % prm[j] == 0) break;
			mu[i * prm[j]] = -mu[i];
		}
	}
	inv[1] = 1;
	for(int i = 2 ; i <= 1e6 ; ++i)
		inv[i] = MOD - 1ll * (MOD / i) * inv[MOD % i] % MOD;
	for(int i = 1 ; i <= 1e6 ; ++i)
		for(int j = i ; j <= 1e6 ; j += i){
			sum[j] = (sum[j] + 1ll * mu[i] * i + MOD) % MOD;
			ys[j].push_back(i);
		}
}

signed main(){
	init(); ios::sync_with_stdio(0);
	for(cin >> N ; N ; --N){
		int p; cin >> p;
		for(auto t : ys[p]){
			sum1[t] = (sum1[t] + p) % MOD;
			sum2[t] = (sum2[t] + 1ll * p * p) % MOD;
		}
	}
	int ans = 0;
	for(int i = 1 ; i <= 1e6 ; ++i)
		ans = (ans + 1ll * sum[i] * inv[i] % MOD * ((1ll * sum1[i] * sum1[i] - sum2[i] + MOD) % MOD * INV2 % MOD) % MOD) % MOD;
	cout << ans;
	return 0;
}


Measured memory_bytes: 137088
#include<iostream>
#include<string>
using namespace std;
int main(){
  int a;cin>>a;
  string s=to_string(a);
  if(s[0]=='1')s[0]='9';
  else s[0]='1';
  if(s[1]=='1')s[1]='9';
  else s[1]='1';
  if(s[2]=='1')s[2]='9';
  else s[2]='1';
  cout<<s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int cnt[26]={0};
  string s;
  cin>>s;
  int ans=(s.size()*(s.size()-1))/2;
  rep(i,s.size() ){
    cnt[s[i]-'a']++;
  }
  rep(i,26 ){
    ans-=(cnt[i]*(cnt[i]-1))/2;
  }
  cout<<ans+1<<endl;
    
  
  

  return 0;
}


Measured memory_bytes: 720
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");

string s;
cin>>s;
if(s[1]=='R')s[1]='B';
else s[1]='R';
cout<<s;


    return 0;
  }


Measured memory_bytes: 3656
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a >= b && a >= c) System.out.println(b + c);
		else if(b >= a && b >= c) System.out.println(a + c);
		else System.out.println(a + b);
	}
}

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

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

	sort(a, a + n, greater<int>());

	int alice = 0;
	int bob = 0;
	for(int i = 0; i < n; i++) {
		if(i % 2 == 0) alice += a[i];
		else bob += a[i];
	}

	cout << alice - bob << endl;

 	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
using namespace std;

void solve(){
	int r,g,b,n;
	cin>>r>>g>>b>>n;
	int x=n/r;
	int y=n/g;
	int res=0;
	int z=n/b;
	for(int i=0;i<=x;i++){
		int n1=r*i;
		for(int j=0;j<=y;j++){
			int n2=g*j;
			if(n1+n2>n)break;
			int t=n-n1-n2;
			if(t%b==0)res++;
		}
	}
	cout<<res;
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

using namespace std;

int gcd(int a, int b)
{
    if (b == 0)
        return a;

    return gcd(b, a % b);
}

int main()
{
    int N;
    cin >> N;
    int g;
    cin >> g;
    while (--N)
    {
        int t;
        cin >> t;
        g = gcd(g, t);
    }

    for (int i = 1; i <= g; i++)
        if (g % i == 0)
            cout << i << endl;

    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define inf 1000000000000000007
#define N 405
using namespace std;
typedef long long ll;
ll n, a[N], pre[N], dp[N][N];

ll top(ll bas, ll son){
	return pre[son] - pre[bas - 1];
}

ll f(ll bas, ll son){
	ll &r = dp[bas][son];
	if(r != -1)
		return r;
	if(bas == son)
		return r = 0;
	r = inf;
	// r = f(bas, son - 1) + a[son];
	// r = min(r, f(bas + 1, son), a[bas]);
	for(ll i = bas; i <= son; i++){
		ll sol = top(bas, i);
		ll sag = top(i + 1, son);
		r = min(r, sol + sag + f(bas, i) + f(i + 1, son));
	}
	// printf("dp[%lld][%lld] = %lld\n", bas,son,dp[bas][son]);
	return r;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	memset(dp, -1, sizeof dp);
	scanf("%lld",&n);
	for(ll i = 1; i <= n; i++)
		scanf("%lld",a + i);
	for(ll i = 1; i <= n; i++)
		pre[i] = pre[i - 1] + a[i];
	printf("%lld\n", f(1, n));
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define mod 1000000007
#define int long long

double dp[301][301][301];

double sushi(vector<int> &a, int x, int y, int z){
	if(x == 0 && y == 0 && z == 0)return dp[x][y][z] = 0;
	if(x < 0 || y < 0 || z < 0)return 0;
	if(dp[x][y][z] > -0.9)return dp[x][y][z];
	
	int n = a.size();
	return dp[x][y][z] = (n + (x*sushi(a,x-1,y,z) + y*sushi(a,x+1,y-1,z) + z*sushi(a,x,y+1,z-1)))/(x+y+z);
}

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	int i;
	for (i = 0; i < n; i++)cin >> a[i];
	int j,k;

	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			for(k=0;k<=n;k++)dp[i][j][k] = -1;
		}
	}

	int x = 0,y = 0,z = 0;

	for(i=0;i<n;i++){
		if(a[i] == 1)x += 1;
		else if(a[i] == 2)y += 1;
		else if(a[i] == 3)z += 1;
	}
	
	double cnt = sushi(a,x,y,z);

	cout<<setprecision(15)<<cnt<<endl;

	return;
}

int32_t main() {
	std::ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 216944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+100;
const int inf=0x3f3f3f3f;
typedef pair<ll,int>P;

ll a[maxn];
int main(){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        puts("Yes");
    else
        puts("No");

}


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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	int x, y, r;
	cin >> x >> y;
	if (x == 0){
		if (y == 0) r = 0;
		else if (y > 0) r = y;
		else r = abs(y) + 1;
	}
	else if (y == 0){
		if (x > 0) r = 1 + x;
		else r = abs(x);
	}
	else if (x > 0 && y > 0){
		if (abs(x) <= abs(y)) r = y - x;
		else r = x - y + 2;
	}
	else if (x > 0 && y < 0){
		if (abs(x) <= abs(y)) r = abs(y) - abs(x) + 1;
		else r = abs(x) - abs(y) + 1;
	}
	else if (x < 0 && y > 0){
		if (abs(x) <= abs(y)) r = abs(y) - abs(x) + 1;
		else r = abs(x) - abs(y) + 1;
	}
	else if (x < 0 && y < 0){
		if (abs(x) <= abs(y)) r = abs(y) - abs(x) + 2;
		else r = abs(x) - abs(y);
	}
	cout << r << endl;


	return 0;
}


Measured memory_bytes: 384
S=input()
T=""
Vocab=["dream", "dreamer", "erase", "eraser"]
Reverse=[]
for word in Vocab:
    Reverse.append(word[::-1])

SReverse = S[::-1]

def searchWord(TargetString, WordList):
    for word in WordList:
        index=TargetString.find(word)
        if index == 0:
            return True, index+len(word)
        else:
            pass
    return False, index

def cutString(TargetString, slicePoint):
    replacement = TargetString[slicePoint:]
    return replacement

while True:
    if searchWord(SReverse, Reverse)[0]:
        index = searchWord(SReverse, Reverse)[1]
        SReverse = cutString(SReverse, index)
    else:
        break

if len(SReverse) == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3380
from math import sqrt
def main():
    n = int(input())
    ans = 0
    for i in range(1, int(sqrt(n))+1):
        y = n - i
        if y % i == 0 and y != 0 and n//(y//i) == i:
            ans += y // i
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int maxn=10;
int x,y;
int main(){
	cin>>x>>y;
	bool flg=0;
	for (int i=0;i<=x;i++){
		if ((x-i)*2+i*4==y){
			flg=1;
			break;
		}
	}
	if (flg) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"sort"
)

func main() {
	// Code for B - Mix Juice
	var n, k int
	var total = 0

	fmt.Scan(&n, &k)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)

	for i := 0; i < k; i++ {
		total += p[i]
	}
	fmt.Println(total)
}


Measured memory_bytes: 1884
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

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

int main() {
    int n, p, v = INF, ans = 0;
    cin >> n;
    while (n--) {
        cin >> p;
        if (p < v)
            ans++;
        v = min(v, p);
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> B(n-1);
    for(int i=0;i<n-1;i++){
        cin >> B[i];
    }
    int ans = B[0];
    for(int i=1;i<n-1;i++){
        ans += min(B[i],B[i-1]);
    }
    ans += B[n-2];
    cout << ans << endl;
}

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent = false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);
// lambda: [](T1 x)->T2{return y;}
// simple lambda: [](T x){return x;}

int solve(int N) {
    VVI ts(N + 1, VI(N + 1));
    REP(i, 1, N + 1) rep(j, N + 1) cin >> ts[i][j];

    VVI dp(N + 1, VI(1 << N, INF));
    dp[0][0] = 0;

    rep(i, N) {
        rep(j, 1 << N) {
            if (dp[i][j] == INF) continue;
    
            rep(to, N) if (!(1 << to & j)) {
                MINUD(dp[i + 1][j | 1 << to], dp[i][j] + ts[to + 1][0]);
    
                rep(from, N) if (1 << from & j) {
                    MINUD(dp[i + 1][j | 1 << to], dp[i][j] + ts[to + 1][from + 1]);
                }
            }
        }
    }


    return dp.back().back();
}

int main(void) {
    int N;
    while (cin >> N, N) cout << solve(N) << endl;


    return 0;
}

Measured memory_bytes: 7620
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    unordered_map<ll,int> mp;

    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]]++;
    }

    sort(A.begin(), A.end(), greater<int>());
    A.erase(unique(A.begin(), A.end()), A.end());

    int found = 0;
    ll ans = 1ll;
    for(auto itr = A.begin(); itr!=A.end(); ++itr){
        if(mp[*itr] >= 4){
            if(found == 0){
                ans = 1ll;
                ans *= *itr;
                ans *= *itr;
                found = 2;
                break;
            }else{
                ans *= *itr;
                found++;
            }
        }
        if(mp[*itr] == 2 || mp[*itr] == 3){
            found++;
            ans *= *itr;
        }

        if(found == 2){
            break;
        }
    }

    if(found < 2){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
//#include "graph.cpp"
#define ll long long
#define loop(i,n) for(int i=0 ; i<n ; ++i)
#define rep(i,x,n) for(int i=x ; i<=n ; ++i)
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)
using namespace std;
using namespace __gnu_pbds;

int main(){
    cin.sync_with_stdio(false), cin.tie(0) , cout.tie(0);
  ///  freopen("in.txt","rt",stdin);
  string str;
  cin>>str;
  if(str[0] == str[1] || str[1]==str[2] || str[2]==str[3]){
    cout<<"Bad"<<endl;
  }else{
    cout<<"Good"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
const int N = 701;
bool con[N][N];
int n,m,num=1;
vi vis,parity;
vector<vi> graph;
int r,b;
void dfs(int start)
{
	vis[start]=num;
	if(parity[start]==0)	r++;
	else	b++;
	for(auto i:graph[start])
	{
		if(vis[i]==0)
		{
			if(parity[i]==-1)
			{
				parity[i]=1-parity[start];
			}
			dfs(i);
		}
		else if(parity[i]!=1-parity[start])
		{
			printf("-1");
			exit(0);
		}
	}
}
int main()
{
	int i,j,x,y;
	scanf("%d %d",&n,&m);
	graph.assign(n+1,vi());
	for(i=1;i<=n;i++)	for(j=1;j<=n;j++)	con[i][j]=true;
	for(i=0;i<m;i++)
	{
		scanf("%d %d",&x,&y);
		con[x][y]=con[y][x]=false;
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(i!=j)
			{
				if(con[i][j]==true)
				{
					graph[i].push_back(j);
				}
			}
		}
	}
	vis.assign(n+1,0);parity.assign(n+1,-1);
	vi fi,se;
	int t=0,s=0;
	for(i=1;i<=n;i++)
	{
		if(vis[i]==0)
		{
			parity[i]=0;r=b=0;
			dfs(i);
			fi.push_back(r);
			se.push_back(b);
			t += max(r,b);
			num++;
		}
	}
//	for(auto i : fi)	printf("%d ",i);	printf("\n");
//	for(auto i:se)	printf("%d ",i);	printf("\n");
//	for(i=1;i<=n;i++)	printf("%d ",parity[i]);	printf("\n");
	m = fi.size();
	bool dp[m+1][t+1];
	for(i=0;i<=m;i++)for(j=0;j<=t;j++)dp[i][j]=false;
	dp[0][0]=true;
	for(i=0;i<m;i++)
	{
		for(j=0;j<=t;j++)
		{
			if(dp[i][j]==true)
			{
				dp[i+1][j+se[i]]=true;
				dp[i+1][j+fi[i]]=true;
			}
		}
	}
/*	for(i=0;i<=m;i++)
	{
		for(j=0;j<=t;j++)
		{
			printf("%d ",dp[i][j]);
		}
		printf("\n");
	}*/
	int ans=n;
	for(i=0;i<=t;i++)
	{
		if(dp[m][i]==true)
		{
			x = max(n-i,i);
			ans = min(ans,x);
		}
	}
	printf("%d",ans*(ans-1)/2+(n-ans)*(n-ans-1)/2);
}


Measured memory_bytes: 6980
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(M);
    pll F[M];
    ll ans=0;
    ans--;
    ll ans1=0;
    FORI(i,0,M)
    {
        READ(F[i].fi);
        READ(F[i].se);
        ans+=F[i].se;
        ans1+=F[i].fi*F[i].se;
    }
    cout<<ans+(ans1-1)/9<<endl;

    return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
const int INF = 100000000;
//typedefで決めておくと便利
typedef pair<int, int> P;
//入力
int h, w;//row, column
int maxh = 20, maxw = 20;
vector<vector<char> > maze(21, vector<char>(21));//迷路を表す
int sx, sy;//start point
vector<vector<int> > d(21, vector<int>(21));//最短距離の配列
void bfs(){
    //dx,dyの初期化   
    vector<int> dx(4);
    vector<int> dy(4);
    dx.at(0) = 1;
    dx.at(1) = 0;
    dx.at(2) = -1;
    dx.at(3) = 0;
    dy.at(0) = 0;
    dy.at(1) = 1;
    dy.at(2) = 0;
    dy.at(3) = -1;
    queue<P> que;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            d.at(i).at(j) = INF;//距離をINFで初期化
        }
    }
    que.push(P(sy,sx));
    d.at(sy).at(sx) = 0;//startは0
    //queが空になるまでroop
    while (que.size()){
        P p = que.front();
        que.pop();//queの最初を取り出す
        //移動4方向をroop
        for(int i = 0; i < 4; i++){
            int ny = p.first + dy.at(i), nx = p.second + dx.at(i);
            if(0 <= nx && nx < w && 0 <= ny && ny < h && maze.at(ny).at(nx) != '#' && d.at(ny).at(nx) == INF){
                //移動できるならqueに入れ、その点の距離をpからの距離+1で確定する
                que.push(P(ny, nx));
                d.at(ny).at(nx) = d.at(p.first).at(p.second) + 1;
            }
        }
    } 
}
void solve(){
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> maze.at(i).at(j);
        }
    }//入力完了
    int ans = 0;
    for(int I = 0; I < h; I++){
        for(int J = 0; J < w; J++){
            sx = J;
            sy = I;//スタート地点を全部の点に回す
            if(maze.at(I).at(J) != '#'){//その点が壁ならスルー
                bfs();
                for(int k = 0; k < h; k++){//任意のゴール地点について距離をチェック、最大値を調べる
                    for(int l = 0; l < w; l++){
                        if(maze.at(k).at(l) != '#' && d.at(k).at(l) != INF){
                            ans = max(d.at(k).at(l), ans);
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
}
int main(){
    solve();
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b==c+d)cout<<"Balanced\n";
  else if(a+b>c+d)cout<<"Left\n";
  else cout<<"Right\n";
  return 0;
}


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 1<<64
#define sf(a) scanf("%d",&a)

using namespace std;

int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}

typedef pair<int,int> pii;

vector<pii> vii;

int n=0,m=0;
int memo[15][15];
//この関数だめ↓なんでちゃんとならないか誰か教えて
int po(int k, int mo){
    int an = pow(10,m-mo);
    int ans = pow(10,(m-mo+k));
    cout << an << ans;
    cout << (n%ans)/an << "a" << endl;
    return (n%ans)/an;
}
//int ans=0;
int arc(int moji,int sum){
    int ans=0,t=1;
    if(moji==0)return sum;
    while(t<=moji){
        t*=10;
        ans += arc(moji/t,moji%t+sum);
    }
    return ans;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cout << arc(n,0) << endl;
return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

   int answer = 0;
   int max = 0;

   for(int i=0;i<N;++i){
      if(H[i]>=max){
         max = H[i];
         answer++;
      }
   }

   cout << answer << endl;

   return 0;
}


Measured memory_bytes: 256
// Problem : B - Substring
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		string s,t;
		cin>>s>>t;
		int l=s.length();
		int len=t.length();
		int ans=len;
		for(int i=0;i<=l-len;i++)
		{
			int k=0;
			for(int j=0;j<len;j++)
			{
				if(t[j]!=s[i+j]) k++;
			}
			ans=min(k,ans);
		}
		cout<<ans;
    }
    return 0;
} 


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

int main() {
    int A1,A2,A3;
    cin >> A1 >>A2 >>A3;
    if(A1+A2+A3>21){
        cout << "bust" <<endl;
    }
    else cout << "win" <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repi(i, a, b) for(int i=(a); i>(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define fi first
#define se second
#define umap unordered_map
#define uset unordered_set
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 3005
using namespace std;

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;

//All indexing is 0-based
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
			 tree_order_statistics_node_update> ordered_set;
//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ ll c = a + b; if(c >= p) c -= p; return c;}
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c;}
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p;}



main()
{	
	#ifndef ONLINE_JUDGE
		//freopen("/home/tarun/Desktop/input.txt", "r", stdin);
//		freopen("/home/tarun/Desktop/output.txt", "w", stdout);
	#endif
	sync;
	clock_t clk = clock();
	cerr << "I will return...\n";
	
	int a, b; cin >> a >> b;
	cout << a * b - a - b + 1 << '\n';

	cerr << "...don't you ever hang your head.\n";
	cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << '\n';
}

//Compile using:
//g++ -o filename.exe --std=c++11 filename.cpp
//Use -D CP for defining a macro CP in the local environment







Measured memory_bytes: 256