akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        int count = 0;

        for(int i=0; i<n; i++) {
            if((i+1) % 2 == 1 && ary[i] % 2 == 1) {
                count++;
            }
        }

        return count;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        if (n == 0) return ret;
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 27296
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
string s,t;
signed main()
{
    cin>>s>>t;
    int n=s.length(), m=t.length();
    int p,q; p=q=0;
    for(ri int i=0;i<n+m;i++)
    {
        if(i&1ll) cout<<t[q++];
        else cout<<s[p++];
    }
    cout<<endl;
    return 0;
}

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

main(){
    cout<<"100 100"<<endl;
    int a,b;
    cin>>a;
    cin>>b;
    int p[101][101]={1};
    for(int i=1;i<51;i++){
        for(int j=1;j<101;j++)
        p[i][j]=0;    }
    for(int i=51;i<101;i++){
        for(int j=1;j<101;j++)
        p[i][j]=1;
    }
    a--;
    b--;
    int j;
    for(int i=1;i<30;i+=2){
        if(a>=50){
            for(j=1;j<101;j+=2){
                p[i][j]=1;
            }
            
        }
        else if(a>0){
            for(j=1;j<=(a*2-1);j+=2){
                p[i][j]=1;
            }
            
        }
        a-=50;
    }
    for(int i=100;i>61;i-=2){
        if(b>=50){
            for(j=1;j<101;j+=2){
                p[i][j]=0;
            }
            
        }
        else if(b>0){
            for(j=1;j<=(2*b-1);j+=2){
                p[i][j]=0;
            }
            
        }
        b-=50;
    }   
    for(int i=1;i<101;i++){
        for(j=1;j<101;j++){
            if(p[i][j]==0) cout<<"#";
            else cout<<".";
        }
        if(i!=100)
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

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

	cout << "33169" << endl;
	cout << "< 2 0 3" << endl;
	cout << "< 2 1 4" << endl;
	cout << "< 3 4 5" << endl;
	cout << "+ 3 5 6" << endl;
	cout << "+ 6 2 10" << endl;
	for (int i = 11; i <= 70; i++) {
		cout << "+ " << i - 1 << " " << i - 1 << " " << i << endl;
	}
	cout << "+ 0 6 0" << endl;
	cout << "+ 1 6 1" << endl;
	cout << "+ 6 2 101" << endl;
	for (int i = 102; i <= 200; i++) {
		cout << "+ " << i - 1 << " 11 " << i << endl;
	}
	for (int i = 329; i >= 300; i--) {
		cout << "+ 6 " << i << " " << i << endl;
		cout << "+ 2 2 1333" << endl;
		for (int j = 329; j >= 300; j--) {
			cout << "+ 1333 1333 1333" << endl;
			cout << "+ 1333 " << j << " 1333" << endl;
		}
		cout << "< 1333 0 " << i << endl;
	}

	for (int i = 429; i >= 400; i--) {
		cout << "+ 6 " << i << " " << i << endl;
		cout << "+ 2 2 1333" << endl;
		for (int j = 429; j >= 400; j--) {
			cout << "+ 1333 1333 1333" << endl;
			cout << "+ 1333 " << j << " 1333" << endl;
		}
		cout << "< 1333 1 " << i << endl;
	}
	for (int i = 0; i < 30; i++) {
		for (int j = 0; j < 30; j++) {
			cout << "+ " << 300 + i << " " << 400 + j << " 1333" << endl;
			cout << "< 6 1333 1333" << endl;
			cout << "+ 1333 " << 500 + i + j << " " << 500 + i + j << endl;
		}
	}
	for (int i = 0; i < 60; i++) {
		for (int j = 101; j < 200; j++) {
			cout << "< " << j << " " << 500 + i << " 1333" << endl;
			cout << "+ 1333 " << 500 + i+1 << " " << 500 + i+1 << endl;
		}
	}
	for (int i = 500; i < 560; i++) {
		cout << "+ 6 " << i << " " << i << endl;
		for (int j = 600; j < 610; j++) {
			cout << "+ 2 2 " << j << endl;
		}
		for (int j = 609; j >= 600; j--) {
			cout << "+ 6 " << j << " " << j << endl;
			cout << "+ 2 2 1333" << endl;
			for (int k = 609; k >= 600; k--) {
				cout << "+ 1333 1333 1333" << endl;
				cout << "+ 1333 " << k << " 1333" << endl;
			}
			cout << "< 1333 " << i << " " << j << endl;
		}
		cout << "+ 600 " << 200 + i << " " << 200 + i << endl;
	}
	for (int i = 760; i >= 700; i--) {
		cout << "+ 2 2 2" << endl;
		cout << "+ 2 " << i << " 2" << endl;
	}
}

Measured memory_bytes: 3636
#include<iostream>
// Need start
#include<vector>
#include<queue>
// Need end
using namespace std;

// Copy start
template <typename T>
class Dijkstra {
    private:
        using P = pair<T, int>;
        struct edge {
            int to;
            T cost;
            edge(int to, T cost):to(to), cost(cost) {}
        };
        T identity_;
        vector<vector<edge>> graph_;
        vector<T> dist_;
    public:
        Dijkstra(int node_num, T identity):
        identity_(identity), graph_(vector<vector<edge>>(node_num)), dist_(vector<T>(node_num, identity)) {}
        void addEdge(int from, int to, T cost) {
            graph_[from].emplace_back(to, cost);
        }
        void calcShortestPath(int root) {
            priority_queue<P, vector<P>, greater<P>> que;
            dist_[root] = 0;
            que.push(P(0, root));
            while (!que.empty()) {
                P now = que.top();
                que.pop();
                int node = now.second;
                if (dist_[node] < now.first) continue;
                for (auto& e : graph_[node]) {
                    if (dist_[e.to] > dist_[node] + e.cost) {
                        dist_[e.to] = dist_[node] + e.cost;
                        que.push(P(dist_[e.to], e.to));
                    }
                }
            }
        }
        T getDist(int u) {
            return dist_[u];
        }
};
// Copy end

using ll = long long;

const ll INF = 1LL << 50;

int main() {
    // This sample is Atcoder Nikkei Contest 2019 Qual D
    int N, M;
    cin >> N >> M;
    Dijkstra<ll> dijkstra(N, INF);
    for (int i = 1; i < N; ++i) {
        dijkstra.addEdge(i, i - 1, 0);
    }
    int L, R;
    ll C;
    for (int i = 0; i < M; ++i) {
        cin >> L >> R >> C;
        --L, --R;
        dijkstra.addEdge(L, R, C);
    }
    dijkstra.calcShortestPath(0);
    ll ans = dijkstra.getDist(N - 1);
    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 10104
S=input()
N=len(S)
now=S[0]
c=1
h=[]
for i in range(N-1):
    if S[i+1]==now:
        c+=1
    else:
        h.append(c)
        now=S[i+1]
        c=1
h.append(c)
k=[]
if S[0]=="L":
    s=h.pop(0)
    k.append(s)
    k+=[0]*(s-1)
n=len(h)
i=0
while(i<len(h)):
    a=h[i]
    b=h[i+1]
    p=(a+1)//2+b//2
    q=a//2+(b+1)//2
    k+=[0]*(a-1)
    k+=[p]
    k+=[q]
    k+=[0]*(b-1)
    i+=2
if S[-1]=="R":
    g=h[-1]
    k+=[0]*(g-1)
    k+=[g]
print(*k, sep=' ')


Measured memory_bytes: 51056
#include <bits/stdc++.h>
typedef long long ll;
#define endl '\n'
using namespace std;
const int MOD = 1000000007, MAX = 2000000007, MAXN = 100005;

bool solve(int n)
{
    while(n)
    {
        if(n%10 == 7)
            return true;
        n/=10;
    }
    return false;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	/*int t;
    cin>>t;
    while(t--)
    {*/
        int n;
        cin>>n;
        
        if(solve(n))
            cout<<"Yes\n";
        else
            cout<<"No\n";
    //}
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
  int X,A;
  cin>>X>>A;
  if(X<A){
      cout<<0<<endl;
  }
  else{
      cout<<10<<endl;
  }
  
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {
  int n, x, result;

  while(1) {
    cin >> n >> x;
    if(n == 0 && x == 0) break;

    result=0;
    for(int i=1; i <= n-2; i++) {
      for(int j=i+1; j <= n-1; j++) {
        for(int k=j+1; k <= n; k++) {
          // cout << k << endl;
          if(i+j+k == x) result++;
        }
      }
    }
    cout << result << endl;
  }

  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
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) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
// head
 
char ch[2001][2001];
int tyo[2001][2001];
int main() {
  int n,m,q;
	scanf("%d %d %d",&n,&m,&q);
	
  string s;
	rep(i,0,n){cin >> s;
    rep(j,0,m){
      ch[i][j] = s[j];
    }
	}int tyo[2001][2001];
  rep(i,1,n+1){
    rep(j,1,m+1){
      tyo[i][j]= tyo[i-1][j] + tyo[i][j-1] - tyo[i-1][j-1];
      if(ch[i-1][j-1] == '1'){
        tyo[i][j] += 1;
      }
    }
  }
  int hen[n+1][m+1] = {};
  rep(i,1,n+1){
    rep(j,1,m+1){
      hen[i][j]= hen[i-1][j] + hen[i][j-1] - hen[i-1][j-1];
      if((ch[i-1][j-1] == '1') && (ch[i-1][j] == '1') && (j <= m-1)){
        hen[i][j] += 1;
      }
    }
  }
  int hen2[n+1][m+1] = {};
  rep(i,1,n+1){
    rep(j,1,m+1){
      hen2[i][j]= hen2[i-1][j] + hen2[i][j-1] - hen2[i-1][j-1];
      if((ch[i-1][j-1] == '1') && (ch[i][j-1] == '1') && (i <= n-1)){
        hen2[i][j] += 1;
      }
    }
  }
  std::vector<std::vector<int>> query;
  rep(i,0,q){
    std::vector<int> v;
    int x1,y1,x2,y2;
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    v = {x1,y1,x2,y2};
    query.pb(v);
  }
  int ans = 0;
  for(auto &q:query){
    ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
    ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
    ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
    std::cout << ans << '\n';
  }
}

Measured memory_bytes: 65708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    int n, m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int res = 0;
	for (char i = '0'; i <= '9'; i++) {
		for (char j = '0'; j <= '9'; j++) {
			for (char k = '0'; k <= '9'; k++) {
				int check = 0;
				for (int idx = 0; idx < n; idx++) {
					if (check == 0 && s[idx] == i) {
						check++;
					}
					else if (check == 1 && s[idx] == j) {
						check++;
					}
					else if (check == 2 && s[idx] == k) {
						check++;
					}
				}
				if (check == 3) res++;
			}
		}
	}
	cout << res;
}

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

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main()	{
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B && A!=C || A!=B && B==C || A==C && B!=C)
    cout<<"Yes"<<endl;
    else 
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
k = int(data[0].split()[1])

l = []

for i in range(1,k+1):
    num = int(data[2*i-1].split()[0])
    for j in range(0,num):
        l.append(int(data[2*i].split()[j]))

counter = 0
for i in range(1,n+1):
    if not i in l:
        counter += 1
print(counter)

Measured memory_bytes: 9132
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include <assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint a,b,c,k;cin>>a>>b>>c>>k;
	if(a<b){swap(a,b);}
	if(a<c){swap(a,c);}
	cout<<(a<<k)+b+c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
using namespace std;

const int inf = 1e18;

int32_t main(){

    FAST;

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

    for(int x=0;x<n;x++){
        int num = a[x];

        int tem = 0;

        while(num % 2 == 0){
            tem++;
            num >>= 1;
        }

        time[x] = tem;


    }

    int ans = *min_element(time , time+n);

    cout << ans;    


    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var r = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var sum = r.Sum();

            long left = 0;
            long ret = long.MaxValue;

            for (long i = 0; i < N - 1; i++)
            {
                left += r[i];
                var right = sum - left;
                if (Math.Abs(left - right) < ret)
                {
                    ret = Math.Abs(left - right);
                }
            }
            Console.WriteLine(ret);
        }

    }
}

