akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  int A=1;
  int M=0;
  for(int i=1;i<=N;i++){
    int a=0;
    int j=i;
    while(j%2==0){
      a++;
      j/=2;
    }
    if(M<a){
      M=a;
      A=i;
    }
  }
  cout<<A<<endl;
}

Measured memory_bytes: 3612
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
        int x = in.nextInt();
        out.println(x*x*x);
        out.flush();
        in.close();
	}
}

Measured memory_bytes: 26144
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int res = 0;
    repr(i,1,N+1){
        int sum = 0;
        int n = i;
        while (n > 0) {
            sum += n % 10;
            n = n / 10;
        }
        if (A <= sum && sum <= B) res += i;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int n;cin>>n;
    int k;cin>>k;
    int onep;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    n-=k;
    int ans=(n+k-2)/(k-1);
    cout<<ans+1<<endl;
}



Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))


def judge_hasOdd(A):
    hasOdd = False
    for a in A:
        if a % 2 == 0:
            continue
        else:
            hasOdd = True
            break
    return hasOdd


count = 0
while True:
    if judge_hasOdd(A) == False:
        A = list(map(lambda x: x/2, A))
        count += 1
    else:
        break

print(count)



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    int n;
    cin >> n;
    vector<int> d(n);
    REP(i,n){
        cin >> d[i];
    }
    sort(all(d));

    int k = n/2;

    cout << d[k] - d[k-1] << endl;

    return 0;
}

Measured memory_bytes: 640
n = int(input())
s = list(input())
flag = False
sec_flag = False
c = 0
for si in s:
    if si == "A":
        flag = True
        sec_flag = False
    elif flag and si == "B":
        sec_flag = True
        flag = False
    elif sec_flag and si == "C":
        c += 1
        flag, sec_flag = False, False
    else:
        flag, sec_flag = False, False
print(c)


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

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

int V;
vector<int> g[1010];
int match[1010];
bool use[1010];

