akhauriyash/Code-Regression huggingface dataset:
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

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

int fact[maxn], inv[maxn];

int n, m;

int powmod(int x, int k)
{
    if(k == 0) return 1;
    int t = powmod(x, k / 2);
    if(k % 2 == 0) return t * 1LL * t % mod;
    else return t * 1LL * t % mod * x % mod;
}

void prep()
{
    fact[0] = 1;
    for(int i = 1; i < maxn; ++i)
        fact[i] = fact[i - 1] * 1LL * i % mod;
    inv[maxn - 1] = powmod(fact[maxn - 1], mod - 2);
    for(int i = maxn - 2; i >= 0; --i)
        inv[i] = inv[i + 1] * 1LL * (i + 1) % mod;
}

int C(int k, int n)
{
    return fact[n] * 1LL * inv[k] % mod * inv[n - k] % mod;
}

int add(int x, int y)
{
    x += y;
    if(x >= mod) x -= mod;
    else if(x < 0) x += mod;
    return x;
}

void read_input()
{
    cin >> n >> m;
}

void solve()
{
    int ans = fact[m] * 1LL * inv[m - n] % mod;
    ans = ans * 1LL * ans % mod;
    int temp = 0;
    for(int i = 1; i <= n; ++i)
    {
        int t = (i & 1 ? 1 : -1);
        int x = C(i, n) * 1LL * fact[m] % mod * inv[m - n] % mod * fact[m - i] % mod * inv[m - n] % mod * t;
        temp = add(temp, x);
    }
    ans = add(ans, -temp);
    cout << ans % mod << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    prep();
    read_input();
    solve();
}



Measured memory_bytes: 7540
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int s=N/1.08;
  int t=(N+1)/1.08;
  bool ans=false;
  int l=-1;
  for(int i=s;i<t+1;i++){
    int k=i*1.08;
    if(k==N){ans=true,l=i;}}
  if(ans){cout<<l<<endl;}
  else cout<<":("<<endl;
}


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

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

using namespace std;

int main (void)
{
	int n,ans = 0;
  cin >> n;
  int arr[n+1];
  for(int i = 1; i <= n; i++) cin >> arr[i];
  for(int i = 1; i <=n; i+=2)
    if(arr[i]%2) ans++;
  cout << ans << endl;
}

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


int main(){
int a, b, c;
cin >> a>> b >>c;
if ((a == b && b== c) || (a!=b&& b!=c&& a!=c)) cout << "No" ;
else cout<< "Yes";
}

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


