akhauriyash/Code-Regression huggingface dataset:
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(  )
{
	int n,i,a[200001],s[200001];
	  cin>>n;
	  //string s;
	  rep(i,n)
	  cin>>a[i];
	  int j;
	  j=0;
	  if(n%2)
	  {
	  	i=n-1;
	  	 while(i>=0)
	  	 {
	  	 	//cout<<a[i]<<" ";
	  	 	s[j]=a[i];
	  	 	j++;
	  	 	i-=2;
	  	 }
	  	 i=1;
	  	 while(i<n)
	  	 	{
	  	 		 s[j]=a[i];
	  	 		 j++;//cout<<a[i]<<" ";
	  	 		 i+=2;
	  	 	}
	  	 	for(i=0;i<=j-1;i++)
	  {
	  	cout<<s[i]<<" ";
	  }
	  }
	  else
	  {
	  	i=n-2;
	  	 while(i>=0)
	  	 {
	  	 	s[j]=a[i];  j++;
	  	 	//cout<<a[i]<<" ";
	  	 	i-=2;
	  	 }
	  	 i=1;
	  	 while(i<n)
	  	 	{
	  	 		s[j]=a[i];  j++;
	  	 		 //cout<<a[i]<<" ";
	  	 		 
	  	 		 i+=2;
	  	 	}
	  	 	for(i=j-1;i>=0;i--)
	  {
	  	cout<<s[i]<<" ";
	  }
	  }


}


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

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll mod = 998244353;
    
    vector<vector<ll>> dp(C+1, vector<ll>(D+1, 0));
    dp[A][B] = 1;
    for (ll i = A; i <= C; i++) {
        for (ll j = B; j <= D; j++) {
            if (i == A && j == B) continue;
            dp[i][j] = (dp[i][j-1]*i + dp[i-1][j]*j - dp[i-1][j-1]*(i-1)*(j-1)%mod + mod) % mod;
            //cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    cout << dp[C][D] << endl;
    return 0;
}


Measured memory_bytes: 73676
from collections import deque

num = int(input())

arr = []

for i in range(num):
    arr.append(int(input()))

arr0 = sorted(arr,reverse=True)
arr00 = arr0[0]
arr01 = arr0[1]

for i in range(num):
    if arr[i] != arr00:
        print(arr00)
    else:
        print(arr01)

Measured memory_bytes: 70104
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int Q;
	cin >> Q;
	while (Q--) {
		int A, B; cin >> A >> B;

		if (B < A)swap(A, B);
		int L = A, R = B + 1, M;
		int ans = 0;


		while (L <= R) {
			M = (L + R) / 2;
			int m = (M + A) / 2;
			if (M == A)m--;
			if (m*(A + M - m) < A*B) {
				L = M + 1;
				chmax(ans, M);
			}
			else {
				R = M - 1;
				//chman(ans, M);
			}



		}
		cout << ans + A - 2 << endl;
	}

	

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int mod = 998244353;
const int maxn = 4040;
typedef std::bitset<maxn> set;
inline set gcd(set x,set y) {
	for(int i = 4000;i >= 0;--i) {
		if(y.none()) return x;
		if(x.none()) return y;
		if(x.test(i) || y.test(i)) {
			if(x.test(i) && y.test(i)) y ^= x;
			if(y.none()) return x;
			if(!x.test(i)) std::swap(x, y);
			int h = i; for(;!y.test(h);--h);
			x ^= y << i - h;
		}
	}
	return x.none() ? y : x;
}
inline set reduce(set x, set y) {
	int h = maxn - 1; for(;!y.test(h);) -- h;
	for(int i = maxn - 1;i >= h;--i) if(x.test(i)) x ^= y << i - h;
	return x;
}
inline bool less(set x, set y) {
	for(int i = maxn - 1;i >= 0;--i) if(x.test(i) != y.test(i))
		return x.test(i) < y.test(i);
	return 1;
}
int n;
set x, g, now;
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> x;
	for(int i = 0;i < n;++i) {
		cin >> now, g = gcd(g, now);
	}
	set p = reduce(x, g);
	int ans = less(x ^ p, x);
	for(;(g >>= 1).any();x >>= 1);
	for(int now = 1, i = 0;i < maxn;++i, now = (now + now) % mod) if(x.test(i)) ans = (ans + now) % mod;
	cout << ans << '\n';
}


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

