akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

ll n,k;
vll a;
ll s=0; 

void solve(){
 cin >> n >> k;
 a.resize(n);
 rep(i,0,n) {
   cin >> a[i];
   s+=a[i];
 }
 vll div; 
 for(ll i=1;i*i<=s;i++){
  if(s%i==0){
    div.eb(i);
    if(i!=s/i) div.eb(s/i);
  }
 }
 sort(all(div));
  
  ll res=0;
  for(ll d:div){
   vll r(n);
   ll tot=0;
    rep(i,0,n) {
      r[i]=a[i]%d;
      tot+=r[i];
    }
   sort(all(r));
   ll need=0; 
   rep(i,0,n-tot/d) need+=r[i];
   if(need<=k) chmax(res,d);
  }
  cout << res << endl;
}

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

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

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

    bitset<64> mask[n];
    for(int i = 0; i < n; i++){
        int k, b;
        cin >> k;
        while(k-- > 0){
            cin >> b;
            mask[i].set(b);
        }
    }

    bitset<64> bs;
    int q, op, m;

    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> op >> m;
        if(op == 0) cout << bs[m] << endl;
        if(op == 1) bs |= mask[m];
        if(op == 2) bs &= ~mask[m];
        if(op == 3) bs ^= mask[m];
        if(op == 4) cout << ((bs&mask[m]) == mask[m]) << endl;
        if(op == 5) cout << (bs&mask[m]).any() << endl;
        if(op == 6) cout << (bs&mask[m]).none() << endl;
        if(op == 7) cout << (bs&mask[m]).count() << endl;
        if(op == 8) cout << (bs&mask[m]).to_ullong() << endl;        
    }
}


Measured memory_bytes: 3108
#include<iostream>
#include<cmath>
using namespace std;
int a[100000],b[100000];
int main()
{
	long long a1=0,b1=0,e1=0,e2=0,c;
	cin>>c;
	for(int n=1;n<=c;n++)
	{
		cin>>a[n];
		a1+=a[n];
	}
	for(int n=1;n<=c;n++)
	{
		cin>>b[n];
		b1+=b[n];
	}
	int d=a1-b1;
	for(int n=1;n<=c;n++)
	{
		if(a[n]<b[n])
		{
			e1+=(b[n]-a[n]+1)/2;
		}
	}
	e2=b1-a1;
	if(e1>e2)
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

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

void output(int A[], int N, int W){
    
    for (int i=0; i<N; i++){
        if (i==N-1)
        {
            cout << A[i] << endl;
            cout << W << endl;
        }
        else
        {
            cout << A[i] << flush;
            cout << " " << flush;
        }
    }
}

int serch(int A[],int N,int X){
    
    int MIN,minj;
    
    MIN=A[X];
    minj=X;
    
    for (int j=X; j<N; j++){
        if (A[j]<MIN){
            MIN=A[j];
            minj=j;
        }
    }
    return minj;
}

int selection(int A[],int N){
    
    int minj,W,X;
    
    W=0;
    for (int i=0; i<N-1; i++){
         X=i;
         minj=serch(A, N, X);
         if (A[minj]<A[i]){
             swap(A[minj], A[i]);
             W++;
         }
    }
    return W;
}

int main() {
    
    int N,W;
    int A[100];
    
    cin >> N;
    
    for (int i=0; i<N; i++){
        cin >> A[i];
    }
    
    W=selection(A, N);
    output(A, N, W);
    
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b;cin>>a>>b;
  if(a==b)cout<<0;
  else
    {
    long long c=a+b;
    if(c%2ll!=0)cout<<"IMPOSSIBLE";
    else cout<<c/2ll;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double i,j,n,a,b,h,m;
double r,an,z,y;
double pi=3.141592653589793238;
string s,t;
int main(){
  cin>>a>>b>>h>>m;
  z=h*30+m*1/2;
  y=m*6;
  an=abs(z-y);
  an=min(an,360-an);
  double x=cos(an*pi/180.0);
  r=a*a+b*b-2*a*b*x;r=sqrt(r);
  printf("%.12lf",r);
}

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

using namespace std;

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

const int MAXN = 4005;
const int MAXM = 400005;

struct Edge {
    int u, v, w;

    bool inline operator < (const Edge &rhs) const {
        return w < rhs.w;
    }
};

class DSU {
private:
    vector<int> pset;

public:
    DSU(int n) {
        pset.resize(n);
        for(int i = 0; i < n; ++i)
            pset[i] = i;
    }

    int findSet(int i) {
        return (pset[i] == i) ? i : (pset[i] = findSet(pset[i]));
    }

    bool unionSet(int i, int j) {
        int p = findSet(i), q = findSet(j);
        if (p == q)
            return false;

        pset[p] = q;
        return true;
    }
};

int n, m, q, maxW[MAXN][MAXN], root;
Edge e[MAXM];
vector<int> g[MAXN];

void DFS(int u, int par) {
    for(int i: g[u]) {
        int v = e[i].u + e[i].v - u;
        if (v == par)
            continue;

        maxW[root][v] = max(maxW[root][u], e[i].w);
        DFS(v, u);
    }
}

int main () {
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; ++i) {
        scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].w);
        --e[i].u;
        --e[i].v;
    }

    sort(e, e+m);
    DSU s(n);

    ll mstWeight = 0;
    for(int i = 0; i < m; ++i) {
        int u = e[i].u, v = e[i].v;
        if (s.unionSet(u, v)) {
            g[u].push_back(i);
            g[v].push_back(i);
            mstWeight += e[i].w;
        }
    }

    for(int u = 0; u < n; ++u) {
        root = u;
        DFS(u, -1);
    }

    scanf("%d", &q);
    for(int i = 0; i < q; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        --u; --v;

        ll ans = mstWeight - maxW[u][v];
        printf("%lld\n", ans);
    }

    return 0;
}


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

