akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int n;
	while(~getI(n)){
		int arr[n],a=0,b=0;
		F(i,0,n) getI(arr[i]);
		sort(arr,arr+n,cmp);
		F(i,0,n) i%2==0?a+=arr[i]:b+=arr[i];
		printf("%d\n",a-b);
	}
}


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

int main() {
  int N, m, x=0;
  cin >> N;
  
  vector<int> moti(N);
  for(int i=0; i<N; i++){
    cin >> m;
    for(int j=0; j<=x; j++){
      if(moti.at(j) == m){
        break;
      }
      if(j==x){
        moti.at(x)=m;
        x++;
        break;
      }
    }
  }
  
  for(int i=0; i<N; i++){
  	if(moti.at(moti.size()-1) == 0)
  	  moti.pop_back();
  	else
  	  break;
  	}
  cout << moti.size() << endl;
}

Measured memory_bytes: 256
# 解説AC
from collections import deque

N = int(input())
edge = [[] for _ in range(N)]
for n in range(N - 1):
    a,b = map(int, input().split())
    edge[a-1].append([b-1, n])
    edge[b-1].append([a-1, n])

def bfs(s:int, g:int):
    """ 始点sから終点gまでのパスを求める """
    in_edge = [-1] * N
    par = [-1] * N
    flag = False # 終点到着フラグ
    
    que = deque([s])
    while que:
        v = que.popleft()
        for w, n in edge[v]:
            if w == par[v]: continue
            in_edge[w] = n
            par[w] = v
            if w == g:
                flag = True
                break
            que.append(w)
        if flag: break
    path = 0
    cur = g
    while in_edge[cur] >= 0:
        path |= 1 << in_edge[cur]
        cur = par[cur]
    return path


M = int(input())
path = [0] * M # 各制約で使用するパス
for i in range(M):
    u,v = map(int, input().split())
    path[i] = bfs(u - 1, v - 1)

ans = 0
# 包除原理
for bit in range(1 << M):
    val = 0
    for i in range(M):
        if (bit >> i) & 1:
            val |= path[i]
    if bin(bit).count("1") % 2 == 0:
        ans += 1 << (N - 1 - bin(val).count("1"))
    else:
        ans -= 1 << (N - 1 - bin(val).count("1"))

print(ans)

Measured memory_bytes: 44072
// 2012/12/13 Tazoe

#include <iostream>
using namespace std;

int main()
{
	for(int i=0; i<3; i++){
		int h1, m1, s1, h2, m2, s2;
		cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;

		int t1 = h1*3600+m1*60+s1;
		int t2 = h2*3600+m2*60+s2;

		int t3 = t2-t1;

		int h3 = t3/3600;
		int m3 = t3%3600/60;
		int s3 = t3%60;

		cout << h3 << ' ' << m3 << ' ' << s3 << '\n';
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <iostream>
#include <cstdio>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
 
#define ll long long
#define pb push_back
#define vi vector<int>
#define sz(a) (int((a).size()))
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>
 
using namespace std;
 
const int mod = 998244353;
const int inf = (int)2e9;
const ll INF = (ll)2e18;
const int N = 100100;
int n, k, x, y;
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k >> x >> y;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i <= k) ans += x;
		else ans += y;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){

  



  int a,b,k;

  cin >> a>>b>>k;
  vector<int> ans;
  int last;

  for (int i = a; i <= b && i<k+a; ++i) {
    ans.push_back(i);
    last=i;

  }

  for (int i = b,j=0; i > last && j<k; --i,j++) {
    ans.push_back(i);
  }

  
  sort(ans.begin(),ans.end());
  for(int x :ans)
    cout<<x<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd =1e5+10;
char s[maxd];
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    scanf("%s",s);
    sort(s,s+4);
    if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) printf("Yes");
    else printf("No");
    return 0;
}  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int H[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", H + i);
	
	int ans = 0, cur = 0, prev = -1;
	REP(i, N) {
		if (prev < H[i]) {
			chmax(ans, cur - 1);
			cur = 1;
		}
		else {
			cur++;
		}
		prev = H[i];
	}
	chmax(ans, cur - 1);
	
	cout << ans << endl;
	
	return 0;
}


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