#define sz(x) (int)x.size()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

const ll INF = 1e18;

ld oth = 1;
ll n, res = 1;
vector<ll> v;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    v.assign(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; ++i){
        res *= v[i];
        oth *= v[i];
        if(oth > INF){
            cout << -1;
            return 0;
        }
    }
    cout << (res <= INF ? res : -1);
    return 0;
}

Measured memory_bytes: 3980
#[allow(unused_macros)]
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 ) * } };
}
#[allow(unused_macros)]
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 ) * } };
}
#[allow(unused_macros)]
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: u64, m: u64
    }
    println!("{}", (1900*m+100*(n-m))*2u64.pow(m as u32));
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void)
{
  int H,W,i,d;
  while(1){
  scanf("%d %d",&H,&W);
  if(H==0 && W==0)break;
  for(i=0;i<H;i++){
    for(d=0;d<W;d++)
  {
    printf("#");
  } 
  printf("\n");
  }
  printf("\n");
  }
  return 0;
  }


Measured memory_bytes: 2032
#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>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

int n , k;
int mem[100005];
bool vis[100005];
int arr[105];
int sol(int rem , bool ff){

	if(vis[rem])
		return mem[rem];
	vis[rem] = true;
	int ret = 0;
	for(int i = 0; i < n; i++){
		if(rem-arr[i]>=0){
			ret|=sol(rem-arr[i],ff^1)==0;
		}
		else break;
	}
	return mem[rem] = ret;
}
int main(){
	cin>>n>>k;
	for(int i = 0; i< n; i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	sol(k,false);
	if(mem[k])
		cout<<"First";
	else cout<<"Second";
	return 0;
}


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

using namespace std;

void execute()
{
	string input;
	int ans = 0;

	cin >> input;

	for (int i = 0; i < input.size(); i++)
	{
		if (input[i] == '1')
			ans++;
	}

	cout << ans << endl;
	return;
}

int main()
{
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = a%100
c = a//100
if 0<b and b<13 and 0<c and c<13:
    print('AMBIGUOUS')
elif 0<b and b<13:
    print('YYMM')
elif 0<c and c<13:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,num=0,temp;
	cin>>n;
	set<int> st; 
	while(n--){
		cin>>temp;
		set<int>::iterator it = st.find(temp);
		if(it != st.end()){
			st.erase(it);
		}
		else st.insert(temp);
	} 
	cout<<st.size()<<endl;
	return 0;
}

Measured memory_bytes: 4864
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N + 1);
    vector<int> B(N);
    vector<int> C(N + 1);
    A[0] = -1;
    rep(i, N) cin >> A[i + 1];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    C[N] = INF;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    ll ans = 0;
    rep(i, N) {
        int L = distance(A.begin(), upper_bound(A.begin(), A.end(), B[i] - 1));
        int R = distance(C.begin(), lower_bound(C.begin(), C.end(), B[i] + 1));
        //cout << L - 1 << " " << N - R << endl;
        ans += (ll)(L - 1) * (N - R);
    }
    cout << ans << endl;




    return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<deque>
#include<cmath>
using namespace std;

