akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  sort(all(a));
  sort(all(b));
  
  if(n & 1) {
    cout << b[n/2] - a[n/2] + 1 << newl;
  }
  
  else {
    cout << (b[n/2-1]+b[n/2]) - (a[n/2-1]+a[n/2]) + 1 << newl;
  }
  
  return 0;
}

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

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

  int count = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      if (s - (x + y) >= 0 && s - (x + y) <= k) count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 3612
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

int main() {
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
  else cout << "No";
} 



Measured memory_bytes: 764
#include <vector>
#include <iostream>
#include <iomanip>
#include <map>
#include <string.h>
#include <cstring>
#include <queue>
#include <limits>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cmath>
#include <stdio.h>
#include <set>
#include <cstdio>
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define FOR(i, a) for(int i = 0; i < (a); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int N = 505;
int c[N], s[N], f[N];
vector<int> res;
int n;
int main() {
    while (cin >> n) {
        res.clear();
        for (int i = 0; i < n - 1; i++) {
            cin >> c[i] >> s[i] >> f[i];
        }
        for (int i = 0; i < n - 1; i++) {
            int t = 0;
            for (int j = i; j < n - 1; j++) {
                if (t <= s[j]) t = s[j];
                else {
                    t = (t + f[j] - 1) / f[j] * f[j];
                }
                t += c[j];
            }
            res.push_back(t);
        }
        res.push_back(0);
        for (auto v : res) {
            cout << v << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 256
function main(){
	var n = scan();
	var m = scan();
	
	var e = [];
	var f = [];
	rep(m, function(){
		var s = scan('string');

		var p = s.split(/<=|>=|\*|\+|-/);
		p[0] = +p[0] - 1;
		p[1] = +p[1] - 1;
		p[2] = +p[2];

		var u;
		if(s.indexOf('*') !== -1){
			u = 2;
		}
		else{
			u = +(s.indexOf('<=') === -1);
		}

		var v = +(s.indexOf('+') === -1);

		if(u == 0){
			if(v == 0){
				e[e.length] = [p[1], p[0], -p[2]];
			}
			else{
				e[e.length] = [p[1], p[0], 0];
				e[e.length] = [p[0], p[1], p[2]];
			}
		}
		else if(u == 1){
			if(v == 0){
				e[e.length] = [p[0], p[1], -p[2]];
			}
			else{
				e[e.length] = [p[1], p[0], p[2]];
				e[e.length] = [p[0], p[1], 0];
			}
		}
		else{
			if(v == 0){
				f[f.length] = [[p[0], p[1], -p[2]], [p[1], p[0], -p[2]]];
			}
			else{
				e[e.length] = [p[1], p[0], p[2]];
				e[e.length] = [p[0], p[1], p[2]];
			}
		}
	});
	rep(n, function(i){
		e[e.length] = [i, 0, 0];
	});

	var ans = -Infinity;
	rep(1 << f.length, function(comb){
		var g = [].concat(e);
		rep(f.length, function(i){
			g[g.length] = f[i][(comb >> i) & 1];
		});

		var d = [];
		rep(n, function(i){
			d[i] = Infinity;
		});
		d[0] = 0;

		rep(n, function(){
			rep(g.length, function(j){
				var edge = g[j];
				d[edge[1]] = Math.min(d[edge[0]] + edge[2], d[edge[1]]);
			});
		});

		if(d[0] == 0){
			ans = Math.max(ans, Math.max.apply(null, d));
		}
	});

	if(ans === Infinity){
		print('inf');
	}
	else if(ans === -Infinity){
		print(-1);
	}
	else{
		print(ans);
	}
}
 
function rep(a, b, c){
	if(c == null){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		c(i);
	}
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var input = '';
var input_index = 0;
 
function scan(type){
	if(type === 'string'){
		return input[input_index++];
	}
	else{
		return +input[input_index++];
	}
}
 
function print(val){
	console.log(val);
}
 
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.split(/\s+/);
	main();
});

Measured memory_bytes: 20076
#include <bits/stdc++.h>
#define test(a) cout << " " << (a) << " "
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

const int MAXN = 1e5 + 10;
const int INF = 0x3f3f3f3f;

ll n, k, t;

int main (void) {
    // freopen("input.txt","r",stdin);
    // ios::sync_with_stdio(false);
    // cin.tie(0); cout.tie(0);

	scanf("%lld%lld", &n, &k);
	if (k % 2 == 0) {
		ll t = n / k + (n % k >= k / 2);
		n /= k;
		printf("%lld\n", n * n * n + t * t * t);
	} else {
		n /= k;
		printf("%lld\n", n * n * n);
	}
    return 0;
}


Measured memory_bytes: 256
<?php   
fscanf(STDIN,"%d %d %d %d",$a,$b,$c,$k);
//fscanf(STDIN,"%s",$t);

//$li = explode(" ",trim(fgets(STDIN)));
$sum=0;
if($a<$k){
  $sum+=$a*1;
  $k = $k-$a;//残り枚数
}else{
  $sum+=$k*1;
  echo $sum."\n";
  exit;
}

if($b<$k){
  $sum+=$b*0;
  $k = $k-$b;//残り枚数
}else{
  $sum+=$k*0;
  echo $sum."\n";
  exit;
}

if($c<$k){
  $sum+=$c*-1;
}else{
  $sum+=$k*-1;
  echo $sum."\n";
  exit;
}


        
echo "${sum}\n";



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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;
int x[100];

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n; i++) scanf ("%d", &x[i]);
	int ans = 0;
	for (int i = 0; i < n; ) {
		int j = i;
		while (j < n && x[j] == x[i]) j++;
		ans += (j - i) / 2;
		i = j;
	}
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;

bool isKaibun(string s)
{
  // cout << s << endl;
  string r = s;
  reverse(r.begin(), r.end());
  int len = s.length();
  rep(i, len)
  {
    if (s[i] != r[i])
      return false;
  }
  return true;
}

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  if (isKaibun(s) && isKaibun(s.substr(0, (n - 1) / 2)) && isKaibun(s.substr((n + 3) / 2 - 1, n)))
    cout
        << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x,ll y,ll m) 
{
    ll res = 1; 
    x = x % m;                
    if (x == 0)
        return 0; 
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

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

void solve()
{
    string s;
    cin>>s;
    if(s=="ARC") cout<<"ABC";
    else cout<<"ARC";
    
}

int main()
{
    fastio;
    int t;
    t=1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout<<newl;
    }

    return 0;
}

Measured memory_bytes: 3644
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int R  = sc.nextInt();
    
    if(R < 1200){
      System.out.println("ABC");
    }else if(R >= 1200 && R < 2800){
      System.out.println("ARC");
    }else if(R >= 2800){
      System.out.println("AGC");
    }
  }
}

