akhauriyash/Code-Regression huggingface dataset:
import sys

X, N = map(int, input().split())
list_p = list(map(int, input().split()))

if N == 0:
    print(X)
    sys.exit()

all_list = [int(x) for x in range(0, 102)]
target_list = sorted(list(set(list_p) ^ set(all_list)))

ans = [abs(num - X) for num in target_list]
# print(all_list)
# print(target_list)
# print(min(ans))
# print(ans.index(min(ans)))
print(target_list[ans.index(min(ans))])


Measured memory_bytes: 9200
package main

import (
	"fmt"
	// "sort"
	//"regexp"
)

var n, m, a, b, ans int

func main() {
	fmt.Scan(&n)
	fmt.Scan(&m)
	min := 0
	max := 1000001
	for i := 0; i < m; i++ {
		fmt.Scan(&a)
		fmt.Scan(&b)
		if min < a {
			min = a
		}
		if max > b {
			max = b
		}
	}
	for i := 1; i < n+1; i++ {
		open := false
		if i >= min && i <= max {
			open = true
		}
		if open {
			ans++
		}
	}
	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 6364
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

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

    long long ans = 0;
    int arr[n];

    for(auto& i : arr) std :: cin >> i;

    std :: sort(arr , arr + n, std :: greater<>());

    if(n == 2) {
        std :: cout << arr[0] << '\n';
        return 0;
    }

    ans += arr[0];
    n -= 2;
    for(int i = 1 ;  ; i++, n -= 2) {
        if(n <= 0) break;

        if(n == 1) {
            ans += arr[i];
            break;
        }
        ans += 2 * arr[i];
    }

    std :: cout << ans << '\n';
}


Measured memory_bytes: 3940
package main

import (
	"fmt"
)

func main() {
	var (
		s string
		k int
	)
	fmt.Scan(&k)
	fmt.Scan(&s)
	if len(s) <= k {
		fmt.Println(s)
	} else {
		fmt.Println(s[:k] + "...")
	}
}


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