int main(){
    ll a , v ;
    ll b, w ;
    ll t ;
    cin >> a >> v >> b >> w >> t ;
    if( b > a ){
        rep(i,t){
            a += v ;
            b += w ;
            if( a >= b ){
                cout << "YES" << endl;
                return 0 ;
            }
        }
        cout << "NO" << endl;
    }
    if( b < a ){
        rep(i,t){
            a -= v ;
            b -= w ;
            if( a <= b ){
                cout << "YES" << endl;
                return 0 ;
            }
        }
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3636
def solve():
    n = int(input())
    al = [int(i) + 1 for i in input().split()]
    amax = max(al) + 3
    ans = [0] * amax
    for i in al:
        ans[i] += 1
        ans[i-1] += 1
        ans[i+1] += 1
    print(max(ans))



if __name__=="__main__":
    solve()

Measured memory_bytes: 52908
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int k, n;

int main() {
	cin >> k >> n;
	if (k == 1) {
		REP(i, (n + 1) / 2) {
			cout << 1 << (i != (n + 1) / 2 ? " " : "");
		}
		cout << endl;
	}
	else if (k % 2 == 0) {
		cout << k / 2;
		REP(i, n - 1) {
			cout << " " << k;
		}
		cout << endl;

	}
	else {
		vector<int> v;
		REP(i, n) {
			v.emplace_back((k + 1) / 2);
		}
		REP(cnt, n / 2) {
			if (v[v.size() - 1] == 1)v.erase(v.end() - 1);
			else {
				v[v.size() - 1]--;
				while (v.size() != n) {
					v.emplace_back(k);
				}
			}
		}
		REP(i, v.size()) {
			cout << v[i] << (i != v.size() - 1 ? " " : "");
		}
		cout << endl;
	}
}

Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int GetDist(vector<int> &A, int K, int i, int j) {
  int mn = min(A[i], A[j]);
  int mx = max(A[i], A[j]);
  return min(mx - mn, K - (mx - mn));
}

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  int mx = 0;
  for (int i = 0; i < N; ++i) {
    int dist = GetDist(A, K, i, (i + 1) % N);
    mx = max(mx, dist);
  }
  cout << K - mx << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000
#define MOD 1000000009

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}


void solve(void){
   int n;
   string s;
   int k;
   cin >> n >> s >> k;
   char key = s[k-1];
   rep(i,0,n){
       if(s[i] != key){
           s[i] = '*';
       }
   }
   cout << s <<endl;

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

Measured memory_bytes: 256
x, y = list(map(int, input().split()))
ans = 0
def sign(x):
    return (x > 0) - (x < 0)
if sign(x)==sign(y):
    if x<y:
        ans = abs(x-y)
    else:
        ans = abs(x-y) + 2
elif x and y:
    if abs(x)!=abs(y):
        ans = abs(abs(x)-abs(y)) + 1
    else:
        ans = 1
else:
    if x==0:
        if sign(y)==-1:
            ans = abs(y) + 1
        elif sign(y)==1:
            ans = abs(y)
    elif y==0:
        if sign(x)==-1:
            ans = abs(x)
        elif sign(x)==1:
            ans = abs(x) + 1




print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int K = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());

		int min = X - (K-1);
		int max = X + (K-1);

		if (min < -1000000) {
			min = -1000000;
		}
		if (max > 1000000) {
			max = 1000000;
		}

		int idx;
		for (idx = min; idx <= max; idx++) {
			System.out.print(idx + " ");
		}

	}

}


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

int main() {
    int64_t a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    string ans = "NO";

    if (w >= v) {
        cout << ans << endl;
    }
    else {
        int64_t dis = abs(a - b);
        int64_t s = v - w;

        if (dis <= t * s) {
            ans = "YES";
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3528
#include <stdio.h>
int main(void){
	int a[6],i;
	for(i=0;i<6;i++){
		scanf("%d",&a[i]);
	}
	if(1000<=a[0]*1+a[1]*5+a[2]*10+a[3]*50+a[4]*100+a[5]*500)puts("1");
	else puts("0");
	return 0;
}

Measured memory_bytes: 584
from collections import Counter
def comb(a, b):
    if b > a:
        return 0
    tmp1 = 1
    tmp2 = 1
    for i in range(b):
        tmp1 *= (a-i)
        tmp2 *= (b-i)
    return tmp1//tmp2

N = int(input())
A = [int(i) for i in input().split()]
count_dict = Counter(A)
# いったん引かなかった場合の総和を計算しておいて、あとで一回分引いて足すをする
comp_sum = 0
for key in count_dict.keys():
    comp_sum += comb(count_dict[key], 2)

# 引かれるやつとそうじゃないのをそれぞれメモしとく
for i in range(N):
    print(comp_sum + comb(count_dict[A[i]]-1, 2) -  comb(count_dict[A[i]], 2))


Measured memory_bytes: 109192
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  vi b = a;
  sort(all(b));
  int ml = b[n/2 - 1], mr = b[n/2];

  rep (i,n) {
    if (a[i] <= ml) {
      cout << mr << endl;
    } else {
      cout << ml << endl;
    }
  }
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <string.h>
#define N 1000000
#define L 14
char A[N][L];
int getChar(char c);
long long getKey(char str[]);
int h1(int key){ return key%N; }
int h2(int key){ return 1+(key%(N-1)); }
int find(char str[]);
int insert(char str[]);
int main(){
  int i, n;
  char str[L], cmp[9];
  for(i = 0; i < N; i++){
    A[i][0] = '\0';
  }
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s %s", cmp, str);
    if(cmp[0] == 'i'){
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      } }
  }
  return 0; }
int getChar(char c){
  if( c == 'A') return 1;
  else if( c == 'C') return 2;
  else if( c == 'G') return 3;
  else if( c == 'T') return 4;
  else return 0;
}
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++){
    sum += p*(getChar(str[i]));
    p *= 5; }
  return sum; }