using PP = pair<long, long>;

long sub(long n) {
  long k = n / 4 * 4;
  long sum = 0;
  for (long i = k; i < n; ++i) {
    sum ^= i;
  }
  return sum;
}

int main() {
  long a, b;
  cin >> a >> b;
  cout << (sub(b + 1) ^ sub(a)) << endl;
}

Measured memory_bytes: 256
from collections import Counter

if __name__ == '__main__':
    h, w = map(int, input().split())
    counts = Counter(''.join(input() for _ in range(h))).values()
    c1, c2 = 0, 0
    for x in counts:
        if x % 2:
            c1 += 1
            x -= 1
        if x % 4:
            c2 += 1
    if c1 == 1 and (h * w) & 1 == 0 or c1 > 1:
        print('No')
        quit(0)
    lim2 = 0
    if h & 1:
        lim2 += w // 2
    if w & 1:
        lim2 += h // 2
    if lim2 >= c2:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define INF 1e9
using ll = int64_t;
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

#define MAX_NUM 1000000
ll n;

void Main() {
  //自動整形防止用コメント
  std::cin >> n;
  std::cout << n * (n - 1) / 2 << '\n';

  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

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

  int ans = -1;
  for(int i = 10000; i >= 0; i--){
    int t_8 = i * 8 / 100, t_10 = i / 10;
    if(t_8 == A && t_10 == B){
      ans = i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long int
ll a[1000000+9]= {0};
using namespace std;
int main ()
{
    ll i,j,p;
    ll s;
    for(i=0; i<3; i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    sort(a,a+3);
    s = 2*a[2];
    s-=a[0];
    s-=a[1];
    if (s%2==0)
    {
        p=0;
    }
    else
    {
        p=2;
    }
    p+=(s/2);
    cout<<p<<endl;
    return 0;
}


Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    
    if op == '?':
        break
        
        
    if op == '+':
        print(a + b)
        
    if op == '-':
        print(a - b)
        
    if op == '*':
        print(a * b)
        
    if op == '/':
        print(a // b)

    

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

int main() {
  int n, cnt = 0;
  while(cin >> n, n) {
    if(cnt++ != 0) cout << endl;
    vector<pair<string, int>> p(n);
    for(int i = 0; i < n; i++) {
      string s;
      int w, l, d;
      cin >> s >> w >> l >> d;
      p[i].first = s, p[i].second = w*3 + d;
    }

    for(int i = 0; i < n; i++) {
      int max = 0;
      for(int j = 0; j < n; j++) {
	if(p[j].second > max) max = p[j].second;
      }

      for(int j = 0; j < n; j++) {
	if(p[j].second == max) {
	  cout << p[j].first << ',' << p[j].second << endl;
	  p[j].second = -1;
	}
      }
    }
  }
}

Measured memory_bytes: 1216
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n, l int
	var s []string
	var tempStr string

	fmt.Scan(&n, &l)
	for i := 0; i < n; i++ {
		fmt.Scan(&tempStr)
		s = append(s, tempStr)
	}
	sort.Strings(s)
	fmt.Println(strings.Join(s, ""))
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N,T;
  cin>>N>>T;
  //cout<<N<<T<<endl;
  int MIN=1000;
  string X="TLE";
  bool b=false;
  vector <int> sc(N);
  vector <int> st(N);
  for (int i=0;i<N;i++) {
    cin>>sc[i]>>st[i];
    if (st[i]<=T) {
      b=true;
      if(sc[i]<MIN) {
        MIN = sc[i];
      }
    }
  }
  if (b) {
    cout<<MIN<<endl;
  }
  else {
    cout<<"TLE"<<endl;
  }
}
    

Measured memory_bytes: 256
module ABC130

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_A
  private :: calculate_answer

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A

    ! variables for this <subroutine>
    integer(INT8) :: X, A

    ! STEP.01
    ! read out the given integer
    read(unit=INPUT_UNIT, fmt=*) X, A

    ! STEP.02
    ! output the result
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') calculate_answer (X, A)

    ! STEP.END
    return

  end subroutine task_A

  pure function calculate_answer (data_X, data_A) result(answer)

    ! arguments for this <function>
    integer(INT8), intent(in) :: data_X, data_A

    ! return value of this <function>
    integer(INT8) :: answer

    if (data_X .lt. data_A) then
      answer = 0_INT8
    else
      answer = 10_INT8
    end if

    return

  end function calculate_answer

end module ABC130


program main

  ! <module>s to import
  use, non_intrinsic :: ABC130

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pa;

#define fst first
#define snd second
#define pb push_back

const int maxn=1000005,maxm=306;
const double pi=acos(-1.0);
const ll mod=1000000007;
const double eps=1e-8;

int cal(int x)
{
    int i,j=0;
    for(i=1;;i++)
    {
        if(i*(i+1)/2<=x) j=i;
        else return j;
    }
}

ll n;
int ans=0;

int main()
{
	int i,j;
	scanf("%lld",&n);
	for(i=2;i*1LL*i<=n;i++)
    {
        if(n%i!=0) continue;
        int cnt=0;
        while(n%i==0) ++cnt,n/=i;
        ans+=cal(cnt);
    }
    if(n>1) ++ans;
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
     
int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    string s1,s2;
    cin >> s1 >> s2;
    if(sz(s1) == sz(s2)){
         if(s1 < s2 ){
             cout <<"LESS";
         }else if(s1 > s2){
             cout << "GREATER";
         }else{
             cout <<"EQUAL";
        }
    }else if(sz(s1) > sz(s2)){
        cout << "GREATER";
    }else{
        cout << "LESS";
    }
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l_lst=[]
r_lst=[]
for i in range(m):
    l,r=map(int,input().split())
    l_lst.append(l)
    r_lst.append(r)
l=max(l_lst)
r=min(r_lst)
if l<=r:
    print(r-l+1)
else:
    print(0)

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


int main() {
	
	string s;
	string t;
	cin >> s >> t;
	string ss = s, tt = t;
	swap(s[0], s[2]);
	swap(t[0], t[2]);
	swap(s, t);
	if (s == ss && t == tt) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}
}

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

int main(int argc, char *argv[])
{
    bool seiv[1000*1000 * 2] = {};

    int n, m, k;
    cin >> n >> m >> k;

    //cout <<"n = " << n << ", m = " << m << endl;
    for(int i = 0; i <= m; ++i)
    {
        seiv[i*n] = true;
        int x = i*n;
        //cout << "i = " << i << endl;
        for(int j = 0; j < n; ++j)
        {
            x -= i;
            x += (m - i);
            if(x > 0)
                seiv[x] = true;
        }
    }

    //for(int i = 0; i < (m*n) + 1; ++i)
    //{
    //    cout << i << ": " << seiv[i] << endl;
    //}
    //cout << endl;

    cout << (seiv[k] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 100005;

int p[N];

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
   
    int n;
    cin >> n;
    FOR(i,1,n){
        cin >> p[i];
    }
    int cnt = 0;
    FOR(i,1,n-1){
        if(p[i] == i){
            swap(p[i], p[i+1]);
            cnt++;
        }
    }
    if(p[n] == n){
        swap(p[1], p[n]);
        cnt++;
    }
    cout << cnt;
    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//abc123d cake
//1,2,3のケーキをそれぞれ降順ソート
//3つを比較して最も大きいものの次を参照
// Kのmaxが3000だから
//X,Y,Zの使わない下半分くらいは取り除いていい?
//abc > K


int main(){
    int x,y,z,k;
    cin >> x >> y >> z >> k;

    vector <ll> a(x);
    vector <ll> b(y);
    vector <ll> c(z);
    REP(i,x)
    {
        cin >> a[i];
    }
    REP(i,y)
    {
        cin >> b[i];
    }
    REP(i,z)
    {
        cin >> c[i];
    }

    sort(a.begin(),a.end(),greater<ll>());
    sort(b.begin(),b.end(),greater<ll>());
    sort(c.begin(),c.end(),greater<ll>());

    vector <ll> vec;

    REP(i,x)
    {
        REP(j,y)
        {
            REP(t,z)
            {
                if((i+1) * (j+1) * (t+1) <= k)
                {
                    vec.push_back(a[i] + b[j] + c[t]);
                }
                else
                {
                    break;
                }
            }
        }
    }

    sort(vec.begin(),vec.end(),greater<ll>());

    for(int i = 0; i < k; ++i)
    {
        cout << vec[i] << endl;
    }

    return 0;    
}



Measured memory_bytes: 1404
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        c: String,
    }
    match c.chars().nth(0).unwrap() {
        'a' | 'i' | 'u' | 'e' | 'o' => println!("vowel"),
        _ => println!("consonant"),
    };
} 


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
int main() {
  int n;
  int i;
  int flag = 1;

  scanf ("%d\n", &n);

  char s[n];
  scanf ("%s", s);

  if (n % 2 != 0) flag = 0;

  for (i = 0; i < n / 2; i++) {
    if (s[i] != s[n / 2 + i]) flag = 0;
  }

  if (flag == 1) printf ("Yes\n");
  else printf ("No\n");

  return 0;
}


Measured memory_bytes: 128
program fifty_fifty
    implicit none
    integer(4):: i,ai,alphabet_counts(26) = 0, count
    character(4):: s

    read*, s

    do i=1,4
        ai=ichar(s(i:i))-64
        alphabet_counts(ai)=alphabet_counts(ai)+1
    end do

    do i=1,26
        count = alphabet_counts(i)
        if (count /= 2 .and. count/= 0) then
            print*, 'No'
            stop
        end if
    end do

    print*, 'Yes'
end program fifty_fifty

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

int main()
{
    int N, M;
    cin >> N >> M;
    string t;
    if(N == 1)
        t = "0";
    else
        t = "1";


    for(int i = 1;i < N;i++)
        t = t + "0";


    map<string,int> r;
    int s,c;
    bool can = true;
    for(int i = 0;i < M;i++)
    {
        cin >> s >> c;
        t[s - 1] = '0' + c;
        if(r.count(to_string(s)) == 0)
        {
            r.insert(make_pair(to_string(s),c));
        }
        else
        {
            if(r[to_string(s)] != c)
                can  = false;
        }
    }
    if(t[0] == '0' && N != 1)
        can = false;
    cout << (can ? t : "-1") << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include<bits/stdc++.h> 
#include <algorithm>
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<pair<string,int>,int> iii;

bool criterio(iii a, iii b){
    if(a.f.f<b.f.f) return true;
    if(b.f.f<a.f.f) return false;
    return a.f.s>b.f.s;
}

int main(){
    ofstream out("output.txt");
    
    
    int n,p;
    string s;
    cin>>n;

    vector<iii> restaurants;

    for(int i = 1; i<=n; i++){
        cin>>s>>p;
        restaurants.pb({{s,p},i});
    }   
    sort(restaurants.begin(),restaurants.end(),criterio);
    for(int i = 0; i<n; i++){
        cout<<restaurants[i].s<<endl;
        //cout<<restaurants[i].f.f<<" "<<restaurants[i].f.s<<endl<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
    int N,Y;
    cin>>N>>Y;
    int x,y,z;
    x=y=z=-1;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            for(int k=0;k<=N-i-j;k++){
                if(10000*i+5000*j+1000*k==Y&&N==i+j+k){
                x=i;
                y=j;
                z=k;
                break;
            }
            }
        }
    }
     cout<<x<<" "<<y<<" "<<z<<endl;
     return 0;
}

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

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

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

  ll x2 = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      x2 += a[i];
    } else {
      x2 -= a[i];
    }
  }

  vector<int> ans(n);
  ans[0] = x2 / 2;
  for (int i = 0; i < n - 1; i++) {
    ans[i + 1] = a[i] - ans[i];
  }
  for (int i = 0; i < n; i++) {
    ans[i] *= 2;
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 2176
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    A.sort(reverse=True)

    print(sum(A[::2]) - sum(A[1::2]))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	double a_d,b_d;
	scanf("%d %d",&a,&b);
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}



Measured memory_bytes: 2732
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define maxn 100001
#define pb push_back
using namespace std;
void solve(){
    ll n,k,mi;
    cin>>n>>k;
    ll a[n],dp[n]={};
    for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=1;i<=n;i++){
        dp[i]=dp[i-1]+abs(a[i-1]-a[i]);
        for(ll j=2;j<=min(k,i);j++){
            dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
        }
    }
    cout<<dp[n-1];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


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




int N, W;
int v[101], w[101], m[101];
int dp[2010][10101];
//-----------------------------------------------------------------------------------
int main() {
    cin >> N >> W;
    rep(i, 0, N) cin >> v[i] >> w[i] >> m[i];

    vector<pair<int, int>> items;
    rep(i, 0, N) {
        for (int j = 1; j <= m[i]; j *= 2) {
            int sm = j - 1;
            int mm = min(m[i] - sm, j);
            items.push_back({ v[i] * mm, w[i] * mm });
            if (m[i] - sm < j) break;
        }
    }

    int n = items.size();
    rep(i, 0, n) rep(j, 0, W + 1) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        if (j + items[i].second <= W)
            dp[i + 1][j + items[i].second] = max(dp[i + 1][j + items[i].second], dp[i][j] + items[i].first);
    }

    int ans = 0;
    rep(j, 0, W + 1) ans = max(ans, dp[n][j]);
    cout << ans << endl;
}

Measured memory_bytes: 58360
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define SIZE -1

int main() {
   string str;
   cin >> str;
   if (str.length() < 4) cout << "No" << endl;
   else if (str.substr(0, 4) == "YAKI") cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "5 2" ].parse.expand.solve == 7 );
	assert( [ "10 0" ].parse.expand.solve == 100 );
	assert( [ "31415 9265" ].parse.expand.solve == 287927211 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	if( k == 0 ) return n ^^ 2;
	
	n++;		// 半開区間のほうがやりやすい
	auto ans = 0L;
	for( auto b = k + 1; b < n; b++ )
	{
		// ( 0 <= a < n - n % b ) かつ ( k <= a % b ) が当てはまる a の数を計算
		ans += n / b * ( b - k );
		
		// ( n - n % b <= a < n ) かつ ( k <= a % b ) が当てはまる a の数を計算
		ans += max( 0L, n % b - k );
	}
	return ans;
}


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

