akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int a,b;
int main(){
cin>>a>>b;
if(a>b){
    cout<<"a"<<" > "<<"b"<<endl;
}else if(a<b){
    cout<<"a"<<" < "<<"b"<<endl;
}else if(a==b){
    cout<<"a"<<" == "<<"b"<<endl;
}
return 0;
}



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



def main():
    n = int(input())
    l = [int(x) for x in input().split()]
    
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                a, b, c = l[i], l[j], l[k]
                if a == b or b == c or c == a:
                    continue
                if a+b>c and b+c>a and c+a>b:
                    ans += 1
                
    
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
/**
*    created: 31.05.2020 21:19:55
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    long double a;
    cin >> a;
    long double b;
    cin >> b;
    cout << (int)floor(a*b) << endl;
    return 0;
}

Measured memory_bytes: 3812
inp = list(map(int,input().split()))
question = [int(input()) for i in range(inp[2])]
point = []
sinshutu = []
for i in range(inp[0]):
    point.append(inp[1])
    sinshutu.append('No')

for i in range(inp[2]):
    point[question[i]-1] = point[question[i]-1]+1

point = list(map(lambda x:x-inp[2], point))

for i in range(inp[0]):
    if point[i] > 0:
        sinshutu[i] = 'Yes'
    print(sinshutu[i])

Measured memory_bytes: 14560
N, Y = map(int, input().split())

for i in range(N + 1):
    for j in range(N - i + 1):
        if i * 10000 + j * 5000 + (N - i - j) * 1000 == Y:
            print(i, j, N - i - j)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 40684
#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 __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<=b;++i)
#define mod 998244353LL
const double pi =3.14159265358979323846;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x,y; cin>>x>>y;
    if(y%2==0 and y/2 >= x and (2*x)>= y/2 )  cout<<"Yes";
    else cout<<"No";
    return 0;
}

/**
pair<ll,ll>fib(ll n)
{
    if(n==0) return {0,1};
    pair<ll , ll >p=fib(n/2);
    ll c=p.first*(2LL*p.second - p.first) ;
    ll d=p.second*p.second + p.first*p.first;
    if(n&1) return {d,c+d};
    else return {c,d};
}
**/
/**
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
**/
/**check for perfect square.
ll is_perfect_square(ll n)
{
    ll tp=floor(sqrt(n));
    if(n==(tp*tp)) return tp;
    else return -1;
}
**/
/**
ll biexp(ll a,ll n)
{
    if(n==0) return 1;
    ll res=1;
    while(n>0)
    {
        if(n%2!=0) res*=a;
        a=a*a;
        n=n/2;
    }
    return res;
}
ll modular_exp(ll a,ll n)
{
    if(n==0) return 1;
    ll res=1;
    while(n>0)
    {
        if(n%2!=0) res*=a;
        a=(a*a)%mod;
        n=n/2;
        res=res%mod;
    }
    res=(res%mod);
    return res;
}
**/
/** sieve implementation**/
/**
    ll N=1299827; // first 100008 primes;
    vector<ll>lp(N+1,0);
    vector<ll>pr;
    for(ll i=2;i<=N;++i)
    {
        if(lp[i]==0)
        {
            lp[i]=i;
            pr.push_back(i);
        }
        for(ll j=0;j<pr.size() and i*pr[j]<=N ;++j)
        {
            lp[i*pr[j]]=pr[j];
        }
    }
**/
/**
bool isprime(ll n)
{
    if(n<2) return false;
    for(ll i=2;i*i<=n;++i)
    {
        if(n%i==0) return false;
    }
    return true;
}
**/
/**factors in sqrt(n);
    ll N=100000;
    vector<vector<ll> >factors(N+1);
    for(ll j=1;j<=N;++j)
    {
        for(ll x=1;x*x<=j;++x)
         {
            if(j%x==0)
            {
                factors[j].push_back(x);
                if(j/x != x) factors[j].push_back(j/x);
            }
         }
    }
**/
/**
vector<pair<ll,ll> >prime_factors(ll n)
{
    vector<pair<ll,ll> >res; ll ct=0;
    if(!(n&1))
    {
        while(!(n&1))
        {
            ct++; n/=2;
        }
        res.push_back({2,ct});
    }
    ct=0;
    for(ll i=3;i*i<=n;i+=2)
    {
        while(n%i==0)
        {
            ct++; n/=i;
        }
        if(ct>0) res.push_back({i,ct});
        ct=0;
    }
    if(n!=1) res.push_back({n,1});
    return res;
}
**/
/** calculating n_C_r();
ll ncr(ll n, ll k) {
    ll res = 1;
    for (ll i = 1; i <= k; ++i)
        res = (res*(n-k+i))/i;

    return res;
}
**//**/