int find(char str[]){
  int i, h;
  h = (h1(getKey(str)) + i * h2(getKey(str))) % N;
  for(i = 0; i < 14; i++){
    h = (h1(getKey(str)) + i * h2(getKey(str))) % N;
    if(strcmp(A[h], str) == 0) return 1;
  }
  return 0; }
int insert(char str[]){
  int i;
  if(find(str)) return 0;
  for(i = 0; i < 14; i++){
    if(A[ (h1(getKey(str)) + i * h2(getKey(str))) % N ][0] == '\0'){
      strcpy(A[ (h1(getKey(str)) + i * h2(getKey(str))) % N ], str);
      return 1;
    } }
  return 0; }


Measured memory_bytes: 15404
ans' cnst ones =
  let d = 21 - cnst - ones
      p = min ones (d `div` 10)
  in
    if cnst + ones > 21
    then 0
    else cnst + ones + p * 10

ans x =
  let ones = length $ filter (== 1) x
      othr = filter (/= 1) x
      cnst = sum $ map (\v -> if v >= 10 then 10 else v) othr
  in
    ans' cnst ones

main = do
  c <- getContents
  let i = takeWhile (/= [0]) $ map (map read) $ map words $ lines c
      o = map ans i
  mapM_ print o

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int x=0,y=0,z=0;
  int p;
  for(int i=0;i<n;i++){
    cin >> p;
    if(p<=a) x++;
    else if(p>b) y++;
    else z++;
  }
  cout << min(x,min(y,z)) << endl;
  return 0;
}


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

#define MAX_A   (200000)