int main() {
  string str;
  cin >> str;
  
  bool ans= false;
  while(true){
    if( str=="" ){
      ans= true;
      break;
    }
    else{
      int len= str.size();
      string str_pad= "000000"+str;
      string suffix= str_pad.substr(len-1);
    	if( suffix=="dreamer" ){
          str= str.substr(0,len-7);
        }
        else if( suffix.substr(1)=="eraser" ){
          str= str.substr(0,len-6);
        }
        else if( suffix.substr(2)=="dream" || suffix.substr(2)=="erase" ){
          str= str.substr(0,len-5);
    	}
    	else{
      		ans= false;
      		break;
    	}
  	}
  }
  
  if( ans ){
  	cout << "YES" << endl;
  }
  else{
  	cout << "NO" << endl;
  }
}


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

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n;
	cin>>n;
	ll x;
	cin>>x;
	vector<ll> v;
	for(int i=0;i<n;i++)
	{
		ll r;
		cin>>r;
		v.push_back(r);
	}
	ll ans=0;
	if(v[0]>x)
	{
		ans+=v[0]-x;
		v[0]=x;
	}
	for(int i=1;i<n;i++)
	{
		if((v[i]+v[i-1])>x)
		{
				ans+=(v[i]+v[i-1])-x;
				v[i]-=(v[i]+v[i-1])-x;
		}
	}
	cout<<ans<<'\n';
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i = 1; i <= n; i++) {
        if(i%3!=0&&i%5!=0) ans+=i;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(){
	int total;
	int book[9];
	int i;
	
	for(;;){
		scanf("%d",&total);
		if(total==0){
			break;
		}
		else {
			for(i=0;i<9;i++){
				scanf("%d",&book[i]);
				total-=book[i];
			}
			printf("%d\n",total);
		}
	}
	return 0;
}

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

int main(){
	int i,chkC=0,chkF=0,chk=0;
	string s;
	cin>>s;
	for(i=0;i<s.size();i++){
		if(s[i]=='C'&&chkF==0) chkC=1;
		if(s[i]=='F'&&chkC==1) chk=1;
	}
	if(chk==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
H = list(map(int, input().split()))
if N == 1:
    print('Yes')
else:
    for i in reversed(range(N-1)):
        if H[i] -H[i+1] > 1: print('No');sys.exit()
        elif H[i] - H[i+1] == 1: H[i] -= 1
        else: continue
    print('Yes')


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
LL ara[200009];
vector<pLL>v;
int main()
{
    LL n,d,a;
    cin>>n>>d>>a;
    for(LL i=0; i<n; i++)
    {
        int p,q;
        cin>>p>>q;
        v.pb(mk(p,q));
    }
    sort(all(v));
    LL ans=0;
    for(LL i=0; i<n; i++)
    {
        if(i!=0)
            ara[i]+=ara[i-1];
        LL x=v[i].ss-ara[i];
        if(x>0)
        {
            pLL pa=mk(v[i].ff+2*d,INF);
            LL r=UB(v,pa);

            LL cnt=(x+a-1LL)/a;
            ara[r]-=cnt*a;
            ara[i]+=cnt*a;
            ans+=cnt;
        }
    }
    cout<<ans;

}


Measured memory_bytes: 6256
if __name__ == '__main__':
  
  flag = 1
  
  wordNum = int(input())
  wordAll = []

  for i in range(wordNum) :

    word = input()
    wordAll.append(word)
    wordLen = len(word)
    
    if i > 0 and wordLast != word[0]:
      flag = 0
      break
    
    
    for j in range(len(wordAll)-1):
      if wordAll[j] == word:
        flag = 0
        break
    
    
    wordLast = word[wordLen - 1]

    
  if flag == 1 :
    print("Yes")
    
  else :
    print("No")


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

int main()
{
	long long n,k;cin>>n>>k;

	if( n >= k)
	{
		long long r1 = n%k;
		if(r1 == 0)
			cout<<0;
		else
		{
			long long diff = k - r1;
			if( diff < r1)
				cout<<diff;
			else
				cout<<r1;
		}
	}
	else 
	{
		long long diff = k - n;
		if( diff < n)
			cout<<diff;
		else
			cout<<n;
	}
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		new ABC133().c();
	}
}

class ABC133{
		void c(){
				long L, R;
				long M = 2019L;
				Scanner in = new Scanner(System.in);
				L = in.nextLong();
				R = in.nextLong();
				int ans = 2018;
				long maxI = (long)Math.min(R, L+M);
				for(long i=L; i<=maxI; ++i){
						long maxJ = (long)Math.min(R, i+1L+M);
						for(long j=i+1; j<=maxJ; ++j){
								ans = (int)Math.min(ans, i*j%M);
						}
				}
				System.out.println(ans);
				in.close();
		}
}


Measured memory_bytes: 23252
#include<stdio.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG


int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG

    int a, b;
    char op;

    while (scanf("%d %c %d", &a, &op, &b), '?' != op)
    {
        switch (op)
        {
            case '+':
                printf("%d\n", a + b);
                break;

            case '-':
                printf("%d\n", a - b);
                break;
            
            case '*':
                printf("%d\n", a * b);
                break;

            case '/':
                printf("%d\n", a / b);
                break;
        }
    }
    
#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}




Measured memory_bytes: 2028
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(vector<int>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

int DIST(int X,int Y)
{
  return abs(X) + abs(Y);
}

void solve(void)
{  
  int N;
  cin>>N;
  int X = 0, Y = 0,TIME = 0;;
  bool possible = true;
  for (int i = 0; i < N; i++)
  {
    int T,A,B;
    cin>>T>>A>>B;
    int D = DIST(A-X,B-Y);
    // DEBUG(T);
  
    if(((T - TIME) >= D) && ((T-TIME)%2 == D%2))
    {
    X = A;
    Y = B;
    TIME = T;
    }
    else
    {
      possible = false;
    }

    
  }
  if(possible)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  

  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n;
vector<int> a;
vector<vector<int> > memo;

int solve(int x, int y)
{
    if(x == y)
        return 0;
    if((x+1)%n == y)
        return abs(a[x] - a[y]);
    if(memo[x][y] != -1)
        return memo[x][y];

    int ret = solve(x, (y-1+n)%n) + abs(a[x] - a[y]); // 最後にa[x]とa[y]の差を足す場合の最大値
    for(int z=(x+1)%n; z!=y; z=(z+1)%n)
        ret = max(ret, solve(z, y) + solve(x, z)); // 最後にa[x]とa[z]の差を足す場合の最大値
    return memo[x][y] = ret;
}

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

    while(--d >= 0){
        cin >> n;
        a.resize(n);
        for(int i=0; i<n; ++i)
            cin >> a[i];

        memo.assign(n, vector<int>(n, -1));
        int ret = 0;
        for(int i=0; i<n; ++i)
            ret = max(ret, solve((i+1)%n, i));
        cout << ret << endl;
    }

    return 0;
}

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

int main(){
    cin >> X;
    for(ll a = -1000; a < 1000; a++){
        for(ll b = -1000; b < 1000; b++){
            if( a - b > 0 ){
                if((X % (a - b) == 0) && (a*a*a*a*a - b*b*b*b*b == X)){
                    cout << a << " " << b << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3612
#!/usr/bin/python
import sys
import math
from decimal import Decimal

l = sys.stdin.readline()
l = l.split(' ')
a = int(l[0])
b = int(l[1])
c = int(l[2])
if( Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt()):
  print("Yes")
else:
  print("No")

sys.stdout.flush()

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)
#define ll long long

ll gcd(ll a,ll b){
  if(b==0)return a;
  //cout<<b<<endl;
  return gcd(b,a%b);
}

int main(){
  ll n;
  cin>>n;
  vector<ll> x(n);
  r(i,n)cin>>x.at(i);
  ll ans=x.at(0);

  for(int i=1;i<n;i++){
    ans=gcd(ans,x.at(i));
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
  return 0;

}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Point[] r = new Point[N];
        for (int i = 0; i < N; i++) {
            Point p = new Point();
            p.x = scan.nextInt();
            p.y = scan.nextInt();
            r[i] = p;
        }
        Point[] b = new Point[N];
        for (int i = 0; i < N; i++) {
            Point p = new Point();
            p.x = scan.nextInt();
            p.y = scan.nextInt();
            b[i] = p;
        }
        Arrays.sort(r, new ReversePointComparator());
        Arrays.sort(b, new PointComparator());
        PointComparator c = new PointComparator();
        int answer = 0;
        boolean[] d_r = new boolean[N];
        Arrays.fill(d_r, false);
        int r_l = -1;
        for (int i = 0; i < N; i++) {
            Point p2 = b[i];
            for (int j = 0; j < N; j++) {
                if (d_r[j]){
                    continue;
                }
                Point p1 = r[j];
                if (p1.x < p2.x && p1.y < p2.y) {
                    d_r[j] = true;
                    answer += 1;
                    break;
                }
            }
        }
        System.out.println(answer);
    }
    class Point {
        int x;
        int y;
    }
    class PointComparator implements Comparator<Point> {
        @Override
        public int compare(Point o1, Point o2) {
            if (o1.x == o2.x) {
                return Integer.compare(o1.y, o2.y);
            }
            return Integer.compare(o1.x, o2.x);
        }
    }
    class ReversePointComparator implements Comparator<Point> {
        @Override
        public int compare(Point o1, Point o2) {
            if (o1.y == o2.y) {
                return -Integer.compare(o1.x, o2.x);
            }
            return -Integer.compare(o1.y, o2.y);
        }
    }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h, w;
  cin >> h >> w;
  
  char c;
  int count = 0;
  for(int i = 0; i < h * w; i++){
    cin >> c;
    if(c == '#') count++;
  }
  
  if(count == h + w - 1) cout << "Possible\n";
  else cout << "Impossible\n";
}

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

using namespace std;

vector<vector<int>> dp(3001, vector<int>(6001, 0));
vector<pair<int,int>> a;
vector<int> prefmax;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, T;
    cin>>N>>T;
    a.resize(N,{0, 0});
    prefmax.resize(N+1, 0);
    for(int i=0;i<N;i++){
        cin>>a[i].second>>a[i].first;
    }
    sort(a.begin(), a.end());
    for(int i=N-1;i>=0;i--) prefmax[i]=max(prefmax[i+1], a[i].first);
    for(int i=a[0].second;i<=T;i++){
        dp[0][i]=a[0].first;
    }
    for(int i=1;i<N;i++){
        for(int j=1;j<=T;j++){
            dp[i][j]=max(dp[i-1][j], ((j-a[i].second)>=0)?(dp[i-1][j-a[i].second]+a[i].first):0);
        }
    }
    int ans=-1;
    for(int i=0;i<N;i++){
        ans=max(ans, dp[i][T-1]+prefmax[i+1]);
        ans=max(ans, dp[i][T]);
    }
    vector<int> was(3001,0);
    int r=T-1, l=N-1;
    while(l>0 && r>0){
        if(l==0) {
            was[l]=1;
            break;
        }
        if(dp[l-1][r] >=(((r-a[l].second)>=0)?(dp[l-1][r-a[l].second]+a[l].first):0)){
            l--;
        }
        else{
            was[l]=1;
            r-=a[l].second;
            l--;
        }
    }
    if(dp[l][r]!=0) was[l]=1;
    int maa=-1;
    for(int i=0;i<N;i++){
        if(was[i]==1) continue;
        maa=max(maa, a[i].first);
    }
    ans=max(ans,maa+dp[N-1][T-1]);

    cout<<ans;
    return 0;
}

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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int x = int.Parse(Console.ReadLine());
            int count = 0;
            for (int i = 0; i <= a; i++)
            {
                for (int j = 0; j <= b; j++)
                {
                    for (int k = 0; k <= c; k++)
                    {
                        if (i * 500 + j * 100 + k * 50 == x) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    int N;
    cin >> N;
    set<string> S;
    rep(i, N) {
        string k;
        cin >> k;
        S.emplace(k);
    }
    cout << S.size() << endl;
}

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

int main()
{
    long long N;
    cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        if (i == 0)
            cin >> a[0];
        else
        {
            long long b;
            cin >> b;
            a[i] += b + a[i - 1];
        }
    }
    long long ans = 2000000000;
    for (int i = 0; i < N - 1; i++)
    {
        ans = min(ans, abs(2LL * a[i] - a[N - 1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)          
{
	int a[100], n;
	int queue, i;

	scanf("%d", &n);

	for (i = 0;i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	for (i = 0; i < n / 2; i++)
	{
		queue = a[i];
		a[i] = a[n - i - 1];
		a[n - i - 1] = queue;
	}
	
	for (i = 0; i < n; i++)
	{
		printf("%d", a[i]);
		if (i != n - 1) printf(" ");
	}
	
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		Long k = Long.parseLong(sc.next());
		int[] town = new int[n]; 
		boolean[] town_flag = new boolean[n];
		for(int i = 0 ; i < n ; i++) {
			town[i] = Integer.parseInt(sc.next());
		}
		
		List visit = new ArrayList<Integer>();
		town_flag[0] = true;
		visit.add(1);
		
		int pos = 0;
		while(true) {
			int temp = town[pos]-1;
			visit.add(temp+1);
			if(town_flag[temp]) {
				break;
			}
			town_flag[temp] = true;
			pos = temp;
		}
		pos = (int) visit.get(visit.size()-1);
		int looppos =visit.indexOf(pos)+1;
		
		
		int ans = 0;
		if(k < looppos) {
			ans = (int) visit.get(k.intValue());
		}else {
			int loop = visit.size() - looppos; 
			pos = (int) ((k-looppos)%loop);
			pos = pos + looppos;
			ans = (int) visit.get(pos);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 50536
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);

int main(){
    ll n,k;cin>>n>>k;
    ll a[n];
    rep(i,n)cin>>a[i];
    rep2(i,k,n){
        if(a[i]>a[i-k]){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 5204
struct team_t{
	char name;
	int win;
	int lose;
	int order;
}t[10];
M(struct team_t*a,struct team_t*b){
	if(a->win!=b->win)
		return b->win-a->win;
	if(a->lose!=b->lose)
		return a->lose-b->lose;
	return a->order-b->order;
}
n,i,j,r;
main(){
	for(;scanf("%d",&n),n;){
		memset(t,0,sizeof(t));
		for(i=0;i<n;i++){
			scanf("\n%c",&t[i].name);
			for(j=0;j<n-1;j++){
				scanf("%d",&r);
				if(r==0)
					t[i].win++;
				if(r==1)
					t[i].lose++;
			}
			t[i].order=i;
		}
		qsort(t,n,sizeof(*t),M);
		for(i=0;i<n;i++)
			printf("%c\n",t[i].name);
	}
	exit(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)


struct cnode
{
    int index[26];
    bool last[26];

    cnode()
    {
        rep(i, 26) 
        {
            index[i] = -1;
            last[i] = false;
        }
    }
};

cnode g_n[2000000];

int main()
{
    int n;
    cin >> n;
    string *s = new string[n];
    pair<int, int> *sindex = new pair<int, int>[n];
    rep(i, n)
    {
        cin >> s[i];
        sindex[i] = make_pair(s[i].length(), i);
    }
    sort(sindex, sindex + n);
    int cindex = 1;

    
    map<string, set<int>> m;
    int ans = 0;

    int clist[26];

    rep(i, n)
    {
        string t = s[sindex[i].second];
        int l = t.length();
        rep(m, 26) clist[m] = 0;
        rep(m, l) clist[t[m]-'a']++;
        int c = 0;
        int pos = 0;
        while( pos + 1 < l )
        {
            int nexti = t[l - 1 - pos] -'a';
            rep(j, 26)
            {
                if( g_n[c].last[j] && clist[j] > 0 ) ans++;
            }
            clist[nexti]--;

            if( g_n[c].index[nexti] < 0 )
            {
                g_n[c].index[nexti] = cindex++;
            }
            c = g_n[c].index[nexti];
            pos++;
        }
        g_n[c].last[t[0]-'a'] = true;
    }
    cout << ans;

    return 0;    
}

Measured memory_bytes: 269024
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		long[] a=new long[n];
		long[] an=new long[n];
		long ans=0;
		for(int i=0; i<n; i++){
			a[i] = 2*sc.nextLong();
			if(i%2==0){
				ans+=a[i];
			}else{
				ans-=a[i];
			}
		}
		ans/=2;
		an[0]=ans;
		System.out.print(an[0]+" ");
		for(int i=1; i<n; i++){
			an[i]=a[i-1]-an[i-1];
			System.out.print(an[i]+" " );
		}
	}
}




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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
}

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif



void solve()
{
    long long a,b,c;
    cin>>a>>b>>c;

    long long res=max(0ll,c-(a-b));
    cout<<res<<endl;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;
    while (t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int A[] = new int[n];
		int i;
		for(i=0; i<n; i++){
			A[i] = sc.nextInt();
		}
		shellSort(A, n);
		for(i=0; i<n; i++){
			System.out.println(A[i]);
		}
	}
	static void shellSort(int A[], int n){
		int G[] = new int[15];
		int i, j, m=0, cnt=0;
		for(i=1; i<n; i=i*3+1){
			for(j=m; j>0; j--){
				G[j] = G[j-1];
			}
			G[0] = i;
			m++;
		}
		if(m==0){
			G[0] = 1;
			m=1;
		}
		System.out.println(m);
		for(i=0; i<m; i++){
			if(i!=0) System.out.print(" ");
			System.out.print(G[i]);
			cnt += insertionSort(A, n, G[i]);
		}
		System.out.println();
		System.out.println(cnt);
	}
	static int insertionSort(int A[], int n, int g){
		int i, j, key, cnt=0;
		for(i=g; i<n; i++){
			key = A[i];
			j = i - g;
			while(j>=0 && A[j]>key){
				A[j+g] = A[j];
				j = j - g;
				cnt++;
			}
			A[j+g] = key;
		}
		return cnt;
	}
}

Measured memory_bytes: 296956
//#pragma GCC diagnostic error "-std=c++11"
#include<bits/stdc++.h>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
string s;
int main(){
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])puts("Yes");
    else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #include<boost/multiprecision/cpp_int.hpp>
// using boost ::multiprecision::cpp_int;
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/
int main()
{
    boost;
    ll k;
    cin>>k;
    string s;
    cin>>s;
    ll x =0;
    // if(x==0)
    x= s.length();
    for(ll i=0;i<min(k,x);i++)
    cout<<s[i];
    if(s.length()> k)
    for(ll i=0;i<3;i++)
    cout<<".";
    cout<<"\n";
    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}
/* AnsHuman_7 || Anshuman Gaur */

Measured memory_bytes: 3676
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int n;
    int [][] card = new int[4][13];

    for(int i=0; i<4; i++)
        for(int j=0; j<13; j++)
            card[i][j] = 0;

    Scanner in = new Scanner(System.in);

    n = in.nextInt();

    String mark;
    int su;

    for(int i=0; i<n; i++){
        in.nextLine();
        mark = in.next();
        su = in.nextInt();

        if(mark.equals("S"))
            card[0][su-1] = 1;
        else if(mark.equals("H"))
            card[1][su-1] = 1;
        else if(mark.equals("C"))
            card[2][su-1] = 1;
        else
            card[3][su-1] = 1;
    }

    for(int i=0; i<4; i++)
        for(int j=0; j<13; j++)
            if(card[i][j] == 0){
                if(i == 0)
                    System.out.println("S " + (j+1));
                else if(i == 1)
                    System.out.println("H " + (j+1));
                else if(i == 2)
                    System.out.println("C " + (j+1));
                else
                    System.out.println("D " + (j+1));
            }
  }
}

Measured memory_bytes: 26232
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
# from copy import deepcopy, copy

import queue
from collections import deque



def main():
    num = int(input())
    data = [int(input()) for i in range(num)]

    ans = 0
    for i in range(num):
        if i == 0:
            ans += data[i] // 2
            data[i] = data[i] % 2
        else:
            ans += (data[i] + data[i - 1]) // 2
            if data[i] != 0:
                data[i] = (data[i] + data[i - 1]) % 2
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 50900
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
s=sum(b)
for x in range(len(a)-1):
    if a[x+1]-a[x]==1:
        s+=c[a[x]-1]
print(s)

Measured memory_bytes: 3060
from itertools import combinations_with_replacement
inputs = open(0).readlines()
n, m, q = map(int, inputs[0].split())
ABCD = [list(map(int, x.split())) for x in inputs[1:]]

ans = 0
for x in combinations_with_replacement(range(1, m+1), n):
    e = 0
    for a, b, c, d in ABCD:
        if x[b-1] - x[a-1] == c:
            e += d
    ans = max(e, ans)
print(ans)

Measured memory_bytes: 9212
#include <iostream>

int main()
{
    int N, d;
    std::cin >> N >> d;
    int p, res = 0;
    for (int i = 0; i < N; i++) {
        std::cin >> p;
        res += std::max(0, p - d);
    }
    if (res == 0) {
        std::cout << "kusoge" << std::endl;
    } else {
        std::cout << res << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n;
long long dp[3007][3007], a[3007];
bool vis[3007][3007];

long long solve(int l, int r, int turn){
	if(vis[l][r]) return dp[l][r];
	vis[l][r] = true;
	if(l == r){
		if(turn == 0) dp[l][r] = a[l];
		else dp[l][r] = -a[l];
		return dp[l][r];
	}
	long long ans = 0, nxt = turn ^ 1;
	if(turn == 0) ans = max(solve(l + 1, r, nxt) + a[l], solve(l, r - 1, nxt) + a[r]);
	else ans = min(solve(l + 1, r, nxt) - a[l], solve(l, r - 1, nxt) - a[r]);
	dp[l][r] = ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	cout << solve(1, n, 0);
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define mp make_pair
#define pb push_back
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

template<class T> inline bool chmin(T& a, T b) 
{ if (a > b) { a = b; return true; } return false; }

template<class T> inline bool chmax(T& a, T b) 
{ if (a < b) { a = b; return true; } return false; }

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

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

    sort(all(S));
    if (S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) yes;
    else no;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;
 
void Main()
{
	int N;
  
  	cin >> N;
    
    int A[N];
    int B[N];
    
    A[0] = 0;
    for(int i = 1; i < N; i++){
    	cin >> A[i];
    }
    
    for(int i = 0; i < N; i++){
    	B[i] = 0;
    }
    
    for(int i = 1; i < N; i++){
    	B[A[i]-1] = B[A[i]-1] + 1;
    }
    
    for(int i = 0; i < N; i++){
    	printf("%d\n", B[i]);
    }
    
	
	
}
 
int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

int main() {
	int a;
	cin >> a;
	int b[a];
	int sum=0;
	for(int i=0;i<a;i++){
		cin >> b[i];
	}
	int c;
	cin >> c;
	for(int i=0;i<c;i++){
		int aa,bb;
		cin >>aa >>bb;
		for(int j=1;j<=a;j++){
			
			if(j==aa){
				sum+=bb;
			}else{
				sum+=b[j-1];
			}	
		}
		
		cout << sum << endl;
		sum=0;
	}
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

	int sum=0;
	for (int i = 0; i < n-1; i++){
		for (int j = i+1; j < n; j++){
			sum+=d[i]*d[j];
		}
	}

	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
A=list(map(int,input().split()))
ans=0
tmp=A[0]
for x in A[1:]:
    if x<tmp:
        ans+=tmp-x
    tmp=max(tmp,x)
print(ans)

Measured memory_bytes: 94140
#include <cstdio>
#include <cstdint>
#include <vector>

struct Edge {
  size_t src, dst;
  int cost;
  Edge(size_t s, size_t d, int c): src(s), dst(d), cost(c) {}
};

int main() {
  size_t L;
  scanf("%zu", &L);

  size_t N=64-__builtin_clzll((unsigned long long)L);
  std::vector<Edge> es;

  size_t M=L-(1<<(N-1));

  for (size_t i=1; i+1<=N; ++i) {
    es.emplace_back(i, i+1, 0);
    es.emplace_back(i, i+1, 1<<(N-i-1));
  }

  int cost=1<<(N-1);
  for (size_t j=N-1, d=2; (j-- && M); ++d) {
    if (M >> j & 1) {
      es.emplace_back(1, d, cost);
      M ^= 1 << j;
      cost += 1 << j;
    }
  }

  printf("%zu %zu\n", N, es.size());
  for (const auto &e: es)
    printf("%zu %zu %d\n", e.src, e.dst, e.cost);
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  ll n, d; cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; ++i){
    ll x, y; cin >> x >> y;
    if(x*x + y*y <= d*d)  ans++;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3648
N = int(input())
num = input()
X = int(num,2)
c = num.count('1')
def A(s):
    if s == 0:
        return 1
    return A(s%(bin(s).count('1'))) + 1
if c==1:
  for i in range(N):
    if num[i] == '1':
      print(0)
    elif i == N-1:
      print(2)
    else:
      print(1)
  exit()
amari1 = X%(c+1)
amari2 = X%(c-1)
for i in range(N):
    if num[i] == '1':
        print(A((amari2-pow(2,N-1-i,c-1))%(c-1)))
    else:
        print(A((amari1+pow(2,N-1-i,c+1))%(c+1)))

Measured memory_bytes: 79900
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())
import sys
sys.setrecursionlimit(10**6)

def valid(i):
    ar=[]
    if i-1>=0:
        ar.append(i-1)
    ar.append(i)
    if i+1<=9:
        ar.append(i+1)
    return ar

k=int(input())
cur=[1,2,3,4,5,6,7,8,9]
if k<=9:
    print(cur[k-1])
else:
    while(k>len(cur)):
        new_cur=[]
        for i in cur:
            temp=valid(i%10)
            for j in temp:
                new_cur.append(i*10 + j)
        k-=len(cur)
        cur=new_cur.copy()
    print(cur[k-1])



Measured memory_bytes: 75860
// Created by sz
#include<bits/stdc++.h>
using namespace std;

int price[100005];

int main() {
//    freopen("./input.txt", "r", stdin);
    int N, K;
    scanf("%d%d", &N, &K);
    for (int i = 0;i < N; i++){
        scanf("%d", &price[i]);
    }
    sort(price, price+N);
    int mini = 1e9+100;
    for(int i = 0; i<N+1-K; i++){
        mini = min(mini, price[i+K-1] - price[i]);
    }
    
    printf("%d\n", mini);
    
    return 0;
}



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

long long N, K;
long long A[200010]; 

bool isPossible(long long x){ //答えはX以下になり得ますか
    int temp = 0;
    for(int i = 0; i < N; i++){
        temp += (A[i] + x - 1)/x - 1;
    }
    if(temp > K) return false;
    else return true;       
}

int main(){
    cin >> N >> K;
    long long max = 0;
    for(int i = 0; i < N; i++){
        long long a;
        cin >> a;
        A[i] = a;
        if(a > max) max = a;
    }
    int l = 1;
    int r = max;
    while(r - l >1){
        int c = (l + r)/2;
        if(isPossible(c)) r = c;
        else l = c;
    }
    if(isPossible(l)) cout << l << endl;
    else cout << r << endl;
}

Measured memory_bytes: 5124
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int N, tmp;
    std::cin >> N;
    std::vector<int> sides;
    for (int i = 0; i < N; i++)
    {
        std::cin >> tmp;
        sides.push_back(tmp);
    }

    std::sort(sides.begin(), sides.end());
    int longest = sides[N - 1];
    int others_sum = 0;
    for (int i = 0; i < N - 1; i++) { others_sum += sides[i]; }

    if (longest < others_sum) { std::cout << "Yes" << std::endl; }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
//#include "SaveFuncs.cpp"

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr int DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

int Main()
{
	int a;
	string s;
	cin >> a >> s;

	if (a >= 3200)
		cout << s;
	else
		cout << "red";

	return 0;
}

/*****/

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

	Main();

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
s = input()
c = 0
a = 0
p = ""
n = 0
for i in s:
    if i != p:
        if i == "<":
            if c < 0:
                a -= c * n
            else:
                a -= c * (n - 1)
            n = 2
            c = 1
        else:
            n = 2
            c -= 1
    else:
        if i == "<":
            c += 1
            n += 1
        else:
            c -= 1
            n += 1
    a += c
    p = i
if p == ">":
    if c < 0:
        a -= c * n
    else:
        a -= c * (n - 1)
print(a)


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

// How Many Divisors?
int main(){
	int a, b, c;
	int count = 0;
	cin >> a >> b >> c;
	for(int i = a; i <= b; i++){
		if(c % i == 0){
			count++;
		}
	} 
	cout << count << endl;

	return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i = (n); i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(1e5+5);

void pre() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  #endif
}

void solve() {
  int n;  cin>>n;
  string s; cin>>s;
  int red = 0, white = 0, cnt = 0,rmx = 0;
  bool r = false;
  repA(i,n-1) {
    if(s[i] == 'W') {
      white++;
      if(r) cnt++;
    }
    else  {
      red++;
      r = true;
    }
  }
  int w = 0, z = white;
  rep(i,z) {
    if(s[n - 1 -i] == 'W') w++;
  }
  rmx = white - w;
  int ans = min(rmx,min(cnt,min(white,red)));
  cout<<ans;
}

int main() {
  pre();
  int t = 1;
  //cin>>t;
  rep(i,t)  {
    //cout<<"Case #"<<(i+1)<<"\n";
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3792
#include<stdio.h>

int main(){
  char str[100000];
  int count=0;
  int n=0;
   int i=0;
   scanf("%s",&str);
    while(1){

       if(str[i+1]=='\0')break;
      if(str[i]!=str[i+1])count++;
   
      i++;
  }
    
   
   printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	double a,b,c,d,e,f,x,y;
	while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
		if(a*e!=b*d){
			x = (e*c-b*f)/(a*e-b*d);
			y = (a*f-c*d)/(a*e-b*d);
			x*=1000;y*=1000;
			if(x>0) x+=0.5;
			else x-=0.5;
			if(y>0) y+=0.5;
			else y-=0.5;
			x=(int)x;y=(int)y;
			x/=1000;y/=1000;
			printf("%.3f %.3f\n",x,y);
		}
	}
	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, D, A;
    cin >> N >> D >> A;
    vector<pair<unsigned long, unsigned long>> enemies(N);
    for(auto& i : enemies){
        cin >> i.first >> i.second;
        i.second = (i.second + A - 1) / A;
    }
    sort(enemies.begin(), enemies.end());
    unsigned long ans{0}, now{0};
    queue<pair<unsigned long, unsigned long>> q;
    for(const auto& i : enemies){
        while(!q.empty() && q.front().first < i.first && (now += q.front().second))q.pop();
        auto k = i.second - min(i.second, ans - now);
        if(k)q.emplace(i.first + D * 2, k);
        ans += k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
import sys

koma_num, goal_num = [int(a) for a in input().split(' ')]

if koma_num >= goal_num:
  print(0)
  sys.exit()

goals = [int(a) for a in input().split(' ')]
goals.sort()
dist_diff = [int(goals[i+1] - goals[i]) for i in range(len(goals)-1)]
dist_diff.sort()
ans_num = goal_num - koma_num
print(sum(dist_diff[:ans_num]))

Measured memory_bytes: 13840
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	for(i=0;i<5;i++){
		cin>>a;
		if(!a)cout<<i+1<<endl;
	}
}

Measured memory_bytes: 3572
#include <iostream>

int main()
{
  int N, K;
  std::cin >> N >> K;
  int ret = 0;
  for(int i=0; i<N; i++) {
    int h;
    std::cin >> h;
    if(h >= K) ret++;
  }

  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
	
		int h = S / (60*60);
		int m = (S - h * (60*60)) / 60;
		int s = (S - h * (60*60) - m*60);
		
		System.out.println(h+":"+m+":"+s);

	}

}

Measured memory_bytes: 26248
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;cin>>x>>y;
  int a[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  if(a[x]==a[y])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double rotH = M_PI / 2.0 - (H / 12.0 + M / 12.0 / 60.0) * 2.0 * M_PI;
    double rotM = M_PI / 2.0 - M / 60.0 * 2.0 * M_PI;

    double ans = sqrt(pow(A * cos(rotH) - B * cos(rotM), 2.0) + pow(A * sin(rotH) - B * sin(rotM), 2.0));

    cout << fixed << setprecision(16) << ans << endl;

    return 0;
}

Measured memory_bytes: 3704
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll n,a,b;
  cin>>n>>a>>b;

  ll n_max,n_min;

  n_min=max((ll)0,a+b-n);
  n_max=min(a,b);

  cout << n_max << " " << n_min << endl;

  return 0;
}


Measured memory_bytes: 256