akhauriyash/Code-Regression huggingface dataset:
//author: chinmay0402
//One day your whole life will flash before your eyes, make sure you make it worth watching
#include<bits/stdc++.h>
using namespace std;

//policy based data structures
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define ll long long int
#define lld long double
#define fl float
#define vs vector<string>
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll>>
#define fst first
#define scd second
#define sll set<ll>
#define mll map<ll,ll>
#define flash ios_base::sync_with_base(false);cin.tie(NULL);
#define INF (ll)10000000000000000
#define MOD (ll)1000000007
#define pb push_back
#define mll map<ll,ll>
#define test ll t;cin>>t;while(t--)
#define sortv(v) sort(v.begin(),v.end())
#define max3(a,b,c) max(a,max(b,c))

#define forn(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define fornr(i,n) for(ll i=n-1;i>=0;i--)
#define forab(i,a,b,c) for(ll i=a;i<=b;i+=c)

template<typename T>
void read(T &x){
 cin>>x;
}
template<typename T,typename T1>
void read(T &x, T1 &y){
 cin>>x>>y;
}
template<typename T,typename T1, typename T2>
void read(T &x, T1 &y, T2 &z){
 cin>>x>>y>>z;
}
template<typename T,typename T1, typename T2, typename T3>
void read(T &x, T1 &y, T2 &z , T3 &a){
 cin>>x>>y>>z>>a;
}
template<typename T>
void reada(T oneD,ll n){
 for(ll i=0;i<n;i++)
  cin>>oneD[i];
}
template <typename T>
void readv(vector< T > &oneD,ll n){
 forn(i,n){
  ll x;
  read(x);
  oneD.push_back(x);
 }
}
ll gcd(ll a, ll b){
 if(a==0)
  return b;
 else
  return gcd(b%a,a);
}

ll gcdExt(ll a,ll b, ll &x, ll &y){
 if(a==0){
  x=0;
  y=1;
  return b;
 }
 ll x1,y1;
 ll gcd=gcdExt(b%a,a,x1,y1);
 x=y1-(b/a)*x1;
 y=x1;
 return gcd;
}

ll pwr(ll a, ll b){
 ll res=1;
 while(b>0){
  if(b&1)
   res=res*a;
  a*=a;
  b>>=1;
 }
 return res;
}

ll pwrm(ll a, ll b, ll m){
 a%=m;
 ll res=1;
 while(b>0){
  if(b&1)
   res=res*a%m;
  a=a*a%m;
  b>>=1;
 }
 return res;
}

vector<bool>sieve(1000000,true);
void Sieve(){
 sieve[0]=false;
 sieve[1]=false;
 for(ll i=2;i*i<=1000000;i++){
  if(sieve[i]==true){
   for(ll j=i*i;j<1000000;j+=i)
    sieve[j]=false;
  }
 }
}

vll sieve_spf(1000001);
void Sieve_spf(){
 ll n=1000001;
 
 forn(i,n)
  sieve[i]=i;
 
 sieve[0]=-1;
 sieve[1]=-1;
 
 forab(i,2,n,2)
  sieve[i]=2;
 
 forab(i,3,n,2)
  if(sieve[i]==i)
   forab(j,i*i,n,i)
    if(sieve[j]==j)
     sieve[j]=i;
}


int main(){
 ll r;
 read(r);
 lld cir=2.0*(3.14)*(lld)r;
 cout<<cir;
 return 0;
}


Measured memory_bytes: 10960
import java.util.*;

public class Main {
	private static Scanner sc;
	public static void main(String[] args) throws java.lang.Exception {
		
		sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a < b) {
			System.out.println("a < b");
		} else if (a == b){
			System.out.println("a == b");
		} else {
			System.out.println("a > b");
		}
	}
}




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

int main(){
  int n,i;
  cin >> n >> i;
  cout << n - i + 1 << endl;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int n, k;
    cin >> n >> k;
    if (n <= k) {
        cout << 0 << endl;
        // d("hello");
        return 0;
    }
    vector<lint> H(n, 0);
    rep(i, n) { cin >> H[i]; }
    sort(all(H));
    reverse(all(H));
    for (int i = 0; i < k; i++) {
        H[i] = 0;
    }
    lint total = 0;
    for (int i = 0; i < n; i++) {
        total += H[i];
    }
    cout << total << endl;
    return 0;
}

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

namespace College
{
    class Program
    {
        static string Join(int[] input)
        {
            string result = "";
            foreach(int i in input)
                result += (" " + i.ToString());
            return result;
        }