Measured memory_bytes: 35456
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
    Mbak Seulgi Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod = 1e9+7;
int n;
ll dp[2020];
ll dfs(int pos)
{
    if(pos == n) return 1;
    if(dp[pos] != -1) return dp[pos];
    ll res = 0;
    for(int i=3;i<=n-pos;i++) {
        res += dfs(pos+i);
        res %= mod;
    }
    return dp[pos] = res;
}
int main()
{
    int i,j,k,x,y,ans,curr,temp,m;
    int tc;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    cout << dfs(0) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <stack>
#define ll long long
using namespace std;

int main(){
  int n; cin>>n;
  stack<ll> h;
  ll m,buf; cin>>m;
  
  for(int i=0;i<n;i++){
    cin>>buf; h.push(buf);
  }
  
  m=h.top(); h.pop();
  
  for(int i=1;i<n;i++){
    buf=h.top();
    if(buf-m>1){cout<<"No"; return 0;}
    if(buf<m){m=buf;}
    h.pop();
  }
  
  cout<<"Yes";
  
  return 0;
}

Measured memory_bytes: 1024
main(q,b,c,C,Q,x,y){for(;scanf("%d%d%d%d%d",&q,&b,&c,&C,&Q)>4;printf(x?"%d %d\n":"NA\n",x,y)){for(x=b/c,x=x<Q?x:Q;x;x--)if(x+(y=(b-x*c)/C)>=q)break;}exit(0);}

Measured memory_bytes: 600
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"(n,m),*s,p=[list(map(int,t.split()))for t in open(0)]\n"
"a=0\n"
"for i in range(1<<n):\n"
" c=[0]*m\n"
" for j in range(n*m):c[j%m]^=i>>j//m&(j//m+1in s[j%m][1:])\n"
" a+=c==p\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 8636
#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 <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>

#define nl '\n'

using namespace std;

long long n, a, x;

bool t = true;

int main(){

    cin >> n;

    vector<long long> v;

    for(long long i = 0; i < n; i++){
        cin >> a;
        v.push_back(a);
    }

    while(t){
        for(long long i = 0; i < n; i++){
            if(v[i] %2 != 0){
                t = false;
                break;
            }
            v[i] = v[i]/2;
        }
        x++;
    }

    cout << x-1;




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


//Surely this is going to AC

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

int main(){
   int H,W;
   cin >> H >> W;
   int h,w;
   cin >> h >> w;
   cout << H*W-(h*W+w*H-h*w);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	
	cout << max(a + b, max(a - b, a * b)) << endl;
	
	return 0;
}


Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
#print(sum(A)-min(A))

A.sort(reverse=True)
ans=A[0]

if n>2:
    if n%2==0:
        for i in range(1,n//2):
            ans+=2*A[i]
    else:
        for i in range(1,n//2):
            ans+=2*A[i]
        ans+=A[n//2]

print(ans)


Measured memory_bytes: 31612
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

set<char> alp;
vector<char> v;
bool check(string s, int idx) {
	bool flag = true;
	REP(i, 0, s.size()) {
		if (s[i] != v[idx]) {
			flag = false;
			break;
		}
	}
	return flag;
}

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

	REP(i, 0, s.size()) {
		alp.insert(s[i]);
	}
	for (auto in : alp) {
		v.push_back(in);
	}
	
	int minV = 10000;
	REP(i, 0, v.size()) {
		int cnt = 0;
		string str = s;
		while (!check(str, i)) {
			string newstr = "";
			REP(j, 0, str.size() - 1) {
				if (str[j] == v[i] || str[j + 1] == v[i]) {
					newstr += v[i];
				}
				else {
					newstr += "*";
				}
			}
			str = newstr;
			cnt++;
		}
		
		minV = min(minV, cnt);
	}

	cout << minV << endl;
	return 0;
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
red = 0
ans = 0
cnt = [0]*10
for x in a:
    if x < 3200:
        cnt[x//400] +=1
    else:
        red+=1
for x in cnt:
    if x >0:ans+=1

if red == n:print(1)
else:print(ans)
ans+=red
print(ans)



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    set<ll> s;
    rep(i, N) {
        ll temp;
        cin >> temp;
        s.insert(temp);
    }
    cout << s.size() - !(s.size() % 2) << endl;
    return 0;
}


Measured memory_bytes: 8272
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;
 
int main() {
    int n, w;
    scanf("%d", &n);
    scanf("%d", &w);
    int weight[n + 1];
    int value[n + 1];
    for (int i = 1; i <= n; i++) {
        scanf("%d", &weight[i]);
        scanf("%d", &value[i]);
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));// dp[i][j] = dp[i-1][j - weight[i]] + v[i]
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= w; j++ ) {
            if (j >= weight[i]) {
                dp[i][j] = max(dp[i - 1][j - weight[i]] + value[i], dp[i - 1][j]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[n][w] <<endl;
    return 0;
}


Measured memory_bytes: 80256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
    int a,b;
    cin>>a>>b;
    if(a>=13)cout<<b<<endl;
    else if(a<=5) cout<<0<<endl;
    else if(a<=12) cout<<b/2<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {

    int a, b;
    std::cin >> a >> b;

    if ( a < b )  std::cout <<  "a < b" << std::endl;
    if ( a > b )  std::cout <<  "a > b" << std::endl;
    if ( a == b ) std::cout << "a == b" << std::endl;

    return 0;
}



Measured memory_bytes: 3100
A,B,C,D = map(int, list(input()))
ans = ''
op_list = ['+', '-']
for op1 in op_list:
    for op2 in op_list:
        for op3 in op_list:
            formula = "{}{}{}{}{}{}{}".format(A,op1,B,op2,C,op3,D)
            if 7 == eval(formula):
                ans = formula+"=7" 
                break
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int a,b,tmp;
	int ga,gb;
	
	long gcd,lcm;
	
	while(scanf("%d %d",&a,&b) != EOF){
		ga = a;
		gb = b;
		
		while(gb > 0){
			if(ga < gb){
				tmp = ga;
				ga = gb;
				gb = tmp;
			}
			tmp = gb;
			gb = ga % gb;
			ga = tmp;
		}
		gcd = ga;
		lcm = (long)a/gcd*(long)b;
		printf("%ld %ld\n",gcd,lcm);
	}
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int main() {
	int n, m;
	scanf("%d %d", &n, &m);

	printf("%d", ((m * 1900) + ((n - m) * 100)) * (int)pow(2, m));
}

Measured memory_bytes: 512
# ABC138D - Ki
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def dfs(v: int, p: int) -> None:
    x = cnt[v]
    for u in T[v]:
        if u != p:
            cnt[u] += x  # cumulative sum
            dfs(u, v)


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    global T, cnt
    N, Q, *A = map(int, open(0).read().split())
    E, P = A[: (N - 1) * 2], A[(N - 1) * 2 :]
    T = [[] for _ in range(N + 1)]
    for v, u in zip(*[iter(E)] * 2):
        T[v].append(u), T[u].append(v)
    cnt = [0] * (N + 1)
    for p, x in zip(*[iter(P)] * 2):
        cnt[p] += x  # increase vertex p by x
    dfs(1, -1)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

Measured memory_bytes: 251184
#include <cstdio>
#include <cstring>
using namespace std;
#define RBSIZE 400

int main() {
  int n, p, h, t;
  char rb[RBSIZE];
  char c, ar[2];
  scanf("%d\n", &n);
  for (int i=0; i<n; i++) {
    memset(rb, (char)-1, RBSIZE);
    p = h = t = 0;
    rb[p] = getchar();
    while (1) {
      ar[0] = getchar();
      if (ar[0] == '\n' || ar[0] == EOF) break;
      ar[1] = getchar();
      c = getchar();
      if (ar[0]=='-') {
        p = (p+1)%RBSIZE;
        if (rb[p] == -1) {
          t = p;
        }
      } else {
        p = (p+RBSIZE-1)%RBSIZE;
        if (rb[p] == -1) {
          h = p;
        }
      }
      rb[p] = c;
    }
    p = h;
    while (1) {
      putchar(rb[p]);
      if (p == t) break;
      p = (p+1)%RBSIZE;
    }
    putchar('\n');
  }
}

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

signed main(){
  string s;
  vector<char> vec;
  char a[]="maerd" , b[]="remaerd" , c[]="esare" , d[]="resare";
  bool f=true , l;
  cin>>s;
  for(int i=s.size()-1;i>=0;i--){
    vec.push_back(s[i]);
    if(vec.size() > 7){
      f=false;
    }
    if(vec.size() == 5){
      l=true;
      for(int j=0;j<5;j++){
        if(vec[j] != a[j]){
          l=false;
        } 
      }
      if(l == false){
        l=true;
        for(int j=0;j<5;j++){
          if(vec[j] != c[j]){
            l=false;
          }
        }
      }
      if(l){
        vec.clear();
      }
    } else if(vec.size() == 7){
      l=true;
      for(int j=0;j<7;j++){
        if(vec[j] != b[j]){
          l=false;
        }
      } 
      if(l){
        vec.clear();
      }
    } else if(vec.size() == 6){
      l=true;
      for(int j=0;j<6;j++){
        if(vec[j] != d[j]){
          l=false;
        }
      }
      if(l){
        vec.clear();
      }
    }
  }
  if(vec.size() > 0){
    f=false;
  }
  
  if(f){
    cout<<"YES\n";
  } else {
    cout<<"NO\n";
  }
  return(0);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout << a[i] << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    ll n; cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
// coded by- mrNOBODY_

#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned long long
using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cin.sync();

    int arr[5];
    for(int i=0; i<5;i++)
    {
        cin>>arr[i];
    }
    for(int i=0;i<5;i++)
    {
        if(arr[i]==0)
        {
            cout<<i+1;
            break;
        }
    }


    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const int mod = 1e9 + 7;
const int MAXN = 5e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> ans(n);
    int x, y;
    cin >> x >> y;
    x--; y--;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans[min(j - i, abs(i - x) + 1 + abs(j - y))]++;
            //cout << i + 1 << " " << j + 1 << " " << min(j - i, abs(i - x) + 1 + abs(j - y)) << endl;
        }
    }
    for (int i = 1; i < n; i++) cout << ans[i] << "\n";
    return 0;
}


Measured memory_bytes: 3604
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(m);   (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
  string S;cin>>S;
  ll N=S.size();
  string s="",rs="";
  REP(i,N)s+=S[i];
  RREP(i,N)rs+=S[i];
  
  string s1="",rs1="";
  int n1=(N-1)/2;
  REP(i,n1)s1+=S[i];
  RREP(i,n1)rs1+=S[i];
  string s2="",rs2="";
  int n2=(N+3)/2-1;
  FOR(i,n2,N)s2+=S[i];
  RFOR(i,n2,N)rs2+=S[i];
  
  if(s==rs&&s1==rs1&&s2==rs2)cout<<"Yes";
  else cout<<"No";
  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 REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int n_max = 82;

bool dp[2][n_max][n_max * n_max * 4];
int A[n_max][n_max];
int B[n_max][n_max];



signed main(){
    int h,w;
    cin >> h >> w;
    REP(i,h){
        REP(j,w) cin >> A[i][j];
    }
    REP(i,h){
        REP(j,w) cin >> B[i][j];
    }

    REP(kk,2) REP(i,n_max) REP(j,n_max * n_max * 4) dp[kk][i][j] = false;
    dp[0][0][80 * (h + w)] = true;

    REP(i,h){
        

        REP(j,w){

            REP(k,160 * (h + w) ) dp[(i+1) %2][j][k] = false; 

            int sa = abs(A[i][j] - B[i][j]);
            if(j != 0){
                //if(i == 0 and j== 1) debug(dp[(i+1)%2][j-1][80 * (h+w)]);
                REP(k,160 * (h+w)){
                    if(dp[(i+1)%2][j-1][k] == false) continue;

                    if(k - sa >= 0) dp[(i+1) %2][j][k-sa] =true;
                    dp[(i+1)%2][j][k+sa] = true;
                }
            }
            REP(k,160 * (h + w)){
                if(dp[(i) % 2][j][k] == false) continue;
                if( k - sa >=0) dp[(i+1) %2][j][k-sa] = true;
                dp[(i+1)%2][j][k+sa] = true;
            }

/*
            debug(i);
            debug(j);
            FOR(k,80 * (h + w) - 80 * (i + j + 2), 80 * (h+w) + 80 *(i + j+ 2)){
                if(dp[(i+1) %2][j][k]){
                    debug( abs(k- 80 * (h+w)));
                }
            }
            cout << endl;
            */

        }
    }




    
    int ans = INF;
    REP(i,n_max * n_max * 4) if(dp[h %2][w-1][i]) chmin(ans, abs(i - 80 * ( h + w)) );
    cout << ans << endl;



}

Measured memory_bytes: 4608
s = gets.chomp.split('').map(&:to_i)
t = s[0]
count = 0
(s.size - 1).times do |i|
  if t == s[i + 1]
    count += 1
    s[i + 1] = s[i + 1].zero? ? 1 : 0
  end
  t = s[i + 1]
end

puts count

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




int main()
{
  ll w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << w*h/2.0 << " ";
  if (x == w/2.0 && y == h/2.0){
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 384
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
class Main {
    static int check;
	public static void main (String[] args) {
		//System.out.println("GfG!");
		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int a[]=new int[n+1];
		int b[]=new int[n+1];
		int c[]=new int[n+1];
		int dp[]=new int[n+1];
		int dp2[]=new int[n+1];
		int dp3[]=new int[n+1];
		for(int i=1;i<=n;i++){
		    a[i]=sc.nextInt();
		    b[i]=sc.nextInt();
		    c[i]=sc.nextInt();
		}
		dp[1]=a[1];
		dp2[1]=b[1];
		dp3[1]=c[1];
		for(int i=2;i<=n;i++){
		    dp[i]=a[i]+Math.max(dp2[i-1],dp3[i-1]);
		    dp2[i]=b[i]+Math.max(dp[i-1],dp3[i-1]);
		    dp3[i]=c[i]+Math.max(dp2[i-1],dp[i-1]);
		}
		int ans = Math.max(dp[n],Math.max(dp3[n],dp2[n]));
		System.out.println(ans);
	
	    
	}}

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

int main() {
	int w, h;
	while (cin >> w >> h) {
		if (w == 0 && h == 0) break;
		vector<string> g(2 * h - 1);
		cin.ignore();
		rep(i, 2 * h - 1) {
			getline(cin, g[i]);
		}
		vector<vector<int>> d(h, vector<int>(w, -1));
		d[0][0] = 0;
		queue<pii> q;
		q.push({0, 0});
		while (!q.empty()) {
			pii p = q.front();
			q.pop();
			int y, x;
			tie(y, x) = p;
			vector<int> dy = {0, 1, 0, -1};
			vector<int> dx = {1, 0, -1, 0};
			rep(i, 4) {
				int ny = y + dy[i];
				int nx = x + dx[i];
				if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
				//上下に進む -> g[2y+dy][2x]が0ならばok
				//左右に進む -> g[2y][2x+dx]が0ならばok
				if (g[ny + y][nx + x] == '1' || d[ny][nx] != -1) continue;
				d[ny][nx] = d[y][x] + 1;
				q.push({ny, nx});
			}
		}
		cout << d[h - 1][w - 1] + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
// * template

#include <bits/stdc++.h>
#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

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

template<class T, class U> inline void fill_array(T &e, const U &v) { e = v; }
template<class T, class U, size_t s> inline void fill_array(T (&a)[s], const U &v) {for(auto&e:a)fill_array(e,v);}
template<class T, class U, size_t s> inline void fill_array(array<T, s> &a, const U &v) {for(auto&e:a)fill_array(e,v);}
template<class T, class U> inline void fill_array(vector<T> &a, const U &v) {for(auto&e:a)fill_array(e,v);}

struct range {
	typedef int Int;
	struct iter {
		Int i;
		const Int s;
		constexpr iter(const Int &i_, const Int &s_):i(i_), s(s_) {}
		constexpr bool operator!=(const iter &r) const { return s > 0 ? i < r.i : i > r.i; }
		constexpr const Int &operator*() const { return i; }
		iter &operator++() { i += s; return *this; }
	};
	const Int f, l, s;
	constexpr range(const Int &f_, const Int &l_, const Int &s_):f(f_), l(l_), s(s_) {}
	constexpr range(const Int &f_, const Int &l_):f(f_), l(l_), s(1) {}
	constexpr range(const Int &num):f(0), l(num), s(1) {}
	constexpr iter begin() const { return iter(f, s); }
	constexpr iter end() const { return iter(l, s); }
};

// * solve

constexpr int MAX_NUM_BLOCK = 1000;
constexpr int MAX_BLOCK_SIZE = 5;
constexpr int WIDTH = 5;
constexpr int HEIGHT = MAX_NUM_BLOCK * MAX_BLOCK_SIZE;

array<array<bool, WIDTH>, HEIGHT> field;

void drop_block() {
	static constexpr int dx[] = {0, 1, 0};
	static constexpr int dy[] = {0, 0, 1};

	int d, p, q;
	cin >> d >> p >> q;

	int x = q - 1;
	int y = 0;
	const int w = (d == 1 ? p : 1);

	for(int i : range(HEIGHT - 1, -1, -1)) {
		if(any_of(begin(field[i]) + x, begin(field[i]) + x + w, [](bool b) { return b; })) {
			y = i + 1;
			break;
		}
	}

	dump(x, y, w);

	for(int i : range(p)) {
		field[y][x] = true;

		if(all_of(begin(field[y]), end(field[y]), [](bool b) { return b; })) {
			field[y].fill(false);
			rotate(begin(field) + y, begin(field) + y + 1, end(field));
			--y;
		}

		x += dx[d];
		y += dy[d];
	}

	dump(field[2]);
	dump(field[1]);
	dump(field[0]);
}

int calc_score() {
	int res = 0;
	for(const auto &row : field) {
		res += count(begin(row), end(row), true);
	}
	return res;
}

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

	for(int n; cin >> n && n;) {
		fill_array(field, false);

		for(int i : range(n)) {
			drop_block();
		}

		cout << calc_score() << endl;
	}

	return EXIT_SUCCESS;
}

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

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define is insert
#define er erase

using namespace std;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(TASK".in", "r", stdin);
        // freopen(TASK".out", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

ll A;
ll B;
ll C;

int solve()
{
    cin >> A >> B >> C;
    if (C - 1 <= A + B)
    {
        cout << C + B << endl;
    }
    else
    {
        ll ans = 0;
        ans += 2 * B;
        C -= B;
        ans += min(A + 1, C);
        cout << ans << endl;
    }
    return 0;
}




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

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

    int N, D;
    cin >> N >> D;
    vector<vector<int> > X(N, vector<int>(D));
    for (auto &V : X) {
        for (auto &x : V) {
            cin >> x;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            int res = 0;
            for (int k = 0; k < D; ++k) {
                res += pow((X.at(i).at(k) - X.at(j).at(k)), 2);
            }
            int rt = sqrt(res);
            if (rt * rt == res) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a =sc.nextInt();
        int b =sc.nextInt();
        int c =sc.nextInt();
        if(a*b>c){
            System.out.println(c);
        }else if(a*b<c){
            System.out.println(a*b);
        }else{
            System.out.println(c);
        }
    }
    
}


Measured memory_bytes: 21972
n=int(input())
t,a=map(int,input().split())
h=list(map(int, input().split()))
li=[]
for i in range(n):
    temp1=t-h[i]*6/1000
    temp2=abs(a-temp1)
    li+=[(i+1,temp2)]
li.sort(key=lambda x:(x[1]))
print(li[0][0])

Measured memory_bytes: 9292
h,w=map(int,input().split())
paint=[]
for _ in range(h):
    paint.append(input())

d=((-1,0),
    (0,1),
    (0,-1),
    (1,0))

def grid():
    for i in range(h):
        for j in range(w):
            if paint[i][j]=="#":
                isOk=False
                for di, dj in d:
                    ni=i+di
                    nj=j+dj
                    if ni>=0 and ni<h and nj>=0 and nj<w:
                        if paint[ni][nj]=="#":
                            isOk=True
                    else:
                        continue
                if not isOk:
                    return False
    return True
            
ans="Yes" if grid() else "No"
print(ans)

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

int main() {
  string s;
  cin >> s;
  if(s.size()==6&&s.at(2)==s.at(3)&&s.at(4)==s.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//Digits Sum
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

typedef unsigned long long int ulli;

ulli sumDigits(string cad){
	ulli sum = 0;
	for(auto c:cad){
		sum += (c-'0');
	}

	return sum;
}

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

	bool is10 = true;
	if(num[0] == '1'){
		for(int i=1; i<num.size(); i++)
			if(num[i] != '0')
				is10 = false;
	}else{
		is10 = false;
	}

	if(is10)
		cout << 10 << endl;
	else
		cout << sumDigits(num) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std ;
int main () {
  string S;;
  int flag1=0,flag2=0,flag3=0,flag4=0;
  int lens=0;
  cin >> S;
  lens = S.size();
  for(int i=2;i<lens-1;i++) {
    if(S[i]=='C') {
      flag1=flag1+1;
    }
    else if(S[i] >= 'A' & S[i] <= 'Z') {
      flag2=1;
    }
  }
  if(S[1] >= 'A' & S[1] <= 'Z'){
    flag3=1;
  }
  else if(S[lens-1] >= 'A' & S[lens-1] <= 'Z'){
    flag3=1;
  }
  if(S[0]=='A' & flag1 == 1 & flag2 == 0 & flag3 == 0) cout << "AC" << endl;
  else cout << "WA" << endl;
  return(0);
}

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

using namespace std;

template <long long Mod> struct ModInt {
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const {
    return ModInt(*this) /= rhs;
  }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
};

const int mod = 1e9 + 7;
using modint = ModInt<mod>;
modint fac[100005];

modint nCr(int n, int r) {
  if (n < 0 or r < 0 or n < r) {
    return 0;
  }
  return fac[n] / fac[r] / fac[n - r];
}

int main() {
  fac[0] = fac[1] = 1;
  for (int i = 2; i < 100005; i++) {
    fac[i] = fac[i - 1] * i;
  }

  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (auto &a : A) {
    cin >> a;
  }
  sort(A.begin(), A.end());
  modint f_max = 0;
  modint f_min = 0;
  for (int i = 1; i <= N; i++) {
    f_max += modint(A[i - 1]) * nCr(i - 1, K - 1);
    f_min += modint(A[i - 1]) * nCr(N - i, K - 1);
  }
  cout << f_max - f_min << endl;

  return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, x, n) for(ll i=x; i<(ll)n; ++i)
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()

int main(){
    ll N, M;
    cin >> N >> M;
    if(M==0){
        cout << -1 << endl;
        return 0;
    }
    vll u(M), v(M);
    rep(i, M){
        cin >> u[i] >> v[i];
    }
    ll S, T;
    cin >> S >> T;
    vector<unordered_set<ll>> m(3*N+3);
    rep(i, M){
        m[3*u[i]-3].insert(3*v[i]-2);
        m[3*u[i]-2].insert(3*v[i]-1);
        m[3*u[i]-1].insert(3*v[i]-3);
    }
    auto c = [](pair<ll, ll> l, pair<ll, ll> r){ return l.first>r.first; };
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, decltype(c)> q(c);
    vll s(3*N+3, -1);
    q.push({0, 3*S-3});
    while(!q.empty()){
        auto e = q.top();
        q.pop();
        ll n = e.second;
        ll d = e.first;
        if(s[n]>=0) continue;
        s[n] = d;
        for(ll a : m[n]){
            if(s[a]==-1){
                q.push({d+1, a});
            }
        }
    }
    if(s[T*3-3]<0) cout << -1 << endl;
    else cout << (s[T*3-3]/3) << endl;
}


Measured memory_bytes: 39296
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	ll d, n;
	cin >> d >> n;
	 
	//if (n == 100)cout << 101 * pow(100, d) << endl;
	//else cout << n * pow(100, d) << endl;
	
	if (n == 100)n = 101;
	while (d--)n *= 100;
	cout << n << endl;


	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll A,B,H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> L;
	vector<ll>A(L + 1);
	vector<vector<ll>>dp(5, vector<ll>(L + 1));
	for (int t = 0; t <= 4; t++)dp[t][0] = 0;
	for (int i = 1; i <= L; i++) {
		cin >> A[i];
		ll min1 = min(dp[0][i - 1], dp[1][i - 1]);
		ll min2 = min(dp[2][i - 1], min1);
		ll min3 = min(dp[3][i - 1], min2);
		ll min4 = min(dp[4][i - 1], min3);
		dp[0][i] = dp[0][i - 1] + A[i];
		dp[4][i] = min4 + A[i];
		if (A[i] & 1) {
			dp[1][i] = min1+ 1;
			dp[2][i] = min2;
			dp[3][i] = min3+ 1;
		}
		else if (!(A[i] & 1) && A[i] > 0) {
			dp[1][i] = min1;
			dp[2][i] = min2 + 1;
			dp[3][i] = min3;
		}
		else {
			dp[1][i] = min1 + 2;
			dp[2][i] = min2 + 1;
			dp[3][i] = min3 + 2;
		}
	}
	ans = dp[0][L];
	for (int t = 1; t <= 4; t++)ans = min(ans, dp[t][L]);
	cout << ans << endl;
}


Measured memory_bytes: 11136
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextInt();
        double a1=a/2.0;
        double b1=b/2.0;
        int sum= (int) (a1+b1);
        if ( Math.abs(a-sum) == Math.abs(b-sum)) {
            System.out.println(sum);
        }
        else System.out.println("IMPOSSIBLE");
    }
}


Measured memory_bytes: 21844
//
// Created on 2020/04/06.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {

    string s,t;
    cin>>s>>t;
    string ans = t+s;

    cout<<ans<<endl;
}


Measured memory_bytes: 256
def main():
    N, Ma, Mb = map(int, input().split())
    yakuhin = []
    sa = 0
    sb = 0
    for i in range(N):
        yakuhin.append(list(map(int, input().split())))
        sa += yakuhin[i][0]
        sb += yakuhin[i][1]
    
    INF = 10**15
    DP = [[[INF for _ in range(sb+1)] for _ in range(sa+1)] for _ in range(N+1)]
    
    for i in range(N):
        DP[i][0][0] = 0
    
    for i in range(N):
        for j in range(sa+1):
            for k in range(sb+1):
                if(j >= yakuhin[i][0] and k >= yakuhin[i][1]):
                    DP[i+1][j][k] = min(DP[i][j][k], DP[i][j-yakuhin[i][0]][k-yakuhin[i][1]]+yakuhin[i][2])
                else:
                    DP[i+1][j][k] = min(DP[i+1][j][k], DP[i][j][k])
        
    ans = INF
    for i in range(1, N+1):
        for j in range(1, sa+1):
            for k in range(1, sb+1):
                if(j*Mb == k*Ma):
                    ans = min(ans, DP[i][j][k])    
        
    print(ans if ans != INF else -1)
    
main()

Measured memory_bytes: 26228
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 50000000000000000;
typedef std::pair<int,int> P;
struct edge {int to,cost;};
    ll N;
    int A[100010];
    int C=0;
    ll ans=0;

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)cin>>A[i];
    REP(i,N){
        DEB(i)DEB(A[i])DEB(A[i-1])DEB(A[i-2])
        if(A[i]==i+1){
            ans++;
            if(C==0)C++;
            else{
                if(i>0&&A[i-1]==i)C++;
                else C=1;
            }
            if(C%2==0&&C!=0)ans--;
            /*if(i>0&&A[i-1]==i){
                ans--;
                if(i>1&&A[i-2]==i-1){
                    ans++;
                }
            }*/
        }else C=0;
        DEB(ans)END
    }
    cout<<ans<<endl;
    return 0;
}

//ARC 082 D - Derangement


Measured memory_bytes: 640
#include<stdio.h>
int east[300005],west[300005];
char a[300005];
int main()
{
 int n;
scanf("%d",&n);
scanf("%s",&a[1]);
int i;
for(i=1; i<=n; i++)
{
 east[i] = east[i-1];
 if(a[i]=='W')east[i]++;
}
for(i=n; i>=1; i--)
{
 west[i] = west[i+1];
 if(a[i]=='E')west[i]++;
}
int ans = n+1;
int cur;
for(i=1; i<=n; i++)
{
 cur = east[i-1] + west[i+1];
if(cur < ans)ans = cur;
}
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 2816