Measured memory_bytes: 34372
n,m,l=list(map(int,input().split()))

m_A=[list(map(int,input().split())) for i in range(n)]

m_B=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
    t=[]
    for k in range(l):
        s=0
        
        for j in range(m):
            s+=m_A[i][j]*m_B[j][k]
        t.append(s)
    print(*t)

Measured memory_bytes: 8628
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	INF int = 1<<62
)

var N int
var W []int
var ans int

func Input(){
	N = NextInt()
	W = NextInts(N)
}

func Solve(){
	ans = INF
	for t, _ := range(W){
		A:=0
		B:=0
		for i, w := range(W){
			if(t <= i){
				A += w
			}else{
				B += w
			}
		}
		ans = Min(ans, Abs(A-B))
	}
}

func Output(){
	fmt.Println(ans)
}

func main() {
	Initialize()
	for {
		Input()
		Solve()
		Output()
	}
}

// Initilize ===================
var io *IO;
func Initialize(){
	io = NewIO()
}
// IO ====================

type IO struct{
	sc *bufio.Scanner
}
func NewIO() *IO {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return &IO{
		sc: sc,
	}
}
func Next() string{
	ok := io.sc.Scan()
	if !ok {
		os.Exit(0)
	}
	return io.sc.Text()
}
func NextInt() int {
	s := Next()
	a, err:= strconv.Atoi(s)
	if err != nil {
		print(err)
	}
	return a
}
func NextInts(N int) []int{
	ret := make([]int, N)
	for i := range ret {
		ret[i] = NextInt()
	}
	return ret
}