namespace ABC138_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(1 / (A.Select(x => 1.0 / x).Sum()));
        }
    }
}


Measured memory_bytes: 13396
N = int(input())
s = input()

sl = list(s)

def calc(i, resl):
  now = resl[i]
  back = resl[i-1]

  if now == 'W':
    if back == 'W':
      if sl[i] == 'o':
        resl[i+1] = 'S'
      else:
        resl[i+1] = 'W'
    else:
      if sl[i] == 'o':
        resl[i+1] = 'W'
      else:
        resl[i+1] = 'S'
  else: # 'S'
    if back == 'W':
      if sl[i] == 'o':
        resl[i+1] = 'W'
      else:
        resl[i+1] = 'S'
    else:
      if sl[i] == 'o':
        resl[i+1] = 'S'
      else:
        resl[i+1] = 'W'

def test2(resl):
  i = 0
  now = resl[0]
  back = resl[-1]
  
  if now == 'W':
    if back == 'W':
      if sl[i] == 'o':
        return resl[1] == 'S' and test2
      else:
        return resl[1] == 'W' and test2
    else:
      if sl[i] == 'o':
        return resl[1] == 'W' and test2
      else:
        return resl[1] == 'S' and test2
  else: # 'S'
    if back == 'W':
      if sl[i] == 'o':
        return resl[1] == 'W' and test2
      else:
        return resl[1] == 'S' and test2
    else:
      if sl[i] == 'o':
        return resl[1] == 'S' and test2
      else:
        return resl[1] == 'W' and test2