int main(void)
{
  unsigned long a[MAX_A];
  unsigned long n;
  
  unsigned long amax1, amax2;
  
  cin >> n;
  
  for( int loop = 0; loop < n; loop ++ ) {
    cin >> a[loop];
    if( amax1 <= a[loop] ) {
      amax2 = amax1;
      amax1 = a[loop];
    }
    else if( amax2 <= a[loop] ) {
      amax2 = a[loop];
    }
  }
  
  for( int loop = 0; loop < n; loop ++ ) {
    if( a[loop] != amax1 ) cout << amax1 << endl;
    else cout << amax2 << endl;
  }

  return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
int main(){

  int a,b,c,d;

  scanf("%d%d%d",&a,&b,&c);

  if ( a > b ){
    d=a;
    a=b;
    b=d;
  }
  if ( b > c ){
    d=b;
    b=c;
    c=d;
  }
  if ( a > b ){
    d=a;
    a=b;
    b=d;
    }
  printf("%d %d %d\n",a,b,c);

  return 0;

}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int di2[] = {1, 1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1};
const int dj2[] = {1, -1, 1, -1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  int ok = n-1, ng = -1;
  while(abs(ok-ng) > 1) {
    int mid = (ok+ng)/2;
    ll now = 0;
    for(int i = 0; i <= mid; ++i) now += a[i];
    bool good = true;
    for(int i = mid+1; i < n; ++i) {
      if(2*now >= a[i]) now += a[i];
      else good = false;
    }
    if(good) ok = mid;
    else ng = mid;
  }
  cout << n-ok << endl;
}

Measured memory_bytes: 4016
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>

using namespace std;

struct node
{
    int s;
    int x,y;
};

int dir[][2] = {0,1,1,0,0,-1,-1,0};
int vis[1010][1010];
int n,m,k,sx[20],sy[20];
char mp[1010][1010];

int bfs(int x,int y,int ex,int ey)
{
    queue<node> q;
    node a,b,d;
    a.x = x;
    a.y = y;
    a.s = 0;
    vis[x][y] = 1;
    q.push(a);
    while(!q.empty())
    {
        b = q.front();
        q.pop();
        if(b.x == ex && b.y == ey)
        {
            return b.s;
        }
        for(int i = 0; i < 4; i++)
        {
            d.x = b.x + dir[i][0];
            d.y = b.y + dir[i][1];
            if(d.x >= 0 && d.x < n && d.y >= 0 && d.y < m && vis[d.x][d.y] == 0)
            {
                if(mp[d.x][d.y] >= '1' && mp[d.x][d.y] <= '9' || mp[d.x][d.y] == '.')
                {
                    vis[d.x][d.y] = 1;
                    d.s = b.s + 1;
                    q.push(d);
                }
            }
        }
    }
}

int main()
{
    while(~scanf("%d%d%d",&n,&m,&k))
    {
        int i,j,t;

        for(i = 0; i < n; i++)
        {
            scanf("%s",mp[i]);
            for(j = 0; j < m; j++)
                if(mp[i][j] == 'S')
                {
                    sx[0] = i;
                    sy[0] = j;
                    mp[i][j] = '.';
                }
        }
        for(i = 0; i < n; i++)
            for(j = 0; j < m; j++)
                if(mp[i][j] >= '1' && mp[i][j] <= '9')
                {
                    sx[mp[i][j]-'0'] = i;
                    sy[mp[i][j]-'0'] = j;
                }
        int ans = 0;
        for(i = 1; i <= k; i++)
        {
            memset(vis,0,sizeof(vis));
            ans += bfs(sx[i-1],sy[i-1],sx[i],sy[i]);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 7664
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	ll memo = mypow(a, b >> 1);
	return memo * memo;
}
signed main() {
	int n, m;
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < n;) {
        int j = i;
        while (s[i] == s[j]) j++;
        ans++;
        i = j;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
q = int(input())
total = sum(a)
mem = [0]*(100000+1)
for v in a:
    mem[v] += 1
while q>0:
    b,c = map(int, input().split())
    total -= b*mem[b]
    mem[c] += mem[b]
    total += c*mem[b]
    mem[b] = 0
    print(total)
    q -= 1

Measured memory_bytes: 21112
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;
ll mod = 1e9+7;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> s(h+1, 1e9);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if (x-y+1 > 0) s[x-y+1] = min(s[x-y+1], y);
    }
    int res = h;
    for (int i = 2; i <= h; i++) {
        if (s[i] < s[i-1]) {
            res = min(res, i+s[i]-2);
        }
    }
    dump(res);
    return 0;  
}

Measured memory_bytes: 1024
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(v)";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function PriorityQueue(){
  this.heap = [];
}
PriorityQueue.prototype = {
  push : function(x){
    var i = this.heap.length++;
    while(i){
      var j = i - 1 >> 1;
      if(x >= this.heap[j])break;
      this.heap[i] = this.heap[j];
      i = j;
    }
    this.heap[i] = x;
  },
  pop : function(){
    var r = this.heap[0];
    var x = this.heap.pop();
    var i = 0;
    var k = this.heap.length >> 1;
    while (i < k) {
      var j = (i << 1) + 1;
      if(this.heap[j] > this.heap[j+1])++j;
      if(x <= this.heap[j])break;
      this.heap[i] = this.heap[j];
      i = j;
    }
    if(this.heap.length)this.heap[i] = x;
    return r;
  },
  size : function(){return this.heap.length;},
  top : function(){return this.heap[0];},
};
console.log(main());
function main(){
  var x = o.a();
  var y = o.a();
  var z = o.a();
  var K = o.a();
  var a = o.l().sort((a,b)=>b-a);
  var b = o.l().sort((a,b)=>b-a);
  var c = o.l().sort((a,b)=>b-a);
  var pq = new PriorityQueue();
  pq.heap = xArray(0,K);
  for(var i = 0, j = 2, k; i < x; i++){
    if(j === 1)break;
    for(j = 0 , k = 1; j < y; j++){
      if(k === 0)break;
      for(k = 0; k < z; k++){
        var t = a[i]+b[j]+c[k];
        if(t <= pq.top())break;
        pq.pop();
        pq.push(t);
      }
    }
  }
  var ans = [];
  while(pq.size())ans.push(pq.pop());
  return ans.reverse().join("\n");
}

Measured memory_bytes: 10940
#include<stdio.h>
int main(){
  int l,r,d,ans=0;
  scanf("%d", &l);
  scanf("%d", &r);
  scanf("%d", &d);
  for(l;l<=r;l++){
    if(l%d==0)ans++;
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 1728
// finish date: 2018/01/23
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N;
    cin >> N;
    ll S = 0;
    map<int, int> mp;
    int A;
    rep(i, N) {
        cin >> A;
        mp[A]++;
    }
    int l1 = 0, l2 = 0;
    for (auto itr = mp.rbegin(); itr != mp.rend(); itr++) {
        if(itr->second>=4){
            l1 = max(l1,itr->first);
            l2 = itr->first;
            break;
        }
        if (itr->second >= 2) {
            if (l1 == 0) l1 = itr->first;
            else {
                l2 = itr->first;
                break;
            }
        }
    }
    S = (ll) l1 * l2;
    cout << S << endl;


    return 0;
}



Measured memory_bytes: 4992
#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

using namespace std;
 
int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << min(A,B) + min(C,D) << endl;
}

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

int mesugaki(int n) {
   int a = 0;
  while( n>0){
    a += n%10;
    n /= 10;
  }
    return a;
}

int main (){
  int b,c,d;
  cin >> b >> c >>d;
  
  int e = 0;
  
  for(int i =0;i<=b;i++){
    int a = mesugaki(i);
    if(a >=c &&a<=d){
      e += i;
    }
  }
  
  cout << e << endl;
}
      
  
 


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc144c()
}

