akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
#include<cstdlib>
using namespace std;

bool isso(long long int a) {
	if (a == 1||a==0)return false;
	for (long long int i = 2; i*i <= a; ++i) {
		if ((a%i)) {
		}
		else {
			return false;
		}
	}
	return true;
}

struct edge {
	int from;
	int to;
	long double time;
};
struct aa {
	int now;
	long double time;
	bitset<8>tickets;
};

class Compare {
public:
	//keiroが昇順に並ぶ
	bool operator()(const aa&l, const aa&r) {
		return l.time> r.time;
	}
};

int main() {
	while (1) {

		long double memo[32][1 << 8];
		for (int i = 0; i < 32; ++i) {
			for (int j = 0; j < 256; ++j) {
				memo[i][j] = 1e20;
			}
		}
		int n, m, p, a, d; cin >> n >> m >> p >> a >> d;
		if (!n)break;
		a--; d--;
		vector<int>horses;
		for (int i = 0; i < n; ++i) {
			int t; cin >> t;
			horses.push_back(t);
		}
		vector<vector<edge>>edges(m);
		for (int i = 0; i < p; ++i) {
			int x, y; long double z; cin >> x >> y >> z;
			x--; y--;
			edges[x].push_back(edge{ x, y, z });
			edges[y].push_back(edge{ y, x, z });
		}

		priority_queue<aa, vector<aa>, Compare>que;
		for (int i = 0; i < (1 << n); ++i) {

			memo[a][i] = 0;
		}
		que.push(aa{ a, 0, bitset<8>(0) });
		while (!que.empty()) {
			aa atop(que.top());
			if (atop.now == d)break;
			que.pop();
			for (int i = 0; i < edges[atop.now].size(); ++i) {
				long double basetime = edges[atop.now][i].time;
				int to = edges[atop.now][i].to;
				for (int j = 0; j < 1 << n; ++j) {
					int usehorsesum = 0;
					bitset<8>used = atop.tickets;
					bool ok = true;
					for (int k = 0; k < n; ++k) {
						if (j&(1 << k)) {
							if (!atop.tickets[k]) {
								if (usehorsesum) {
									ok = false;
									break;
								}
								usehorsesum += horses[k];
								used[k] = true;
							}
						}
					}
					if (!ok)continue;
					if (usehorsesum) {
						long double realtime = basetime / usehorsesum;
						if (memo[to][used.to_ulong()]>atop.time + realtime) {
							que.push(aa{ to, atop.time + realtime, used });
							memo[to][used.to_ulong()] = atop.time + realtime;
						}
					}
					else {
						continue;
					}
				}

			}
		}
		long double ans = 1e20;
		for (int i = 0; i < (1 << n); ++i) {
			ans = min(ans, memo[d][i]);
		}
		if (ans > 1e19) {
			cout << "Impossible" << endl;
		}
		else {
			cout <<setprecision(11)<< ans << endl;
		}
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> mod(2019);
    mod.at(0)=1;
    int before=0, temp=0, dig=1;
    for(int i = 0; i < n; i++){
        temp = 0;
        temp = (int) (unsigned char) (s.at(n-i-1) - '0');

        if(i!=0)dig = dig*10%2019;
        temp *= dig;
        temp += before;
        temp %= 2019;
        mod.at(temp)++;
        before = temp; 
    }
    int result = 0;
    rep(i,2019){
        result += (mod.at(i)*(mod.at(i)-1))/2;
    }
    cout << result << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<long long>;

struct UnionFind{
    vll par;
    vll rank;
    //* member functions
    UnionFind(ll n){
        par = vll(n);
        rank = vll(n, 0);
        for(ll i=0; i< n; i++) 
            par[i] = i;
    }

    int find(ll x){
        if(par[x] == x) return x;
        else{
            return par[x] = find(par[x]);
        }
    }

    void unite(ll x, ll y){
        x = find(x); y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y; //* new root is y
        }
        else {
            par[y] = x; //* new root is x
            if(rank[x] == rank[y]) rank[x] ++;
        }
    }

    bool same(ll x, ll y){
        return find(x) == find(y);
    }
};
void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    ll cnt = 0;
    for(ll i=0; i< M; i++){
        UnionFind uf(N);
        for(ll j = 0; j< M; j++){
            if (j == i) continue;
            uf.unite(a[j]-1, b[j]-1);
        }
        ll cnt_inner = 0;
        for(ll k = 0; k < N; k++){
            if(uf.par[k] == k) cnt_inner++;
        }
        if(cnt_inner > 1) cnt ++;
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<assert.h>
#define ll long long
using namespace std;
int main(void){
    //freopen("test.txt", "r", stdin);
    ll N;
    scanf("%lld", &N);
    ll i;
    ll a[N], b[N];
    for(i=0;i<N;i++){
        scanf("%lld %lld", &a[i], &b[i]);
    }
    ll res=0;
    for(i=N-1;i>=0;i--){
        if((a[i]+res)%b[i]!=0){
            res+=b[i]-((a[i]+res)%b[i]);
        }
    }
    printf("%lld\n", res);
    return 0;
}


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

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

  int ans=0;
  int idx=1;
  bool one=false;
  for(int i=0; i<n; i++){
    if(a[i]==1) one=true;
    if(a[i]!=idx){
      ans++;
      continue;
    }
    else{
      idx++;
    }
  }

  if((ans==0 && idx!=(n+1)) || one==false) cout<<-1;
  //else(ans!=0 && idx==(n+1))
  else cout << ans;
  return 0;
}


Measured memory_bytes: 1152
use std::io;

fn main() {
  let mut input = String::new();
  io::stdin().read_line(&mut input).ok();
  let mut it = input.split_whitespace().map(|n| n.parse().unwrap());
  let (h, a): (i32, i32) = (it.next().unwrap(), it.next().unwrap());
  println!("{}", (h + a - 1) / a);
}


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

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

	int num = 0;
	auto isAllEven = [&]() {
		for (auto&& elm : list) {
			if (elm % 2) {
				return false;
			}
		}
		return true;
	};
	while (isAllEven()) {
		for (auto&& elm : list) {
			elm /= 2;
		}
		++num;
	}

	cout << num << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n,m;
	cin >> n >> m;
	for(long long i=1,j=m+1;i<j;i++,j--){
		cout << i << " " << j << endl;
	}
	for(long long i=m+2,j=2*m+1;i<j;i++,j--){
		cout << i << " " << j << endl;
	}
} 


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#define ll long long
#define vi vector<int>
#define vs vector<string>
#define fr(i, k, n) for (ll i = k; i < n; i++)
#define rep(i, n) fr(i, 0, n)
#define aintl(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)
#define rdd(a) int a; cin >> a
#define rrd rdd(a); rep(i, a)
//min({a,b,c,d})などの記法
using namespace std;
template <class X> void pr(X x) { cout << x << endl; }
template <class X> void prr(X x) { for (auto it : x) { cout << it<<" ";}cout<<endl; }