Measured memory_bytes: 3644
//Be Name Khoda
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
#define RETD(x) { cout << fixed << setprecision(15) << x; exit(0); }
const ll M=2e5+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;

ll n;
ll a[M];

bool solve()
{
    ll t=0;
    For(i,0,n) t+=a[i]%2;
    t=n-t;
    //ER(t);
    if (t&1) return 1;
    if (n-t>1) return 0;
    t=0;
    For(i,0,n)
    {
        if (a[i]&1) a[i]--;
        if (a[i]==0) return 0;
        t=__gcd(t,a[i]);
    }
    For(i,0,n) a[i]/=t;
    return !solve();
}

int main()
{
	ios::sync_with_stdio(0);
    cin >> n;
    For(i,0,n) cin >> a[i];         	
    RET((solve()?"First":"Second"));
} 

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

using namespace std;

int main()
{
    long long N, K;
    std::cin >> N >> K;

    long long r = N % K;
    long long ans = std::min(r, (long long)abs(r - K));
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

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

    bool c[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            c[i][j] = false;
        }
    }

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < n; k++) {
                if (a[i][j] == b[k]) {
                    c[i][j] = true;
                    break;
                }
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (!c[i][j]) {
                break;
            }
            if (j == 2) {
                goto Exit;
            }
        }
    }
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (!c[j][i]) {
                break;
            }
            if (j == 2) {
                goto Exit;
            }
        }
    }
    for (int i = 0; i < 3; i++) {
        if (!c[i][i]) {
            break;
        }
        if (i == 2) {
            goto Exit;
        }
    }
    for (int i = 0; i < 3; i++) {
        if (!c[2 - i][i]) {
            break;
        }
        if (i == 2) {
            goto Exit;
        }
    }
    cout << "No" << endl;
    return 0;
Exit:
    cout << "Yes" << endl;
    return 0;
}

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

int main(int argc, char** argv){
  char c;
  cin >> c;
  if(c == 'A') cout << "T" << endl;
  else if(c == 'T') cout << "A" << endl;
  else if(c == 'G') cout << "C" << endl;
  else if(c == 'C') cout << "G" << endl;
  return 0;  
}

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


int main() {

	int N;
	cin >> N;
	vector<int64_t> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A.at(i);
	}

	int count_odd = 0;
	for (int i = 0;i < N;i++) {
		if (A.at(i) % 2 != 0) {
			count_odd++;
		}
	}
	if (count_odd % 2 == 0) {
		cout << "YES";
	}

	else
		cout << "NO";
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  int sz = S.size();
  if (sz == 1 || sz == 2) {
    cout << (sz == 1 || S[0] == S[1] ? 1 : 2) << '\n';
  }
  vector<int> dp(sz);
  dp[0] = 1;
  dp[1] = (S[0] == S[1] ? 1 : 2);
  dp[2] = (S[0] != S[1] && S[1] != S[2] ? 3 : 2);
  for (int i = 3; i < sz; i++) {
    if (S[i - 1] == S[i]) {
      dp[i] = dp[i - 3] + 2;
    } else {
      dp[i] = dp[i - 1] + 1;
    }
  }
  cout << dp[sz - 1] << '\n';
  return 0;
}