fun abc144c() {
    val n = readLine()!!.toLong()

    for (i in Math.pow(n.toDouble(), 0.5).toLong() downTo 1) {
        if (n % i == 0L) return println(i + n / i - 2)
    }
}


Measured memory_bytes: 33600
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <ctype.h>
using namespace std;
int a,b,n;
char s[101][101];
int flag[101];
int flag2[101];
int main(void)
{
    cin >> a >> b;
    for(int i = 0; i < a; i++)
    {
        for(int j = 0; j < b; j++)
        {
            cin >> s[i][j];
            if(s[i][j] == '#')flag[i]=1;
        }
    }

    for (int i = 0; i < a; i++)
    {
        for (int j = 0; j < b; j++)
        {
            if (s[i][j] == '#')flag2[j] = 1;
        }
    }

    for (int i = 0; i < a; i++)
    {
        if (flag[i] == 0)continue;

        for (int j = 0; j < b; j++)
        {
            if (flag2[j] == 0)continue;
            cout << s[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
signed main(){
    int x,y,a,b,c,A,B;
    scanf("%d %d",&x,&y);
    a=0;
    b=0;
    c=0;
    while(a<=x){
        b=x-a;
        A=a*2;
        B=b*4;
        if(A+B==y){
            c++;
        }
        a++;
    }
    if(c!=0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return(0);
}

Measured memory_bytes: 1660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1LL<<60
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;


int main() {
	
	ll n, k;
	cin >> n >> k;
	vector<ll> x(n);
	for (int i = 0; i < n; i++)cin >> x[i];
	int pl = n;
	for (int i = 0; i < n; i++) {
		if (x[i] >= 0) {
			pl = i;
			break;
		}
	}
	vector<ll> minus, plus;
	for (int i = pl-1; i >=0; i--)minus.push_back(x[i]);
	for (int i = pl; i < n; i++)plus.push_back(x[i]);


	ll ans = 10000000000;
	if (k <= minus.size()) {
		ans = min(ans, -minus[k - 1]);
	}
	if (k <= plus.size()) {
		ans = min(ans, plus[k - 1]);
	}
	for (int i = 1; i < k; i++) {
		ll minum = k - i;
		if (plus.size() < i || minus.size() < minum)continue;
		ans = min(ans, plus[i-1] - 2*minus[minum-1]);
		ans = min(ans, 2*plus[i-1] - minus[minum-1]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2424
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
MOD = 10**9+7

N,W = imn()
wv = [iln() for _ in range(N)]
max_v = 10**3*100+1

dp = [[10**10 for _ in range(max_v)] for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for sum_v in range(max_v):
        if wv[i][1] <= sum_v: 
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v-wv[i][1]]+wv[i][0])
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])
ans = 0
for v in range(max_v):
    if dp[N][v] <= W: ans = v
print(ans)

Measured memory_bytes: 181820
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int n = int.Parse(Console.ReadLine());

            while (n-- > 0)
            {
                TimeSpan input = TimeSpan.Parse(Console.ReadLine());

                int h = input.Hours;
                int m = input.Minutes;

                double s = h * 30 + m * 0.5;
                double l = m * 6;

                double dig = Math.Abs(s - l);
                if (dig > 180) dig = 360 - dig;

                if (dig < 30) sb.AppendLine("alert");
                else if (dig >= 90) sb.AppendLine("safe");
                else sb.AppendLine("warning");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 8856
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
using namespace std;
const int Maxn=100+5;
int n,a[Maxn],sum;
int main()
{
	//freopen("std.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	sort(a+1,a+n+1);
	if(!(sum%10))
	for(int i=1;i<=n;i++)
		if(a[i]%10)
		{
			sum-=a[i];
			break;
		}
	if(!(sum%10))sum=0;
	printf("%d",sum);
	return 0;
}


Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

A = iil()
A.sort()

print(A[0]+A[1]+10*A[2])

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

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

    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0,K) << "..." << endl;
    }
} 

Measured memory_bytes: 3592
//  Created by ZJYelizaveta on Monday, September 18, 2017 AM10:07:55 CST
//  Copyright (c) 2017年 ZJYelizaveta. All rights reserved.

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
template<typename T> T readIn() {
	T x(0), f(1);
	char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}
const int MAX_N = 300 + 3;
const int INF = 0x3f3f3f3f;
int n;
ll a[MAX_N][MAX_N], dis[MAX_N][MAX_N];
ll ans;

int main()
{
	n = readIn<int>();
	for (register int i = 1; i <= n; ++i) {
		for (register int j = 1; j <= n; ++j) {
			ll w = readIn<ll>();
			a[i][j] = dis[i][j] = a[j][i] = dis[j][i] = w;
		}
	}

	ans = 0;
	for (register int k = 1; k <= n; ++k) {
		for (register int i = 1; i <= n; ++i) {
			for (register int j = 1; j <= n; ++j) {
				if (a[i][j] > a[i][k] + a[k][j]) {
					ans = -1;
					break;
				}
				if (a[i][j] == a[i][k] + a[k][j]) { //
					if (dis[i][k] != 0 && dis[k][j] != 0) dis[i][j] = 0;
				}
			}
		}
	}
	if (ans != -1) {
		ans = 0;
		for (register int i = 1; i < n; ++i) {
			for (register int j = i + 1; j <= n; ++j) {
				ans += dis[i][j];
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1664
while line = gets
  h, w = line.chomp.split(" ").map(&:to_i)
  break if h == 0 && w == 0
  if w.odd?
    str1 = '#.' * ((w - 1)/2) + '#'
    str2 = '.#' * ((w - 1)/2) + '.'
  else
    str1 = '#.' * (w / 2)
    str2 = str1.reverse
  end
  (1..h).each do |hh|
    if hh.odd?
      puts str1
    else
      puts str2
    end
  end
  puts
end

Measured memory_bytes: 6112
#include<iostream>
using namespace std;
int main(){
    int a,b;
    while(cin >> a >> b){
        if(a == 0&&b == 0)break;
        for(int i = 0;i < a;i++){
            for(int j = 0;j < b;j++){
                if((i + j) % 2 == 0){
                    cout << "#";
                }    
                else{
                    cout << ".";
                }
            }
        cout << endl;
        }
    cout << endl;
    }
}


Measured memory_bytes: 3088
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

D, N = ISI()
num = 100 ** D
if N < 100:
    print(num*N)
else:
    print(num*101)

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

int main()
{
    char c;
    cin >> c;

    string vowel = "aeiou";

    bool is_vowel = false;
    for (int i = 0; i < 5; i++)
    {
        char v = vowel.at(i);
        if (c == v)
        {
            is_vowel = true;
            break;
        }
    }
    if (is_vowel)
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;
int n,a[200005];
ull ans=0;
ull go(ull t){return t*(t+1)>>1;}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int i=0,j=0,xorm=a[0],sum=a[0];
	while(i<n)
	{
		while(j<n&&xorm==sum)
		j++,sum+=a[j],xorm^=a[j];
//		cout<<'\t'<<i<<' '<<j<<' '<<sum<<' '<<xorm<<endl;
		ans+=j-i;
		sum-=a[i];
		xorm^=a[i];
		i++;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long double w,h,x,y; cin>>w>>h>>x>>y;
    printf("%llf ",w*h/2.0 );
    //cout<<w*h/2<<endl;
    if(w/2 == x&& h/2 == y) cout<<1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;

int dp[10005];
int N,W;

signed main(){
    memset(dp,0,sizeof(dp));
    cin>>N>>W;
    for(int i=1;i<=N;++i){
        int v,w;
        cin>>v>>w;
        for(int j=W;j>=0;--j){
            if(j<w)continue;
            dp[j]=max(dp[j-w]+v,dp[j]);
        }
    }
    cout<<dp[W]<<endl;
}

Measured memory_bytes: 1244
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18
const long MOD = 998244353;



const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long power(long a, long b, long MOD){
	if(b == 0){
		return 1l;
	}else if(b % 2 == 1){
		return a * power(a, b-1, MOD) % MOD;
	}else{
		long r = power(a, b/2, MOD);
		return r * r % MOD;
	}
}

long n,m,k;

int main(){
    scanf("%ld%ld%ld", &n,&m, &k);
    COMinit();
    long ans = 0;
    for(long i = 0; i <= k; i++){
    //    printf("%ld\n", i);
        long res = COM(n-1, i) * m % MOD * power(m-1, n-i-1, MOD) % MOD;
        ans += res;
        ans %= MOD;
    }
    printf("%ld\n",ans);
}


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

//cmdで g++ test.cpp とするとコンパイルできる

#define MOD 1000000007
typedef pair<int,int> pii;

int main() {
    int N;
    cin>>N;
    vector<int> X(N);
    for(int i=0;i<N;i++){
        cin>>X.at(i);
    }
    int ans=MOD;
    for(int p=1;p<=100;p++){
        int sum=0;
        for(int i=0;i<N;i++){
            int d=X.at(i)-p;
            sum+=d*d;
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FASTNIBBA   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define lbnd        lower_bound
#define ubnd        upper_bound
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl        '\n'
ll dp[100005][105];
void solve()
{
   int n,w; cin>>n>>w;
   int wt[n],v[n];
   rep(i,0,n) cin>>wt[i]>>v[i];
   rep(i,0,w+1)
   {
     rep(j,0,n+1)
     {
       if(i==0 || j==0) dp[i][j]=0;
       else{
        if(i>=wt[j-1]) dp[i][j]=max(dp[i-wt[j-1]][j-1]+v[j-1],dp[i][j-1]);
        else dp[i][j]=dp[i][j-1];
       }
     }
   }
   cout<<dp[w][n];
}
int main()
{
    FASTNIBBA;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 82304
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

#define endl "\n"
#define PRIME 1000000007

#define int long long

#define f(i,a,n) for(int i = a; i < n; i++)
#define fs(i,a,n,k) for(int i = a; i < n; i+=k)

#define fr(i,a,n) for(int i = n; i > a; i--)
#define frs(i,a,n,k) for(int i=n; i>a; i-=k)

#define out1(a) cout << a << endl
#define out2(a,b) cout << a << " " << b << endl
#define out3(a,b,c) cout << a << " " << b << " " << c << endl


signed main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    //enable fast I/O
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    int a=0, w=0, t=0, r=0;
    string s;

    f(i, 0, n){
        cin >> s;

        if(s == "AC")   a++;
        else if(s == "WA")  w++;
        else if(s == "TLE") t++;
        else if(s == "RE")   r++;
    }

    out3("AC", "x", a);
    out3("WA", "x", w);
    out3("TLE", "x", t);
    out3("RE", "x", r);

    return 0;
}

Measured memory_bytes: 3672
s = int(input())
new = s%10
output = 'abc'
if new == 2 or new ==4 or new ==5 or  new ==7 or new ==9:
    output = 'hon'
elif new == 0 or new == 1 or new == 6 or new == 8:
    output = 'pon'
elif new == 3:
    output = 'bon'

print(output)



Measured memory_bytes: 9152
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (A, B): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    fn gcd(a: i64, b: i64) -> i64 { if b == 0 { a } else { gcd(b, a % b) } }

    let ans = A / gcd(A, B) * B;

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

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sz(a) int((a).size())
#define all(c) c.begin,c.end()
#define tr(c,i) for(typeof(c).begin() i=c.begin; i!=c.end(); i++)
#define present(c,x) (c.find(x)!=c.end())
#define cpresent(c,x) (find(all(c),x)!=c.end())
#define pb push_back
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

void solve(){
    int s,w;
    cin>>s>>w;
    if(s<=w) cout<<"unsafe";
    else cout<<"safe";
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

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

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

int main() {
  vector<int> ans;
  int coin[6] = {500, 100, 50, 10, 5, 1};
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;

    int oturi = 1000 - n;
    int res = 0;
    rep(i,6) {
      if (oturi == 0) break;
      if (oturi < coin[i]) continue;
      res += oturi / coin[i];
      oturi = oturi % coin[i];
    }
    ans.push_back(res);
  }
  rep(i,ans.size()) cout << ans[i] << endl;
  return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
const int N = 51;
const int max_dis= 2500;
const int inf = 0x3f3f3f3f;
typedef pair<ll, pair<int,int>> lll;
vector<pair<int, pair<int, int> > > G[N];
vector<int> C, D;
vector<vector<ll> > dp(N, vector<ll>(max_dis+1, 0));

void dijkstra(int S){
    fill(dp.begin(), dp.end(), vector<ll>(max_dis, 1e18));
    S=min(S,max_dis);
    dp[0][S]=0;
    priority_queue<lll, vector<lll>, greater<lll> > que;
    que.push({0, {0, S}});
    while (!que.empty()) {
        auto tmp = que.top();
        que.pop();
        int nowpos = tmp.second.first;
        int nows = tmp.second.second;
        ll nowcost = tmp.first;
        for(auto i:G[nowpos]) {
            int to = i.first;
            ll newcost = nowcost + i.second.second;
            int news = nows - i.second.first;
            if (news >= 0) {
                if(dp[to][news]>newcost) {
                    dp[to][news]=newcost;
                    que.push({newcost,{to, news}});
                }
            }
        }
        ll newcost = nowcost+D[nowpos];
        int news = nows + C[nowpos];
        news = min(news, max_dis);
        if(dp[nowpos][news]>newcost) dp[nowpos][news] = newcost, que.push({newcost, {nowpos, news}});

    }
}


int main(){
    int n,m, S;
    cin>>n>>m>>S;
    for (int i = 0; i < m; i++) {
        int u,v , a, b;
        cin>>u>>v>>a>>b;
        --u, --v;
        G[u].push_back({v, {a, b}});
        swap(u, v);
        G[u].push_back({v, {a, b}});
    }
    for (int i = 0; i < n; i++) {
        int c, d;
        cin>>c>>d;
        C.push_back(c);
        D.push_back(d);
    }
    dijkstra(S);
    for (int i = 1; i < n; i++) {
        ll ans = 1e18;
        for(int j = 0; j<max_dis;j++){
            if(dp[i][j]<ans){
                ans = dp[i][j];
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 5824
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

bool cmp(const pair<long,long> &a, const pair<long,long> &b){
  return a.second < b.second;
}

int main(void) {
  long ta, tb, n;
  vector<pair<long,long>> v;
  long time;
  bool b = true;
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    pair<long,long> tmp;
    cin >> tmp.first >> tmp.second;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end(), cmp);
  time = 0;
  for (vector<pair<long,long>>::iterator itr = v.begin(); itr != v.end(); itr++) {
    //cout << itr->first << ", " << itr->second << endl;
    time += itr->first;
    if (time > itr->second) {
      b = false;
      break;
    }
  }
  cout << (b ? "Yes" : "No") << endl;
  return 0;
}
  

Measured memory_bytes: 6384