bool dfs(int v){
  use[v] = true;
  for(int u : g[v]){
    int w = match[u];
    if(w<0 || (!use[w] && dfs(w))){
      match[u] = v;
      match[v] = u;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res = 0;
  memset(match,-1,sizeof(match));
  for(int i=0;i<V;i++){
    if(match[i]<0){
      memset(use,0,sizeof(use));
      if(dfs(i))res++;
    }
  }
  return res;
}

int main(){
  int m,n;
  while(cin >> m >> n){
    if(m==0 && n==0)break;
    V = m+n;
    rep(i,V)g[i].clear();

    vector<int> a(m),b(n);
    rep(i,m)cin >> a[i];
    rep(i,n)cin >> b[i];

    rep(i,m)rep(j,n){
      if(gcd(a[i],b[j])!=1){
	g[i].push_back(j+m);
	g[j+m].push_back(i);
      }
    }
   
    cout << bipartite_matching() << endl;
  }
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;

vi X, Y;
int N;
vi vis;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    
    cin >> N;
    X = vi(N); Y = vi(N); vis = vi(N);
    rep(i, N){
        cin >> X[i] >> Y[i];
    }
    double s = 0;
    vi I(N);
    rep(i, N)I[i] = i;
    do{
        for(int j=1; j < N; j++){
            int i = I[j];
            int k = I[j-1];
            s+=sqrt((X[i]-X[k])*(X[i]-X[k])+(Y[i]-Y[k])*(Y[i]-Y[k]));
        }
    }
    while (next_permutation(all(I)));

    rep(i, N){
        s/=(i+1);
    }
        cout << fixed << setprecision(10) << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a[15];
  	int N;
  	int i;
  	int MAX=0;
  	int SUM = 0;
  
  scanf("%d",&N);
  
  for(i=0; i<N; i++){
  	scanf("%d",&a[i]);
  }
  
  /*for(i=0; i<N; i++){
  	printf("%d",a[i]);
  }*/
  for(i=0; i<N;i++){
  	if(MAX<a[i]) MAX=a[i];
  }
  
  for(i=0; i<N; i++){
  	SUM = SUM + a[i];
  }
  SUM = SUM-MAX;
  if(SUM > MAX){
  	printf("Yes");
  }
  else{
  	printf("No");
  }
}

Measured memory_bytes: 128
N,M = map(int, input().split())
s = [list(map(int, input().split()))[1::] for _ in range(M)]
p = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    lamp=0
    for j in range(M):
        switch = 0
        for k in s[j]:
            k-=1
            if i&(1<<k):
                switch^=1
        if switch == p[j]:
            lamp+=1
    if lamp==M:
        ans+=1
print(ans)


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

int main()
{
    int a,b,x = 1,y = 3;
    cin >> a >> b;

    for(int i = 3; i < 1003; i++){
        if(x - a == y - b){
            cout << x - a << endl;
            return 0;
        }
        x = y;
        y = x + i;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var inputnum = new int[5];
            for (int i = 0; i < 5; i++)
            {
                inputnum[i] = int.Parse(input[i]);
                if (inputnum[i] == 0)
                {
                    Console.WriteLine(i + 1);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 17808
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int r = 0;
  while(n--) {
    int t;
    scanf("%d", &t);
    r += 2 * min(t, k-t);
  }
  printf("%d\n", r);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n;
  int a;
  cin>>n>>a;
  if(a>=n%500)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, d, mod = 1e9 + 7;
string s;
long long dp[ 10005 ][ 105 ][ 2 ];

long long solve( int pos, int sum, bool allowed )
{
	if( pos == n )
	{
		return ( sum == 0 ? 1 : 0 );
	}
	if( dp[ pos ][ sum ][ allowed ] != -1 )
	{
		return dp[ pos ][ sum ][ allowed ];
	}
	dp[ pos ][ sum ][ allowed ] = 0;
	for( int i = 0; i <= ( allowed ? 9 : s[ pos ] - '0' ); ++i )
	{
		dp[ pos ][ sum ][ allowed ] += solve( pos + 1, ( sum + i ) % d, ( allowed || i < ( s[ pos ] - '0' ) ) );
		if( dp[ pos ][ sum ][ allowed ] >= mod )
		{
			dp[ pos ][ sum ][ allowed ] -= mod;
		}
	}
	return dp[ pos ][ sum ][ allowed ];
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> s >> d;
	n = s.length();
	memset( dp, -1, sizeof( dp ) );
	cout << ( solve( 0, 0, 0 ) - 1 + mod ) % mod << "\n";
	return 0;
}


Measured memory_bytes: 17536
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <queue>
using namespace std;

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

typedef double Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

pair<Weight, Edges> minimumSpanningTree(const Graph &g, int r = 0) {
  int n = g.size();
  Edges T;
  Weight total = 0;

  vector<bool> visited(n);
  priority_queue<Edge> Q;
  Q.push( Edge(-1, r, 0) );
  while (!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (visited[e.dst]) continue;
    T.push_back(e);
    total += e.weight;
    visited[e.dst] = true;
    FOR(f, g[e.dst]) if (!visited[f->dst]) Q.push(*f);
  }
  return pair<Weight, Edges>(total, T);
}


#define dis(x,y,z,x2,y2,z2) sqrt((x2-x)*(x2-x)+(y2-y)*(y2-y)+(z2-z)*(z2-z)) 

int main() {
  int n;
  while(cin>>n,n) {
    Graph g(n);
    double x[n], y[n], z[n], r[n];
    REP(i,n) {
      cin >> x[i] >> y[i] >> z[i] >> r[i];
      REP(j,i) {
        double d;
        if ((d = dis(x[i],y[i],z[i],x[j],y[j],z[j])-r[i]-r[j]) >= 0) {
          g[j].push_back(Edge(j,i,d));
          g[i].push_back(Edge(i,j,d));
        } else {
          g[j].push_back(Edge(j,i,0));
          g[i].push_back(Edge(i,j,0));
        }
      }
    }
    
    printf("%.3lf\n", minimumSpanningTree(g).first);
  }
}

Measured memory_bytes: 1324
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  long long K;
  cin >> K;
  int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout << A[K-1] << endl;
}


Measured memory_bytes: 256
def main():

    N, M = map(int, input().split())
    stairs = [1] * N
    ans = [0] * N
    for _ in range(M):
        stairs[int(input()) - 1] = 0
    for i in range(N):
        if i == 0:
            ans[i] = stairs[i]
        elif i == 1:
            ans[i] = ans[i - 1] * stairs[i - 1] + stairs[i]
        else:
            ans[i] = (stairs[i - 1] * ans[i - 1] + stairs[i - 2] * ans[i - 2]) % (10 ** 9 + 7)
    print(ans[N - 1])

if __name__ == "__main__":
    main()

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

bool has3(int x){
    while(x){
     if( x % 10 == 3 ) return true;
     x /= 10;
    }
    return false;
}

void call(int n){
    for ( int x = 1; x <= n; x++ ){
        if ( x % 3 == 0 || has3(x) ){
         cout << " " << x;
        }
    }
    cout << endl;
}

int main(){
  int n;
  cin >> n;
  call(n);
    
 return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, Q;
  cin >> N;
  vector<ll> A(N);
  vector<ll> cnt(100005);
  rep(i, N) {
    cin >> A[i];
    cnt[A[i]]++;
  }
  ll sum = accumulate(all(A), 0LL);
  cin >> Q;
  vector<ll> B(Q), C(Q);
  rep(i, Q) cin >> B[i] >> C[i];
  rep(i, Q) {
    sum += cnt[B[i]] * (C[i] - B[i]);
    cnt[C[i]] += cnt[B[i]];
    cnt[B[i]] = 0;
    cout << sum << endl;
  }
  return 0;
}


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

long long q;

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

    cin>>q;
    while(q--)
    {
        long long x,y;
        cin>>x>>y;
        if(x>y)
            swap(x,y);
        if(x==y)
            cout<<2*x-2<<endl;
        else if(x==y-1)
            cout<<2*x-2<<endl;
        else
        {
            long long c=sqrt(x*y);
            if(c*c==x*y)
                c--;
            if(c*(c+1)>=x*y)
                cout<<2*c-2<<endl;
            else
                cout<<2*c-1<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,M,X; cin>>N>>M>>X;
	vector<bool> nap(N+1, false);
	rep(i,M){
		int t; cin>>t;
		nap[t] = true;
	}
	int ans_a = 0;
	int ans_b = 0;
	for(int i = X; i<=N; ++i){
		if(nap[i])++ans_a;
	}
	for(int i = 0; i<=X; ++i){
		if(nap[i])++ans_b;
	}
	cout<<min(ans_a,ans_b)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b;
	char c;
	while(1){
		scanf("%d %c %d",&a,&c,&b);
		if(c=='?')break;
		else if(c=='+')printf("%d\n",a+b);
		else if(c=='-')printf("%d\n",a-b);
		else if(c=='*')printf("%d\n",a*b);
		else printf("%d\n",a/b);
	}
	return 0;
}

Measured memory_bytes: 600
<?php

    // AtCoder Beginner Contest 161
    // B - Popular Vote

    list($n, $m) = in_ints();
    $a = in_ints();

    rsort($a);
    $threshold = array_sum($a) / (4 * $m);
    if ($a[$m - 1] >= $threshold) {
        yes();
    } else {
        no();
    }
    
    /**
    * お手伝い関数さんたち
    */
    function in() {
        return trim(fgets(STDIN));
    }
    function in_int() {
        return (int)in();
    }
    function in_vals() {
        return explode(' ', in());
    }
    function in_ints() {
        return array_map('intval', in_vals());
    }
    function out($s) {
        echo $s . PHP_EOL;
    }
    function yes() {
        out('Yes');
    }
    function no() {
        out('No');
    }



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

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

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

    long minval = a[0], maxval = a[0], sum = a[0];
    for (int i = 1; i < n; i++) {
        minval = min(minval, a[i]);
        maxval = max(maxval, a[i]);
        sum += a[i];
    }

    cout << minval << " " << maxval << " " << sum << endl;

    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<stack>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>

using namespace std;

int main(void)
{
	int i, n, m;
	string t;
	
	cin >> n>>m;
	vector<string>s(n);
	for (i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	for (i = 0; i < n; i++)
	{
		cout << s[i];
	}
	return 0;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(ll a=b;a<=c;a++)
#define PER(a,b,c) for(ll a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<ll,ll>
#define pii pair<pair<ll,ll>,ll>
using namespace std;
const ll MAXN=1e6+5;
ll n,m,t;
ll mod=1e9+7;
void exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll INV(ll a)
{
    ll x,y;
    exgcd(a,mod,x,y);
    return (x+mod)%mod;
}
ll v[MAXN];
char s[MAXN];
ll qk(ll x,ll n){
    ll ans=1;
    while(n){
        if(n%2)ans=ans*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return ans;
}
ll C(ll a){
    ll ans=1;
    REP(i,1,a){
        ans=ans*(n-i+1)%mod*INV(i)%mod;
    }
    return ans;
}
main(){
    cin>>n>>m>>t;
    ll ans=(qk(2,n)-1+mod)%mod;
    ans-=C(m)+C(t);
    cout<<(ans+mod*2)%mod;
}

Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(12)

using namespace std;

const long double EPS = 1e-13;

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

    double x1, x2, x3, y1, y2, y3;
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    cin >> x3 >> y3;

    double S = abs((x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)) / 2;

    double a = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
    double b = sqrt(pow(x3 - x2, 2) + pow(y3 - y2, 2));
    double c = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));

    double R = 2 * S / (a + b + c);

    double l = 0;
    double r = max({a, b, c});

    while (r - l > EPS) {
        double m = (l + r) / 2;
        double t = max({a, b, c}) * (R - m) / R;
        if (t >= 2 * m) {
            l = m;
        } else {
            r = m;
        }
    }
    fcout << l << endl;

    return 0;
}


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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

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

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, a; cin >> n >> a;

  cout << n * n - a << endl;
  
  return (0);
}

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

const int N = 105, M = 1e4 + 5;

int n, m, K, djq, inv[N], f[N][N], C[N][N], pw[N][M], ipw[N][M];

inline void add(int &a, const int &b) {if ((a += b) >= djq) a -= djq;}

int main()
{
	std::cin >> n >> m >> K >> djq; inv[1] = 1;
	for (int i = 2; i <= K; i++) inv[i] = 1ll * (djq - djq / i) * inv[djq % i] % djq;
	f[0][0] = 1;
	for (int i = 0; i <= 100; i++) C[i][0] = 1;
	for (int i = 1; i <= 100; i++)
		for (int j = 1; j <= i; j++)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % djq;
	for (int i = 1; i <= K; i++)
	{
		pw[i][0] = ipw[i][0] = 1;
		for (int j = 1; j <= n * m; j++)
			pw[i][j] = 1ll * pw[i][j - 1] * i % djq,
				ipw[i][j] = 1ll * ipw[i][j - 1] * inv[i] % djq;
	}
	for (int T = 1; T <= K; T++)
	{
		for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++)
			f[i][j] = 1ll * f[i][j] * ipw[K - T + 1][i * j] % djq;
		for (int j = 0; j <= m; j++)
			for (int i = n; i >= 0; i--)
				for (int k = 0; k < i; k++)
					f[i][j] = (1ll * f[k][j] * C[n - k][i - k] + f[i][j]) % djq;
		for (int i = 0; i <= n; i++)
			for (int j = m; j >= 0; j--)
				for (int k = 0; k < j; k++)
					f[i][j] = (1ll * f[i][k] * C[m - k][j - k] + f[i][j]) % djq;
		for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++)
			f[i][j] = 1ll * f[i][j] * pw[K - T + 1][i * j] % djq;
		if (T < K)
		{
			for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++)
				f[i][j] = 1ll * f[i][j] * ipw[K - T][i * j] % djq;
			for (int j = 0; j <= m; j++)
				for (int i = n; i >= 0; i--)
					for (int k = 0; k < i; k++)
					{
						int delta = 1ll * f[k][j] * C[n - k][i - k] % djq;
						add(f[i][j], i - k & 1 ? djq - delta : delta);
					}
			for (int i = 0; i <= n; i++)
				for (int j = m; j >= 0; j--)
					for (int k = 0; k < j; k++)
					{
						int delta = 1ll * f[i][k] * C[m - k][j - k] % djq;
						add(f[i][j], j - k & 1 ? djq - delta : delta);
					}
			for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++)
				f[i][j] = 1ll * f[i][j] * pw[K - T][i * j] % djq
					* pw[T + 1][(n - i) * (m - j)] % djq *
						ipw[T][(n - i) * (m - j)] % djq;
		}
	}
	return std::cout << f[n][m] << std::endl, 0;
}

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

typedef long long int int64;

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  if(a[0]!=0){
    printf("-1\n");
    return;
  }
  int zeroIndex=0;
  for(i=1;i<n;i++){
    if(a[i]==0){
      zeroIndex=i;
    } else if(a[i]>i-zeroIndex || a[i-1]<a[i]-1){
      printf("-1\n");
      return;
    }
  }
  int64 ans=0;
  i=n-1;
  while(i>=0){
    int j=i-1;
    while(j>=0 && a[j]+1==a[j+1]) j--;
    ans+=a[i];
    i=j;
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 896
s=input()
#SUN,MON,TUE,WED,THU,FRI,SAT 

if s=='SUN':
  num=7
elif s=='MON':
  num=6
elif s=='TUE':
  num=5
elif s=='WED':
  num=4
elif s=='THU':
  num=3
elif s=='FRI':
  num=2
elif s=='SAT':
  num=1
print(num)




Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL H,W;
	cin>>H>>W;
	if (H==1 || W==1){
		cout<<1<<endl;
		return 0;
	}
	LL HW=H*W;
	if (HW%2==0){
		cout<<HW/2<<endl;
	}else{
		cout<<HW/2+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

int gcd(int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void task()
{
    //code here...
    
    int n, k, ans = 0;
    
    cin >> n >> k;
    int ara[n];
    for(int K=0; K<n; K++) cin >> ara[K];
    
    sort(ara, ara+n);
    
    for(int K=0; K<k; K++) ans += ara[K];
    
    cout << ans << "\n";
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}




Measured memory_bytes: 3612
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#define fi first
#define sec second
#define INF 100000000
using namespace std;
typedef pair<int,int> P;

int N;
P A[500000];

bool compare_y(P a, P b){
	return a.sec < b.sec;
}

int closest(P *a, int n){
	if(n <= 1) return INF;
	int m = n/2;
	int x = a[m].fi;
	int d = min(closest(a,m),closest(a+m,n-m));
	inplace_merge(a,a+m,a+n,compare_y);
	vector<P> b;
	for(int i = 0; i < n; i++){
		if(abs(a[i].fi-x) >= d) continue;
		for(int j = 0; j < b.size(); j++){
			int dx = a[i].fi-b[b.size()-j-1].fi;
			int dy = a[i].sec-b[b.size()-j-1].sec;
			if(dy >= d) break;
			d = min(d,dx*dx+dy*dy);
		}
		b.push_back(a[i]);
	}
	return d;
}

int main(){
	scanf("%d",&N);
	for(int i = 0; i < N; i++) scanf("%d%d",&A[i].fi,&A[i].sec);
	sort(A,A+N);
	printf("%d\n",closest(A,N));
}

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

vector<pair<long long,long long>> a(20001);
long long dp[2001][2001];



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

  for(long long i=0;i<n;i++)
  {
    long long x;
    cin>>x;
    a[i] = make_pair(x,i+1);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());

  for(long long i=0;i<=n;i++)    //for every element in revsoerted array
  {
      for(long long j=0;j<=i;j++)  //check every possibility
      {
        long long  l = i-j;
        long long r = j;
        if(l!= 0)dp[l][r] = max(dp[l][r] , dp[l-1][r] + a[l+r-1].first*(abs(l - a[l+r-1].second)));
        if(r != 0)dp[l][r] = max(dp[l][r] , dp[l][r-1] + a[l+r-1].first * (abs(n-r+1 - a[l+r-1].second)));
      }
  }


  long long ans = 0;
  for(long long i=0;i<=n;i++)
  {
    ans = max(ans  , dp[i][n-i]);
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 26140
"""
#問題の意味わかってないね
#print(l)
mini = l[0] 
maxi = l[len(l)-1]
#print(id(mini))#idは有効期間が重ならない２つのオブジェクトについては同じ値を持つことがあるらしい
#print(id(maxi))
for i in range(1,len(l)):
    if l[i]<mini:
        mini=l[i]
        if(i == len(l)-1):
            print(-1)
            sys.exit(0)
    
if mini is maxi:
    print(-1)
    sys.exit(0)

for i in range(l.index(mini),len(l)):
    if l[i]>maxi:
        maxi=l[i]
print(maxi-mini)
"""

import sys
n = int(input())
#l = [int(input().rstrip()) for _ in range(n)]
mini = int(input())
t=int(input())
maxi=t-mini
if t<mini:
    mini=t
for i in range(n-2):
    n=int(input())
    if n-mini>maxi:
        maxi=n-mini
    if n<mini:
        mini=n
print(maxi)        


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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int x; read(x);
	write(360 / __gcd(x, 360));
}


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

using namespace std;

long long int N,num[200010],ans;

int cmp(long long int a,long long int b)
{
	return a<b;
}

int main()
{
	scanf("%lld",&N);
	for(int i=1;i<=N;i++)
		scanf("%lld",&num[i]);
	sort(num+1,num+1+N,cmp);
	for(int i=2;i<=N;i++)
	{
		if(num[i]==num[i-1])
		{
			ans=1;
			break;
		}
	}
	if(ans==1)
	    printf("NO\n");
	else
	    printf("YES\n");
	return 0;
} 

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 16
char a[MAXN+5];
int main()
{
	scanf("%s",a);
	int len=strlen(a);
	int ans=(len-1)*9;
	int sum=0;
	for(int i=0;i<len;i++)
	{
		if(a[i]!='0')
			ans=max(ans,sum+a[i]-'1'+(len-i-1)*9);
		sum+=a[i]-'0';
	}
	ans=max(ans,sum);
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e9;

ll N,ans=0;
ll S[101];

int main(){
    cin >> N;
    priority_queue<ll, vector<ll>, greater<ll> > pq;
    ll sum=0;
    for(int i=0;i<N;i++){
        cin >> S[i];
        sum += S[i];
        pq.push(S[i]);
    }

    while(!(pq.empty())){
        if(sum%10 == 0){
            ll tmp = sum - pq.top();
            if(tmp%10){
                sum = tmp;
                break;
            }
            pq.pop();
        }else break;
    }
    ans = sum;
    if(ans % 10 == 0)ans=0;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    float a, b, c, max_, square=1;
    cin >> a >> b >> c;
    max_ = max({a, b, c});
    if(a!=max_) square*=a;
    if(b!=max_) square*=b;
    if(c!=max_) square*=c;
    out(square/2);
}

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

enum {
  MAXN = 200000 + 5
};

int n;
char out[MAXN];
int ans[MAXN];

void may(int u, int v) {
  int i;
  ans[0] = u, ans[1] = v;
  for (i=1; i<n-1; ++i)
    ans[i+1] = (out[i] == 'x') ^ ans[i] ^ ans[i-1];
  if (ans[0]   == ((out[n-1] == 'x') ^ (ans[n-1]) ^ (ans[n-2])) &&
      ans[n-1] == ((out[0]   == 'x') ^ (ans[0])   ^ (ans[1]))) {
    for (i=0; i<n; ++i)
      putchar(ans[i]? 'W' : 'S');
    puts("");
    exit(0);
  }
}

void exec() {
  scanf("%d%s", &n, out);
  may(0, 1), may(1, 0), may(0, 0), may(1, 1);
  puts("-1");
}

int main() {
  if (fopen("D.in", "r") != NULL) {
    freopen("D.in", "r", stdin);
    freopen("D.out", "w", stdout);
  }
  exec();
  return 0;
}


Measured memory_bytes: 768
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <assert.h>
#include <math.h>
#include <memory.h>
#include <stdio.h>

#include <algorithm>
#include <complex>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define left asdgashgrketwjklrej
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-12
#define M_PI 3.141592653589793
#define bsize 1024

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 200031;

int n;
string st[N];
int cnt[100][100];

long long eval_it(string st){
	int f=-1;
	for (int i=0;i<st.size();i++){
		if (st[i]=='.')
			f=i;
	}
	if (f==-1)
		st+=".",
		f=st.size()-1;
	while (st.size()<=f+9)
		st+='0';
	//cout<<st<<endl;
	long long res=0;
	for (int i=0;i<st.size();i++){
		if (st[i]=='.')
			continue;
		res=res*10+st[i]-48;
	}
	return res;
}

long long pw2[1000],pw5[1000];
long long ans;

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

  pw2[0]=1;
  pw5[0]=1;
  for (int i=1;i<20;i++){
	  pw2[i]=pw2[i-1]*2;
	  pw5[i]=pw5[i-1]*5;
  }

  cin>>n;
  for (int i=1;i<=n;i++){
	  cin>>st[i];
  }

  for (int i=n;i>=1;--i){
	 long long P=eval_it(st[i]);
	 long long have_a=0;
	 long long have_b=0;
	 long long PP=P;
	 while (PP%2==0)
		 have_a++,PP/=2;
	 while (PP%5==0){
		 have_b++;
		 PP/=5;
	 }
//	 cout<<P<<" "<<have_a<<" "<<have_b<<endl;

	 if (have_a>=18)
		 have_a=18;
	 if (have_b>=18)
		 have_b=18;

	 ans+=cnt[18-have_a][18-have_b];

	 //cout<<ans<<endl;

	 for (int a=0;a<=18;a++){
		 for (int b=0;b<=18;b++){
			 if (P%(pw2[a]*pw5[b])==0)
				 cnt[a][b]++;
		 }
	 }
  }

  cout<<ans<<endl;

  cin.get(); cin.get();
  return 0;
}


Measured memory_bytes: 9924
import java.io.IOException;
import java.util.*;

/**
 */
class Main {
	final static int N = 10;

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			int d = in.nextInt();
			solve(d);
		}
	}

	public static void solve(int d) {
		int res = d;
		List<Integer> ansArr = new ArrayList<>();
		for(int i=9;i>=0;i--) {
			int target = (int)Math.pow(2, i);
			if(res - target >= 0) {
				res -= target;
				ansArr.add(target);
			}
		}
		Collections.sort(ansArr);
		for(int i=0;i<ansArr.size();i++) {
			System.out.print(String.format("%d%s", ansArr.get(i), ((i == ansArr.size() - 1) ? "" : " ")));
		}
		System.out.println("");
	}
}

Measured memory_bytes: 26452
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int a, b;
  cin >> a >> b;
  int maxv = 0;
  maxv = max(maxv, a+a-1);
  maxv = max(maxv, a+b);
  maxv = max(maxv, b+b-1);
  cout << maxv << endl;
  
  return 0;
}


Measured memory_bytes: 256
n, k= map(int, input().split())
d=[]
sunukes=[]
for i in range(k):
    d.append(input())
    sunukes = set(sunukes) | set(list(map(int, input().split())))

allsunuke = [i for i in range(1,(n+1))]

ans = set(allsunuke)- set(sunukes)

print(len(ans))

Measured memory_bytes: 9200
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int k,n,h[100005];
int main()
{
	scanf("%d%d",&n,&k);for(int i=1;i<=n;++i) scanf("%d",&h[i]);
	sort(h+1,h+1+n);int ans=0x7fffffff;
	for(int i=k,j=1;i<=n;++i,++j) ans=min(ans,h[i]-h[j]);printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
int main()
{
    string s;cin >> s;
    if (s[0]==s[1] && s[2]==s[3])
    {
        if(s[0]!=s[2])
            Yes(true);
        else 
            Yes(false);
    }
    else if (s[0]==s[2] && s[1]==s[3])
    {
        if(s[0]!=s[1]) 
            Yes(true);
        else 
            Yes(false);
    }
    else if (s[0]==s[3] && s[2]==s[1])
    {
        if(s[0]!=s[2])
            Yes(true);
        else 
            Yes(false);
    }
    else
    {
        Yes(false);
    }
}

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

int main()
{
	int m, f, r;
	
	while (1) {
		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) {
		    cout << 'A' << endl;
		} else if (m + f >= 65 && m + f < 80) {
		    cout << 'B' << endl;
		} else if (m + f >= 50 && m + f < 65) {
		    cout << 'C' << endl;
		} else if (m + f >= 30 && m + f < 50) {
		    if (r >= 50)
		        cout << 'C' << endl;
		    else
		        cout << 'D' << endl;
		} else {
			cout << 'F' << endl;
		}
	}
}



Measured memory_bytes: 3092
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)