// =============
func Sort( a[]int){
	sort.Ints(a)
}
func Min(nums ...int) int {
	ret := int(nums[0])
	for _, n := range nums {
		if n < ret {
			ret = n
		}
	}
	return ret
}
func Max(nums ...int) int {
	ret := int(nums[0])
	for _, n := range nums {
		if n > ret {
			ret = n
		}
	}
	return ret
}
func Abs(n int)int{
	if n < 0{
		return -n
	}
	return n
}


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

int main() {
  int r, c;

  while(1) {
    cin >> r >> c;
    if(r == 0 && c == 0)
      break;

    if((r*c)%2 == 0)
      cout << "yes" << endl;
    else
      cout << "no" << endl;

  }
  return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
#include<algorithm>
using namespace std;

typedef long long LL;

class Combination
{
public:
	Combination(LL sz, LL m) :
		size(sz+1),
		mod(m),
		param(size, 1)
	{
		for(LL i=2; i<size; i++)
		{
			param[i] = param[i-1] * i;
			param[i] %= mod;
		}
	}

	LL nCr(LL n, LL c)
	{
		LL ret = param[n];
		ret *= inverse(c);
		ret %= mod;
		ret *= inverse(n-c);
		ret %= mod;

		return ret;
	}

private:
	LL inverse(LL n)
	{
		LL ret = 1;
		LL a = param[n];
		for(LL i=mod-2; i>0; i/=2)
		{
			if(i&1)
			{
				ret *= a;
				ret %= mod;
			}
			a *= a;
			a %= mod;
		}
		return ret % mod;
	}

	const LL size;
	const LL mod;
	vector<LL> param;
};

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

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

	int left, right;
	for(auto it=table.begin(); it!=table.end(); it++)
	{
		if(it->second == 2)
		{
			left = find(a.begin(), a.end(), it->first) - a.begin();
			right = find(a.begin()+left+1, a.end(), it->first) - a.begin();

			break;
		}
	}

	const LL mod = 1E9 + 7;
	Combination comb(n+1, mod);
	for(int i=1; i<=n+1; i++)
	{
		LL ret = comb.nCr(n+1, i);
		if(left+n-right >= i-1)
			ret -= comb.nCr(left+n-right, i-1);

		ret += mod;
		ret %= mod;

		cout << ret << endl;
	}

	return 0;
}