int next_sum(int sum, int r, int D)
{
  return r*sum - D;
}

int main()
{
  int sum, r, D;
  cin >> r >> D >> sum;
  for(int i = 0; i < 10; i++)
  {
    sum = next_sum(sum, r, D);
    cout << sum << endl;
  }
  return 0;
}

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

#define ll long long
#define endl "\n";
#define mod 1000000007
#define inf 1e18
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define mk(arr,n,type) type *arr=new type[n];

void fastio() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

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

    unordered_set<string> se;
    for (int i=0; i<n; i++) {
    	string s;
    	cin >> s;

    	se.insert(s);
    }

    cout << se.size();

    return 0;
}


Measured memory_bytes: 17752
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 998244353
#define floop(i,a,b) for (int i=(a);i<(b);i++)
#define rloop(i,a,b) for (int i=(a);i>=(b);i--)
#define floopeq(i,a,b) for (int i=(a);i<(b);i++)
#define pa pair<int,int>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll modInverse(ll a, ll m) 
{ ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0; while (a > 1){ ll q = a / m; ll t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } 
    if (x < 0) x += m0; return x; 
}
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b){if(a.fi==b.fi)return b.se>a.se;return a.fi>b.fi;}
void run(vector<int>v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void solve()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

int main() 
{ 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    
        solve();
        
    
    
    return 0; 
} 

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

using namespace std;

int main() {
    int X, Y;
    cin >> X >> Y;

    for(int i=0; i<=X; i++){
        int legs = i*4+(X-i)*2;
        if(legs == Y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3640
import sys,math

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	to = [[] for _ in range(N)]
	ans = {}
	order = []
	for i in range(N-1):
		a,b = MI()
		a -= 1;b -= 1
		ans[str(a)+"-"+str(b)] = 0
		order.append(str(a)+"-"+str(b))
		to[a].append(b);to[b].append(a)
	
	def bfs():
		from collections import deque
		hist = [True]*N
		que = deque()
		que.append(0)
		e_colors = [0]*N
		max_c = 0
		while len(que) > 0:
			n = que.popleft()
			hist[n]=False
			for i in to[n]:
				if(hist[i]):
					ch = e_colors[n] | e_colors[i]
					index = int(math.log2(~ch & -~ch))
					e_colors[n] += 1 << index
					e_colors[i] += 1 << index
					ans[str(min(n,i))+"-"+str(max(n,i))] = index+1
					if(max_c < index+1): max_c = index+1
					que.append(i)
		print(max_c)
		for i in order:
			print(ans[i])

	bfs()


main()

Measured memory_bytes: 115868
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	map<int, int> m;
	string s;
	cin >> s;
	for(int i = 0; i < 4; i++)
		m[s[i]-'A']++;
	if(m.size() != 2)
		return cout << "No", 0;
	for(auto i: m){
		if(i.se != 2)
			return cout << "No", 0;
	}	
	cout << "Yes";
	return 0;
}

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

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

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

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

ll MOD = 1e9 + 7;

// g = eGCD(a, b, s, t)  --->  sa + tb = g
constexpr ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

constexpr ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(a, b, dummy1, dummy2);
}

struct Fp {
  ll val;

  Fp(ll t = 0) :
    val(t < 0 ? MOD + t % MOD : t >= MOD ? t % MOD : t) {}

  Fp& operator +=(const Fp& t) {
    val += t.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }

  Fp& operator -=(const Fp& t) {
    val -= t.val;
    if (val < 0) val += MOD;
    return *this;
  }

  Fp& operator *=(const Fp& t) {
    val = (val * t.val) % MOD;
    return *this;
  }

  Fp inv() const {
    if (val == 0) {
      cerr << "inv() is called for zero." << endl;
      exit(1);
    }
    ll u = 0;
    ll v = 0;
    eGCD(val, MOD, u, v);
    return Fp(u);
  }

  Fp& operator /=(const Fp& t) {
    return (*this) *= t.inv();
  }

  Fp operator +(const Fp& t) const { return Fp(val) += t; }
  Fp operator -(const Fp& t) const { return Fp(val) -= t; }
  Fp operator *(const Fp& t) const { return Fp(val) *= t; }
  Fp operator /(const Fp& t) const { return Fp(val) /= t; }
  Fp operator -() const { return Fp(-val); }

  bool operator ==(const Fp& t) const { return val == t.val; }
  bool operator !=(const Fp& t) const { return val != t.val; }
  
  operator ll() const { return val; }

};


int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  string S; cin >> S;

  Fp comb(1);
  int rem = 0;

  for (int i = 0; i < 2*N; i++) {
    if (rem % 2 == 0) {
      if (S.at(i) == 'B') {
	rem ++;
      }else {
	comb *= (Fp)rem;
	rem --;
      }
    }else {
      if (S.at(i) == 'B') {
	comb *= (Fp)rem;
	rem --;
      }else {
	rem ++;
      }
    }
    if (rem < 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (rem > 0) {
    cout << 0 << endl;
    return 0;
  }

  Fp fact(1);
  for (int n = 1; n <= N; n++) fact *= (Fp)n;
  comb *= fact;
  
  cout << (int)comb << endl;

  

  return 0;
}



Measured memory_bytes: 720
#include<stdio.h>
#define N 250000

int main(void){
  int prime[N],i,j,n;

  for(i=2;i<N;i++)
    prime[i]=0;

  prime[0]=1;
  prime[1]=1;

  for(i=2;i*i<=N;i++){
    if(prime[i]==0){
      for(j=2*i;j<N;j+=i){
	prime[j]=1;
      }
    }
  }

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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll MRINF = 5000000000000000;

int main() {

  char a;
  cin >> a;
  // cout << int(a) << endl;
  if(a - 'a' >= 0)cout << "a" << endl;
  else cout << "A" << endl;
    
  
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

int main(){
  int n;
  cin>>n;
  string s=to_string(n);
  int i=s.length()-1;
  int rrr=9,ans=0;
  int j=1;
  while(j<=i){
    ans+=rrr;
    j+=2;
    rrr=rrr*100;
  }
  int kkk=1;
  if(i%2==0){for(int k=0;k<i;k++)kkk*=10;
  ans+=n-kkk+1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, ans, r, g, b, c;
    r=g=b=0;
    string s;
    cin >> n;
    cin >> s;
     for(int i = 0 ;i<n ;i++)
     {
        if(s[i]=='R')
            r++;
        else if(s[i]=='G')
            g++;
        else if(s[i]=='B')
            b++;
     }

     ans = r*b*g;

    for(int i=0; i<s.size(); i++)
    {
        for(int j=i, k=i; k<s.size(); j++, k+=2)
        {
            
                if(s[i]*s[j]*s[k] == 'R'*'G'*'B')
                {
                    
                        ans--;
                }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int n,i,sum=0,array[10001];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>array[i];
		sum=sum+array[i];
	}
	sort(array,array+n);
	cout<<sum-(array[n-1]/2)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
def factorize(n):
    fct = set()
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.add(b)
        b,e = b+1,0
    if n > 1:
        fct.add(n)
    return fct
a,b = map(int,input().split())
print(len(factorize(a)&factorize(b))+1)

Measured memory_bytes: 62364
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define coyes cout << "Yes" << endl;
#define cono cout << "No" << endl;
#define coYes cout << "YES" << endl;
#define coNo cout << "NO" << endl;
using namespace std;
using ll = long long int;
string large_al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string small_al = "abcdefghijklmnopqrstuvwxyz";
using Graph = vector<vector<int>>;
using i64 = int64_t;


int main() {
  i64 h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
  }
  else if (h % 2 == 0) {
    cout << (h / 2) * ((w + 1) / 2) + (h / 2) * (w / 2) << endl;
  }
  else if (h % 2 == 1) {
    cout << ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2) << endl;
  }
  
}
 
      


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <functional>
using namespace std;

using ll = long long;

struct Edge {
    int to, cost;
};

struct State {
    int node, rem, cost;
    State(int node, int rem, int cost) :
        node(node), rem(rem), cost(cost) {}

    bool operator>(const State& s) const {
        return cost > s.cost;
    }
};

const int MAX_R = 10;
const int MAX_N = 100010;
const int INF = (1 << 28);

int cost[MAX_R][MAX_N];

vector<Edge> rev_graph[MAX_N];
set<int> nodes[MAX_R];

int n, m, r, q;

void dijkstra() {
    for (int rem = 0; rem < r; rem++) {
        priority_queue<State, vector<State>, greater<State>> que;

        for (int v = 0; v < n; v++) {
            cost[rem][v] = (v % r == rem) ? 0 : INF;
        }

        for (int v : nodes[rem]) {
            cost[rem][v] = 0;
            que.push(State(v, rem, 0));
        }

        while (!que.empty()) {
            State s = que.top(); que.pop();
            if (cost[rem][s.node] < s.cost) continue;

            for (Edge e : rev_graph[s.node]) {
                if (cost[rem][e.to] > s.cost + e.cost) {
                    cost[rem][e.to] = s.cost + e.cost;
                    que.push(State(e.to, rem, cost[rem][e.to]));
                }
            }
        }
    }
}

int main() {
    cin >> n >> m >> r >> q;

    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin>> a >> b >> c;
        a--; b--;

        rev_graph[b].push_back((Edge){a, c});
        nodes[b % r].insert(b);
    }

    dijkstra();

    ll ans = 0;
    for (int i = 0; i < q; i++) {
        ll x, y, z;
        cin >> x >> y >> z;
        x--; y--;

        ll val = 0;
        for (int r_i = 0; r_i < r; r_i++) {
            val = max(val, z - cost[r_i][x] - cost[r_i][y]);
        }
        ans += val;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 17284
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int a,b;cin>>a>>b;
    int ans=0;
    if(a==3)ans+=100000;
    else if(a==2)ans+=200000;
    else if(a==1)ans+=300000;
    if(b==3)ans+=100000;
    else if(b==2)ans+=200000;
    else if(b==1)ans+=300000;
    if(a==1&&b==1)ans+=400000;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a[4][13],i,j,k,x,n;
    char m;
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            a[i][j]=0;
        }
    }
        scanf("%d",&n);
        for(k=0;k<2*n;k++){
            scanf("%c %d",&m,&x);
            if(m=='S')a[0][x-1]=1;
            else if(m=='H')a[1][x-1]=1;
            else if(m=='C')a[2][x-1]=1;
            else if(m=='D')a[3][x-1]=1;
        }
        for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(a[i][j]==0){
                if(i==0){printf("S %d\n",j+1);}
                else if(i==1){printf("H %d\n",j+1);}
                else if(i==2){printf("C %d\n",j+1);}
                else if(i==3){printf("D %d\n",j+1);}
            }
        }
    }
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n%2==0) cout << 0.5 << "\n";
  else if(n==1) cout << 1 << "\n";     
  else cout << ceil((double)n/2)/n << "\n";
  return 0;
}

Measured memory_bytes: 3892
list_score = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(list_score[n-1])

Measured memory_bytes: 3060
#include <stdio.h>

void dis(int *arr,int n)
{
    for(int i = 0;i<n;i++)
    {
        if(i>0)
            printf(" ");
        printf("%d",arr[i]);
    }
    printf("\n");
}

int BubbleSort(int * arr,int n)
{
    int Num = 0;
    for(int i = 0;i<n;i++)
        for(int j = n-1;j>i;j--)
        {
            if(arr[j-1]>arr[j])
            {
                arr[j-1] ^= arr[j];
                arr[j] ^= arr[j-1];
                arr[j-1] ^= arr[j];
                Num++;
            }
    }
    return Num;
}



int main(int argc, char *argv[])
{
    int N;
    int A[100];

    scanf("%d",&N);
    for(int i = 0;i<N;i++)
    {
        scanf("%d",&A[i]);
    }
    int num = BubbleSort(A,N);
    dis(A,N);
    printf("%d\n",num);
    return 0;
}



Measured memory_bytes: 2076
#include <stdio.h>
#define N 100

int main()
{
  int a[N],n,i,j,t=0,tmp;

  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&a[i]);
  for(i = 0;i < n;i++)
    {
      for(j = n-1;j > i;j--)
	{
	  if(a[j] < a[j - 1])
	    {
	      tmp = a[j];
	      a[j] = a[j - 1];
	      a[j - 1] = tmp;
	      t++;
	    }
	}
    }
  
  for(i = 0;i < n;i++)
    {
      if(i > 0) printf(" ");
      printf("%d",a[i]);
    }
  
  printf("\n%d\n",t);

  return 0;
}



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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    cin >> N;

    set<string> s;
    string str;
    Rep(i,N) cin >> str, s.insert(str);

    cout << s.size() << endl;

    return 0;
}



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

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;
    vector<int> dif(N - 1, 0);

    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            int dis1 = abs(j - i);
            int dis2 = abs(X - i) + 1 + abs(j - Y);
            int dis3 = abs(Y - i) + 1 + abs(j - X);

            int k = min({dis1, dis2,dis3});
            dif[k - 1]++;
        }
    }
    for(int m: dif) {
        cout << m << endl;
    }
    return 0;
}

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