def test(resl):
  i = N-1
  now = resl[-1]
  back = resl[-2]
  
  if now == 'W':
    if back == 'W':
      if sl[i] == 'o':
        return resl[0] == 'S' and test2(resl)
      else:
        return resl[0] == 'W' and test2(resl)
    else:
      if sl[i] == 'o':
        return resl[0] == 'W' and test2(resl)
      else:
        return resl[0] == 'S' and test2(resl)
  else: # 'S'
    if back == 'W':
      if sl[i] == 'o':
        return resl[0] == 'W' and test2(resl)
      else:
        return resl[0] == 'S' and test2(resl)
    else:
      if sl[i] == 'o':
        return resl[0] == 'S' and test2(resl)
      else:
        return resl[0] == 'W' and test2(resl)


def printer(resl):
  print("".join(resl))

def check(resl):
  for i in range(1, N-1):
    calc(i, resl)
  return test(resl)

resl = [""]*N
(resl[0], resl[1]) = ('W', 'W')
if check(resl):
  printer(resl)
else:
  resl = [""]*N
  (resl[0], resl[1]) = ('W', 'S')
  if check(resl):
    printer(resl)
  else:
    resl = [""]*N
    (resl[0], resl[1]) = ('S', 'W')
    if check(resl):
      printer(resl)
    else:
      resl = [""]*N
      (resl[0], resl[1]) = ('S', 'S')
      if check(resl):
        printer(resl)
      else:
        print(-1)