int main(int argc, const char * argv[]) {
    
    ll x;
    cin>>x;
    
    ll a=50;
    vector<ll> vv(a);
    rep(i, a) vv[i]=i;
    ll cnt=0;
    rep(i, x){
        ll hoge = (x-i)/a;
        while(hoge!=0 && x-i>=hoge*(a)){
            cnt+=hoge;
            x-=(hoge*a);
        }
        if(x==0){
            cnt--;
            x+=50;
        }
        while(x-i>=a+1){
            cnt++;
            x-=a;
        }
        ll yy=vv[0],indx=0;
        for(int j=0;j<vv.size();j++){
            if(vv[j]<yy){
                indx=j;
                yy=vv[j];
            }
        }
        for(int j=0;j<vv.size();j++){
            if(indx==j) vv[indx]+=a;
            else vv[j]--;
        }
        
    }
    for(int j=0;j<vv.size();j++){
        vv[j]+=cnt;
    }
    pr(a);
    prr(vv);
    
    return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())

if (a - b) % 2 == 0:
    print(abs(a-b)//2)
else:
    if a > b:
        a, b = b, a
    c = a - 1
    d = n - b
    ans = 0
    if c <= d:
        ans += c + 1
        b -= 1
        ans += (b - a) // 2
    else:
        ans += d + 1
        a += 1
        ans += (b - a) // 2
    print(ans)

Measured memory_bytes: 38384
#include <stdio.h>

int main(void)
{
	int h,m,s;
	scanf("%d",&s);
	h=s/3600;
	s=s%3600;
	m=s/60;
	s=s%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 1836
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    rep(i,N) cin >> V[i];
    rep(i,N) cin >> C[i];
    vector<int> G(N);
    rep(i,N) G[i]=V[i]-C[i];
    int sum = 0;
    rep(i,N) if(G[i]>0) sum+=G[i];
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    map<char, ll> mp;
    rep(i, N) mp[S[i]]++;
    ll res = 1;
    for(auto p : mp) {
        res = res * (1 + p.second) % MOD;
    }
    cout << res - 1 << endl;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  rep(i, N) {
    int x;
    cin >> x;
    int a = x * 2;
    int b = (K - x) * 2;
    if ( a < b ) {
      sum += a;
    }
    else {
      sum += b;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
	 static int[][] c;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int H = sc.nextInt();
	        int W = sc.nextInt();
	        
	        c=new int[10][10];
	        for(long i=0;i<10;i++)list.add(new ArrayList<Integer>());	        
	        for(int i=0;i<10;i++) {
	        	for(int j=0;j<10;j++) {
	        			c[i][j]=sc.nextInt();
	        	}
	        }
	        
	        
	        LinkedList<Integer> queue = new LinkedList<Integer>();
        	int[] weight = new int[10];
	        for(int i=0;i<10;i++) {
	        	boolean[] visited=new boolean[10];
	        	queue.add(i);
	        	queue.add(0);
	        	int min=c[i][1];
	        	while(!queue.isEmpty()){
	        		int now = queue.poll();
	        		int w = queue.poll();
	        		visited[now]=true;
	        		for(int j=0;j<10;j++) {
	        			if(now==j)continue;
//	        			if(visited[j])continue;
	        			if(w>min)continue;
	        			if(j==1) {
	        				min=Math.min(min, w+c[now][j]);
	        			} else {
	        				if(w+c[now][j]<min) {
		        				queue.add(j);
		        				queue.add(w+c[now][j]);
	        				}
	        			}
	        		}
	        	}
	        	weight[i]=min;
	        }
	        
	        int ans=0;
	        for(int i=0;i<H;i++) {
	        	for(int j=0;j<W;j++) {
	        		int tmp=sc.nextInt();
	        		if(tmp!=-1) {
	        			ans=ans+weight[tmp];
	        		}
	        	}
	        }
	        
	        
	        
	        System.out.println(ans);
	        
	 }
	 

}

Measured memory_bytes: 47052
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let n = read_as_vec::<usize>()[0];
    let a = read_as_vec::<usize>();
    let mut sum = a.iter().sum::<usize>();
    let mut bits = vec![0;64];

    for &x in &a{
        for i in 0..64{
            if (x & (1 << i)) > 0{
                bits[i] += 1;
            }
        }
    }

    let mut ans = 0;
    //for &x in a.iter().take(n-1){
    for i in 0..n-1{
        let x = a[i];
        //remove current
        for j in 0..64{
            if (x & (1 << j)) > 0{
                bits[j] -= 1;
            }
        }
        //println!("x = {}", x);
        //println!("{:?}", bits);
        for j in 0..64{
            if (x & (1 << j)) > 0{
                ans += ((1 << j)%1_000_000_007) * (n - i - 1- bits[j]);
            }else{
                ans +=  ((1 << j)%1_000_000_007) * bits[j];
            }

            ans %= 1_000_000_007
        }
        //println!("ans = {}", ans);

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


Measured memory_bytes: 14456
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
	int a,b;
    cin>>a>>b;
    if((a+b)%2==0) OUT((a+b)/2);
    else OUT("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  set<string>s;
  cin>>n;
  for(int i=0;i<n;i++){
    string in;
    cin>>in;
    s.insert(in);
  }
  cout<<s.size()<<"\n";
  return 0;
}


Measured memory_bytes: 19116
#python3
def main():
    s = input()
    addfront = ''
    addback = ''
    q = int(input())
    direction = 0
    for i in range(q):
        t = input()
        if t[0] == '1':
            direction += 1
            continue
        if t[0] == '2':
            if direction % 2 == 0:
                if t[2] == '1':
                    addfront = t[4] + addfront 
                if t[2] == '2':
                    addback = addback + t[4]
            else:
                if t[2] == '1':
                    addback = addback + t[4]
                if t[2] == '2':
                    addfront = t[4] + addfront
    ans = addfront + s + addback
    if direction%2 == 0:
        print(ans)
    else:
        ans = ''.join(reversed(ans))
        print(ans)
main()


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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
//#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	ios::sync_with_stdio(false);
	char c;
	cin >> c;
	cout << static_cast<char>(c + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
#define endl '\n'

int32_t main()
{
    IOS;
    char c;
    cin>>c;
    if(c>='A'&&c<='Z')
        cout<<"A";
    else
        cout<<"a";
}


Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] A = new int[n];
		long sum = 0;
		
		for(int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		
		Arrays.sort(A);
		
		System.out.println(A[0] + " " + A[n - 1] + " " + sum);
		
		sc.close();
	}

}



Measured memory_bytes: 41780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________
int main()
{
       int a,b,m;
       cin>>a>>b>>m;
       int aa[a];
       int bb[b];
       arrin(aa,a);
       arrin(bb,b);
       int mini = mod;
       int minn;
       fri(i,0,a){mini = min(mini,aa[i]);}
       minn = mini;
       mini = mod;
       fri(i,0,b){mini = min(mini,bb[i]);}
       minn += mini;
       fri(i,0,m){
              int a1,b1,c1;
              cin>>a1>>b1>>c1;
              --a1;--b1;
              minn = min(minn,(aa[a1]+bb[b1]-c1));
       }
       cout<<max(minn,0)<<endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main () {
    char a, b;
    
    scanf("%c %c", &a, &b);
    //printf("%c ", a);
    if (a == 'H') {
        printf("%c", b);
    }
    else {
        if (b == 'H') {
            printf("D");
        }
        else {
            printf("H");
        }
    }

}






Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var W = input[1];

        var total = 0;
        for(var i =0; i < 2; i++)
        {
            var ans = 0;
            if (N >= W)
            {
                ans = N;
                N--;
            } else
            {
                ans = W;
                W--;
            }
            total += ans;
        }

        Console.WriteLine(total);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include<bitset>
#include<iostream>
using namespace std;
#include<math.h>
#include<map>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long
#define ld double
#include<stdio.h>
#define f first
#define s second
#include<stack>
#include<queue>
#define its set<int>::iterator
#define itmp map<int,int>::iterator
#include<stack>
#define lp for(int i=0;i<n;i++)
#define dlp for(int i=0;i<n;i++) for(int j=0;j<n;j++)
#define mod 1000000009
//#define N 101
//#include <boost/functional/hash.hpp>
//bitset<1000> b;
//b.set();   all bit have 1
//seive of Erat
//totient theorm for co-prime
/*ll int N=1000;
	int p[1001]={0};
	p[2]=1;
		vector<int>v;
        for(ll int i=3;i<=N;i+=2)
        p[i]=1;
        v.push_back(2);
        for(ll int i=3;i<=N;i+=2)
        {
            if(p[i])
            {
			v.push_back(i);
                for(ll int j=i*i;j<=N;j+=2*i)
                p[j]=0;
            }
        }  */
/*
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} */
/*
stringstream ss;  
ss<<c;  
string s1;
ss>>s1;
*/
/*
int power(int x, unsigned int y) 
{ 
    int temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
}*/
int main()
{
	ios_base::sync_with_stdio(false); 
    	cin.tie(NULL); 
	 
      	ll int t=1;
	//cin>>t;
	while(t--)
	{
        int x;
        cin>>x;
        if(x==0)
        cout<<1<<endl;
        else if(x==1)
        cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll dp[100010][2];
vector<int> v(0);
int main(){
    string s; cin >> s;
    memset(dp,0,sizeof(dp));
    for (int i = 0; i < s.size(); i++){
        v.push_back(s[i]-'0');
    }
    dp[0][0] = 1;
    for (int i = 0; i < v.size(); i++){
        for (int j = 0; j < 2; j++){
            if (v[i] == 0) {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            } else {
                dp[i+1][1] += dp[i][j];
                dp[i+1][1] %= MOD;
            }

            if (v[i] == 1) {
                dp[i+1][j] += 2*dp[i][j];
                dp[i+1][j] %= MOD;
            } else if (j == 1){
                dp[i+1][j] += 2*dp[i][j];
                dp[i+1][j] %= MOD;
            }
        }
    }
    ll ans = 0; 
    ans += dp[v.size()][0] + dp[v.size()][1];
    cout << (ans%MOD) << endl;
}

Measured memory_bytes: 2556
#include<stdio.h>
int main(void){
  char S[10],T[10],U[10];
  unsigned int A,B;
  scanf("%s %s",S,T);
  scanf("%d %d",&A,&B);
  scanf("%s",U);
  if(S[0]==U[0])A--;
  else B--;
  printf("%d %d",A,B);
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  bool A = true;
  for(int i = 0;i < 26;i++) {
    int count = 0;
    for(int j = 0;j < S.size();j++) {
      if(S.at(j) == 'a' + i) {
        count++;
      }
    }
    if(count % 2 == 1) {
      A = false;
    }
  }
  if(A == true) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    typedef pair<int,int> P;
    int H,W;
    cin>>H>>W;
    vector<string> S(H);
    int h,w;
    REP(i,H){
        cin>>S[i];
        REP(j,W) if(S[i][j]=='.'){
            h=i;w=j;
        }
    }
    int ans=0;
    int dx[4]={-1,1,0,0},dy[4]={0,0,1,-1};
    vector<vector<bool>> used(H,vector<bool>(W,false));
    REP(hoge,5){
        vector<vector<int>> d(H,vector<int> (W,-1));
        queue<P> que;
        que.push(P(h,w));
        d[h][w]=0;
        used[h][w]=true;
        while(!que.empty()){
            P p=que.front();que.pop();
            int x=p.first,y=p.second;
            REP(j,4){
                int nx=x+dx[j],ny=y+dy[j];
                if(0<=nx&&nx<H&&0<=ny&&ny<W&&S[nx][ny]=='.'&&d[nx][ny]==-1){
                    que.push(P(nx,ny)); d[nx][ny]=d[x][y]+1;
                    ans=max(ans,d[nx][ny]);
                    if(!used[nx][ny]){
                        h=nx;w=ny;
                    }
                }
            }
            
        }
    }
    std::cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout<<'\n'
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    ll ans[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        ans[a[i]]=i+1;
    }
    for(int i=1;i<=n;i++)
    cout<<ans[i]<<" ";
}

Measured memory_bytes: 2432
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
CB = [list(map(int, reversed(input().split()))) for _ in range(M)]

A.sort()
CB.sort()

ans = 0
for _ in range(N):
    a = A[-1] if A else -INF
    c, b = CB[-1] if CB else (-INF, -INF)
    if a > c:
        ans += a
        A.pop()
    else:
        ans += c
        CB[-1][1] -= 1
        if CB[-1][1] <= 0:
            CB.pop()
print(ans)


Measured memory_bytes: 78912
import sys

MOD = 10 ** 9 + 7

def make_table(size=2*10**6+2, p=MOD):
    fac = [None] * (size + 1)
    fac[0] = 1
    for i in range(size):
        fac[i+1] = fac[i] * (i + 1) % p
    ifac = [None] * (size + 1)
    ifac[size] = pow(fac[size], p-2, p)
    for i in range(size, 0, -1):
        ifac[i-1] = ifac[i] * i % p
    return fac, ifac

fac, ifac = make_table()

def comb(n, r, mod=MOD):
    if r > n or r < 0:
        return 0
    return fac[n] * ifac[r] % mod * ifac[n-r] % mod

def g(y, x):
    return comb(y+x+2, y+1) - 1

r1, c1, r2, c2 = map(int, sys.stdin.readline().split())

def main():
    ans = (g(r2, c2) - (g(r1-1, c2) + g(r2, c1-1) - g(r1-1, c1-1))) % MOD
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 161396
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define type 26

int max(int D, int s[][type+1]);
int score_calc(int D, int s[][type+1], int schedul[], int c[type+1], int last[type+1]);
void swap(int D, int s[][type+1], int schedul[], int c[type+1], int last[type+1], int *ini);

int main(void)
{
    int i, j;
    int D, c[type+1], last[type+1];
    int ini;
    clock_t start, stop;
    // 計測開始
    start = clock();
    // 入力
    scanf("%d",&D);
    int s[D+1][type+1], schedul[D+1];
    for(i=1; i<type+1; i++){
        scanf("%d", &c[i]);
    }
    for(i=1; i<D+1; i++){
        for(j=1; j<type+1; j++){
            scanf("%d", &s[i][j]);
        }
    }
    // 初期
    for(i=1; i<D+1; i++){
        schedul[i] = max(i, s);
    }
    for(i=1; i<type+1; i++){
        last[i] = 0;
    }
    ini = score_calc(D, s, schedul, c, last);
    stop = clock();
    // 改善
    srand((unsigned int)time(NULL));
    while((double)(stop - start) / CLOCKS_PER_SEC < 1.990000){
        swap(D, s, schedul, c, last, &ini);
        stop = clock();
    }
    //出力
    for(i=1; i<D+1; i++){
        printf("%d\n",schedul[i]);
    }
    
    return 0;
}

int max(int D, int s[][type+1]) // D日目の満足度が一番高いタイプを返す
{
    int i;
    int max_score = 0, max_type;
    
    for(i=1; i<type+1 ;i++){
        if(s[D][i] > max_score){
            max_score = s[D][i];
            max_type = i;
        }
    }
    return max_type;
}

int score_calc(int D, int s[][type+1], int schedul[], int c[type+1], int last[type+1])
{
    int i,j;
    int score = 0;
    
    for(i=1; i<D+1; i++){
        score += s[i][schedul[i]];
        last[schedul[i]] = i;
        for(j=1; j<type+1; j++){
            score -= c[j] * (i-last[j]);
        }
    }
    
    return score;
}

void swap(int D, int s[][type+1], int schedul[], int c[type+1], int last[type+1], int *ini)
{
    int i;
    int a, b, tmp, imp = 0;
    
    a = rand()%D+1;
    b = rand()%D+1;
    tmp = schedul[a];
    schedul[a] = schedul[b];
    schedul[b] = tmp;
    
    for(i=1; i<type+1; i++){
        last[i] = 0;
    }
    imp = score_calc(D, s, schedul, c, last);
    
    if(imp > *ini){
        *ini = imp;
        
    }else{
        schedul[b] = schedul[a];
        schedul[a] = tmp;
    }
}


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

int main(){
  string S;
  int r = 0;
  cin >> S;
  
    if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R' ){
      r=3;
    }else if((S[0] == 'R' && S[1] == 'R') ||(S[1] == 'R' && S[2] == 'R')){
      r=2;
    }else if(S[0] == 'R' || S[1] == 'R' || S[2] == 'R'){
      r=1;
    }
  cout << r << endl;
      
  return 0;
}

Measured memory_bytes: 3564
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

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

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn is_palindrome(cs: &[char]) -> bool {
    let n = cs.len();
    for i in 0..n/2 {
        if cs[i] != cs[n-1-i] {
            return false;
        }
    }
    true
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S: Vec<char> = sc.chars();
    let N = S.len();
    if is_palindrome(&S) && is_palindrome(&S[0..(N-1)/2]) && is_palindrome(&S[(N+3)/2-1..]) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <cstring>

#define nl '\n'

using namespace std;

int n, m;

int main(){

    cin >> n >> m;
    
    if(n == m) {
        cout << "Yes";
        return 0;
    }

    cout << "No";



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

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

int main(void)
{

    int64_t X, K, D;
    cin >> X >> K >> D;

    X = abs(X);

    if(abs(X) < D){
        if( K % 2 ==0 ){
            cout << X << endl;
        }else{
            cout << min(abs(X+D), abs(X-D)) << endl;
        }
    }else{
        int64_t N;
        N = floor(abs(X)/D);
        if(N > K){
            cout << min(abs(X - K * D), abs(X + K * D)) << endl;
            exit(0);
        }

        if(X < 0){
            if( abs(X + N * D) > abs(X + (N+1)*D)){
                K = K - N - 1;

                if( K % 2 == 0){
                    cout << abs(X + (N+1)*D) << endl;
                }else{
                    cout << abs(X + N*D) << endl;
                }
            }else{
                K = K - N;
                if( K % 2 == 0){
                    cout << abs(X +N*D) << endl;
                }else{
                    cout << abs(X + (N+1)*D) << endl;
                }
            }
        }else{
            if( abs(X - N * D) > abs(X - (N+1)*D)){
                K = K - N -1;
                if( K % 2 == 0){
                    cout << abs(X - (N+1)*D) << endl;
                }else{
                    cout << abs(X - N*D) << endl;
                }
            }else{
                K = K - N ;
                if( K % 2 == 0){
                    cout << abs(X - N*D) << endl;
                }else{
                    cout << abs(X - (N+1)*D) << endl;
                }
            }
        }
    }
}

Measured memory_bytes: 3632
h, w = map(int, input().split())
l = [input() for i in range(h)]
idh=[]
idw=[]

for i in range(w):
    fl = True
    for j in range(h):
        if l[j][i]=='#':
            fl=False
    if fl:
        idw.append(i)
for i in range(h):
    if l[i].count('#')==0:
        idh.append(i)
for i in range(h):
    if i in idh:
        continue
    for j in range(w):
        if j in idw:
            continue
        print(l[i][j], end='')
    print('')

Measured memory_bytes: 4468
import java.util.Scanner;
import java.math.BigDecimal;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double pi = 3.141592653589;
        double r = sc.nextDouble();
        String str = BigDecimal.valueOf(r*r*pi).toPlainString();
        System.out.println(str+" "+r*2*pi);
    }
}


Measured memory_bytes: 28268
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

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

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

class Point{
public:
	long long x;
	long long y;
	long long dis;
	Point(long long _x,long long _y,long long _dis){
		x=_x;
		y=_y;
		dis=_dis;
	}
};

typedef long long ll;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	ll sun=0;
	ll m=0;
	vector<ll>a(s.length()+1,0);
	for(int i=0;i<s.length();i++){
		if(s[i]=='<')a[i+1]=a[i]+1;
	}
	vector<ll>aa(s.length()+1,0);
	for(int i=(int)s.length()-1;i>=0;i--){
		if(s[i]=='>'){
			if(a[i]>a[i+1])continue;
			a[i]=a[i+1]+1;
		}
	}
	ll sum=0;
	//cout<<endl;
	for(int i=0;i<s.length()+1;i++){
		//cout<<a[i]<<endl;
		sum+=a[i];
	}
	//cout<<sum-m*((int)s.length()+1)<<endl;
	cout<<sum<<endl;
}


Measured memory_bytes: 8732
import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc =new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();

        int AB = A * B;
        int R = (A + B - 1);

            System.out.println(AB - R);

    }
}


Measured memory_bytes: 23892
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


l = []
n, k = LI()
X = []
Y = []
ans = INF
for _ in range(n):
  x, y = LI()
  X += [x]
  Y += [y]
  l.append((x,y))

X.sort()
Y.sort()
for xl,xr in combinations(X, 2):
  for yl,yr in combinations(Y, 2):
    cnt = 0
    for x,y in l:
      if xl<=x<=xr and yl<=y<=yr:
        cnt += 1
      if cnt >= k and ans > (xr - xl) * (yr - yl):
         ans = (xr - xl) * (yr - yl)
print(ans)

Measured memory_bytes: 48092
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct{
  int top;         // スタックポインタ(一番上の位置)
  int S[MAX];
}Stack;


// スタック st の初期化
void initialize(Stack *st)
{
  st->top = 0;
  st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
  return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{  
  return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
  if (isFull(st)) 
    exit(1);

  st->top++;
  st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
  if (isEmpty(st)) 
    exit(1);

  st->top--;
  return st->S[st->top+1];
}


int main(void)
{
  Stack st1;     // '\' の開始位置を格納するスタック
  Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
  Stack st2_a;   // 各水たまりの水量を格納するスタック

  // スタック初期化
  initialize(&st1);
  initialize(&st2_j);
  initialize(&st2_a);

  char c;
  int sum = 0;  // 水たまりの総水量

  // 地形を読み込み，各水たまりの水量を計算
  for (int i = 0; (c = getchar()) != EOF; i++) {
    if (c == '\\') {                                 // '\\' が出た時の処理
      // 位置 i を st1 にプッシュ(write your code)
    	push(i,&st1);
    	
    }else if (!isEmpty(&st1) && c == '/') {          // '/' が出た時の処理
      // 水たまりの総水量 sum を更新(write your code)
    	int j=pop(&st1);
    	sum+=(i-j);
    	
      // st2_j と st2_a を用いて水たまりの水量を更新 
      int a = i - j;   // 更新する水たまりの水量を a に格納していく
      while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
        // 水たまりの水量を求めていく (write your code)
      	pop(&st2_j);
      	a=a+pop(&st2_a);
      }
      // 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)
    	push(j,&st2_j);
    	push(a,&st2_a);
    }
  }

  printf("%d\n", sum);       // 水たまりの総水量を出力
  printf("%d", st2_a.top);   // 水たまりの個数を出力

  // 各水たまりの水量を断面図の左から出力(スタックの底から出力)
  for (int i = 1; i <= st2_a.top; i++) 
    printf(" %d", st2_a.S[i]);  
  printf("\n");

  return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
/*
if(x=='N')
	{m1=d2;m2=d6;m6=d5;m5=d1;
	}
if(x=='S')
	{m1=d5;m5=d6;m6=d2;m2=d1;
	}
if(x=='W')
	{m3=d6;m6=d4;m4=d1;m1=d3;
	}
if(x=='E')
	{m6=d3;m3=d1;m1=d4;m4=d6;
	}
*/
int main(){
//DICE input
int d1,d2,d3,d4,d5,d6;
int x1,x2,x3,x4,x5,x6;
cin>>x1>>x2>>x3>>x4>>x5>>x6;
d1=x1,d2=x2,d3=x3,d4=x4,d5=x5,d6=x6;
int m1,m2,m3,m4,m5,m6;
//END DICE input
int a,x,y;
cin>>a;
for(int i=0;i<a;i++)
{
//DICE replace original
d1=x1;d2=x2;d3=x3;d4=x4;d5=x5;d6=x6;
//END DICE replace
//memory replace
m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
//
cin>>x>>y;

for(int i3=0; i3<6 ; i3++)
	{
	for(int i2=0;i2<4;i2++)
		{
		m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
		m1=d2;m2=d6;m6=d5;m5=d1;
		d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;
		if(d1==x && d2==y) {cout<<d3<<endl; break;}
		}
	if(d1==x && d2==y) break;
	if(i3<3)
	{m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
	m3=d6;m6=d4;m4=d1;m1=d3;
	d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;}
	if(i3==3)
	{m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
	m1=d2;m2=d6;m6=d5;m5=d1;
	d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;
	m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
	m3=d6;m6=d4;m4=d1;m1=d3;
	d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;}
	if(i3==4)
	{m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
	m3=d6;m6=d4;m4=d1;m1=d3;
	d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;
	m1=d1;m2=d2;m3=d3;m4=d4;m5=d5;m6=d6;
	m3=d6;m6=d4;m4=d1;m1=d3;
	d1=m1;d2=m2;d3=m3;d4=m4;d5=m5;d6=m6;}
	}
}

return 0;
}


Measured memory_bytes: 3104
const r = 10^9 + 7

f(n, k) = k * (n - k + 1) + 1

function calc(n, k)
    s = 0
    for i = k:n+1
        s += f(n, i) % r
        s %= r
    end
    s
end

n, k = parse.(Int, split(readline()))
result = calc(n, k)
println(result)


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

using namespace std;

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

  int connect = 0;
  int out = 0;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == 'a' && connect < A + B) {
      cout << "Yes" << endl;
      ++connect;
    } else if(S[i] == 'b') {
      if(connect < A + B && out < B) {
        cout << "Yes" << endl;
        ++connect;
        ++out;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
//最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
bool prime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        return false;
    }
    return true;
}
int main(){
    string s,t;
    int ans=0;
    cin>>s>>t;
    for(int i=0;i<s.length();i++){
        if(s.compare(i,1,t,i,1)!=0)
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=200005;
int n,f1,f2,s[N];ll ans;
struct st{int x,o;}p[N];
inline bool cmp(const st&a,const st&b){return a.x<b.x;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&p[i].x,&p[i+n].x),p[i].o=i,p[i+n].o=-i;
	sort(p+1,p+n+n+1,cmp);
	for(int i=1;i<=n;i++)ans+=p[i].x;
	for(int i=1;i<=n;i++)if(s[abs(p[i].o)]++)f1=1;
	for(int i=1;i<n;i++)if((p[i].o<0&&p[i+1].o>0)||(p[i].o>0&&p[i+1].o<0))f2=1;
	if(f1||!f2)printf("%lld\n",ans);
	else if(p[n].o+p[n+1].o)printf("%lld\n",ans-p[n].x+p[n+1].x);
	else printf("%lld\n",ans+min(p[n+2].x-p[n].x,p[n+1].x-p[n-1].x));
	return 0;
}


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

int main() {
    int a[3];
    string s;
    cin >> a[0] >> a[1] >> a[2];
    
    sort(a, a+3);
    
    cout << a[2]-a[0] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
/*
all white -> no
all black -> 0
black row -> num of non-black cols
find row -> find black there -> color whites in that row
         -> no black there -> take any black and put it there
 */
void opt(in a){
  cout<<a<<endl;
  exit(0);
}
vector<string> bd;
in n;
in nallblcol=0;
VI hasblcol,haswcol;
VI whitesinrow;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n;
  bd.resize(n);
  const in inf=1e9;
  in bst=inf;
  bool hasbl=0;
  forn(i,n){
    cin>>bd[i];
    forn(j,n)
      hasbl|=(bd[i][j]=='#');
  }
  if(!hasbl)
    opt(-1);
  hasblcol=haswcol=whitesinrow=VI(n,0);
  forn(i,n){
    forn(j,n){
      if(bd[i][j]=='#'){
	hasblcol[j]=1;
      }
      else{
	haswcol[j]=1;
	whitesinrow[i]++;
      }
    }
  }
  forn(i,n)
    nallblcol+=(!haswcol[i]);
  forn(rowcand,n){
    in cus=0;
    if(!hasblcol[rowcand])
      ++cus;
    cus+=whitesinrow[rowcand];
    cus+=n-nallblcol;
    bst=min(bst,cus);
  }
  opt(bst);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, m, x;
	cin >> n >> m >> x;
	int cnt = 0;
	for(int i = 0; i < m; ++i){
		int temp;
		cin >> temp;
		if(temp < x)++cnt;
	}
	int ans = min(cnt, m - cnt);
	cout << ans << endl;

}

Measured memory_bytes: 256
n, k = map(int,input().split())
mod = 10**9+7

#nCrをmodで割った余りを求める。Nに最大値を入れて使用。
N = n
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
def cmb(n,r,mod):
    if r<0 or r>n :
        return 0
    r = min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod
for i in range(2,N+1):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1])%mod)

ans = 0
for i in range(min(n-1,k)+1):
    di = cmb(n,i,mod)*cmb(n-1,i,mod)%mod
    ans = (ans+di)%mod

print(ans)


Measured memory_bytes: 27092