int main(){
    int N,A,B,in=0,out=0;
    cin>>N>>A>>B;
    string s;
    cin>>s;
    for(int i=0;i<(int)s.size();i++){
        if(s[i]=='a'){
            if(in+out<A+B){
                cout<<"Yes"<<endl;
                in++;
            }else cout<<"No"<<endl;
        }else if(s[i]=='b'){
            if(in+out<A+B && out<B){
                cout<<"Yes"<<endl;
                out++;
            }else cout<<"No"<<endl;
        }else cout<<"No"<<endl;
    }
}



Measured memory_bytes: 896
#include<stdio.h>
int main(void)
{
	float re,le;		/*右目,左目*/
	int ra,la,rb,lb,rc,lc,rd,ld;
	int i;
	
	ra=0; la=0; rb=0; lb=0; rc=0; lc=0; rd=0; ld=0;
	i=0;
	
	while(scanf("%f %f",&re,&le) != EOF) {
		
		if(1.1 <= re) {
			ra++;
		}
		else if(0.6 <= re) {
			rb++;
		}
		else if(0.2 <= re) {
			rc++;
		}
		else {
			rd++;
		}
		
		if(1.1 <= le) {
			la++;
		}
		else if(0.6 <= le) {
			lb++;
		}
		else if(0.2 <= le) {
			lc++;
		}
		else {
			ld++;
		}
	}
	
	printf("%d %d\n",ra,la);
	printf("%d %d\n",rb,lb);
	printf("%d %d\n",rc,lc);
	printf("%d %d\n",rd,ld);
	
	return 0;
}