void solve() {
	int n; cin >> n;
	unordered_set<string> uniqueString;
	while(n--) {
		string s; cin >> s;
		uniqueString.insert(s);
	}
	cout << uniqueString.size() << endl;

	//cout << "Case #" << t + 1 << ": " << count << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	/*int t; cin >> t;
	for (int i = 0; i < t; i++) {
		solve(i);
	}*/

	solve();

    return 0;
}

Measured memory_bytes: 17668
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	const double  PI = acos(-1);
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	double theta;
	theta = abs(6*M-0.5*(60 * H + M));
	//if (theta > 180)theta = theta - 180;
	//if (theta == 180)cout << A + B << endl;
	//else if (theta == 0)cout << abs(A - B) << endl;
	//else cout << sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(theta * PI / 180)) << endl;
	//else 
	printf("%.15lf\n", sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(theta * PI / 180)));
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

// cout<<fixed<<setprecision(10);

template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
const int NM = 100000;

P f(int x){
    int a = x%10;
    int b = 0;
    while(x){
        b=x;
        x/=10;
    }
    return P(a, b);
}

int main(){
    int n; cin>>n;
    map<P, int> freq;
    for(int i=1; i<=n; i++){
        P p = f(i);
        freq[p]++;
    }
    ll ans = 0;
    for(int i=1;i<=n; i++){
        P p = f(i);
        P q(p.second, p.first);
        ans +=freq[q];
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    double r,S,l,PI;
    PI=3.14159265359;
    scanf("%lf",&r);
    S=PI*r*r;
    l=2*PI*r;
    printf("%0.6f %0.6f\n",S,l);
    return 0;
}


Measured memory_bytes: 2044
# coding: utf-8

Tp, Ta, Ap, Aa = map(int, input().split())

while True:
  # 高橋攻撃
  Ap = Ap - Ta
  if Ap <= 0:
    print('Yes')
    break
  # 青木攻撃
  Tp = Tp - Aa
  if Tp <= 0:
    print('No')
    break

Measured memory_bytes: 9040
#include<stdio.h>
#define N 100
int main(void){
  int A[N],i,j,n;
  int t,count=0;
  int flag;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  flag = 1;
  while(flag){
    flag = 0;
    for(j=n-1;j>0;j--){
      if(A[j] < A[j-1]){
        t = A[j];
        A[j] = A[j-1];
        A[j-1] = t;
        count++;
        flag = 1;
      }
    }
  }
  for(i=0;i<n-1;i++) printf("%d ",A[i]);
  printf("%d\n",A[n-1]);
  printf("%d\n",count);
}


Measured memory_bytes: 1988
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();

		if(n==m){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <unistd.h>
#include <cctype>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cmath>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
using ll = long long;
using Pll = pair<ll,ll>;
using Pii = pair<int,int>;
using Pdd = pair<double,double>;
using dcomplex = complex<double>;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;for(ll i=1;i<=a;i++)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}
double inf() {return std::numeric_limits<double>::infinity();}

ll X, Y;

int main(int argc, char const *argv[]) {
  cin >> X >> Y;
  ll cnt = 0;
  while(X <= Y) {cnt++; X*=2;}
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
 
signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    string S;
    cin>>S;
    int n = S.length();
    map<int,int> ma;
    ma[0]=1;
    int now=0;
    int zurasu = 1;
    for(int i = n-1;i>=0;i--){
        now=(now+(S[i]-'0')*zurasu)%2019;
        zurasu*=10;
        zurasu%=2019;
        ma[now]++;
    }
    int ans =0;
    for(auto e: ma){
        ans+=e.second*(e.second-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <string.h>

void main()
{
    char S[256], T[256];
    int i;

    scanf("%s", S);

    // 元の文字数より1文字多いかチェック
    if(strlen(S) != 3){
        printf("NG\n");
        return;
    }

  	if(!strcmp(S, "SSS")){
      printf("0\n");
    }else if(!strcmp(S, "SSR")){
      printf("1\n");
    }else if(!strcmp(S, "SRS")){
      printf("1\n");
    }else if(!strcmp(S, "SRR")){
      printf("2\n");
    }else if(!strcmp(S, "RSS")){
      printf("1\n");
    }else if(!strcmp(S, "RSR")){
      printf("1\n");
    }else if(!strcmp(S, "RRS")){
      printf("2\n");
    }else if(!strcmp(S, "RRR")){
      printf("3\n");
    }else{
      printf("NG\n");
    }

}


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

using namespace std;

int main(){
    long long  A, V;
    cin >> A >> V;
    long long B, W;
    cin >> B >> W;

    long long T;
    cin >> T;

    long long dist;
    if( B >=0 ){
        dist = B - A;
    }else{
        dist = abs(B - A);
    }

    long long speed = V - W;
    if( speed * T >= dist){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c)cout << "Yes" << endl;
    else cout << "No" << endl;    
}


Measured memory_bytes: 3608
def gcd(a,b):
    while True:
#         print(a,b)
        if a >= b:
            x = a
            y = b
        else:
            x = b
            y = a

        mod = x%y

        if mod == 0:
            return y
        
        else:
            a = y
            b = mod

A,B = list(map(int,input().split()))
ans = int(A*B / gcd(A,B))
print(ans)

Measured memory_bytes: 61824
//wawando's template

#include <iostream>
#include <string>
#include <fstream>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>  //clock_t , clock() , CLOCKS_PER_SEC
#include <cstring>
#include <cctype>
#include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

//MACROS
#define pb              push_back
#define mp              make_pair
#define INF             1000000000     //1 billion safer for floyd warshall, avoid overflow

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(0);

  int A,P;
  cin >>A >>P;
  cout <<(A*3 + P)/2 <<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HossamDoma
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public ArrayList<Integer>[] g = new ArrayList[100010];
        public int[] dist1 = new int[100010];
        public int[] distN = new int[100010];
        int f = 1;
        int snuke = 1;

        void dfs(int node, int parent, int[] dArray) {

            for (int x : g[node]) {
                if (x != parent) {
                    dArray[x] = dArray[node] + 1;
                    dfs(x, node, dArray);
                }
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {


            int n = in.nextInt();

            for (int i = 0; i < n - 1; ++i) {

                int x = in.nextInt();
                int y = in.nextInt();

                if (g[x] == null)
                    g[x] = new ArrayList<>();

                if (g[y] == null)
                    g[y] = new ArrayList<>();

                g[x].add(y);
                g[y].add(x);
            }

            dist1[1] = distN[n] = 0;

            dfs(1, 0, dist1);
            dfs(n, 100001, distN);

            for (int i = 1; i <= n; ++i) {
                if (dist1[i] <= distN[i])
                    f++;
                else
                    snuke++;
            }

            if (f > snuke)
                out.println("Fennec");
            else
                out.println("Snuke");

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 73728
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;

struct Edge {
	int from,to,cap,flow;
	Edge(int u,int v,int c,int f):from(u),to(v),cap(c),flow(f) {}
};

int n,m;
vector<Edge>edges;
vector<int>G[maxn];
int a[maxn],p[maxn];

int maxflow (int s,int t) {
	int flow=0;
	while (1) {
		memset(a,0,sizeof(a));
		queue<int>q;
		q.push(s);
		a[s]=INF;
		while (q.size()) {
			int x=q.front(); q.pop();
			for (int id:G[x]) {
				Edge &e=edges[id];
				if (!a[e.to] && e.cap>e.flow) {
					p[e.to]=id;
					a[e.to]=min(a[x],e.cap-e.flow);
					q.push(e.to);
				}
			}
			if (a[t]) break;
		}
		if (!a[t]) break;
		for (int u=t;u!=s;u=edges[p[u]].from) {
			edges[p[u]].flow+=a[t];
			edges[p[u]^1].flow-=a[t];
		}
		flow+=a[t];
	}
	return flow;
}

int main() {
	cin>>n>>m;
	for (int i=0;i<m;i++) {
		int u,v,c; cin>>u>>v>>c;
		edges.pb(Edge(u,v,c,0));
		edges.pb(Edge(v,u,0,0));
		int id=edges.size()-2;
		G[u].pb(id);
		G[v].pb(id+1);
	}
	cout<<maxflow(0,n-1)<<'\n';
}


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

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
        int[] arr = {a, b, c};
        Arrays.sort(arr);
        System.out.println(arr[0] + " " + arr[1] + " " + arr[2]); 
    }
}

Measured memory_bytes: 26196
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 2005
#define INF 1000000005
#define INFLL 2000000000000000003
#define PI 3.1415926535897
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    vector<int>a(n+1);
    REP(i,n+1)cin>>a[i];
    vector<ll>m(n+1);
    m[0]=1-a[0];
    bool f=true;
    REP(i,n){
        m[i+1]=2*m[i]-a[i+1];
        if(m[i+1]>INFLL)m[i+1]=INFLL;
        if(m[i+1]<0)f=false;
    }
    if(m[0]<0)f=false;
    vector<ll>d(n+1);
    d[n]=a[n];
    for(int i=n-1;i>=0;i--){
        if(d[i+1]<=m[i]){
            d[i]=d[i+1]+a[i];
        }else{
            d[i]=m[i]+a[i];
        }
    }
    ll ans=0;
    REP(i,n+1){
        ans+=d[i];
    }
    if(!f)ans=-1;
    OUT(ans);
    return 0;
}


Measured memory_bytes: 5092
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define shalaby ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);cerr.tie(0);
#define mod 100000000
using namespace std;

inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}
 ll Max=1e18+8;
const int OO=-1e6;
int xt[4]= {1,0,0,-1};
int yt[4]= {0,1,-1,0};
////////////////////////////////////////////////////////////////////////////////////

ll mem[100005],a[100005],n,m,k;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
void init()
{
    memset(mem,-1,sizeof mem);
}
/////////////////////////////////////////////////////////////////////
ll solve(int i=0)
{
    if(i>=n)
        return Max;
        if(i==n-1)
            return 0;

    ll &ret=mem[i];
    if(~ret)return ret;
    ret=Max;
    for(int j=1;j<=k;j++)
    ret=min((solve(i+j)+abs(a[i]-a[i+j])),ret);

    return ret;
}
/**5 3
10 30 40 50 20


3 1
10 20 10
*/
int main()
{
    init();
    int T=1;
///   T=D();
    while(T-->0)
    {
        cin >> n >>k;
        for(int i=0; i<n; i++)
        {
            cin >> a[i];
        }
        cout << solve();
    }
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

int	main() {
	int H, A;
	cin >>H >>A;
	cout <<(H+A-1)/A <<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
	}

	static void solve() {
		int n = in.nextInt();
		int w = in.nextInt();
		
		int[][] items = new int[n][2];
		for(int i = 0; i < n; i++)
		{
			items[i][0] = in.nextInt();
			items[i][1] = in.nextInt();
		}
		
		long[][] dp = new long[n + 1][w + 1];
		
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= w; j++)
			{
				long x = dp[i - 1][j];
				long y = 0;
				if(items[i - 1][0] <= j)
				{
					y = dp[i - 1][j - items[i - 1][0]] + items[i - 1][1];
				}
				dp[i][j] = Math.max(x, y);
				
			}
		}
		System.out.println(dp[n][w]);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int[] readarr(int abc) {
			int[] temp = new int[abc];
			for (int i = 0; i < abc; i++)
				temp[i] = nextInt();
			return temp;
		}
	}
}