        static void Main(string[] args)
        {
            List<List<int[]>> college = new List<List<int[]>>();

            for(int i = 0; i < 4; i++)
            {
                college.Add(new List<int[]>());
                for(int j = 0; j < 3; j++)
                {
                  college[i].Add(new int[10]);
                  for(int k = 0; k < 10; k++)
                      college[i][j][k] = 0;
                }          
            }

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

            for(int i = 0; i < limit; i++)
            {
                int[] _c = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();
                college[_c[0] - 1][_c[1] - 1][_c[2] - 1] = college[_c[0] - 1][_c[1] - 1][_c[2] - 1] + _c[3];
            }

            for(int j = 0; j < college.Count; j++)
            {
                List<int[]> b = college[j];
                foreach(int[] r in b)
                    Console.WriteLine(Join(r));
                if(j != college.Count - 1)
                    Console.WriteLine(new string('#', 20));
            }
        }
    }
}

Measured memory_bytes: 9660
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize
    }
    let ans = if a == b && b == c || a != b && b != c && c != a {
        "No"
    } else {
        "Yes"
    };
    println!("{}", ans);
}


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

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> v[n];
    for(int i = 0; i < n; i++){
        int t,d;
        cin >> t >> d;
        v[t-1].push_back(d);
    }
    vector<int> use,non;
    for (int i = 0; i < n; ++i) {
        if (!v[i].empty()) {
            sort(v[i].begin(), v[i].end());
            use.push_back(v[i].back());
            v[i].pop_back();
 
            while (!v[i].empty()) {
                non.push_back(v[i].back());
                v[i].pop_back();
            }
        }
    }
    sort(use.rbegin(),use.rend()),sort(non.rbegin(),non.rend());
    vector<ll> use_sum = {0},non_sum = {0};
    for (int i = 0; i < use.size(); ++i) {
        use_sum.push_back(use_sum.back() + use[i]);
    }
    for (int i = 0; i < non.size(); ++i) {
        non_sum.push_back(non_sum.back() + non[i]);
    }
    while(non_sum.size() < k) non_sum.push_back(0);

    ll ans = 0;
    for(ll i = 1; i <= min(k,(int)use.size()); i++){
        ans = max(ans,use_sum[i]+non_sum[k-i]+i*i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7796
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100011;
int n,a[N],r=0,l=0,ans=0;
int c[N*10],s[N<<1];
int cc[N*10],d[N*10],tot=0;
void add(int x)
{
	while(x<=N*2)
	  c[x]++,x+=x&(-x);
}
ll ask(int x)
{
	ll ans=0;
	while(x)
	{
		ans+=c[x];
		x-=x&(-x);
	}
	return ans;
}
//求中位数小于等于x的区间数至少为n*(n+1)/2/2+1的最小的x
bool check(int x)
{
	for(int i=1;i<=2*N;i++) c[i]=0;
	s[0]=0;
	for(int i=1;i<=n;i++)
	  s[i]=s[i-1]+(a[i]<=x?1:-1);
	ll sum=0;
	for(int i=0;i<=n;i++)
    {
       sum+=ask(s[i]-1+N);
       add(s[i]+N);
	}  
//	cout<<x<<" "<<sum<<endl;
	return sum>=(((ll)n*(n+1)/2/2)+1);
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
  scanf("%d",&n);  l=987654321;
  for(int i=1;i<=n;i++) scanf("%d",&a[i]),r=max(r,a[i]),l=min(l,a[i]);
//  for(int i=1;i<=n;i++)
//    for(int j=i;j<=n;j++)
//	  {
//	  	for(int z=1;z<=j-i+1;z++)
//	  	  cc[z]=a[i+z-1];
//	  	sort(cc+1,cc+j-i+2);
//	  	d[++tot]=cc[(j-i+1)/2+1];
//	  } 
//  sort(d+1,d+tot+1);
//  for(int i=1;i<=tot;i++) 
//    cout<<d[i]<<" ";
//  cout<<"---------"<<endl; 
//  cout<<d[tot/2+1]<<endl;
// 
//  for(int i=l;i<=r;i++)
//    check(i);
  while(l+1<=r)
  {
	int mid=(l+r)>>1;
  	if(check(mid)) 
	  r=mid;
	else l=mid+1;
  }
  printf("%d\n",r);
  return 0;
}


Measured memory_bytes: 4736
N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
for i in range(1, N):
    if H[i] - H[i - 1] > 0:
        H[i] -= 1

pre = 0
flg = True
for h in H:
    if h < pre:
        flg = False
        break
    pre = h
print('Yes' if flg else 'No')


Measured memory_bytes: 85388
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;

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

    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
#define lint long long
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int k;cin>>k;
  string s;cin>>s;
  int n=s.length();
  if(n<=k){
    cout<<s<<"\n";
  }
  else{
    for(int i=0;i<k;++i){
      cout<<s[i];
    }
    cout<<"..."<<endl;
  }
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      String s = sc.next();
      String a ="";
      
      for(int i=0; i<s.length(); i++){
      a =a+"x";
      }
      System.out.println(a);  
    }
}

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