Measured memory_bytes: 1300
#include<iostream>
using namespace std;
int main() {
	long int N, M,count=0;
	cin >> N >> M;
	if (N >= 1 && M >= 2) {
		if (N >= (M / 2)) {
			count += (M / 2);
			N -= (M / 2);
			M -= 2*(M / 2);
		}
		else {
			count += N;
			M -= (2 * N);
			N = 0;
		}
	}
	if (N == 0 && M >= 4) {
		count += (M / 4);
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    vector<pair<int,int>> TREE(N-1);
    vector<int> amount(N);
    vector<int> firste(N-1);
    REP(i,N-1){
        cin >> TREE[i].first;
        cin >> TREE[i].second;
        firste[i] = TREE[i].second;
    }
    REP(i,N-1){
        amount[TREE[i].first - 1]++;
    }
    int color = 0;
    REP(i,N){
        if(i == 0){
            color = max(color,amount[i]);
        }else{
            color = max(color,amount[i] + 1);
        }
    }
    sort(all(TREE));
    int before = 0;
    int counter = 0;
    cout <<color<< "\n";
    vector<int> next(N+1);
    next[1] = 0;
    REP(i,N-1){
        if(before != TREE[i].first){
            counter = 1;
        }
        if(next[TREE[i].first] == counter)counter++;
        next[TREE[i].second] = counter;
        counter++;
        before = TREE[i].first;
    }
    REP(i,N-1){
        cout <<next[firste[i]]<< "\n";
    }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
long long b[900000],a[900000],c[900000],x[900000],n,p,q,sum,maxn;
int main() {
    cin>>n>>p>>q;c[0]=p*q;
    for(int i=0;i<n;i++){cin>>b[i];a[i]=b[i]-(q-i)*p;sum+=b[i];}
    sort(a,a+n);maxn=sum;
    for(int i=0;i<n;i++){
        sum-=a[i];
        sum+=2*i*p;
        maxn=max(sum,maxn);
    }
    cout<<maxn<<endl;
}

Measured memory_bytes: 10972
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI=acos(-1);

int main() 
{
	fastIO;
	int n;
	ll ans;
	cin >> n;
	vector<int> v(n);
	
	for(int i = 0; i<n; i++)
		cin >> v[i];
		
	sort(rall(v));
	
	ans = v[0];
	for(int i = 2; i<n; i++)
		ans+=v[i/2];
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3968
import java.math.*

fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    
    val evenCnt = mutableMapOf<Int, Int>()
    val oddCnt = mutableMapOf<Int, Int>()
    
    val vs = readInputLine().split(" ").map{it.toInt()}
    
    for (i in 0 until n) {
        val num = vs[i]
        
        val useCnt = if (i % 2 == 0) oddCnt else evenCnt
        val cnt = useCnt.get(num) ?: 0
        useCnt.put(num, cnt + 1)
    }
    
    val evenList = evenCnt.toList().sortedByDescending{it.second}
    val oddList = oddCnt.toList().sortedByDescending{it.second}
    
    if (evenList.size == 1 && oddList.size == 1) {
        if (evenList.first().first != oddList.first().first) {
            println(0)
        } else {
            println(n / 2)
        }
    } else {
        if (evenList.first().first != oddList.first().first) {
            println(n - evenList.first().second - oddList.first().second)
        } else {
            println(Math.min(n - evenList[1].second - oddList.first().second, n - evenList.first().second - oddList[1].second))
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 58224
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

vector<int> v[mx];
vector<int> ans(mx,1);
vector<int> a(mx);
vector<int> dp(mx,inf);

void dfs(int n, int p){
  int idx = lower_bound(dp.begin(),dp.end(),a[n]) - dp.begin();
  int tmp = dp[idx];
  dp[idx] = a[n];
  ans[n] = lower_bound(dp.begin(),dp.end(),inf) - dp.begin();
  for(auto to:v[n]){
    if(to==p) continue;
    dfs(to,n);
  }
  dp[idx] = tmp;
}
 
int main(){
  int n;
  cin >> n;
  rep(i,n){ cin >> a[i]; }
  rep(i,n-1){
    int a,b; cin >> a >> b; a--; b--;
    v[a].emplace_back(b);
    v[b].emplace_back(a);
  }
  dfs(0,-1);

  rep(i,n){
    cout << ans[i] << endl;
  }
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

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

    int n;
    cin >> n;

    vector<int> a(n + 1);
    for (auto &a_i : a) cin >> a_i;

    ll sum = accumulate(a.begin(), a.end(), 0ll);
    for (int i = 0; i < n; ++i) {
        ll b; cin >> b;
        if (a[i] <= b) b -= a[i], a[i] = 0;
        else a[i] -= b, b = 0;

        if (a[i + 1] <= b) b -= a[i + 1], a[i + 1] = 0;
        else a[i + 1] -= b, b = 0;
    }

    cout << sum - accumulate(a.begin(), a.end(), 0ll) << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
string s;
cin>>s;
ll int n,i,c,ans;
n=s.length();
ans=0,c=0;
for(i=0;i<n;i++)
{
c=0;
if(s[i]=='R' && i<n)
{
while(s[i]=='R')
{
c++;
i++;
}
ans=max(ans,c);
}
}
cout<<ans;
return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
	int i,j,k=0,l,n,p=0;
	 string str;
	 cin>>str;
	 n=str.size();
	for(i=0;i<n;i++)
	{
		if(str[i]=='0')
		{
			k++;
		}
		else p++;
	}
	if(k<p)
	cout<<k*2<<endl;
	else cout<<p*2<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int x;
  cin >> x;
  while(1){
    bool flag = false;
    for(int i=2;i*i<=x; i++){
      if(x%i==0){
        flag = true;
        // cerr << x << "%" << i << endl;
        break;
      }
    }if(flag){
      x++; continue;
    }
    cout << x << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	double a,b,c,d,e,f,g;
	double x,y;
	while(cin>>a>>b>>c>>d>>e>>f){
		g=a*e-b*d;
		x=(c*e-b*f)/g;if(!x)x=0;
		y=(a*f-c*d)/g;if(!y)y=0;
		printf("%.3f %.3f\n",x,y);
	}
}

Measured memory_bytes: 3148
#include <iostream>
using namespace std;
int main() {
    int spade, dia, heart, club;
    spade = dia = heart = club = 0;
    int n;
    cin >> n;
    for (int i = 0; i< n; i++) {
      char type;
      int num;
      cin >> type >> num;
      int mask = 1;
      mask <<= num-1;
      if (type == 'S') {
        spade |= mask;
      } else if (type == 'D') {
        dia |= mask;
      } else if (type == 'H') {
          heart |= mask;
      } else if (type == 'C') {
        club |= mask;
      }
    }

    int bit1mask = 1;
    for (int i = 0; i < 13; i++) {
      if (!(spade & bit1mask)) {
        cout << "S " << i + 1 << endl;
      }
      spade >>= 1;
    }


    for (int i = 0; i < 13; i++) {
      if (!(heart & bit1mask)) {
        cout << "H " << i + 1 << endl;
      }
      heart >>= 1;
    }

    for (int i = 0; i < 13; i++) {
      if (!(club & bit1mask)) {
        cout << "C " << i + 1 << endl;
      }
      club >>= 1;
    }

    for (int i = 0; i < 13; i++) {
      if (!(dia & bit1mask)) {
        cout << "D " << i + 1 << endl;
      }
      dia >>= 1;
    }

    return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long k = sc.nextLong();

    if (k <= a) {
      a = a-k ;
      k = 0;
    } else {
      k = k-a ;
      a = 0;
    }

    if (k <= b) {
      b = b-k ;
      k = 0;
    } else {
      k = k-b ;
      b = 0;
    }


      System.out.println(a + " " + b);

  }
}


Measured memory_bytes: 21844
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    cnt = [0]*N
    AB = [[int(i)-1 for i in input().split()] for j in range(M)]
    for a, b in AB:
        cnt[a] += 1
        cnt[b] += 1
    if all(c % 2 == 0 for c in cnt):
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

const int max_v=202;
struct edge{int to,cap,rev;};
vector<edge> graph[max_v];
bool used[max_v];

void add_edge(int from,int to,int cap){
    graph[from].push_back(edge{to,cap,int(graph[to].size())});
    graph[to].push_back(edge{from,0,int(graph[from].size()-1)});
}

int ford_fulkerson_dfs(int v,int t,int f){
    if(v==t) return f;
    used[v]=true;
    for(auto &e:graph[v]){
        if(used[e.to] or e.cap<=0) continue;
        int d=ford_fulkerson_dfs(e.to,t,min(f,e.cap));
        if(d>0){
            e.cap-=d;
            graph[e.to][e.rev].cap+=d;
            return d;
        }
    }
    return 0;
}

int ford_fulkerson(int s,int t){
    int flow=0,f;
    while(true){
        fill_n((bool*)used,max_v,false);
        f=ford_fulkerson_dfs(s,t,inf);
        if(f==0) return flow;
        flow+=f;
    }
}

void solve(){
    int x_size,y_size,e_size;
    cin >> x_size >> y_size >> e_size;
    rep(i,0,e_size){
        int x,y;
        cin >> x >> y;
        add_edge(x,x_size+y,1);
    }
    
    rep(i,0,x_size) add_edge(x_size+y_size,i,1);
    rep(i,0,y_size) add_edge(x_size+i,x_size+y_size+1,1);
    
    cout << ford_fulkerson(x_size+y_size,x_size+y_size+1) << endl;
}

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

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


int main(){
	string s,t;
	cin>>s>>t;	
	
	int n = (int)s.length();
	int m = (int)t.length();
	vector<vector<int>> S(26);


	for(int i = 0; i < n; i++) S[s[i]-'a'].push_back(i);
	for(int i = 0; i < n; i++) S[s[i]-'a'].push_back(i+n);
	long long ans = 0; 
	
	int p = 0;

	for(int i = 0; i < m; i++){
		int c = t[i] - 'a';
		if(S[c].size() == 0){
			cout<<-1;
			return 0;
		}
		p = *lower_bound(S[c].begin(),S[c].end(),p)+1;
		if(p>=n){
			p-=n;
			ans+=n;
		}
	}

	cout<<ans+p;

}

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

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

  if( a > b ) swap(a, b);
  if( b > c ) swap(b, c);
  if( a > b ) swap(a, b);

  cout<<a<<" "<<b<<" "<<c<<endl;

  return 0;
}



Measured memory_bytes: 3112
import math

mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    a, b, h, m = map(int,input().split())
    
    min_pos = (m / 60) * 360
    
    hr_pos = (h / 12) * 360
    
    hr_pos += (m / 60) * (360 / 12)
    
    #print((m / 60) * (360 / 12))
    
    deg = abs(hr_pos - min_pos)
    
    if deg > 180:
        deg = 360 - deg
    
    #if min_pos - hr_pos < deg:
    #    deg = min_pos - hr_pos
    
    #print(deg)
    
    rad = math.radians(deg)
    
    # c^2 = a^2 + b^2 - 2ab * cos y 
    
    ans = math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * math.cos(rad)))
    
    print(ans)
    
        
    
    

main()

Measured memory_bytes: 62432
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 444;

vector<int> E[MAX];
bool bio[MAX];

int inDeg[MAX];
int outDeg[MAX];
int N, H;

vector<int> v;

void dfs(int x) {
  if (bio[x]) return;
  bio[x] = true;
  v.push_back(x);
  for (int y: E[x]) dfs(y);
}

bool solve() {
  REP(i, 2*H) {
    if (!bio[i] && E[i].size()) {
      v.clear();
      dfs(i);
      
      bool haveStart = false;
      bool haveEnd = false;
      
      int balance = 0;
      for (int x: v) {
        if (x < H) {
          haveStart |= inDeg[x] < outDeg[x];
          if (inDeg[x] > outDeg[x]) return false;
          balance += outDeg[x] - inDeg[x];
        } else {
          haveEnd |= inDeg[x] > outDeg[x];
          if (inDeg[x] < outDeg[x]) return false;
          balance -= inDeg[x] - outDeg[x];
        }
      }
      if (!haveStart || !haveEnd || balance != 0) return false;
    }
  }
  return true;
}

int main(void) {
  scanf("%d %d", &N, &H);
  REP(i, N) {
    int A, B, C, D;
    scanf("%d %d %d %d", &A, &B, &C, &D);

    int u = C == 0 ? A-1 : H+C-1;
    int v = D == 0 ? H+B-1 : D-1;

    E[u].push_back(v);
    E[v].push_back(u);
    outDeg[u]++;
    inDeg[v]++;
  }

  puts(solve() ? "YES" : "NO");
  return 0;
}


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

int32_t main()
{
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<s.size();i++)
    if(s[i]!=t[i])
      ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3816
import java.util.Scanner;

class Main {
    static int n;
    static int q;
    static int head;
    static int tail;
    static Process[] a;
    static int elaps;

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        q = sc.nextInt();
        a = new Process[n + 1];

        for (int i = 0; i < n; i++) {
            a[i] = new Process(sc.next(), sc.nextInt());
        }

        head = 0;
        tail = n;

        while(head != tail) {
            Process p = dequeue();
            int time = getMin(p.time, q);
            p.time -= time;
            elaps += time;
            if (p.time > 0) {
                enqueue(p);
            } else {
                System.out.printf("%s %d\n", p.name, elaps);
            }
        }
    }

    public static Process dequeue() {
        Process p = a[head];
        head = (head + 1) % (n + 1);
        return p;
    }

    public static void enqueue(Process p) {
        a[tail] = p;
        tail = (tail + 1) % (n + 1);
    }

    public static int getMin(int a, int b) {
        if (a > b) {
            return b;
        }
        return a;
    }
}

class Process {
    String name;
    int time;
    public Process(String name, int time) {
        this.name = name;
        this.time = time;
    }
}



Measured memory_bytes: 114400
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();

    let mut from = 0;
    println!("{}", from);
    let mut from_s = state(&sc.read::<String>());

    if from_s == 2 {
        return;
    }

    let mut to = n - 1;
    println!("{}", to);
    let mut to_s = state(&sc.read::<String>());

    if to_s == 2 {
        return;
    }


    for _ in 0..18 {
        let mid = (from + to) / 2;
        println!("{}", mid);
        let mut mid_s = state(&sc.read::<String>());
        if mid_s == 2 { return; }
        let prefix = mid - from + 1;
        if (mid - from) % 2 == 0 {
            if from_s != mid_s {
                to = mid;
                to_s = mid_s;
            } else {
                from = mid;
                from_s = mid_s;
            }
        } else {
            if from_s == mid_s {
                to = mid;
                to_s = mid_s;
            } else {
                from = mid;
                from_s = mid_s;
            }
        }
    }
    panic!();
}