Measured memory_bytes: 130600
#include <bits/stdc++.h>
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int k;
	cin>>k;
	cout<<a[k-1];
	return 0;
}



Measured memory_bytes: 256
import sys
import copy
import math
import itertools
import numpy as np
N = int(input())
A = [int(input()) for c in range(N)]
B = sorted(copy.deepcopy(A),reverse=True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Measured memory_bytes: 38576
#include<bits/stdc++.h>
#define P pair<int,int>
#define int long long
#define INF LLONG_MAX/3
using namespace std;

vector<P>rinsetu[1000000];//cost to
int mincost[1000000];
signed main() {
	int a, b, c; cin >> b >> a >> c; a--; b--;
	map<int, vector<P>>n, m;
	for (int d = 0; d < c; d++) {
		int e, f; scanf("%lld%lld", &f, &e); e--; f--;
		n[e].push_back(P(f,d*2));
		m[f].push_back(P(e,d*2+1));
		rinsetu[d*2].push_back(P(1,d*2+1));
		rinsetu[d*2+1].push_back(P(1,d*2));
	}
	m[0].push_back(P(0,c*2));
	n[a].push_back(P(b,c*2+1));
	m[b].push_back(P(a,c*2+1));
	for (auto k = n.begin(); k != n.end(); k++) {
		vector<P>r = k->second;
		if (r.size() > 1) {
			sort(r.begin(), r.end());
			for (int ttt = 1; ttt < r.size(); ttt++) {
				rinsetu[r[ttt].second].push_back(P(r[ttt].first-r[ttt-1].first,r[ttt-1].second));
				rinsetu[r[ttt-1].second].push_back(P(r[ttt].first - r[ttt - 1].first, r[ttt].second));
			}
		}
	}
	for (auto k = m.begin(); k != m.end(); k++) {
		vector<P>r = k->second;
		if (r.size() > 1) {
			sort(r.begin(), r.end());
			for (int ttt = 1; ttt < r.size(); ttt++) {
				rinsetu[r[ttt].second].push_back(P(r[ttt].first - r[ttt - 1].first, r[ttt - 1].second));
				rinsetu[r[ttt - 1].second].push_back(P(r[ttt].first - r[ttt - 1].first, r[ttt].second));
			}
		}
	}
	fill(mincost, mincost + c * 2 + 2, INF);
	priority_queue<P, vector<P>, greater<P>>Q;
	mincost[c * 2] = 0;
	Q.push(P(0,c*2));
	while (Q.size()) {
		P t = Q.top(); Q.pop();
		if (t.first > mincost[t.second])continue;
		for (P i : rinsetu[t.second]) {
			if (mincost[i.second] > mincost[t.second] + i.first) {
				mincost[i.second] = mincost[t.second] + i.first;
				Q.push(P(mincost[i.second],i.second));
			}
		}
	}
	if (mincost[c * 2 + 1] == INF)puts("-1");
	else cout << mincost[c * 2 + 1] << endl;
}

Measured memory_bytes: 81612
from sys import stdin


def main() -> None:
    n = next_int()
    l = [next_int() for _ in range(2 * n)]
    l.sort()

    ans = sum(l[::2])
    print(ans)


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)
 
function main()
    R, G, B, N = readline() |> split |> parseMap
 
    ans = 0
    for r in 0:div(N, R)
        for g in 0:div(N-R*r, G)
            if mod(N - R*r - G*g, B) == 0
                ans += 1
            end
        end
    end
 
    println(ans)
end

main()

Measured memory_bytes: 110548