int main() {
  long long int q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  h=min(h,2*q);
  s=min(s,min(2*h,4*q) );
  d=min(d,min(2*s,min(4*h,8*q)));
  long long int ans;
  ans=n/2*d;
  if(n%2==1)
    ans+=s;
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

int _mod = 1000000007;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> v(K+5);
    ll ans = 0;
    for (ll x = K; x >= 1; --x) {
        ll tmp = modpow(K / x, N, _mod);
        tmp %= _mod;
        for (ll y = x * 2; y <= K; y += x) {
            tmp -= v[y];
            tmp += _mod;
            tmp %= _mod;
        }
        v[x] = tmp;
        ans += x * tmp % _mod;
        ans %= _mod;
    }
    // for (int i = 1; i <= K; ++i) {
    //     cout << i << " : " <<  v[i] << endl;
    // }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3992
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();

		List<Integer> list = new ArrayList<>();
		list.add(a);
		list.add(b);
		list.add(c);
		Collections.sort(list);
		int min = list.get(0) + list.get(1);
		System.out.println(min);

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric> // accumulate
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main()
{
    ll n, q;
    vector<ll> a(100010, 0), b(100010, 0), c(100010, 0);
    vector<ll> count(100010, 0);
    cin >> n;
    rep(i, n)
    {
        cin >> a[i];
        count[a[i]]++;
    }
    cin >> q;
    rep(j,q)
    {
        cin >> b[j] >> c[j];
    }
    ll res = 0;
    rep(k, 100010)
    {
        res += count[k] * k;
    }
    rep(j,q)
    {
        res += count[b[j]] * (c[j] - b[j]);
        count[c[j]] += count.at(b[j]);
        count[b[j]] = 0;
        cout << res << endl;
    }
}

Measured memory_bytes: 5804
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double l = scanner.nextDouble();
        double hen = recursive(l);

        System.out.println(hen * hen * hen);
    }

    static double recursive(double l) {
        double hen = l / 3;
        if (hen + hen + hen == l) {
            return hen;
        }
        double diff = l - (hen + hen + hen);
        if(diff < 0.0000001){
            return hen;
        }
        double hen2 = recursive(diff);
        return hen + hen2;
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
//#define int long long

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

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

    LL n;
    cin >> n;
    vector<LL> a(n);
    REP(i, n) cin >> a[i];
    LL sum = 0;
    REP(i, n) sum += a[i];
    if(sum % (n * (n+1) / 2) != 0){
        cout << "NO" << endl;
        return 0;
    }
    LL num = sum / (n * (n+1) / 2);

    vector<LL> b(n);
    REP(i, n) b[i] = a[(i+1)%n] - a[i];
    REP(i, n) b[i] = b[i] - num;

    sum = 0;
    REP(i, n){
        if(b[i] % n != 0){
            cout << "NO" << endl;
            return 0;
        }
        sum += abs(b[i] / n);
    }

    cout << (sum == num ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;
int f[111000];
int p[111000],m,n,a,b,c;
int find(int p) {
	if(p!=f[p]) {
		return f[p]=find(f[p]);
	}
	return p;
}
int main() {
	cin>>n>>m;
	for(int x=1; x<=n; x++) {
		f[x]=x;
	}
	for(int x=0; x<m; x++) {
		scanf("%d%d%d",&a,&b,&c);
		int ax=find(a),bx=find(b);
		if(ax!=bx) {
			f[bx]=ax;
		}
	}
	int ans=0;
	for(int x=1; x<=n; x++) {
		int q=find(x);

		if(x==q) {
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 768
import fractions
N, X= map(int,input().split())
x = list(map(int,input().split()))
for i in range(N):
  x[i] = abs(X - x[i])

ans = x[0]
for i in range(1,N):
  ans = fractions.gcd(ans, x[i])
  
print(ans)

Measured memory_bytes: 16296
#include <cstdio>
int n,a[200003],max;long long ans;
int main(){
    scanf("%d",&n);for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    max=a[1];
    for(int i=2;i<=n;i++){
        if(max>a[i]) ans+=max-a[i];
        else max=a[i];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2496
(function(stdin){
	var lines = stdin.toString().split('\n')[0].split(' ').map(Number);
	var a = lines[0];
	var b = lines[1];
	if(a > b){
		console.log("a > b");
	}else if(a < b){
		console.log("a < b");
	}else{
		console.log("a == b");
	}
	
}(require('fs').readFileSync('/dev/stdin','utf8')));

Measured memory_bytes: 7380
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    string s, t;
    cin >> s >> t;
    string sloop = "";
    while(sloop.size() <= s.size() + t.size()) {
        sloop += s;
    }
    vector<int> table(t.size(), 0);
    int i = 2;
    int j = 0;
    table[0] = -1;
    if(t.size() >= 2) table[1] = 0;
    while(i < t.size()) {
        if(t[i-1] == t[j]) {
            table[i] = j + 1;
            i++;
            j++;
        } else if(j > 0) {
            j = table[j];
        } else {
            table[i] = 0;
            i++;
        }
    }
    int m = 0;
    i = 0;
    vector<bool> pat(s.size(), false);
    while(m < s.size()) {
        if(t[i] == sloop[m + i]) {
            i++;
            if(i == t.size()) {
                pat[m] = true;
                i--;
                m = m + i - table[i];
                if(i > 0) {
                    i = table[i];
                }
            }
        } else {
            m = m + i - table[i];
            if(i > 0) {
                i = table[i];
            }
        }
    }
    int ans = 0;
    vector<bool> used(s.size(), false);
    int smul = 0;
    while(smul < t.size()) {
        smul += s.size();
    }
    REP(i, s.size()) {
        if(pat[i] == true && used[i] == false) {
            int j = i;
            while(true) {
                if(pat[(j - t.size() + smul) % s.size()] == true) {
                    j = (j - t.size() + smul) % s.size();
                    if(i == j) {
                        cout << -1 << endl;
                        return 0;
                    }
                } else {
                    break;
                }
            }
            int k = 0;
            while(true) {
                used[j] = true;
                k++;
                if(pat[(j + t.size()) % s.size()] == true) {
                    j = (j + t.size()) % s.size();
                } else {
                    break;
                }
            }
            if(k > ans) ans = k;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>

using namespace std;
typedef pair<int, int> P;


void solve()
{
	int N;
	cin >> N;
	vector<long long int> A(N);
	vector<long long int> S(N + 1);
	map<long long int, unsigned long long int> Map;
	Map[0]++;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		Map[S[i] + A[i]]++;
		S[i + 1] = S[i] + A[i];
	}
	unsigned long long int ans = 0;
	map<long long int, unsigned long long int>::iterator it = Map.begin();
	while (it != Map.end())
	{
		if (it->second >= 2)
		{
			ans += (it->second - 1) * it->second / 2;
		}
		++it;
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 15872
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する

bool solve() {
    int n, m;
    cin >> n >> m;
    if (n == 0) return false;

    vector<int> ta(n), ha(m);
    int sum_ta = 0;
    int sum_ha = 0;
    for (int i = 0; i < n; i++) {
        cin >> ta[i];
        sum_ta += ta[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> ha[i];
        sum_ha += ha[i];
    }

    int min_v = 114514;
    int ans_ta = -1, ans_ha = -1;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int hta = ta[i];
            int hha = ha[j];

            int tmp_ta = sum_ta - hta + hha;
            int tmp_ha = sum_ha - hha + hta;

            if (tmp_ta == tmp_ha) {
                int val = hta + hha;
                if (min_v > val) {
//                    ans_ta = i + 1;
//                    ans_ha = j + 1;
                    ans_ta = hta;
                    ans_ha = hha;
                    min_v = val;
                }
            }
        }
    }

    if (ans_ta == -1) {
        cout << -1 << endl;
    } else {
        cout << ans_ta << " " << ans_ha << endl;
    }
    return true;

}

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

    while (solve());


    return 0;
}



Measured memory_bytes: 3108
/*input
5 5 2 3



*/
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
 {
 static Scanner in = new Scanner(System.in);
 
 
 
 
    public static void solve()
    {   
        int n=in.nextInt();
        int ac=0,wa=0,tle=0,re=0;
        in.nextLine();
        for(int i=0;i<n;i++)
        {
            String s=in.nextLine();
            if(s.equals("AC"))ac++;
            else if(s.equals("WA"))wa++;
            else if(s.equals("TLE"))tle++;
            else re++;
            
        }
        
        System.out.println("AC x "+ac);
        System.out.println("WA x "+wa);
        System.out.println("TLE x "+tle);
        System.out.println("RE x "+re);
    	
    	
    }
    
	public static void main (String[] args)
	 {
	 int t=1;
	 while(t-->0)
	 {
	  solve();
	 }
}
}

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

vector<int> W;
vector<vector<int>> dp;
// -1 : 未探索
// 0  : 全消し不可能
// 1  : 全消し可能

// [L, R)を全消しできるか？
bool rec(int L, int R) {
	int& ret = dp[L][R];
	if (ret >= 0) return ret;

	if (L == R) return ret = 1;
	if ((R - L) & 1) return ret = 0;

	ret = 0;
	for(int i = L + 1; i < R; i += 2) {
		if (abs(W[L] - W[i]) > 1) continue;
		if (rec(L + 1, i) && rec(i + 1, R)) return ret = 1;
	}
	return ret;
}

bool solve() {
	int N;
	cin >> N;
	if (N == 0) return false;

	W.resize(N);
	for(auto& w : W) cin >> w;

	dp.resize(N + 1);
	for(auto& v : dp) {
		v.assign(N + 1, -1);
	}

	vector<int> ans(N + 1, -1);
	ans[0] = 0;
	for(int L = 0; L <= N; ++L) {
		if (L > 0) ans[L] = max(ans[L], ans[L - 1]);
		for(int len = 2; L + len <= N; ++len) {
			if (rec(L, L + len)) ans[L + len] = max(ans[L + len], ans[L] + len);
		}
	}

	cout << ans[N] << endl;
	return true;
}

int main() {
	while (solve());
	return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define INFI ((ll)1e9)
#define MINI ((ll)-1e16)
using namespace std;
typedef long long ll;       
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }          
ll a[100001][4];
ll dp[100001][4];
ll n,k,x;

ll solve (ll day, ll prev){
	if(day==n+1)return 0;
	if(dp[day][prev]!=-1)return dp[day][prev];
	dp[day][prev] = MINI;
	fore(i,1,4){
		if(i!=prev)dp[day][prev]=max(dp[day][prev],a[day][prev]+solve(day+1,i));
	}
	return dp[day][prev];
}

int main(){FIN;
	cin >> n;
	fore(i,1,n+1){
		fore(j,1,4){
			cin >> a[i][j];	
		}
	}
	memset(dp,-1,sizeof(dp));
	cout << max(solve(1,1),max(solve(1,2),solve(1,3)));
}

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

int main(){
  int n;
  cin >> n;
  vector<int> L(3),S(3);
  for(int j=0; j<3; j++){
    cin >> L.at(j);
    S.at(j)=L.at(j);
  }
  sort(L.begin(), L.end());
  int a=0;
  if(L.at(1)==S.at(1)){
    a++;
  }
    for(int i=3; i<n; i++){
      L.at(0)=S.at(1);
      L.at(1)=S.at(2);
      cin >> L.at(2);
      for(int j=0; j<3; j++){
        S.at(j)=L.at(j);
      }
      sort(L.begin(), L.end());
      if(L.at(1)==S.at(1)){
        a++;
      }
    }
  cout << a << endl;
}

Measured memory_bytes: 256
N  = int(input())
t = [0]*110000
x= [0]*110000
y= [0]*110000

for n in range(N):
        t[n+1],x[n+1],y[n+1] = (map(int, input().split()))

can = True

for i in range(N):
    dt = t[i+1] - t[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])

    if dt < dist: #dt が大きければたどり着ける
        can = False
    if (dist % 2 != dt % 2):#動いていなければ偶数奇数がずれる
        can = False

if can == True:
    print('Yes')
else:
    print('No')


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

int main(){
  int n,m;
  cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    // 整数の入力
    scanf("%d", &n);
    // 出力
	switch(n%10){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
		printf("hon\n");
		break;
		case 0:
		case 1:
		case 6:
		case 8:
		printf("pon\n");
		break;
		case 3:
		printf("bon\n");
		break;
	}
    return 0;
}


Measured memory_bytes: 1648
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);		
		while (true) {
			String s = sc.next();
			if(s.equals("-")) break;
			int shuffles = sc.nextInt();
			for (int i=0; i<shuffles; i++){
				int h = sc.nextInt();
				String tmp = s.substring(h, s.length());
				tmp+=s.substring(0, h);
				s =tmp;
			}
		
		System.out.println(s);
		
		}
		
	}
}


Measured memory_bytes: 26728
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll N,M,L,O,P,Q,R;
string S;

int main(){
    cin>>N;
    vector<int>p(N);
    int ans=0;
    for(int i=0;i<N;i++)cin>>p[i];
    sort(p.begin(),p.end());
    int half=N/2;
    for(int i=0;i<N;i++){
        ans=p[half]-p[half-1];
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int h,w;cin>>h>>w;
	vector<vector<char>>a(h+2,vector<char>(w+2));
	for(int i=0;i<=h+1;++i){
		for(int j=0;j<=w+1;++j){
            if(i==0||i==h+1||j==0||j==w+1)a[i][j]='#';
            else cin>>a[i][j];
        }
	}
	rep(i,h+2){
		rep(j,w+2){
			if(j==w+1){
				cout<<a[i][j]<<endl;
			}
			else cout<<a[i][j];
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e5;
const int INF = 1e9+1;
bool solve()
{
    set<pair<int,int>> done;
    set<pair<int,int>> not_done;
    int n; cin >> n;
    for(int i = 0; i < (1<<n); i++)
    {
        int x; cin >> x;
        not_done.insert({x,i});
    }

    done.insert(*--not_done.end());
    not_done.erase(--not_done.end());

    for(int i = 0; i < n; i++)
    {
        set<pair<int,int>> pending;
        for(const auto&  p : done)
        {
            auto x = not_done.upper_bound({p.first-1,INF});  
            if(x==not_done.begin())
                return false;
            else
            {
                pending.insert(*(--x));
                not_done.erase(x);
            }
        }
        for(const auto& p : pending)
            done.insert(p);
    }
    return true;
}
int main()
{
    cout<<(solve() ? "Yes" : "No")<<endl;
    return 0;
}

Measured memory_bytes: 21992
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var n = rlong();
        long ans = n * (n + 1) / 2;
        long n3 = n / 3, n5 = n / 5, n15 = n / 15;
        ans -= 3 * n3 * (n3 + 1) / 2;
        ans -= 5 * n5 * (n5 + 1) / 2;
        ans += 15 * n15 * (n15 + 1) / 2;
        Write(ans);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27544
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;


struct point{
	double x, y;
};

double Func(point p1,point p2,point p3)
{
	double x1 = p2.x - p1.x;
	double y1 = p2.y - p1.y;
	double x2 = p3.x - p2.x;
	double y2 = p3.y - p2.y;

	return (x1*y2 - x2*y1);
}

int main()
{
	point p1, p2, p3, p4;
	while (cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y >> p4.x >> p4.y){

		string ans = (Func(p1, p2, p4) > 0 && Func(p2, p3, p4) > 0 && Func(p3, p1, p4) > 0)||
			(Func(p1, p2, p4) < 0 && Func(p2, p3, p4) < 0 && Func(p3, p1, p4) < 0)
			
			? "YES" : "NO";

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<vector>
using namespace std;
int h[100005];
vector<int> vc[100005];
int main(void)
{
    int n,m,a,b,sum=0;
    cin >> n >> m;
    for(int i=1;i<=n;i++)
        cin >> h[i];
    for(int i=1;i<=m;i++)
    {
        cin >> a >> b;
        vc[a].push_back(b);
        vc[b].push_back(a);
    }
    for(int i=1;i<=n;i++)
    {
        int cnt=0;
        for(int j=0;j<vc[i].size();j++)
        {
            if(h[i]<=h[vc[i][j]])
                cnt++;
        }
        if(cnt==0)
            sum++;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 9124
#include <bits/stdc++.h>  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
using namespace std;
typedef long long ll;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll k;

void dfs(ll cur,ll d, vector<vector<pair<ll,ll>>> &adj, vector<ll> &distances){
//   cout<<"INSIDE"<<cur<<endl;
  distances[cur] = d;
  for(auto p:adj[cur])
  	if(!distances[p.first] && p.first!=k)
      dfs(p.first,d+p.second,adj,distances);
  
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  ll n;
  cin>>n;
  vector<vector<pair<ll,ll>>> adj(n+1);
  for(ll i=0;i<n-1;i++){
  	ll x,y,w;
    cin>>x>>y>>w;
    adj[x].push_back({y,w});
    adj[y].push_back({x,w});
  }
  ll q;
  cin>>q>>k;
  vector<ll> distances(n+1);
  distances[k]=-1;
  dfs(k,0,adj,distances);
//   for(auto i:distances)
//     cout<<i<<" ";
// cout<<endl;
  for(ll i=0;i<q;i++){
  	ll a,b;
    cin>>a>>b;
    cout<<distances[a]+distances[b]<<endl;
  }
    return 0;
}

Measured memory_bytes: 15600
#include<stdio.h>

int main()
{
    char S[4];
    int ans=0;
    scanf("%s",S);
    for(int i=0;i<4;i++){
        if(S[i]=='+'){
            ans++;
        }else if(S[i]=='-'){
            ans--;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>

using namespace std;
const int limit = 50;
int n, m;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];
void dfs(int v) {
	visited[v] = true;
	for (int v2 = 0; v2 < n; ++v2) {
		if (graph[v][v2] == false) continue;
		if (visited[v2] == true) continue;
		dfs(v2);
	}
}
int main(void) {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		a[i] --, b[i] --;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	int ans = 0;
	for (int i = 0; i < m; ++i) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
		for (int j = 0; j < n; ++j) visited[j] = false;
		dfs(0);
		bool bridge = false;
		for (int j = 0; j < n; ++j)
			if (visited[j] == false) bridge = true;
		if (bridge) ans += 1;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }

        int max = 0;
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < n; j++) {
                if (i < j) {
                    sum += b[j];
                } else if (i == j) {
                    sum += a[j];
                    sum += b[j];
                } else {
                    sum += a[j];
                }
            }
            max = Math.max(max, sum);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 35976
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public int goal;
    public int[][] arr;

    public void run() {
        int n = sc.nextInt() /* <= 10 */;
        goal = sc.nextInt();
        arr = new int[n][5];
        for (int i = 0; i < n; i++) {
            arr[i][0] = (i + 1) * 100; // for which score problem
            arr[i][1] = sc.nextInt(); // how many
            arr[i][2] = sc.nextInt(); // bonus
            arr[i][3] = arr[i][0] * arr[i][1] + arr[i][2]; // total
        }

        boolean[] left = new boolean[n];
        for (int i = 0; i < n; i++) {
            left[i] = true;
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int count = 0;
            int score = 0;
            min = Math.min(rec(count, score, left, i), min);
        }
        System.out.println(min);
    }

    public int rec(int count, int score, boolean[] left, int idx) {
        if (score >= goal) {
            return count;
        }

        for (int i = 0; i < arr[idx][1]; i++) {
            score += arr[idx][0];
            count++;
            if (score >= goal) {
                return count;
            }
        }
        score += arr[idx][2];
        if (score >= goal) {
            return count;
        }

        int min = Integer.MAX_VALUE;
        left[idx] = false;
        for (int i = 0; i < left.length; i++) {
            if (left[i]) {
                min = Math.min(rec(count, score, left, i), min);
            }
        }
        left[idx] = true;
        return min;
    }
}


Measured memory_bytes: 26768
#include<iostream>
#include<string>
using namespace std;
int main()
{
	//string dog;
	//getline(cin, dog);
	//if (dog[2] == dog[3] && dog[4] == dog[5])
	//	cout << "Yes";
	//else
	//	cout << "No";
	long long dog;
	cin >> dog;
	int ans = 0;
	ans += dog / 500 * 1000;
	dog -= dog / 500 * 500;
	ans += dog / 5 * 5;
	cout << ans;
    return 0;
}



Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int maxn=1e5+5;
struct node{
	int x,y;
}p1[maxn];
vector<int>vec[maxn],vec1[maxn];
int cnt[maxn];
int pre[maxn];
int find(int x){
	if(x==pre[x])return x;
	else return pre[x]=find(pre[x]);
}
void Merge(int x,int y){
	int xx=find(x);
	int yy=find(y);
	if(xx!=yy){
		pre[xx]=yy;
		return ;
	}
	return ;
}
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    memset(cnt,0,sizeof(cnt));
    for(int i=1;i<=n;i++){
        pre[i]=i;
    }
    for(int i=1;i<=m;i++){
    	scanf("%d%d",&p1[i].x,&p1[i].y);
    	vec[p1[i].x].push_back(p1[i].y);
    	vec[p1[i].y].push_back(p1[i].x);
    	Merge(p1[i].x,p1[i].y);
    }
    int xx,yy;
    for(int i=1;i<=k;i++){
    	scanf("%d%d",&xx,&yy);
    	if(find(xx)==find(yy)){
    	vec1[xx].push_back(yy);
    	vec1[yy].push_back(xx);
    	    
    	}
    	
    }
    for(int i=1;i<=n;i++){
    	cnt[find(i)]++;
    }
   
    for(int i=1;i<=n;i++){
    	cout<< cnt[find(i)]-vec[i].size()-vec1[i].size()-1<<" ";
    }

	return 0;
}

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

using namespace std;
using ll = long long;
int n,m;

void add(vector<pair<int, int>> &segtree, pair<int,int> val, int x, int ind=1, int l=0, int r=n){
    if(l==r){
        segtree[ind] = val;
        return;
    }
    int mid = (l + r) / 2;
    if(x <= mid)
        add(segtree, val, x, ind*2, l, mid);
    else
        add(segtree, val, x, ind*2+1, mid+1, r);
    segtree[ind] = min(segtree[ind*2], segtree[ind*2+1]);
}

pair<int, int> find(vector<pair<int,int>> &segtree, int x, int y, int ind=1, int l=0, int r=n){
    if(x<=l && r<=y){
        return segtree[ind];
    }
    int mid = (l+r)/2;
    if(mid >= y) return find(segtree, x, y, ind*2, l, mid);
    else if(mid < x) return find(segtree, x, y, ind*2+1, mid+1, r);
    else return min(find(segtree, x, mid, ind*2, l, mid), find(segtree, mid+1, y, ind*2+1, mid+1, r));
}

int main(){
    cin>>n>>m;
    vector<pair<int,int>> segtree(4*n, {INT_MAX,0});
    vector<int> ans(n+1);
    string s;
    cin>>s;
    bool imp = false;
    for(int i=n; i>=0 ;i--){
        if(s[i] == '1'){
            if(i == n || i == 0) {imp = true; break;}
            continue;
        }
        //cout<<"------------------\n"<<i<<endl;
        if(i == n){
            add(segtree, {0,i}, i);
            ans[i] = 0;
        }
        else{
            auto ind = find(segtree, i+1, min(i+m, n));
            //cout<<ind.first<<" "<<ind.second<<endl;
            if(ind.first != INT_MAX){
                add(segtree, {ind.first+1, i}, i);
                ans[i] = (ind.second - i);
            }
            else if(i == 0){
                imp = true;
            }
        }
    }
    int pos = 0;
    if(imp || ans[0] > n){
        cout<<-1<<endl;
    }
    else while(pos != n){
        cout<<ans[pos]<<" ";
        pos += ans[pos];
    }
}


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

int main() {
  int N,M; cin >>N>>M;
  vector<int> a(M); vector<int> b(M);
  for(int i=0; i<M; i++) cin >>a.at(i)>>b.at(i);
  int ans=0;
  for(int j=0; j<N; j++){
    for(int i=0; i<M; i++){
      if(a.at(i)==(j+1) || b.at(i)==(j+1)) ans++;
    }
    cout <<ans<<endl;
    ans=0;
  }
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int f(int a,int x) {
	if (a >= 0)return (a / x+1);
	else return 0;
}

signed main(void) {
	int a, b, x;
	cin >> a >> b >> x;
	print(f(b, x) - f((a - 1), x));
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int main() {
    string s; cin >> s;
    int c = 0;
    rep(i, s.size()) {
        if (s[i] == 'o') c++;
    }
    c += 15 - s.size();
    if (c >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{    
    int n;
    cin>>n;
    if(n==19||n==29||n==39||n==49||n==59||n==69||n==79||n==89||n==90||n==91||n==92||n==93||n==94||n==95||n==96||n==97||n==98||n==99){
         cout<<"Yes";

    }
    else cout<<"No";
    return 0;
    
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
 
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
uf = UnionFind(N)
 
deg = [0]*N
to = [[] for _ in range(N)]
 
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)
    deg[a] += 1
    deg[b] += 1
 
for i in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    to[c].append(d)
    to[d].append(c)
 
res = []

for i in range(N):
    r = uf.size(i)-1-deg[i]
    for u in to[i]:
        if uf.same(i, u):
            r -= 1
    res.append(str(r))

print(" ".join(res))

Measured memory_bytes: 33672