int main(){
    int n;
    double x[100],y[100],dis,ans=0.0,xx,yy,a,b;
    const double PI=3.14159265358979323846;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lf%lf",&x[i],&y[i]);
    }
    for(double i=0;i<100000.0;i++){
        xx=yy=0.0;
        a=cos(PI*i/1000.0);
        b=sin(PI*i/1000.0);
        for(int j=0;j<n;j++){
            if(a*x[j]+b*y[j]>=0){
                xx+=x[j];
                yy+=y[j];
            }
        }
        dis=xx*xx+yy*yy;
        ans=max(ans,sqrt(dis));
    }
    printf("%.12f\n",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    string s1, s2, s3; cin >> s1 >> s2 >> s3;
    cout << (char)(s1[0]-0x20) << (char)(s2[0]-0x20) << (char)(s3[0]-0x20) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	vector<string> s(3);
	while(cin>>s[0]>>s[1]>>s[2]) {
		ll c=0;
		VI i(3);
		while(1) {
			if(i[c]==s[c].size()) break;
			c=s[c][i[c]++]-'a';
		}
		cout<<string(1, 'A'+c)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[2][n];
    rep(i, 0, 2) rep(j, 0, n) cin >> a[i][j];
    int ans = 0;
    rep(i, 0, n) {
        int sum = 0;
        rep(j, 0, i + 1) sum += a[0][j];
        rep(j, i, n) sum += a[1][j];
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ITP1_3_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int a = int.Parse(strs[0]);
            int b = int.Parse(strs[1]);
            int c = int.Parse(strs[2]);
            int n = 0;
            for (int i = a; i <= b; i++)
            {
                if (c % i == 0) n++;
            }
            Console.WriteLine(n);
        }
    }
}

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

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

	long long s = 0;
	for (int i = 0; i < m; ++i) {
		int a;
		cin >> a;
		s += a;
	}

	long long d = n - s;
	if (d < 0) {
		cout << -1;
	} else {
		cout << d;
	}
	
	return 0;
}
	

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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vl;


int main(){
    long long N,M,K;
    cin >> N >> M >> K;
    vl a(N+2),b(M+2);
    a[0]=0; b[0]=0;
    a[N+1]=1e12; b[M+1]=1e12;
    for(int i=1;i<=N;i++){
        cin >> a[i];
    }
    for(int i=1;i<=M;i++){
        cin >> b[i];
    }
    for(int i=1;i<=N;i++){
        a[i]+=a[i-1];
    }
    for(int i=1;i<=M;i++){
        b[i]+=b[i-1];
    }
    long long ans=0;
    for(int i=0;i<=M;i++){
        if(b[i]>K) break;
        long long index=upper_bound(a.begin(),a.end(),K-b[i])-a.begin();
        //cout << i << "  " << index-1 << endl;
        if(index!=0) index--;
        ans=max(ans,i+index);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
    long long n, k;   cin >> n >> k;
    
    long long ans = 0, i, mod = 1e9+7;
    for (i = 0; i <= n - k + 1; i++) {
        ans += (k+i)*(2*n+1-(k+i))/2%mod - (k+i-1)*(k+i)/2%mod + 1;
        ans %= mod;
    }

    cout << (ans+mod)%mod << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e3 + 5;
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    ll res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int last = vec[i] + vec[j] - 1;
            int l = j + 1, r = n - 1, mid, curr = 0;
            while (l <= r) {
                mid = (l + r) / 2;
                if (vec[mid] > last) r = mid - 1;
                else {
                    l = mid + 1;
                    curr = mid - j;
                }
            }
            res += curr;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/abc160/tasks/abc160_b

use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! { x: u32, }
    let ans = (x / 500 * 1000) + (x % 500 / 5 * 5);
    println!("{}", ans);
}


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

int main(){

    while(true){
        int m, f, r;
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1){
            break;
        }
        else if(m == -1 || f == -1){
            // 中間試験、期末試験のいずれかを欠席した場合
            cout << 'F' << endl;
        }
        else if(m + f >= 80){
            // 中間試験と期末試験の合計点数が 80 以上
            cout << 'A' << endl;
        }        
        else if(m + f >= 65){
            // 中間試験と期末試験の合計点数が 65 以上 80 未満
            cout << 'B' << endl;
        }
        else if(m + f >= 50){
            // 中間試験と期末試験の合計点数が 50 以上 65 未満
            cout << 'C' << endl;
        }
        else if(m + f >= 30){
            // 中間試験と期末試験の合計点数が 30 以上 50 未満
            if(r >= 50){
                // 再試験の点数が 50 以上
                cout << 'C' << endl;
            }
            else{
                cout << 'D' << endl;
            }
        }
        else{
            // 中間試験と期末試験の合計点数が 30 未満
            cout << 'F' << endl;           
        }
    } 

    return 0;
}


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