fn state(s: &str) -> usize {
    if s == "Female" { 0 } else if s == "Male" { 1 } else { 2 }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



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

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << min({a + b, a + c, b + c}) << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3528
import math


def main():
    k = int(input())
    ans = 0
    gcd = math.gcd
    for i in range(1, k+1):
        for j in range(1, k+1):
            for l in range(1, k+1):
                ans += gcd(gcd(i,j), l)

    print(ans)

main()

Measured memory_bytes: 9016
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
int main()
{
	int n,a[224514],m=1145141919,c,s[224514],d[224514];
	char cc;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>cc;
		if(cc=='.')a[i]=0;
		else a[i]=1;
	}
	s[0]=0;
	s[1]=a[1]==1;
	for(int i=2;i<=n;i++)s[i]=s[i-1]+(a[i]==1);
	d[n+1]=0;
	d[n]=a[n]==0;
	for(int i=n-1;i>0;i--)d[i]=d[i+1]+(a[i]==0);
	for(int i=0;i<=n;i++)m=min(m,s[i]+d[i+1]);
	cout<<m<<endl;
}

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

int main() {
  long H, N;
  cin >> H >> N;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  long sum = accumulate(A.begin(), A.end(), 0L);
  cout << ((sum >= H) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define dF3(i,a,b) for(int i=(a)-1;i>=(b);--i)
using namespace std;typedef long long ll;typedef double ld;int INF=0x3f3f3f3f;int INF2=0x7fffffff;ll LNF=0x3f3f3f3f3f3f3f3f;ll LNF2=0x7fffffffffffffff;

int n,L;
int a[100001];

int h[100001],nxt[200001],to[200001],tot;
void ins(int x,int y){nxt[++tot]=h[x];to[tot]=y;h[x]=tot;}

int main(){
	scanf("%d%d",&n,&L);
	F(i,1,n) scanf("%d",a+i);
	int ok=0,I=0;
	F(i,1,n-1) if(a[i]+a[i+1]>=L) {ok=1; I=i;}
	if(!ok) return 0*puts("Impossible");
	puts("Possible");
	F(i,1,I-1) printf("%d\n",i);
	dF(i,n-1,I+1) printf("%d\n",i);
	printf("%d",I);
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for ( int i = 0; i < H; i++ ){
                for ( int j = 0; j < W; j++ ){
                    System.out.print("#");
                }
                System.out.println("");
            }
            System.out.println("");
        }

    }
}