Measured memory_bytes: 7040
# Union-Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True


def same(x, y):
    return find(x) == find(y)


def size(x):
    return -par[find(x)]


N, M, K = map(int, input().split())
Friend = [[] for _ in range(N)]

par = [-1] * N
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)
    Friend[a].append(b)
    Friend[b].append(a)

Block = [[] for _ in range(N)]
for i in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    Block[c].append(d)
    Block[d].append(c)

Ans = []
for i in range(N):
    ans = size(i) - 1
    ans -= len(Friend[i])
    for b in Block[i]:
        if same(i, b):
            ans -= 1
    Ans.append(str(ans))

print(' '.join(Ans))

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

int main() {
    int N, M;
    cin >> N >> M;
    vector <int> P(M), Y(M), cnt(N+1, 0);
    vector <pair <int, pair <int, int>>> py(M);
    vector <string> ans(M);
    rep (i, M) {
        cin >> P[i] >> Y[i];
        py[i] = make_pair(P[i], make_pair(Y[i], i));
        cnt[P[i]]++;
    }
    rep (i, N) cnt[i+1] += cnt[i];

    sort(py.begin(), py.end());

    rep (i, M) {
        int num = (i+1) - cnt[py[i].first-1];
        string pre = to_string(py[i].first), post = to_string(num);
        range (j, (int)pre.size(),  6) pre  = "0" + pre;
        range (j, (int)post.size(), 6) post = "0" + post;
        ans[py[i].second.second] = pre + post;
    }


    rep (i, M) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define int long long
#define sz(x) (x.size())
#define pb push_back
#define fi first
#define se second
using namespace std;
const int inf = 9e18, N = 1e6 + 5;
struct Node {
    int cost, dir, id;
    bool operator < (const Node &x) const
    {
        return cost > x.cost;
    }
};
int n;
string a[55];
int c[55], ans = inf;
int dist[2][N], ispal[N];
map <string, int>mp;
priority_queue <Node>q;
inline bool check (string a) {
    string tmp = a;
    reverse (tmp.begin(), tmp.end());
    return tmp == a;
}
signed main() {
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i = 1; i <= n; i++) {
        cin>>a[i]>>c[i]; int len = sz(a[i]);
        string tmp = a[i]; reverse (tmp.begin(), tmp.end());
        if (tmp == a[i]) ans = min (ans, c[i]); tmp = "";
        for (int j = 0; j < len; j++) {
            tmp.pb (a[i][j]);
            if (mp.count (tmp) == 0) mp[tmp] = sz(mp);
        } tmp = "";
        for (int j = len - 1; j >= 0; j--) {
            tmp = a[i][j] + tmp;
            if (mp.count (tmp) == 0) mp[tmp] = sz(mp);
        }
    }
    vector <string> v(sz(mp) + 5);
    map <string, int>::iterator it;
    it = mp.begin ();
    while (it != mp.end()) {
        //cout<<it->fi<<" "<<it->se<<endl;
        ispal[it -> se] = check (it -> fi);
        dist[0][it -> se] = dist[1][it -> se] = inf;
        v[it -> se] = it -> fi;
        it++;
    }
    for (int i = 1; i <= n; i++) {
        int id = mp[a[i]];
        // dist[0][id] = dist[1][id] = inf;
        q.push ((Node) {c[i], 0, id});
        q.push ((Node) {c[i], 1, id});
    }
    while (q.size()) {
        Node now = q.top (); q.pop ();
        if (dist[now.dir][now.id] < now.cost) continue;
        for (int i = 1; i <= n; i++) {
            string Le = v[now.id], Ri = a[i];
            if (now.dir) swap (Le, Ri);
            int pos = 0, nowx = now.cost + c[i];
            while (pos < min (sz(Le), sz(Ri))) {
                if (Le[pos] != Ri[sz(Ri) - pos - 1]) break;
                pos++;
            }
            if (pos < min (sz(Le), sz(Ri))) continue;
            if (pos == sz(Le) && pos == sz(Ri)) ans = min (ans, nowx);
            else if (pos == sz(Le)) {
                string rm = Ri.substr (0, sz(Ri) - pos);
                if (ispal[mp[rm]]) ans = min (ans, nowx);
                else {
                    int npi = mp[rm];
                    if (dist[1][npi] > nowx) dist[1][npi] = nowx, q.push((Node) {nowx, 1, npi});
                }
            }
            else {
                string rm = Le.substr (pos);
                if (ispal[mp[rm]]) ans = min (ans, nowx);
                else {
                    int npi = mp[rm];
                    if (dist[0][npi] > nowx) dist[0][npi] = nowx, q.push((Node) {nowx, 0, npi});
                }
            }
        }
    }
    if (ans == inf) printf ("-1\n");
    else printf ("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3976
#include <iostream>
#include <string>
#include <algorithm>
#include <climits>

using namespace std;

int main(){
    int N; string S; cin >> N >> S;
    //int totalW = count(S.begin(), S.end(), 'W');
    int totalE = count(S.begin(), S.end(), 'E');
    int MIN = totalE, wPassed = 0, ePassed = 0;
    for (int i = 0; i < N; i++){
        (S[i] == 'W') ? ++wPassed : ++ePassed;
        MIN = min(MIN, totalE-ePassed+wPassed);
    }   cout << MIN << endl;
    return 0;
}


Measured memory_bytes: 900
#include <stdio.h>
#include <string.h>
int main(void)
{
  int a,b,i,j=0,k,n,x,y,z;
  char s[500],c[500];

  scanf("%d",&n);

  for (size_t i = 1; i <= n; i++)
  {
    if((i>=1)&&(i<=9)) j++;
    if((i>=100)&&(i<=999)) j++;
    if((i>=10000)&&(i<=99999)) j++;

  }
  printf("%d",j);
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int res = 0;
    for (int i1 = 0; i1 * r <= n; ++i1) {
        for (int i2 = 0; i2 * g + i1 * r <= n; ++i2) {
            int i3 = (n - i2 * g - i1 * r) / b;
            if (i2 * g + i1 * r + i3 * b == n)
                ++res;
        }
    }
    cout << res << endl;
    
    
}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

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


    string ans;
    if (w>=s) ans = "unsafe";
    else ans = "safe";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100005
#define MOD 998244353;
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(ll i=0;i<n;i++)
#define revf(i,n) for(ll i=n-1;i>=0;i--)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define inp(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define outp(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "
#define outp1(a,n) for(ll i=1;i<n;i++)cout<<a[i]<<" "
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define pb push_back
#define mp make_pair
#define mem(x,n) memset(x,n,sizeof(x))
#define BINSC binary_search
#define BITOUT __builtin_popcount
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define cn cout<<"\n";
int main()
{
     ll n;
     cin>>n;
     ll ar[2*n];
     inp(ar,2*n);
     ll k=0;
     for(ll i=0;i<2*n;i+=2)
     {
          if(ar[i]==ar[i+1])
          k++;
          else
          k=0;
          if(k==3)
          break;
     }
     if(k==3)
     cout<<"Yes";
     else
     cout<<"No";
}

Measured memory_bytes: 3632
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>

using namespace std;




vector<int> prime_sieve(int n)
{
    int* arr = new int[n+1];
    
    int i, p;
    for (i = 0; i <= n; ++i) {
        arr[i] = i;
    }
    for (i = 2; i <= n; ++i) {
        if (arr[i] != 0) {
            for (p = arr[i] * arr[i]; p <= n; p += arr[i]) {
                arr[p] = 0;
            }
        }
    }
    vector<int> primes;
    for (i = 2; i <= n; ++i) {
        if (arr[i] != 0) {
            primes.push_back(arr[i]);
        }
    }
    return primes;
}

int min(int a, int b)
{
    return a < b ? a : b;
}


int main()
{
    long long n,a,b;
    cin >> n >> a >> b;
    vector<int> arr;
    int i,ele;
    for (i = 0; i < n; ++i){
        cin >> ele;
        arr.push_back(ele);

    }
    long long ans = 0;
    for (i = 1; i < n; ++i) {
        ans += min(b, (arr[i] - arr[i - 1]) * a);
    }
    cout << ans;


    
}

Measured memory_bytes: 892
A, B, C = map(int, input().split())
ans = float('inf')

if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
    print(0)
else:
    ans = min(ans, abs((A//2)*B*C - (A//2 + 1)*B*C))
    ans = min(ans, abs((B//2)*A*C - (B//2 + 1)*A*C))
    ans = min(ans, abs((C//2)*B*A - (C//2 + 1)*B*A))
    print(ans)

Measured memory_bytes: 3064
s = input()
flag = True
for i in range(len(s)):
  if i%2==0:
    if s[i] not in ['R', 'U', 'D']:
      flag = False
      break
  else:
    if s[i] not in ['L', 'U', 'D']:
      flag = False
      break
if flag:
  print("Yes")
else:
  print("No")

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

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	
	string s;
	cin>>s;

	if(s[1] == 'B')
	cout<<"ARC";
	else
	cout<<"ABC";

	return 0;
}

Measured memory_bytes: 3608
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20

N = int(input())
H = list(map(int,input().split()))
H[0]-=1
ans = 'Yes'
for i in range(1,N):
    if H[i] - 1 >= H[i-1]:
        H[i]-=1
    if H[i-1] > H[i]:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 17192
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int n;
int s;
int ans;

void dfs(int i, int sumCount, int sum)
{
	if (sum == s && sumCount == n)
	{
		++ans;
		return;
	}
	if (i == 10 || sumCount == n)
	{
		return;
	}

	dfs(i + 1, sumCount + 1, sum + i);
	dfs(i + 1, sumCount, sum);
	return;
}

int main()
{
	while (true)
	{
		ans = 0;
		cin >> n >> s;
		if (n == 0 && s == 0) return 0;
		dfs(0, 0, 0);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)

int compare(const void *b1, const void *b2){
  return strcmp(b1,b2);
}

int main(){
  int n;
  scanf("%d",&n);
  char s[n][20];
  int count=0;
  F(i,0,n){
    scanf("%s",s[i]);
  }
  qsort(s,n,sizeof(*s),compare);
  F(i,0,n-1){
    if(strcmp(s[i],s[i+1])==0) count++;
  }
  printf("%d\n",n-count);
  
  return 0;
}

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int S=0,ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='S')S++;
		else ans+=(S==0),S=max(0,S-1);
	}
	cout<<S+ans<<endl;	
	return 0;
}


Measured memory_bytes: 640
import Data.List


fff a
  | (read (fst a)::Int) == 0 = return ()
  | otherwise = putStrLn $ "Case " ++ show (snd a) ++ ": " ++ fst a


main = do
  a <- getContents
  let aaa = lines a
  let bbb = take (length aaa) $ iterate (+1) 1
  let ccc = zip aaa bbb
  mapM fff ccc


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

int main(){
    int a, b;
    cin >> a >> b;

    int count = 0;
    for (auto i = a; i <= b; i++) {
        if((i%10 == i/10000) && ((i/1000)%10 == (i/10)%10)) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

bool isPrime(ll a){
  if(a == 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(ll i=3;i*i<=a;i += 2){
    if(a%i == 0) return false;
  }
  return true;
}

int howdiv(int n,int d){
  if(n%d) return 0;
  else return 1+howdiv(n/d,d);
}

int main(){
  int n;
  cin >> n;
  vector<ll> primes(0);
  for(ll i=2;i<32000;i++){
    if(isPrime(i))primes.push_back(i);
  }
  int m = primes.size();
  ll dp[1001][m] = {0};
  rep1(i,1000){
    rep(j,m){
      dp[i][j] = dp[i-1][j] + howdiv(i,primes[j]);
    }
  }
  ll ans = 1;
  rep(j,m){
    ans *= (dp[n][j]+1);
    ans %= 1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 27136
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    ml = A.copy()
    ml.sort(reverse=True)

    Am = ml[0]
    As = ml[1]

    for i in range(N):
        if(A[i] == Am):
            print(As)
        else:
            print(Am)
    

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14116
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long
#define pb push_back

int q, h, s, d, n, ans;
int32_t main() {
	cin >> q >> h >> s >> d >> n;
	ans = 0;
	h = min(h, q*2);
	s = min(s, h*2);
	d = min(d, s*2);
	while (n > 1) {
		ans += d;
		n -= 2;
	}
	while (n > 0) {
		ans += s;
		n -= 1;
	}
	cout << ans;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int r = Math.min(n, k);
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        
        int opCount = 1;
        int max = 0;
        while (opCount <= r) {
            for (int i = 0; i <= opCount; i++) {
                int score = calcScore(values, k, opCount - i, i);
                max = Math.max(max, score);
            }
            opCount++;
        }
        
        System.out.println(max);
    }
    
    public static int calcScore(int[] values, int k, int aCount, int bCount) {
        List<Integer> list = new ArrayList<Integer>(); 
        int score = 0;
        for (int i = 0; i < aCount; i++) {
            list.add(values[i]);
            score += values[i];
        }
        for (int i = values.length - 1; i > values.length - 1 - bCount; i--) {
            list.add(values[i]);
            score += values[i];
        }
        
        Collections.sort(list);
        
        int canRemoveCount = k - aCount - bCount;
        for (int i = 0; i < canRemoveCount && i < list.size(); i++) {
            if (list.get(i) < 0) {
                score -= list.get(i);
            }
        }
        
        return score;
    }
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
// #define fore(i, b, e) for (int i = (int)(b); i <= (int)(e); ++i)
// #define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef long long ll;
#define sz(x) int((x).size())

int main() {
#ifdef LOCAL
//     freopen("a.in", "r", stdin);
#endif

    i64 a, b, c;
    cin >> a >> b >> c;
    if (a%2 == 0 || b%2 == 0 || c%2 == 0) cout << 0 << endl;
    else cout << min(a*b, min(a*c, b*c)) << endl;

#ifdef LOCAL
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair

const int N = 1e5 + 10;
const int M = 1e9 + 7;

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

PII a[N];
int inv[N];

ll pow_mod(ll a, ll p){
	if(p == 0) return 1;
	ll ans = pow_mod(a, p/2);
	ans = ans * ans % M;
	if(p % 2 == 1) ans = ans * a % M;
	return ans;
}

int main ()
{
	int n;
	scanf("%d", &n);
	for(int i = 0; i <= n; i++){
		scanf("%d", &a[i].first);
		a[i].second = i;
		if(i) inv[i] = pow_mod(i, M - 2);
	}
		
	sort(a, a+n+1);
	
	int m;
	for(int i = 1; i <= n; i++){
		if(a[i].first == a[i-1].first){
			m = a[i-1].second + n - a[i].second;
			break;
		}
	}
	
	ll x = n + 1, y = 1;
	printf("%d\n", n);
	for(int i = 2, j; i <= n; i++){
		x = x * (n + 1 - i + 1) % M;
		x = x * inv[i] % M;
		if(i - 1> m) y = 0;
		else{
			y = y * (m - (i - 1) + 1) % M;
			y = y * inv[i-1] % M;
		} 
		printf("%lld\n", (x - y + M) % M);
	}
	printf("1\n");
	
}

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

int main() {
  int n;
  long long int max = 0;
  long long int x = 0, y = 0;

  cin >> n;

  vector<int> v(n);

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

  sort(v.begin(), v.end(), greater<int>());

  for (int i = 0; i < n; i++) {
    if (v[i] == v[i+1]) {
      x = y * v[i];
      y = v[i];
      if (x > max) {
        max = x;
      }
      i++;
    }
  }

  cout << max << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
    bitset<1000100 + 1> b;
    auto t = b;
    t.set();
    t[0] = false;
    t[1] = false;
    int i = 0;
    while (true) {
        bool done = false;
        while (!t[i]) {
            ++i;
            if (i == t.size()) {
                done = true;
                break;
            }
        }
        if (done) {
            break;
        }

        b[i] = true;
        for (int j = i; j < t.size(); j += i) {
            t[j] = false;
        }
    }

    while (true) {
        int a, bb;
        cin >> a >> bb;
        int aa = a;
        int bbb = bb;
        if (a == 0 && bb == 0) {
            return 0;
        }

        vector<int> pa;
        int j = 2;
        while (true) {
            while (!b[j]) {
                ++j;
            }
            if (a == 1) {
                break;
            }
            if (a % j == 0) {
                pa.push_back(j);
                a /= j;
            }
            else {
                j += 1;
            }
        }
        vector<int> pb;
        j = 2;
        while (true) {
            while (!b[j]) {
                ++j;
            }
            if (bb == 1) {
                break;
            }
            if (bb % j == 0) {
                pb.push_back(j);
                bb /= j;
            }
            else {
                j += 1;
            }
        }
        pa.erase(unique(begin(pa), end(pa)), end(pa));
        pb.erase(unique(begin(pb), end(pb)), end(pb));

        auto f = [](const vector<int>& v) {
            auto s = accumulate(begin(v), --end(v), 0);
            return v.back() - s;
        };
        if (f(pa) > f(pb)) {
            cout << "a" << endl;
        }
        else {
            cout << "b" << endl;
        }
    }
}

Measured memory_bytes: 3248
#include <stdio.h>

int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    int x;
    int a,b;
    scanf("%d",&x);

    a=x/500 * 1000;
    b=x%500 /5 *5;

    printf("%d\n",a+b);

    
    return 0;
}

Measured memory_bytes: 1704
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 5000
#define MO 1000000007
using namespace std;
char str[MAXN+5];
int N;
int dp[MAXN+5][MAXN+5];//dp[i][j]:走到第j位花了i步
int main()
{
	scanf("%d",&N);
	scanf("%s",str+1);
	int len=strlen(str+1);
//	int len=N/2;
	dp[0][0]=1;
	for(int tmn=1;tmn<=N;tmn++)
	{
		for(int pos=0;pos<=N;pos++)
		{
			if(pos!=N)
				dp[tmn][pos]=(1LL*dp[tmn][pos]+2LL*dp[tmn-1][pos+1]%MO)%MO;
			if(pos!=0)
				dp[tmn][pos]=(1LL*dp[tmn][pos]+1LL*dp[tmn-1][pos-1])%MO;
			if(pos==0)
				dp[tmn][pos]=(1LL*dp[tmn][pos]+1LL*dp[tmn-1][pos])%MO;
		}
	}
	printf("%d\n",dp[N][len]);
	return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 1; i < n - 1; i++){
        if(s[i-1] == 'A' && s[i] == 'B' && s[i+1] == 'C'){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i].first;
    b[i].second = i;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i = 0; i < n; i++) {
    if (a[i].first > b[i].first) {
      cout << "No\n";
      return 0;
    }
  }
  for (int i = 1; i < n; i++) {
    if (a[i] <= b[i - 1]) {
      cout << "Yes\n";
      return 0;
    }
  }
  vector<int> to(n);
  for (int i = 0; i < n; i++) {
    to[a[i].second] = b[i].second;
  }
  int cur = 0;
  int cnt = 0;
  do {
    cur = to[cur];
    cnt++;
  } while (cur != 0);
  //cerr << cnt << endl;
  cout << (cnt == n ? "No\n" : "Yes\n");
  return 0;
}


Measured memory_bytes: 2176
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=t.inr(),n=0,i=0;i<=999;i++){for(var o=[Math.floor(i/100)%10,Math.floor(i/10)%10,i%10],s=0,u=!1,c=0;c<e;c++)if(r[c]==o[s]&&3==++s){u=!0;break}u&&n++}console.log(n)}}]);

Measured memory_bytes: 7628
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;

class Branch{
    private:
        int root=-1;
        int value;
        int child1=-1;
        int child2=-1;
    public:
        void setRoot(int a1){this->root = a1;}
        void setChild1(int b){this->child1 = b;}
        void setChild2(int c){this->child2 = c;}
        void setValue(int d){this->value = d;}
        int getRoot(){return root;}
        int getChild1(){return child1;}
        int getChild2(){return child2;}
        int getValue(){return value;}
};

int main(){
    int N;
    cin >> N;
    vector<Branch> a(N);
    int count,v1,v2,b;
    rep(i,N){
        cin >> b;
        a[i].setValue(b);
        count = 0;
        if(i==0){continue;}
        else{
            while(count!=-1){
                v1=a[i].getValue();
                v2=a[count].getValue();
                if(v1 > v2){
                    if(a[count].getChild2()==-1){
                        a[count].setChild2(i);
                        a[i].setRoot(count);
                        count=-1;
                    }else{
                        count=a[count].getChild2();
                    }
                }else if(v1==v2){
                    cout << "NO" <<endl;
                    count =-1;
                    return 0;
                }else{
                    if(a[count].getChild1()==-1){
                        a[count].setChild1(i);
                        a[i].setRoot(count);
                        count=-1;
                    }else{
                        count=a[count].getChild1();
                    }
                }
            }
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include <string>
using namespace std;
int main()
{
	int num_a, num_b;
	cin >> num_a >> num_b;

	int multi = num_a * num_b;

	if ((multi % 2) == 1) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	}

	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long

const ll inf = 1e18+7;
const int N = 1e6;
const int mod = 1e9+7;
int n, a[N], u[N];
int main()
{	
	cin >> n;
	for(int i = 1; i <= n;++i){
		cin >> a[i];
	}
	int l = 1,ans =0;
	for(int i = 1; i <= n; ++i){
		if(u[i])i++;
		u[i]=1;
		l = i;
		while(a[l+1] <= a[l] && l<n)
			l++;
		ans = max(l-i, ans);
	
		i = l-1;
	}
	cout << ans;
 	return 0;
}

Measured memory_bytes: 4736