int a;
int b;
int c;
int s;

int main(){
	cin >> a;
	cin >> b;
	cin >> c;
	if ( a<b ) {
		s=a;
		a=b;
		b=s;
	}
	if ( a<c ) {
		s=a;
		a=c;
		c=s;
	}
	if ( b<c ) {
		s=b;
		b=c;
		c=s;
	}
	cout << c << " " << b << " " << a << endl;
    return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

ll lcm(ll a, ll b) { return (a / __gcd(a, b) * b); }

int main() {
  //
  ll n, m;
  cin >> n >> m;
  ll t = max(0LL, (m - 2 * n) / 4);
  ll ans = min(n + t, (m - 2 * t) / 2);
  cout << ans << endl;
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int r = s.size()-1, l = 0;
    int ans = 0;
    while(l < r) {
        if(s[r]==s[l]) {
            r--;
            l++;
            continue;
        } 
        if(s[l]=='x'){
            ans++;
            l++;
            continue;
        }
        if(s[r]=='x'){
            ans++;
            r--;
            continue;
        }
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 55;
int n;
LL a[MAX];
LL cnt[MAX];

void TLE() {
    LL cnt = 0;
    LL ma = -1, idx = -1;
    while (true) {
        ma = -1, idx = -1;
        REP(i, n) if (chmax(ma, a[i])) idx = i;
        if (ma < n) break;
        REP(i, n) {
            if (i == idx) a[i] -= n;
            else a[i]++;
        }
        ++cnt;
    }
    cout << cnt << endl;
}

int main(void) {
    scanf("%d", &n);
    REP(i, n) {
        scanf("%lld", a + i);
    }
    sort(a, a + n);
    LL ans = 0;
    while (true) {
        LL nowCnt = 0;
        bool f = false;
        RREP(i, n) {
            cnt[i] = 0;
            if (a[i] >= n) {
                LL buf = (a[i]) / n;   // こいつをN - 1以下まで持ってくのに必要な回数
                a[i] = (a[i]) % n;
                nowCnt += buf;
                cnt[i] = buf;
            }
        }
        REP(i, n) {
            a[i] += nowCnt - cnt[i];
            f |= a[i] >= n;
        }
        ans += nowCnt;
        if (!f) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

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

	ll countR = 0;
	ll countL = 0;
	ll s = S.size();
	countR++;
	vec ans(s + 1, 0);
	ll RLpos = 0;
	FOR(i, 1, s) {
		// debug(countR);
		if (countL > 0 && S[i] == 'R') {
			// ans[i] = 0;
			ans[RLpos] = (countR + 1) / 2 + countL / 2;
			ans[RLpos + 1] = countR / 2 + (countL + 1) / 2;
			countR = 1;
			countL = 0;
		} else if (S[i - 1] == 'R' && S[i] == 'L') {
			RLpos = i - 1;
			countL = 1;
			// ans[i] = 0;

		} else if (S[i] == 'L') {
			// ans[i]=0;
			countL++;
		} else if (S[i] == 'R') {
			// ans[i]=0;
			countR++;
		}

	}
	ans[RLpos] = (countR + 1) / 2 + countL / 2;
	ans[RLpos + 1] = countR / 2 + (countL + 1) / 2;

	REP(i, s - 1) {
		cout << ans[i] << " ";
	}
	cout << ans[s - 1] << endl;


	return 0;
}

Measured memory_bytes: 1408
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

#define int ll

//get vector of prime numbers which is lower than or equal n
vector<int> get_primes(int n)
{
    vector<bool> is_prime(n + 1, true);
    vector<int> res;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++)
    {
        if (is_prime[i])
        {
            res.push_back(i);
            for (int j = 2 * i; j < is_prime.size(); j = j + i)
            {
                is_prime[j] = false;
            }
        }
    }
    return res;
}

vector<pair<int, int>> factorize(int n)
{
    vector<pair<int, int>> res;
    for (int i = 2; i * i <= n; i++)
    {
        int tmp = 0;
        while (n % i == 0)
        {
            tmp++;
            n /= i;
        }
        res.push_back(make_pair(i, tmp));
    }
    if (n != 1)
    {
        res.push_back(make_pair(n, 1));
    }
    return res;
}

int mpow(int x, int n)
{
    int res = 1;
    while (n != 0)
    {
        if (n & 1)
            res = res * x % INF;
        x = x * x % INF;
        n = n >> 1;
    }
    return res;
}

//mod frac
vector<int> mfrac;
void set_mfrac(int n)
{
    if (mfrac.size() == 0)
    {
        mfrac.push_back(1);
    }
    for (int i = mfrac.size(); i <= n; i++)
    {
        mfrac.push_back((i * mfrac[i - 1]) % INF);
    }
}

//get nCm mod INF
int mcomb(int n, int m)
{
    if (mfrac.size() <= n)
    {
        set_mfrac(n);
    }
    int res = mfrac[n];
    res = res * mpow(mfrac[m], INF - 2) % INF;
    res = res * mpow(mfrac[n - m], INF - 2) % INF;
    return res;
}

vector<int> get_gcd(int n){
    vector<int> res;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            if(i*i==n)
            {res.push_back(i);}
            else
            {res.push_back(i);
            res.push_back(n/i);}
        }
    }
    return res;
}

signed main()
{
    int N;
    cin >> N;
    vector<int> d;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }

    int ans = 0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            ans += d[i] * d[j];
        }
    }

    cout << ans <<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

