akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
//#include <functional>
#include <queue>
//#include <stack>
//#include <set>
#include <cmath>
//#include <bitset>
#include <map>
using namespace std;
typedef long long ll;

int main() {
  int N[4];
  for(int i=0; i<4; i++){
    cin >> N[i];
  }
  int count[4]={};
  for(int i=0; i<4; i++){
    if(N[i] == 1) count[0]=1; 
    if(N[i] == 9) count[1]=1;
    if(N[i] == 7) count[2]=1;
    if(N[i] == 4) count[3]=1;
  }
  if (count[0] && count[1] && count[2] && count[3]) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;

}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    string s;
    cin >> s;
    vector<bool> v(26);
    string ans = "yes";
    for(auto i : s){
        if(!v[i - 'a']){
            v[i - 'a'] = true;
        }else{
            ans = "no";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#define min(a,b)    (((a) < (b)) ? (a) : (b))
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define abs(x)    ((x) < 0 ? -(x) : (x))
#define INF 0x3f3f3f3f
#define delta 0.85
#define eps 1e-3
#define PI 3.14159265358979323846
using namespace std;
struct st{
	int p;
	string s;
	st(int p, string s) : p(p), s(s) {}
};
const int dx[4] = {4, -4, 1, -1};
map<string, int> dp;

bool judge(int x, int d){
	if((x == 3 && d == 1) || (x == 4 && d == -1)) return 0;
	x += d;
	return x >= 0&& x <= 7;
}

void bfs(){
	queue<st> que;
	string f = "01234567";
	dp[f] = 0;
	que.push(st(0, f));
	while(!que.empty()){
		st now = que.front(); que.pop();
		int x = now.p;
		for(int i = 0; i < 4; i++){
			if(judge(x, dx[i])){
				int nx = x + dx[i];
				string s = now.s;
				swap(s[x], s[nx]);
				if(dp.find(s) == dp.end()){
					dp[s] = dp[now.s] + 1;
					que.push(st(nx, s));
				}
			}
		}
	}
}

int main(){
	bfs();
	string s;
	while(getline(cin, s)){
		s.erase(remove(s.begin(), s.end(), ' '), s.end());
		cout << dp[s] << endl;
	}
	return 0;
}


Measured memory_bytes: 5436
"use strict"

function main(input) {
  input = input.split(' ').map(v => ~~v)

  let ans = (Math.abs(input[1] - input[0]) < Math.abs(input[2] - input[0])) ? 'A' : 'B'
  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))


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

using namespace std;

int main(){
	int a[] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	scanf("%d", &k);
	printf("%d\n", a[k]);
	return 0;
}


Measured memory_bytes: 256
s = list(input())
a = ["g"] * (-(-len(s) // 2)) + ["p"] * (len(s) // 2)
ans = 0
for i in range(len(s)):
    if s[i] == "g" and a[i] == "p":
        ans += 1
    elif s[i] == "p" and a[i] == "g":
        ans -= 1
print(ans)

Measured memory_bytes: 5420
h, w = map(int, input().split())

def divide(h, w):
  ans = h*w
  for w1 in range(1, w):
    s1 = h*w1
    # Pattern1 : ||
    w2 = (w-w1)//2
    s21 = h*w2
    s31 = h*(w-w1-w2)
    ans1 = max(s1, s21, s31) - min(s1, s21, s31)
    # Pattern2 : |-
    h2 = h//2
    s22 = (w-w1)*h2
    s32 = (w-w1)*(h-h2)
    ans2 = max(s1, s22, s32) - min(s1, s22, s32)
    ans = min(ans, ans1, ans2)
  return ans
    
print(min(divide(h, w), divide(w, h)))



Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int p,q;
    int i,k=0;
    int a,b,c,d,e;
    scanf("%d %d",&p,&q);
    for(i=p;i<=q;i++)
    {
        a=i/10000%10;
        b=i/1000%10;
        c=i/100%10;
        d=i/10%10;
        e=i%10;
        if(a==e&&b==d)
        {
            k++;
        }
    }
    printf("%d",k);
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;

#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
int main(){
	int n;
	while(cin>>n && n){	
		int a[200];
		rep(i,n)cin>>a[i+1];
		a[0]=0;
		double b;
		double r,v,e,f;
		cin>>b>>r>>v>>e>>f;
		static double dist[10001];
		dist[0]=0;
		for(int i=0;i<10000;i++){
			if(i>=r)dist[i+1] = dist[i] + 1./(v - e*(i - r));
			if(i<r) dist[i+1] = dist[i] + 1./(v - f*(r - i));
		}
		static double dp[200];
		for(int i=0;i<200;i++)dp[i]=1e100;
		dp[0]=0;
		for(int i=1;i<=n;i++){
			for(int j=0;j<i;j++){
				int d=a[i]-a[j];
				double t = dp[j]+dist[d];
				if(j!=0)t+=b;
				dp[i] = min(dp[i], t);
			}
		}
		printf("%.10lf\n", dp[n]);
	}
}

Measured memory_bytes: 1316
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

int main(void){
  string n;
  cin >> n;
  
  int nn = stoi(n);
  
  unordered_map<string, int> m;
  //vector<int> vec(nn);
  string s;
  bool y = true;
  for (int i = 0; i < nn; i++) {
    //cin >> vec.at(i);
    cin >> s;
    if (m.find(s) == m.end()){
      m[s] = 1;
    }
    else {
      y = false;
      break;
    }
  }
  
  if (y){
    cout << "YES";
  }
  else {
    cout << "NO";
  }
  
  /*for (int i = 0; i < vec.size(); ++i){
    for (int j = i + 1; j < vec.size(); ++j){
      if (vec.at(i) == vec.at(j)){
        cout << "NO" << endl;
        return 0;
      }
    }
  } 
  
  cout << "YES" << endl;*/
  return 0;
}

Measured memory_bytes: 23624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;

int main(){
    int N, M; cin >> N >> M;
    vector<pair<int, int>> P(N);
    for(int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        P[i] = make_pair(a, b);
    }
    priority_queue<int> Q;
    sort(P.begin(), P.end());
    int idx=0;
    int a = 1;
    ll ans = 0;
    while(a <= M){
        while(idx < N && P[idx].first <= a){
            Q.push(P[idx].second);
            idx++;
        }
        if(!Q.empty()){ans += Q.top(); Q.pop();}
        a++;
        //cout << ans << " " << idx << endl;
    }
    cout << ans << endl;
}

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

using namespace std;

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

    int min_num = 1001;
    int max_num = -1;
    int ai;
    for (int I = 0; I < N; I++) {
        cin >> ai;
        min_num = std::min(min_num, ai);
        max_num = std::max(max_num, ai);
    }

    cout << (max_num - min_num) << endl;

    return 0;
}

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

int main(void)
{
    int n;
    int flag;
    scanf("%d", &n);
    
    while (n != 0){
        flag = 1;
        
        int num1[81] = {0};
        int num2[81] = {0};
        int max_len;
        
        char in[3000];
        scanf("%s", in);
        // êUlðæèÞ
        int len = (int)strlen(in);
        if (80 < len) flag = 0;
        // üÁ½lª80Èã¾Á½çAflagð0É·é
        else {
            max_len = len;
            int j = 0;
            for (int i = (len - 1); -1 < i; i--){
                num1[j] = in[i] - '0';
                j++;
            }
        }
        
        scanf("%s", in);
        // êUlðæèÞ
        len = (int)strlen(in);
        if (80 < len) flag = 0;
        // üÁ½lª80Èã¾Á½çAflagð0É·é
        else {
            if (max_len < len) max_len = len;
            int j = 0;
            for (int i = (len - 1); -1 < i; i--){
                num2[j] = in[i] - '0';
                j++;
            }
        }
        
        // üÁ½lª80Èã¶áÈ¢Æ«ÉZ
        if (flag == 1){
            for (int i = 0; i < 80; i++){
                num1[i] += num2[i];
                if (10 <= num1[i]){
                    num1[i + 1] += 1;
                    num1[i] %= 10;
                }
            }
            
            if (num1[80] != 0){
                flag = 0;
                // 81Úª0¶áÈ¢ = overflow
            }
            
            // overflowµÄÈ¢Æ«ÉoÍ
            if (flag == 1){
                // ÅãÌ«µã°ÅJèãªèµÄé©Ç¤©
                if (num1[max_len] == 0){
                    for (int i = max_len - 1; -1 < i; i--){
                        printf("%d", num1[i]);
                    }
                    printf("\n");
                }
                else {
                    for (int i = max_len; -1 < i; i--){
                        printf("%d", num1[i]);
                    }
                    printf("\n");
                }
            }
        }
        
        // ¡ÜÅÉflagª0ÉÈÁÄ½çoverflowI
        if (flag == 0){
            printf("overflow\n");
        }
        
        n--;
    }
    
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        String sli = scan.next();
        int count = N;
        char latestChar = sli.charAt(0);
        for (int i = 1; i < sli.length(); i++) {
            if (latestChar == sli.charAt(i)) {
                count--;
            }
            latestChar = sli.charAt(i);
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 25300
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>
#include <numeric>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0l);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}


//-----------------------------------------------------------------------------



int main() {
    srand(time(NULL));

    retry:
#ifdef LOCAL
    // gen();

    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
#endif

    string s;
    cin >> s;
    int k;
    cin >> k;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'a') {
            continue;
        }
        int need = 'z' - s[i] + 1;
        if (need <= k) {
            s[i] = 'a';
            k -= need;
        }
    }

    k %= 26;
    s.back() += k;
    if (s.back() > 'z') {
        s.back() -= 26;
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 512
#include  <bits/stdc++.h>
using namespace std;
//  pair<int,int>pa;
//  vector<pair<int,int>>vec;

int main(){
  int N,ans=0;
  cin>>N;
  vector<int>vecv(N);
  vector<int>vecc(N);
  
   for(int i=0;i<N;i++){
    cin>>vecv.at(i);
   }
   for(int i=0;i<N;i++){
     cin>>vecc.at(i);
   }
  for(int i=0;i<N;i++){
    if(vecv.at(i)-vecc.at(i)>0){
      ans+=vecv.at(i)-vecc.at(i);
    }
  }
    cout << ans<<endl;
    
    
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "Yes";
		if(s.equals("AAA") || s.equals("BBB")) result = "No";
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<string.h>
using namespace std;
int n,ans;
bool a[1000000];
int main(){
	while(cin>>n){
		memset(a,true,sizeof(a));
		a[0]=false;
		a[1]=false;
		ans=0;
		for(int i=2;i<=n;i++){
			if(a[i])
				for(int j=2*i;j<=n;j+=i)
					a[j]=false;
		}
		for(int i=1;i<=n;i++)
			if(a[i]) ans++; 
		cout<<ans<<endl;
	}
} 


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
ll ch[200010];
int main() {
	ll n,m;
	cin>>n>>m;
	ll l=0;
	ll r=m+1;
	for(ll i=0;i<m;i++){
		if(i%2==0){
			ch[l]=m-i;
			ch[l+m-i]=m-i;
			l++;
		}
		else{
			ch[r]=m-i;
			ch[r+m-i]=m-i;
			r++;
		}
	}
	vector<ll>a[100010];
	for(ll i=0;i<n;i++){
		ll now=ch[i];
		a[now].push_back(i+1);
	}
	for(ll i=1;i<=m;i++){
		cout << a[i][0]<<" "<<a[i][1]<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 10008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    if (M <= 2 * N) ans = M / 2;
    else {
        ans = N;
        M -= 2 * N;
        ans += M / 4;
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  if ( (N/10)%111 == 0) {
    cout << "Yes" << endl;
  }
  else if ( (N%1000)%111 == 0 ) {
    cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}


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

#define Max 1000000

int isPrime[Max];

int main(){
    int num;
    int i,j;

    //配列の初期化
    isPrime[0] = isPrime[1] = 0;
    for(i = 2; i < Max; ++i){
        isPrime[i] = 1;
    }

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

    while(cin >> num){
        int count = 0;
        for(i = 2; i <= num; ++i){
            if(isPrime[i] == 1){
                count++;
            }
        }
        cout << count << endl;
    }
}


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

using namespace std;

int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> A_cnt(N);

    int count=0;

    for(int i=0; i<N; i++){
        int a; cin >> a;

        if(A_cnt.at(a-1) == 0){
            count++;
        }
        A_cnt.at(a-1)++;
    }

    sort(A_cnt.rbegin(),A_cnt.rend());

    int ans = 0;

    for(int i=K; i<count; i++){
        ans += A_cnt.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3936
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var n = int.Parse(Console.ReadLine());
    var s = Console.ReadLine();
    if(s.Length > n){
      var a = s.Substring(0,n);
      Console.Write(a+"...");
    }
    else {
     Console.Write(s);
   
    }
  }
}

Measured memory_bytes: 17604
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
// using Graph = vector<vector<int>>;
const int MOD = 1000000007;

// modint: mod 計算を int を扱うように扱える構造体
template <int MOD>
struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) val += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
  constexpr Fp operator+(const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator-(const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator*(const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator/(const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator+=(const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator-=(const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator*=(const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator/=(const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator==(const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator!=(const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator<<(ostream& os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD>& a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
};
using mint = Fp<1000000007>;

vector<pair<long long, long long> > prime_factorize(long long n) {
  vector<pair<long long, long long> > res;
  for (long long p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> num(1100000, 0);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    auto pf = prime_factorize(A[i]);
    for (auto p : pf) num[p.first] = max(num[p.first], p.second);
  }

  mint LCM = 1;
  for (int v = 2; v < 1100000; ++v) {
    LCM *= modpow(mint(v), num[v]);
  }

  mint res = 0;
  for (auto a : A) {
    res += LCM / a;
  }
  cout << res << endl;
}

Measured memory_bytes: 8960
N=int(input())
Red=[]
Blue=[]
for _ in range(N):
  Red.append(list(map(int,input().split())))
for _ in range(N):
  Blue.append(list(map(int,input().split())))

Red.sort(key=lambda x:x[1])
Blue.sort(key=lambda x:(x[0],x[1]))

answer=0
for Bluei in range(N):
  popwant=101
  count=0
  while(True):
    if count==len(Red) or Blue[Bluei][1]<=Red[count][1]:
      break
    if Red[count][0]<Blue[Bluei][0]:
      popwant=count
    count+=1
  if popwant<100:
    Red.pop(popwant)
    answer+=1
print(answer)

Measured memory_bytes: 3064
#include <iostream>

template<typename T>
constexpr T gcd( T m, T n )
{
	if (n==0)
      return m;
  
  return gcd(n,m%n);
}

template<typename T>
constexpr T lcm( T m, T n )
{	
	return ((m / gcd<T>(m, n)) * n);
}

int N;
long long T;
int main(){
  std::cin>>N;
  long long ans=1LL;
  for(int i=0;i<N;++i){
    std::cin>>T;
    
    ans=lcm(ans,T);
  }
  std::cout<<ans<<std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<math.h>
using namespace std;
int main()
{
    int P,Q,R;
    cin >> P >> Q >> R;
    int mind = 1000;
    mind = min(P+Q, mind);
    mind = min(R+Q, mind);
    mind = min(R+P, mind);
    cout << mind << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(){
    int n, c, v[50];
    scanf("%d", &n);
    int i;
    for(i=0;i<n;i++){
        scanf("%d", &v[i]);
    }
    int max = 0;
    for(i=0;i<n;i++){
        scanf("%d", &c);
        if(v[i] - c > 0) max += v[i] - c;
    }
    printf("%d\n", max);
    return 0;
}

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

int main()
{
    string S;
    bool qualifies;
    cin >> S;
    int length_S = S.length();

    if (S[0] != 'A')
    {
        qualifies = false;
    }
    else
    {
        int C_occurrences = 0;
        int C_position;
        for (int i=2;i<length_S - 1;i++)
        {

                if(S[i] == 'C')
                {
                    C_occurrences++;
                    C_position = i;
                }
            if (C_occurrences == 2)
            {
                qualifies = false;
                break;
            }
        }
        if (C_occurrences == 1) {
            int ascChar;
            for (int i = 1; i < length_S; i++)
                if (i != C_position)
                {
                    if (S[i] >= 97 && S[i] <= 172)
                    {
                        qualifies = true;
                    }
                    else
                    {
                        qualifies = false;
                        break;
                    }
                }
        }
    }

    if (!qualifies) printf("WA");
    else cout << "AC";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n,x;
  cin >>n>>x;
  ll a[n];
  for(ll i=0;i<n;i++) cin >>a[i];
  ll ans=0;
  for(ll i=0;i<n-1;i++){
    ll k=a[i]+a[i+1];
    if(k>x) {
      ll p=k-x;
      ans+=p;
      if(a[i+1]>=p) a[i+1]-=p;
      else {
        a[i+1]=0;
        a[i]-=(p-a[i+1]);
      }
    }
  }
  cout <<ans<<endl;
  }


Measured memory_bytes: 1024
def isSame(n):
    if n[0] == n[1] and n[1] == n[2]:
        return True
    else:
        return False

n_s = input()
n_i = int(n_s)

while True:
    if isSame(n_s):
        print(n_s)
        break
    else:
        n_i += 1
        n_s = str(n_i)


Measured memory_bytes: 9064
n=int(input())
a=[int(x) for x in input().rstrip().split()]
cnt=[0 for i in range(n)]
for i in a:
  cnt[i-1]+=1

nc2=[(i*(i-1))//2 for i in cnt]

All=sum(nc2)
for i in range(n):
  now=cnt[a[i]-1]-1
  print(All-nc2[a[i]-1]+((now)*(now-1))//2)


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

using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define int long long
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int) (1e9) + 7;

int tc, q;
map<int, int> factorize(long long n)
{
    map<int, int> factors;
    int count = 0;

    while (!(n % 2)) {
        n >>= 1;
        count++;
    }

    if(count)factors[2] = count;

    for (long long i = 3; i <= sqrt(n); i += 2) {
        count = 0;
        while (n % i == 0) {
            count++;
            n = n / i;
        }
        if (count)
            factors[i] = count;
    }

    if (n > 2)
        factors[n] = 1;
    return factors;
}



void _() {
    int n, m;
    cin >> n >> m;
    string s,t;
    cin >> s >>t;
    int l = n*m/ __gcd(n, m);
    for (int i = 0; i < __gcd(n, m); ++i) {
        if(s[i*n/__gcd(n,m)] != t[i*m/__gcd(n,m)]){
            cout << -1 ;return;
        }
    }
    cout << l;

};

#undef int
int main() {
#if __MINGW32__
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Input.txt", "r", stdin);
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Output.txt", "w", stdout);

#endif

    _();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


}

Measured memory_bytes: 512
#include<algorithm>//sort(all(変数),greater<型名>())で降順に、*max_element(all(変数))で最大値を獲得
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric>
// xとyのgcdは__gcd(x,y),xとyのlcmは(x*y)/__gcd、accumulate(all(変数),0)で要素の全加算
#include<queue>//priority_queue<型名> 変数
#include<set>
#include<stack>
#include<string>//変数.substr(どこから,いくつ)
#include<vector>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define rrep(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int n,T; cin >> n >> T;
  vi t(n); rep(i,n) cin >> t[i];
  ll ans = 0;
  rep(i,n-1){
    ans += min(T,t[i+1]-t[i]);
  }
  cout << ans+T;
  cout << "\n";
  return 0;
}


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

int main()
{
	fast;
	int n;
	cin >> n;
	int ans = 7 % n;
	for (int i = 1; i <= 1e6; i++)
	{
		if (ans == 0)
		{
			cout << i;
			return 0;
		}
		ans = (ans * 10 + 7) % n;
	}
	cout << -1;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char words[10][5]={"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
char in[10];
int main(){
	int r,K;
	int x;
	scanf("%d%d%d",&r,&K,&x);
	for(int i=0;i<10;i++){
		x=x*r-K;
		printf("%d\n",x);
	}
}

Measured memory_bytes: 128
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

A = int(stdin.readline())
B = int(stdin.readline())
print(6-A-B)


Measured memory_bytes: 4088
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main() {    
    double n; cin >> n;
    double res = n / 1.08;
    double a = ceil(res), b = floor(res);
    if(floor(a*1.08) == n) cout << a << ln;
    else if(floor(b*1.08 == n)) cout << b << ln;
    else cout << ":(" << ln;

}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
Aodd = [a for i, a in enumerate(A, 1) if i%2 == 0]
Aoddsum = sum(Aodd)
X1 = S - 2*Aoddsum
X = [X1]
for n in range(1, N):
    X.append(2*A[n-1] - X[n-1])
    
for x in X:
    print(x, end=" ")


Measured memory_bytes: 14092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main(){
  long k;
  cin>>k;
  string s;
  cin>>s;
  if(s.size()<=k){
    cout<<s<<endl;
  }
  else{
    rep(i,k){
      cout<<s.at(i);
    }
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3628
from numpy import *
M=998244353
N,S,*A=map(int,open(0).read().split())
a=0
f=zeros(S+1,int)
for b in A:
  f[0]+=1
  f[b:] += f[:-b].copy()
  f%=M
  a+=f[S]
print(a%M)

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

typedef long long LL;

const int N=100000,INF=(1<<30)-1;

int n,m,sk,a[N+9],b[N+9];

int main(){
  scanf("%d%d%d",&n,&m,&sk);
  int mn0=INF,mn1=INF;
  for (int i=1;i<=n;++i){
	scanf("%d",&a[i]);
	mn0=min(mn0,a[i]);
  }
  for (int i=1;i<=m;++i){
	scanf("%d",&b[i]);
	mn1=min(mn1,b[i]);
  }
  int ans=mn0+mn1;
  for (int i=1;i<=sk;++i){
	int x,y,c;
	scanf("%d%d%d",&x,&y,&c);
	ans=min(ans,a[x]+b[y]-c);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 4600
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int r = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        double result = 2 * r * Math.PI;

        // 出力
        System.out.println(result);
    }
}


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

using namespace std;

template <class T> inline T updmax(T& a, T b) { return a = max(a, b); }
template <class T> inline T updmin(T& a, T b) { return a = min(a, b); }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << endl;
    return 0;
}

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

using namespace std;

int main()
{
    using ll = long long;
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;

    ll q = 8 * Q, h = 4 * H, s = 2 * S, d = D;
    ll m2 = min(q, min(h, min(s, d)));
    
    if (N % 2 == 0) {
        cout << N / 2 * m2 << endl;
    }
    else {
        cout << N / 2 * m2 + min(q / 2, min(h / 2, s / 2)) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# input
N, M= map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

A = sorted(A, key=lambda x: x[0])

ans = 0
cnt = 0
for i in range(N):
    ans += A[i][0] * A[i][1]
    cnt += A[i][1]
    if cnt >= M:
        ans -= A[i][0] * (cnt - M)
        break

print(ans)


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

namespace ABC144_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var ans = false;
            for (int i = 1; i <= 9; i++)
                for (int j = 1; j <= 9; j++)
                {
                    if (i * j == n)
                    {
                        ans = true;
                        break;
                    }
                }
            Console.WriteLine(ans ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define sci(x) scanf("%d",&x)
#define scs(s) scanf("%s",s)
#define scc(c) scanf("%c",c)
#define scd(d) scanf("%lf",&d)
#define scld(ld) scanf("%Lf",&ld)
#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;
 
typedef pair<int, int> i_i;
 
//********************************************
//Error tracking
#define show(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
 
vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}
 
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
    err(++it, args...);
}
//********************************************
 
const int NMAX = 200005;
 
int n,k,l,f[NMAX],f1[NMAX];;
int comp[NMAX], comp1[NMAX];
 
void Union(int x, int y, int *fat, int *c)
{
    if (c[x] > c[y])
    {
        fat[y] = x;
        c[x] += c[y];
    }
    else
    {
        fat[x] = y;
        c[y] += c[x];
    }
}
 
int Find(int x, int *fat)
{
    while (x != fat[x]) x = fat[x];
    return x;
}
 
int main()
{
    int i;
 
   // freopen("input","r",stdin);
  //  freopen("output","w",stdout);
    cin.sync_with_stdio(false);
 
    cin >> n >> k >> l;
 
    for (i = 1; i <= n; i++) 
        {
            f[i] = f1[i] = i;
            comp[i] = comp1[i] = 1;
        }
 
    //make components
    for (i = 1; i <= k; i++)
    {
        int x,y;
 
        cin >> x >> y;
        if (Find(x, f1) != Find(y, f1))
            Union(Find(x, f1), Find(y, f1), f1, comp1);
 
    }
 
    for (i = 1; i <= l; i++)
    {
        int x,y;
 
        cin >> x >> y;
        if (Find(x, f) != Find(y, f)) 
            Union(Find(x, f),Find(y, f), f, comp);
    }
 
    map<i_i, int> mp;
    for (i = 1; i <= n; i++)
    {
        int x = Find(i, f), y = Find(i, f1);
        mp[i_i(x, y)]++;
    }
    for (i = 1; i <= n; i++)
    {
        int x = Find(i, f), y = Find(i, f1);
        cout << mp[i_i(x,y)] << " ";
    }
 
    cout << endl << "\n";
    return 0;   
}

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

//Short code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

//Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)

int main ()
{
  //freopen ("input.txt","r",stdin);
  //freopen ("output.txt","w",stdout);

  /* Code here */
  int n,T,c,t,cptr = 0;
  vector<pair<int,int> > arr;
  cin>>n>>T;
  while(n--){
  	cin>>c>>t;
  	if(t<=T) cptr++;
  	arr.PB(MP(c,t));
  }
  if(cptr == 0) cout<<"TLE";
  else{
  	
  	sort(arr.begin(),arr.end());
  	for(int i=0; i<arr.size() ; i++){
  		if(arr[i].S <= T)
  		{
  			cout<<arr[i].F;
  			break;
		  }
	  }
  }
  //fclose (stdin);
  //fclose (stdout);
  return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,x,i,j,k,ans1,ways=0;
	for(;;){
		cin>>n>>x;
		if(n==0&&x==0)
			break;
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				for(k=1;k<=n;k++){
					ans1=i+j+k;
					if(ans1==x && i!=k && i!=j && k!=j && i<j && j<k && i<k){
						ways++;
					}
				}
			}
		}
		cout<<ways<<endl;
		ways=0;
	}

	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
const int MAXK = 2e5 + 2;
const int MAXN = 3000 + 2;
int my_map[MAXN][MAXN];
LL dp[MAXN][MAXN][4];

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int R, C, K;
    cin >> R >> C >> K;
    vector<int> r(MAXK), c(MAXK), v(MAXK);
    for (int i = 0; i < K; ++i) {
        cin >> r[i] >> c[i] >> v[i];
        my_map[r[i]][c[i]] = v[i];
    }
    for (int i = 1; i <= R; ++i) {
        for (int j = 1; j <= C; ++j) {
            dp[i][j][0] = max(dp[i-1][j][3], dp[i][j-1][0]);
            for (int k = 1; k < 4; ++k) {
                dp[i][j][k] = dp[i][j-1][k];
                dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][3] + my_map[i][j]);
                dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + my_map[i][j]);
            }
            // cout << dp[i][j][3] << ' ';
        }
        // cout << endl;
    }
    cout << dp[R][C][3] << endl;
    return 0;
}


Measured memory_bytes: 321936
//BISMILLAHIR RAHMANIR RAHEEM
//ALLAH IS WATCHING ME
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test IOS long long t;cin >> t;while(t--)
#define ses   "\n"
#define whp   " "
#define mxi 200003
#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)
#define INF 0x3f3f3f3f
#define CLR(a,b) memset(a,b,sizeof(a));
#define PI acos(-1)
#define what_is(x) cout<<x<<ses;
//set <int, greater <int> > ::iterator it;
//vector<pair<int,int> >a;
//memset(arr,0,sizeof(hg));
//priority_queue <int, vector<int>, greater<int> > pq;
///  string single character erase-
///             s.erase(s.begin()+x); where s is st ring name
///               ans x is index;
///    transform(sl.begin(), sl.end(), sl.begin(), ::tolower);
///    transform(su.begin(), su.end(), su.begin(), ::toupper);
typedef long long v99;
typedef unsigned long long ull;
using namespace std;
v99 fx[4]= {1,-1,0,0};
v99 fy[4]= {0,0,1,-1};
v99 ox8[] = {0, 0, 1, 1, 1, -1, -1, -1};
v99 oy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
bool sort2val(const pair<int,int> &a,const pair<int,int> &b)
{
    if(a.second==b.second)return a.first<b.first;
    return a.second<b.second;
}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
/**
bool prime[1000020];vector<v99>prm;
void SieveOfEratosthenes(v99 n)
{
	memset(prime, true, sizeof(prime));
	for(v99 i=4;i<=n;i+=2)prime[i]=false;
	for (v99 p=3; p*p<=n; p++)
	{
		if (prime[p] == true)
		{
			/// Update all multiples of p
			for (v99 i=p*p; i<=n; i += 2*p)
				prime[i] = false;
		}
	}
	rep1(i,2,n)if(prime[i])prm.push_back(i);

}*/
v99 pw(v99 a, v99 b)
{
	v99 ans = 1;
	for(v99 i = 1; i <= b; ++i)
		ans = (ans * a);
	return ans;
}

template <class T> inline T bigmod(T n,T p,T m)
{
    if(p==0)return 1;
    else if(p%2==0)
    {
        v99 val=bigmod(n,p/2,m);
        return (T)((val*val)%m);
    }
    else return (T)(((v99)n*(v99)bigmod(n,p-1,m))%m);
}


///-------------------------------------------------------------------------------------------------------



int main()
{

    //freopen("data.out","w",stdout);
    //test
    //while(1)
    {
        v99 n;cin>>n;
        v99 cr_h=n%1000;
        if(cr_h)cout<<1000-cr_h<<ses;
        else cout<<0<<ses;

    }
    return 0;
}




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

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, r;
	cin >> n >> r;
	if (n >= 10) cout << r << '\n';
	else cout << r + 100 * (10 - n) << '\n';
}


Measured memory_bytes: 256
P=998244353
N,K=map(int, input().split())
LR=[list(map(int, input().split())) for _ in range(K)]

s=[0 for _ in range(N+1)]
s[1]=1
for i in range(1,N):
  s[i+1] = s[i]
  for l,r in LR:
    s[i+1]+=(s[max(0,i-l+1)]-s[max(0,i-r)])%P
    s[i+1]%=P
print((s[N]-s[N-1])%P)

Measured memory_bytes: 16920
//https://atcoder.jp/contests/abc160/tasks/abc160_b
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x;
	cin>>x;
	ll a;
	a=x/500;
	ll fin1;
	fin1=a*1000;
	ll b;
	b=x%500;
	ll c;
	c=b/5;
	ll fin2;
	fin2=c*5;
	ll sum=0;
	sum=fin1+fin2;
	cout<<sum<<"\n";
	return 0;
}

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

int main(){

    string S;
    cin >> S;
    int N = S.size();
    vector<int> ans(N,1);
    
    for(int i = 0; i < N-1;i++){
        if(S[i]=='R' && S[i+1]=='R'){
            ans[i+2] += ans[i];
            ans[i] = 0;
        }
    }
    
    for(int i = N-1; i > 0;i--){
        if(S[i]=='L' && S[i-1]=='L'){
            ans[i-2] += ans[i];
            ans[i] = 0;
        }
    }   
    
    for(int i = 0; i < N;i++){
        cout << ans[i];
        if(i != N)cout <<" ";
        else cout << endl;
    }
    return 0;
    
}

Measured memory_bytes: 1024
from heapq import heappushpop, heappush
left, right = [], []
q = int(input())
ans = 0
for _ in range(q):
	a = list(map(int, input().split()))
	if a[0] == 1:
		left_out = heappushpop(left, -a[1])
		right_out = heappushpop(right, a[1])
		ans += a[2] + abs(left_out+right_out)
		heappush(left, -right_out)
		heappush(right, -left_out)
	else:
		print(-left[0], ans)

Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    string s; cin >> s;
    ll sl=s.length();
    ll ans=(ll)(sl*(sl-1))/2;
    map<char,ll> m;
    rep(i,sl) m[s[i]]++;
    for(auto x : m) ans-=(ll)((x.second)*(x.second-1))/2;
    cout << ans+1 << endl;
return 0;
}

Measured memory_bytes: 3732
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e9
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	while (true) {
		int a, d, n;
		cin >> a >> d >> n;
		if (a == 0) return 0;
		for (int i = a;; i += d) {
			int ok = 1;
			if (i == 1) ok = 0;
			for (int q = 2; q <= sqrt(i); ++q) {
				if (i % q == 0) {
					ok = 0;
					break;
				}
			}
			n -= ok;
			if (n == 0) {
				cout << i << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 3016
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n && n)
	{
		bool f = true;
		set<int> table;
		vector<ll> v(4005, 0);

		rep(i, n)
		{
			int num;
			ll a, s;
			cin >> num >> a >> s;

			if(table.find(num) == table.end())
			{
				v[num] += a * s;
				if(1000000 <= v[num])
				{
					f = false;
					table.insert(num);
					cout << num << endl;
				}
			}
		}

		if(f) cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define MOD 1000000007

using namespace std;
int N, M, S[50][2], C[51][2];

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d", &N, &M);
	for(int i = 0; i < N; i++) scanf("%d%d", &S[i][0], &S[i][1]);
	for(int i = 1; i <= M; i++) scanf("%d%d", &C[i][0], &C[i][1]);
	for(int i = 0; i < N; i++){
		int n = INT_MAX;
		int v = 0;
		for(int j = 1; j <= M; j++){
			int m = abs(S[i][0] - C[j][0]) + abs(S[i][1] - C[j][1]);
			if(m < n) n = m, v = j;
		}
		printf("%d\n", v);
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    priority_queue<pair<ll, int>> pq;
    for (int i = 0; i < N; i++) {
        cin >> B[i];
        if (A[i] < B[i]) {
            pq.push({B[i], i});
        }
        if (A[i] > B[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = 0;
    while (!pq.empty()) {
        int pos = pq.top().second;
        pq.pop();
        int pre = (pos+N-1)%N;
        int nxt = (pos+1)%N;
        ll dist = B[pre]+B[nxt];
        if (dist > B[pos]-A[pos]) {
            cout << -1 << endl;
            return 0;
        }
        ans += (B[pos]-A[pos])/dist;
        B[pos] -= (B[pos]-A[pos])/dist*dist;
        if (B[pos] > A[pos]) pq.push({B[pos], pos});
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9456