Measured memory_bytes: 620
#include<stdio.h>

int main()
{
  int N,A[100];
  int i,j,minj,cnt=0;
  int a;//交換する際に使う

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

  for(i=0;i<N-1;i++){
    minj = i;
    for(j=i;j<N;j++){
      if(A[j] < A[minj]){ //比較
	minj = j;
      }
    }
    if(i!=minj){//iとminjが一致したら含めない。
      a =  A[i];
      A[i] = A[minj];
      A[minj] = a;
      cnt++;
    }    
  }
  
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);

  return 0;
}



Measured memory_bytes: 2084
H, W = map(int, input().split())
As = [list(map(int, input().split())) for _ in range(H)]

before_A = None
history = []
for h, row in enumerate(As):
    it = enumerate(row)
    if h % 2 == 0:
        it = reversed(list(it))
    for w, A in it:
        if A % 2 == 0:
            if before_A is not None:
                path.append((h, w))

        else:
            if before_A is None:
                before_A = (h, w)
                path = [(h, w)]
            else:
                path.append((h, w))
                history.append(path[:])
                before_A = None

ans = []
for path in history:
    for i in range(len(path) - 1):
        ans.append( (path[i], path[i+1]) )

print(len(ans))
for (a, b), (c, d) in ans:
    print(a+1, b+1, c+1, d+1, sep = ' ')



    

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