void piyo(int& a, int& b, int& c, int& d) {
	int tmp = a;
	a = b;
	b = c;
	c = d;
	d = tmp;
}

void hoge(vector<int>& a, char c) {
	switch (c) {
	case 'W': piyo(a[0], a[2], a[5], a[3]); break;
	case 'S': piyo(a[0], a[4], a[5], a[1]); break;
	case 'N': piyo(a[0], a[1], a[5], a[4]); break;
	case 'E': piyo(a[0], a[3], a[5], a[2]); break;
	}
}

int main() {
	vector<int> a(6), b(6);;
	for (int i = 0; i < 6; i++) cin >> a[i];
	for (int i = 0; i < 6; i++) cin >> b[i];
	for (int i = 0; i < 10000; i++) {
		if (a == b) {
			cout << "Yes" << endl;
			return 0;
		}
		if (rand() % 2) hoge(a, 'N');
		else hoge(a, 'E');
	}
	cout << "No" << endl;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v) cout << i << ' ' << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vin2(v, w) for (ll i = 0; i < v.size(); ++i) cin >> v[i] >> w[i];
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 (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(18);

	vi x(5); vin(x);
	rep(i, 5){
		if(x.at(i)==0)cout << i+1;
	}
	



	return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

struct UF {
  vector<int> parent_, rank_;
  UF(int N) : parent_(N + 5), rank_(N + 5, 1) {
    for (int i = 0; i < N + 5; ++i) {
      parent_[i] = i;
    }
  }

  int find_set(int x) {
    if (x != parent_[x]) {
      parent_[x] = find_set(parent_[x]);
    }
    return parent_[x];
  }

  void unite(int x, int y) {
    int px = find_set(x), py = find_set(y);
    if (px == py) { return; }
    if (rank_[px] < rank_[py]) { swap(px, py); }
    parent_[py] = px;
    if (rank_[px] == rank_[py]) { ++rank_[px]; }
  }

  bool is_connected(int x, int y) {
    return find_set(x) == find_set(y);
  }

};

int main()
{
  int N, K, L; scanf("%d %d %d", &N, &K, &L);
  int a, b;
  UF uf1(N + 5), uf2(N + 5);
  for (int i = 0; i < K; ++i) {
    scanf("%d %d", &a, &b);
    uf1.unite(a, b);
  }
  for (int i = 0; i < L; ++i) {
    scanf("%d %d", &a, &b);
    uf2.unite(a, b);
  }
  vector<pair<int, int>> v(N), cities(N + 5);
  for (int i = 0; i < N; ++i) {
    v[i] = make_pair(uf1.find_set(i + 1), uf2.find_set(i + 1));
    cities[i + 1] = v[i];
  }
  sort(v.begin(), v.end());
  map<pair<int, int>, int> freqs;
  for (int i = 0; i < N; ) {
    int j = i;
    while (j < N and v[j] == v[i]) { ++j; }
    freqs[v[i]] = (j - i);
    i = j;
  }
  for (int i = 1; i <= N; ++i) {
    int ans = freqs[cities[i]];
    if (i == 1) { printf("%d", ans); }
    else { printf(" %d", ans); }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 18048
#include <stdio.h>

int main(void)
{
    int X, amari;
    long long int uresisa=0;

    scanf("%d",&X);

    uresisa = X/500;
    amari = X%500;

    uresisa*=1000;

    amari = amari/5;

    uresisa += amari*5;

    printf("%lld\n",uresisa);
    
    return 0;
}

Measured memory_bytes: 128
n = int(input())
table = {}
def prime_decomposition(n):
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            if not i in table:
                table[i] = 1
                n /= i
            else:
                n /= i
                table[i] += 1
        i+=1
    if n>1:
        if not n in table:
            table[int(n)] = 1
        else:
            table[int(n)] += 1
    return 0
for i in range(1,n+1):
    prime_decomposition(i)
ans = 1
for key in table.keys():
    ans *= (table[key]+1)
print(ans%(10**9+7))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    long r = 0;
    long g = 0;
    long b = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')r++;
        else if(s[i] == 'G')g++;
        else b++;
    }
    long ans = 0;
    ans += r*g*b;
    for(int i=1;i<=n;i++){
        for(int j=0;j+2*i<n;j++){
            if(s[j] != s[j+i] && s[j] != s[j+2*i] && s[j+i] != s[j+2*i])ans--;
        }
    }
    cout << ans << endl;
}

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

#include <boost/algorithm/cxx11/all_of.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm/equal.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using namespace boost::algorithm;

main() {
  int64_t n, m;
  cin >> n >> m;

  vector<string> a(n), b(m);
  for (auto&& aa : a) {
    cin >> aa;
  }
  for (auto&& bb : b) {
    cin >> bb;
  }

  for (auto si : irange(0L, n - m + 1)) {
    for (auto sj : irange(0L, n - m + 1)) {
      auto ok = all_of(combine(a | sliced(si, si + m), b), [&](const auto& ab) {
        return boost::equal(boost::get<0>(ab) | sliced(sj, sj + m),
                            boost::get<1>(ab));
      });

      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
colors = list(map(int, input().split()))
# n = 14
# colors = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 1, 2, 3, 4]
ans = []
i = 0
cnt = 0
while True:
    if i == n-1:
        cnt += 1
        ans.append(cnt)
        break
    if colors[i] != colors[i+1]:
        cnt += 1
        ans.append(cnt)
        cnt = 0
    else:
        cnt += 1
    i += 1


ans = list(map(lambda x: x //2, ans))
print(sum(ans))


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

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


Measured memory_bytes: 3632
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

int N,X,Y;
vector<int> G[2001];
int ans[2001]={0};
int dist;
int start;

int seeker(vector<int> startG,int visit[]){
    vector<int> next;
    rep(si,startG.size()){
        int starti = startG[si];
        rep(ni,G[starti].size()){
            int nexti = G[starti][ni];
            if(visit[nexti]!=1){
                visit[nexti]=1;
                ans[dist]++;
                //cout << start << ">" << nexti << " = " << dist << endl;
                next.push_back(nexti);
            }
        }
    }
    dist++;
    if(next.size()>0) seeker(next,visit);
}

int main(){

    cin >> N;
    cin >> X;
    cin >> Y;
    for( int ni = 1 ; ni <N+1 ; ni++ ){
        G[ni].push_back(ni-1);
    }
    rep(ni,N-1){
        G[ni].push_back(ni+1);
    }
    X=X-1;
    Y=Y-1;
    G[X].push_back(Y);
    G[Y].push_back(X);


    rep(starti,N){
        start=starti;
        dist = 1;
        int visit[N]={0};
        vector<int> startG = {starti};
        //dcout << "++++" << starti << endl;
        seeker(startG,visit);
    }

    ans[2] = ans[2] - N;

    for( int ni = 1 ; ni <N ; ni++ ){
        cout << ans[ni]/2 << endl;
    }



    /*
    rep(ni,N){
        cout << "-----" << ni << endl;
        rep(nii,G[ni].size()){
            cout << G[ni][nii] << " " << endl;
        }
    }
    */
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P  = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int N;
    cin >> N;
    vector<ll> L(N);
    rep(i, N) cin >> L[i];
    ll ans = 0;
    rep(i, N-2)rep2(j, i+1, N-1)rep2(k, j+1, N)
    {
        bool x = (L[i] + L[j] > L[k]);
        bool y = (L[k] + L[i] > L[j]);
        bool z = (L[k] + L[j] > L[i]);
        bool w = (L[i] != L[j]) && (L[j] != L[k]) && (L[k] != L[i]);
        if(x&&y&&z &&w) ++ans;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, -1, sizeof(mat))
const int N=100000;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	string s;
	cin>>a>>b>>s;
	FOR(i,0,a){
		if(s[i]>'9'||s[i]<'0'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	if(s[a]!='-'){
		cout<<"No"<<endl;
		return 0;
	}
	FOR(i,a+1,b+a+1){
		if(s[i]>'9'||s[i]<'0'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main() {
  int H, W; cin >> H >> W;
  vector<vector<string>> S(H, vector<string>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) cin >> S.at(i).at(j);
  }
  string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (S.at(y).at(x) == "snuke") {
        cout << alp.at(x) << to_string(y+1) << endl;
        return 0;
      }
    }
  }
}

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

const int N = 1 << 20;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    int ans = 0;
    int xa = 0, bx = 0, ba = 0;
    for (auto& str : s)
    {
        for (int i = 0; i + 1 < str.length(); i++)
        {
            if (str.substr(i, 2) == "AB") ans++;
        }
        if (str.front() == 'B' && str.back() == 'A')
            ba++;
        else if (str.front() == 'B')
            bx++;
        else if (str.back() == 'A')
            xa++;
    }
    // // cerr << ans << endl;
    // vector<vector<vector<vector<int>>>> dp(sz + 1, vector<vector<vector<int>>>(first_b + 1, vector<vector<int>>(back_a + 1, vector<int>(2, -1))));
    // dp[0][0][0][0] = 0;
    // for (int i = 0; i < sz; i++)
    // {
    //     for (int j = 0; j <= first_b; j++)
    //         for (int k = 0; k <= back_a; k++)
    //         {
    //             for (int l = 0; l < 2; l++)
    //             {
    //                 if (~dp[i][j][k][l])
    //                 {
    //                     if (l == 0) // not A
    //                     {
    //                         // append B...A
    //                         if (sz - j - k > 0)
    //                             dp[i + 1][j][k][1] = max(dp[i + 1][j][k][1], dp[i][j][k][l]);
    //                         // append B...
    //                         if (j < first_b)
    //                             dp[i + 1][j + 1][k][0] = max(dp[i + 1][j + 1][k][0], dp[i][j][k][l]);
    //                         // append ...A
    //                         if (k < back_a)
    //                             dp[i + 1][j][k + 1][1] = max(dp[i + 1][j][k + 1][1], dp[i][j][k][l]);
    //                     }
    //                     else
    //                     {
    //                         // append B...A
    //                         if (sz - j - k > 0)
    //                             dp[i + 1][j][k][1] = max(dp[i + 1][j][k][1], dp[i][j][k][l] + 1);
    //                         // append B...
    //                         if (j < first_b)
    //                             dp[i + 1][j + 1][k][0] = max(dp[i + 1][j + 1][k][0], dp[i][j][k][l] + 1);
    //                         // append ...A
    //                         if (k < back_a)
    //                             dp[i + 1][j][k + 1][1] = max(dp[i + 1][j][k + 1][1], dp[i][j][k][l]);
    //                     }
    //                 }
    //             }
    //         }
    // }
    // cout << ans + max(dp[sz][first_b][back_a][0], dp[sz][first_b][back_a][1]) << endl;
    if (xa > 0)
        cout << ans + min(xa, bx) + ba;
    else if (ba > 0)
        cout << ans + ba - 1 + (bx > 0) << endl;
    else
        cout << ans << endl;
}

Measured memory_bytes: 768
N = int(input())
S1 = input()
S2 = input()

MOD = 1000000007


pattern = []
i = 0
while i < N - 1:
    if S1[i] == S1[i + 1]:
        pattern.append('-')
        i += 2
    else:
        pattern.append('|')
        i += 1
else:
    if i == N - 1:
        pattern.append('|')

cnt = 3 if pattern[0] == '|' else 6
for i in range(1, len(pattern)):
    l = pattern[i - 1]
    r = pattern[i]
    if (l, r) == ('|', '|'):
        cnt *= 2
    elif (l, r) == ('|', '-'):
        cnt *= 2
    elif (l, r) == ('-', '|'):
        cnt *= 1
    elif (l, r) == ('-', '-'):
        cnt *= 3
    else:
        raise Exception
    cnt %= MOD

print(cnt)


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

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}


int main(){
    init();

    string arr[3];
    int p[3] = {0};
    cin >> arr[0] >> arr[1] >> arr[2];
    int role = 0;
    while(true){
        if(p[role] == arr[role].size())
            return cout << char('A' + role), 0;
        role = arr[role][p[role]++] - 'a';
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	int count=0;
	for(int i=0;i<=x;i++)
	{
		for(int j=0;j<=x;j++)
		{
			if((2*i)+(4*j)==y && i+j==x )
			{
				count=-1;
				break;
			}
		}
		if(count==-1)
		{
			break;
		}
	}
	if(count==-1)
	{
		cout<<"Yes"<<endl;
	}
	else 
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3624
#include <stdio.h>

typedef struct {
	int key, id;
} data;

void merge_sort(data x[], int n)
{
	static data y[200001] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, j, k, H, W, N, tmp;
	data d[200001];
	scanf("%d %d %d", &H, &W, &N);
	for (i = 0; i < N; i++) scanf("%d %d", &(d[i].key), &(d[i].id));
	merge_sort(d, N);
	for (i = 0; i < N; i++) {
		tmp = d[i].key;
		for (j = i; j < N && d[j].key == tmp; j++) {
			d[j].key ^= d[j].id;
			d[j].id ^= d[j].key;
			d[j].key ^= d[j].id;
		}
		merge_sort(&(d[i]), j - i);
		i = j - 1;
	}
	for (i = 2, j = 0, k = 1; i <= H; i++) {
		for (; j < N && d[j].id < i; j++);
		if (d[j].id == i && d[j].key <= k) break;
		else if (j >= N || d[j].id > i || d[j].key > k + 1) k++;
	}
	printf("%d\n", i - 1);
	fflush(stdout);
	return 0;
}

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

using namespace std;

#define ll  long long
#define vi  vector<int>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b == 0) return b;
  else gcd(b, a%b);
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

int main(){

  int a,b,x;
  cin >> a >> b >> x;
  if(a <= x && a+b >= x) pr("YES");
  else pr("NO");

  return 0;
}


Measured memory_bytes: 256