Measured memory_bytes: 52276
#include <iostream>
  
using namespace std;
  
int main()
{
 int n;
 int rank;
 char suit;
 int s[14], h[14], c[14], d[14];
 for (int i = 0; i < 14; i++)
 {
  s[i] = h[i] = c[i] = d[i] = 0;
 }
 cin >> n;
 
 for (int i = 0; i < n; i++)
 {
  cin >> suit;
  cin >> rank;
  switch(suit)
  {
   case 'S':
    s[rank] = 1;
    break;
   case 'H':
    h[rank] = 1;
    break;
   case 'C':
    c[rank] = 1;
    break;
   case 'D':
    d[rank] = 1;
    break;
   default:
    break;
  }
 }
 for (int i = 1; i <= 13; i++)
 {
  if (s[i] != 1)
  {
   cout << "S " << i << endl;
  }
 }
 for (int i = 1; i <= 13; i++)
 {
  if (h[i] != 1)
  {
   cout << "H " << i << endl;
  }
 }
 for (int i = 1; i <= 13; i++)
 {
  if (c[i] != 1)
  {
   cout << "C " << i << endl;
  }
 }
 for (int i = 1; i <= 13; i++)
 {
  if (d[i] != 1)
  {
   cout << "D " << i << endl;
  }
 }
}


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