Measured memory_bytes: 33028
#include<stdio.h>
int main(void)
{
	int a, b;
  int i = 0 ;

  while(1)
    {
      i++;

      scanf("%d %d", &a, &b);
      if( a == 0 && b ==0)
    	break;
			else if(a > b){
				printf("%d %d\n", b, a);
			}
			else{
				printf("%d %d\n", a, b);
			}

    }

	return 0;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

void solve(){
	int n;
	cin>>n;
	if(n%1000)
		cout<<(n/1000*1000+1000)-n<<endl;
	else
		cout<<0<<endl;
}

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

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {

	int n; cin >> n;
	vector<int > v(n);
	vector<int >v2(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> v2[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += max(0, v[i] - v2[i]);
	}
	cout << ans;
	
	return 0;
}



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

int main(void){
    // Your code here!
   string s,s1,s2;
   cin >> s;
   
   int q;
   int flag = 0;
   cin >> q;
   
   rep(i,q){
      int d;
      cin >> d;
      if(d==1){
         flag = (flag+1)%2;
         continue;
      }
      char e;
      cin >> d >> e;
      if((d+flag)==2){
         s2.push_back(e);
      }
      else{
           s1.push_back(e);
      }
   }

   reverse(s1.begin(),s1.end());
   s = s1 + s + s2;
   if(flag==1)  reverse(s.begin(),s.end());

   cout << s << endl;
}


Measured memory_bytes: 1348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i, n)
    {
        cin >> vec.at(i);
    }
    double sum = 0.0;
    rep(i,n)
    {
        sum += 1.0 / vec.at(i);
    }
    cout << fixed << setprecision(9);
    cout << 1.0 / sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int a[100050];
int main()
{
    long long int n,i,u=0;
    scanf("%lld",&n);
    if(n==1)
        printf("Yes\n");
    else
    {
        for(i=0;i<n;i++)
            scanf("%lld",&a[i]);
        for(i=n-2;i>=0;i--)
        {
            if(a[i]>a[i+1])
            {
                if(a[i]-1==a[i+1])
                    a[i]--;
                else
                {
                    u=1;
                    break;
                }
            }
        }
        if(u==1)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
   cin>>n;
   for(i=0,k=0;i<n;i++)
   {
       cin>>o;
       v.PSB(o);
       u[o]++;
   }
   sort(v.B,v.E,greater<LL>());
   p=1;
   for(i=0,k=0;i<n;i++)
   {
       if(u[v[i]]>3 && p==1)
       {
           k=2;
           p=v[i]*v[i];
           break;
       }
       else if(u[v[i]]>1)
       {
           p*=v[i];
           u[v[i]]=0;
           k++;
           if(k==2)
           {
               break;
           }
       }
   }
   if(k==2)
   {
       cout<<p<<endl;
   }
   else
   {
       cout<<0<<endl;
   }

    return 0;

}


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

int main() {
  int s,k;
  cin >> k >>s;
  
  int sum = 0;
  int x,y;
  rep(x,k+1){
    rep(y,k+1){
      int z = s - x - y;
      if (x+y+z == s && z>=0 && z<=k){
        sum++;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
use std::collections::VecDeque;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut s: VecDeque<char> = s.trim_right().chars().collect();

    let mut q = String::new();
    std::io::stdin().read_line(&mut q).unwrap();
    let q: u64 = q.trim_right().parse().unwrap();

    let mut reversed = false;

    for _ in 0..q {
        let mut query = String::new();
        std::io::stdin().read_line(&mut query).unwrap();
        let query: Vec<&str> = query.trim_right().split_whitespace().collect();

        if query[0] == "1" {
            reversed = !reversed;
        }
        if query[0] == "2" {
            let push_front = query[1] == "1";
            if reversed ^ push_front {
                s.push_front(query[2].chars().next().unwrap());
            } else {
                s.push_back(query[2].chars().next().unwrap());
            }
        }
    }

    let mut res = String::new();
    if reversed {
        res.extend(s.iter().rev());
    } else {
        res.extend(s.iter());
    };

    println!("{}", res);
}


Measured memory_bytes: 8700
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    string a[H];
    for(int i=0;i<H;i++){
        cin>>a[i];
    }
    for(int i=0;i<W+2;i++){
        cout<<"#";
    }
    puts("");
    for(int i=0;i<H;i++){
        cout<<"#"<<a[i]<<"#"<<endl;
    }
    for(int i=0;i<W+2;i++){
        cout<<"#";
    }
    puts("");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  ModInt() : v(0) {}
  ModInt(auto x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool) *this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t) v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  M pow(auto n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  friend M operator*(auto l, M r) { return M(l) *= r; }
  friend M operator/(auto l, M r) { return M(l) /= r; }
  friend M operator+(auto l, M r) { return M(l) += r; }
  friend M operator-(auto l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  friend bool operator==(auto l, M r) { return M(l) == r; }
  friend bool operator!=(auto l, M r) { return !(l == r); }
};
using Mint = ModInt<(unsigned) 1e9 + 7>;

V<Mint> fact, ifact, inv, powB;
void init(int n, int B = 2) {
  fact.resize(n + 1);
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = i * fact[i - 1];
  }
  ifact.resize(n + 1);
  ifact[n] = fact[n].inv();
  for (int i = n; i > 0; --i) {
    ifact[i - 1] = i * ifact[i];
  }
  inv.resize(n + 1);
  inv[1] = 1;
  for (int i = 2; i <= n; ++i) {
    int q = Mint::p() / i;
    inv[i] = -q * inv[Mint::p() - i * q];
  }
  powB.resize(n + 1);
  powB[0] = 1;
  for (int i = 0; i < n; ++i) {
    powB[i + 1] = powB[i] * B;
  }
}
Mint comb(int n, int r) {
  if (r < 0 or r > n) return 0;
  return fact[n] * ifact[r] * ifact[n - r];
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  lint n, m, k; cin >> n >> m >> k;
  init(n * m);
  Mint res;
  for (lint i = 0; i < n; ++i) {
    res += Mint(i * (i + 1) / 2 + (n - i) * (n - 1 - i) / 2) * m * m;
  }
  for (lint j = 0; j < m; ++j) {
    res += Mint(j * (j + 1) / 2 + (m - j) * (m - 1 - j) / 2) * n * n;
  }
  res /= 2;
  res *= comb(n * m - 2, k - 2);
  cout << res << '\n';
}

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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define vi vector <ll>
#define hell 998244353
#define pii pair <ll,ll>
#define inf (ll)(1e16)
#define pb push_back

using namespace std;

void solve()
{
    ll n;
    cin>>n;
    cout<<(n*(n-1))/2;
}

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


Measured memory_bytes: 256
n = int(input())
w_list = [input() for i in range(n)]
dum = w_list[0][-1]
#print(dum)
for i in range(1,n):
    if w_list[i][0] != dum:
        print("No")
        exit()
    dum = w_list[i][-1]
w_list_len = len(w_list)
w_set = set(w_list)
w_set_len = len(w_set)
if w_set_len != w_list_len:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 38256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]*(N+1)
b = [0]*(M+1)
for i in range(1, N+1):
    a[i] = a[i-1] + A[i-1]
for j in range(1, M+1):
    b[j] = b[j-1] + B[j-1]

ans = 0
j = M
for i in range(N+1):
    if K - a[i] < 0:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47696
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  vector<pair<long long int, int>> AB(N);
  for (int i = 0; i < N; i++){
    int A, B;
    cin >> A >> B;
    AB.at(i) = make_pair(A, B);
  }
  sort(AB.begin(), AB.end());
  long long int money = 0;
  int drink = 0;
  for (int i = 0; i < N; i++){
    money += AB.at(i).first * AB.at(i).second;
    drink += AB.at(i).second;
    if (M < drink){
      money -= (drink - M) * AB.at(i).first;
      break;
    }
  }
  cout << money << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  int a[110000];
  int res=0;
  cin >> N;

  rep(i,N) cin >> a[i];

  map<int,int> mp;
  rep(i,N){
    auto it = mp.find(a[i]);
    if(it != mp.end()){
      it->second = mp.at(a[i])+1;
    }
    else{
      mp.emplace(a[i],1);
    }
  }

  for(auto it:mp){
    if(it.first!=it.second){
      if(it.first<it.second) res += it.second-it.first;
      else res+=it.second;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 5120
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var result = 0;
        for (int i = 0; i < N; i++)
        {
            if ((i + 1) % 2 == 1 && a[i] % 2 == 1)
            {
                result++;
            }
        }
        Console.WriteLine(result);
    }
}

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> p(n + 1), c(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> p[i];
	for (int i = 1; i <= n; i++)
		cin >> c[i];

	long long true_max;
	for (int i = 1; i <= n; i++)
	{
		long long max = c[p[i]];
		int step_count = 0;
		int cur_idx = i;
		long long cur_val = 0;
		vector<long long> maxes = { 0 };
		while (true)
		{
			step_count++;
			cur_idx = p[cur_idx];
			cur_val += c[cur_idx];
			if (cur_val > max)
				max = cur_val;
			maxes.push_back(max);
			if (step_count == k)
				break;

			if (cur_idx == i)
			{
				long long full_cycle_sum = cur_val;
				int cycle_length = step_count;
				int max_num_of_cycles = k / cycle_length;
				if (full_cycle_sum <= 0)
					break;

				long long max_1 = max_num_of_cycles * full_cycle_sum;
				if (maxes[k - max_num_of_cycles * cycle_length] > 0)
					max_1 += maxes[k - max_num_of_cycles * cycle_length];
				long long max_2 = (max_num_of_cycles - 1) * full_cycle_sum + max;

				if (max_1 > max)
					max = max_1;
				if (max_2 > max)
					max = max_2;
				break;
			}
		}

		if (i == 1)
			true_max = max;
		else if (max > true_max)
			true_max = max;
	}

	cout << true_max << endl;

	return 0;
}

Measured memory_bytes: 3744
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll a;
string b;

int main() {
	cin >> a >> b;
	ll bint = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
	cout << a * bint / 100 << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  int index = -1;
  for(int i=0;i<N-1;++i) {
    if(A[i]!=A[i+1]) {
      index = i;
      break;
    }
  }
  if(index==-1) {
    cout<<1000<<endl;
    return 0;
  } 
  bool up;
  ll money, kabu;
  if(A[index]<A[index+1]) {
    money = 1000%A[index];
    kabu = 1000/A[index];
    up = true;
  }
  else {
    money = 1000;
    kabu = 0;
    up = false;
  }
  for(int i=index+1;i<N-1;++i) {
    if(up) {
      if(A[i]>A[i+1]) {
        money += kabu*A[i];
        kabu = 0;
        up = false;
      }
    }
    else {
      if(A[i]<A[i+1]) {
        kabu = money/A[i];
        money = money%A[i];
        up = true;
      }
    }
  }
  money += kabu*A[N-1];
  cout<<money<<endl;
}



Measured memory_bytes: 3600
// Grading
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_A
//
// Accepted

use std::io::{BufRead, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    loop {
        let mut buf = String::new();
        stdin.read_line(&mut buf).unwrap();
        let mut buf = buf.split_whitespace();

        let m: i8 = buf.next().unwrap().parse().unwrap();
        let f: i8 = buf.next().unwrap().parse().unwrap();
        let r: i8 = buf.next().unwrap().parse().unwrap();

        if m == -1 && f == -1 && r == -1 {
            break;
        }

        println!("{}",
            if m == -1 || f == -1 { "F" }
            else if m + f >= 80 { "A" }
            else if m + f >= 65 { "B" }
            else if m + f >= 50 || r >= 50 { "C" }
            else if m + f >= 30 { "D" }
            else { "F" }
        );
    }
}


Measured memory_bytes: 5020