using namespace std;

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

    const int len = S.length();
    vector<char> buf;
    int cnt = 0;
    for (int i=0; i<len; i++) {
        char cur = S[i];
        if (buf.empty()) {
            buf.push_back(cur);
        } else {
            if (buf.back() != cur) {
                buf.pop_back();
                cnt += 2;
            } else {
                buf.push_back(cur);
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
// ConsoleApplication72.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

// ConsoleApplication71.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include<algorithm>
#include<iomanip>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
using namespace std;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	set<char> aa;
	char a[4];
	cin >> a;
	for (int i = 0; i < 4; i++)
	{
		aa.insert(a[i]);
	}
	if (aa.size() == 2)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}
	return 0;
}


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

int main() {
  string s; cin >> s;
  if(s[s.size()-1] != 's') s += 's';
  else s += "es";
  
  cout << s << endl;
}

Measured memory_bytes: 3628
#!/usr/bin/env python3
import collections as cl
import sys

import math


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """

    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * \
                modinv[self.mod % i] % self.mod
        return modinv


MOD = 10 ** 9 + 7


def main():
    N = II()
    if N < 3:
        print(0)
        return
    max_divide = math.floor(N/3)

    comb = Combination(N)
    ans = 0
    for i in range(1, max_divide+1):
        k = N - 3 * i
        tmp = comb(k + i - 1, i - 1)
        ans += tmp
        ans %= MOD
    print(ans)


main()


Measured memory_bytes: 68164
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>


using namespace std;

typedef long long LL;



int main()
{
   int a,b;
   while (cin >>a>>b)
   {
       int ll1 =a+b;
       int ll2 =a-b;
       int ll3 =a*b;
       int ans =max(ll1,ll2);
       ans =max(ll3,ans);
       cout<<ans<<endl;
   } 




#ifdef VSCode
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<pair<int,int> > e;
	for(int i = 0; i < n; i++){
		int x, v; cin >> x >> v;
		e.push_back({v, x});
	}
	sort(e.begin(), e.end());
	vector<int> pos;
	for(auto u : e) pos.push_back(u.second);
	vector<pair<int, int> > t(n);
	vector<pair<int, int> > mp;
	for(int i = 0; i < n; i++){
		int p = lower_bound(mp.begin(), mp.end(), make_pair(pos[i], 0)) - mp.begin();
		if(p == mp.size()){
			t[i].first = i;
			mp.push_back(make_pair(pos[i], i));
		} else {
			t[i].first = mp[p].second;
		}
	}
	mp.clear();
	for(int i = n - 1; i >= 0; i--){
		int p = lower_bound(mp.begin(), mp.end(), make_pair(-pos[i], 0)) - mp.begin();
		if(p == mp.size()){
			t[i].second = i;
			mp.push_back(make_pair(-pos[i], i));
		} else {
			t[i].second = mp[p].second;
		}
	}
	sort(t.begin(), t.end());
	const int mod = 1'000'000'007;
	auto add = [&](int a, int b){
		a += b;
		if(a >= mod) a -= mod;
		return a;
	};
	vector<int> f(n + 2, 0), nf(n + 2, 0);
	f[n] = nf[n] = 1;
	for(int i = n - 1, j = n - 1; i >= 0; i--){
		nf[i] = nf[i + 1];
		while(j >= 0 && t[j].first > i) j--;
		while(j >= 0 && t[j].first == i){
			int r = t[j].second;
			nf[i] = add(add(nf[i], nf[i]), mod - nf[r+2]);
			j--;
		}
	}
	cout << add(nf[0], mod - nf[1]) << endl;
	return 0;
}



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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 100005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long 

#define mod  1000000007



int main()
{
	FAST;
	
	ll n, m;
	cin >> n >> m;
	
	ll ans = 2020;
	if(m - n >= 2019 ){
		cout << 0; return 0;
	}
	for(ll i = n; i <= m; i ++){
		for(ll j = i + 1; j <= m; j ++){
			if((i * j) % 2019 < ans) 
				ans = i*j  % 2019;
			
		}
		
	}
	cout << ans;
	return 0;
	
}

Measured memory_bytes: 3636