int main(){
	long long X;
	cin >> X;
	long long A,B;
	long long A5,B5;
	int tr=0;
	for(A=0;A<1001;A++){
		A5=A*A*A*A*A;
		for(B=-1000;B<1001;B++){
			B5=B*B*B*B*B;
			if(A5-B5==X){
				tr=1;
				break;
			}else if(A5-B5<X){
				break;
			}
		}
		if(tr)break;
	}
	cout << A << " " << B << endl;
	return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a, b; cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		cin >> a >> b;
		cout << a + b << endl;
	}
	cin >> n;
}

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

int main() {
	int H, W;

	cin >> H >> W;

	while(!(H == 0 && W == 0)) {
		for (int h = 0; h < H; h++) {
			if (h == 0 || h == H - 1) {
				for (int w = 0; w < W; w++) {
					cout << '#';
				}
			}
			else{
				for (int w = 0; w < W; w++) {
					if (w == 0 || w == W - 1) cout << '#';
					else cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}

	return 0;
}



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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	ll n, r;
	cin >> n >> r;

	if ( n >= 10 ) {
		cout << r << endl;
	}
	else {
		cout << (r + 100 * (10 - n)) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read()
{
	ll num=0;
	bool b=false;
	int c=getchar();
	while (c==' ' || c=='\n') c=getchar();
	if (c=='-') {b=true; c=getchar();}
	while (c>='0' && c<='9')
	{
		num=(num<<1)+(num<<3)+c-'0';
		c=getchar();
	}
	if (b) return(0-num);
	else return(num);
}
ll n,a[200010],b[200010],ans,p,l,r;
int main()
{
	n=read();
	p=n%2==1?1:2;
	for (int i=1;i<=n;++i)
	{
		a[i]=read()*p; b[i]=read()*p;
	}
	sort(a+1,a+1+n); sort(b+1,b+1+n);
	if (p==1)
	{
		l=a[n/2+1];
		r=b[n/2+1];
	}
	else
	{
		l=(a[n/2]+a[n/2+1])/2;
		r=(b[n/2]+b[n/2+1])/2;
	}
	ans=r-l+1;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 6868
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    for i in range(n):
        b = int(input())
        for j in range(3):
            for k in range(3):
                if b == a[j][k]:
                    a[j][k] = 0
    ans = 1
    for i in range(3):
        ans = 1
        for j in range(3):
            if a[i][j]:
                ans = 0
                break
        if ans:
            print("Yes")
            return
    for j in range(3):
        ans = 1
        for i in range(3):
            if a[i][j]:
                ans = 0
                break
        if ans:
            print("Yes")
            return
    ans = 1
    for i in range(3):
        if a[i][i]:
            ans = 0
            break
    if ans:
        print("Yes")
        return
    if a[2][0] or a[1][1] or a[0][2]:
        print("No")
        return
    print("Yes")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int is_prime(int n){
  if(n <= 1)
    return 0;
  int m = floor(sqrt(n) + 0.5);
  for(int i = 2; i < m; i++){
    if(n % i == 0)
      return 0;
  }
  return 1;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        // その結果を push
        res.push_back({a, ex});
    }
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

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

    ll A, B;
    cin >> A >> B;

    ll num = gcd(A,B);
    auto res  = prime_factorize(num);
    cout << res.size()+1 << endl;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li cnt[33];

int main() {
    string s;
    cin >> s;
    for (auto c : s) {
        cnt[c - 'a']++;
    }
    rep(i, 26) {
        if (cnt[i] == 0) {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    puts("None");

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
#include <complex>
int main() {
	int n; std::cin >> n;
	std::vector<int> values(n); for (auto& v : values) std::cin >> v;
	std::sort(values.begin(), values.end());
	std::cout << values.back() << ' ' << *std::min_element(values.begin(), values.end(), [&](const int a, const int b) {return std::abs(values.back() - (a << 1)) < std::abs(values.back() - (b << 1)); });
}

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

static const int MAX = 10000;

int n;

class Edge {
public:
	int s, t, w;
	Edge() {}
	Edge(int s, int t, int w): s(s), t(t), w(w) {}

	bool operator < (const Edge &e) const{
		return w < e.w;
	}
};

vector<Edge> E;
int p[MAX];

int ans() {
	for (int i = 0; i < n; i++)	{
		p[i] = i;
	}
	int cnt = 0, sum = 0, i = 0;
	sort(E.begin(), E.end());

	while (cnt < n - 1) {
		int s1 = E[i].s, t1 = E[i].t;
		while (p[s1] != s1) s1 = p[s1];
		while (p[t1] != t1) t1 = p[t1];
		if (s1 != t1) {
			p[s1] = t1;
			sum += E[i].w;
			cnt++;
		}
		i++;
	}
	return sum;
}

int main() {
	int e;
	cin >> n >> e;
	int s, t, w;
	for (int i = 0; i < e; i++) {
		cin >> s >> t >> w;
		E.push_back(Edge(s, t, w));
	}

	cout << ans() << endl;

	return 0;
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
int main(){
	ll s;
	cin>>s;
	ll x1,y1,x2,y2;
	x1=1e9;
	x2=1;
	y2=s/x1;
	y1=(ll)(x1*y2-s);
	if(y1<0){
		y2++;
		y1=(ll)(x1*y2-s);
	}
	printf("0 0 %d %d %d %d",x1,y1,x2,y2);
	return 0;
}

Measured memory_bytes: 256
S=input()
n=len(S)
mod=2019

T=[]
now=1
for i in range(n):
    T.append(now*int(S[-i-1])%mod)
    now=now*10%mod
C=[]
now=0
for i in range(n):
    now+=T[i]
    now%=mod
    C.append(now)
C.sort()
now=0
cnt=1
A=[]
for i in range(n):
    if now==C[i]:
        cnt+=1
    else:
        if cnt>=2:
            A.append(cnt)
        now=C[i]
        cnt=1
if cnt>=2:
    A.append(cnt)

ans=0
for a in A:
    ans+=a*(a-1)//2
print(ans)

Measured memory_bytes: 88776
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int res = 0;
    FOR(i, 1, n) {
        int tmp = 0;
        string s = to_string(i);
        for (auto c : s) {
            tmp += atoi(&c);
        }
        if ((a <= tmp) && (tmp <= b)) {
            res += i;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        A: usize, B: usize,
    }

    println!("{}",
        if A == B {
            "Draw"
        } else if A == 1 && B == 13 || (A > B && !(A == 13 && B == 1)) {
            "Alice"
        } else {
            "Bob"
        }
    );
}

Measured memory_bytes: 4352
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int c[3][3];
	REP(i, 3) {
		REP(j, 3) {
			cin >> c[i][j];
		}
	}

	REP(i, 3) {
		int aMax = 1000;
		REP(j, 3) {
			aMax = min(aMax, c[i][j]);
		}
		REP(j, 3) {
			c[i][j] -= aMax;
		}
	}

	string ans = "Yes";
	REP(i, 3) {
		if ((c[0][i] != c[1][i])||(c[1][i] != c[2][i])) {
			ans = "No";
			break;
		}
	}

	cout << ans << endl;
	return 0;

}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
ll fibonacci(ll n){
  if(n==0){
    return 0;
  }else if(n==1){
    return 1;
  }else{
    return fibonacci(n-1)+fibonacci(n-2);
  }
}

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


Measured memory_bytes: 256