akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if((a <= b && b <= (a + w)) || (b <= a && a <= (b + w))){
			System.out.println(0);
		}else{
			if(a < b){
				System.out.println(b - (a + w));
			}else{
				System.out.println(a - (b + w));
			}
		}

		sc.close();
	}
}


Measured memory_bytes: 21844
function comb(r) {
	var c = [];
	c[0] = -1;
	var k = 1;
	c[1] = 0;
	var ret = [];

	while (k != 0) {
		for (var i = k + 1; i <= r; i++) {
			c[i] = c[i - 1] + 1;
		}

		var arr = []
		for (var i = 1; i <= r; i++) {
			arr.push(c[i]);
		}
		ret.push(arr);

		k = r;
		while (c[k] == 9 - r + k)
			k = k - 1;

		c[k] = c[k] + 1;
	}

	return ret;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.trim().split('\n');

var line;
while (line = lines.shift()) {
	var nums = line.split(' ');
	var n = +nums[0];
	var s = +nums[1];
	if (n + s == 0)
		break;

	var c = comb(n);

	var cnt = 0;
	for (var i = 0; i < c.length; i++) {
		var arr = c[i];
		if (s == arr.reduce(function(prev, now){return prev + now;})) {
			cnt++;
		}
	}

	console.log(cnt);
}

Measured memory_bytes: 9960
#include <cstdio>

int tosec(int h,int m,int s)
{
  return h*3600+m*60+s;
}

int main()
{
  for(int i=0; i<3; i++)
    {
      int h1,m1,s1,h2,m2,s2;
      scanf("%d%d%d%d%d%d",&h1,&m1,&s1,&h2,&m2,&s2);
      
      int diff;
      diff = tosec(h2,m2,s2) - tosec(h1,m1,s1);
      printf("%d %d %d\n",diff/3600,diff%3600/60,diff%60);
    }
}

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

string s[3] = {"Sunny","Cloudy","Rainy"};
int main(){
    string S;
    cin >> S;
    for(int i=0;i<3;i++){
        if(s[i]==S){
            cout << (s[(i+1)%3]) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
int i;
#define rep2(i, a, b) for(i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
using namespace std;
// _________コーディングはここから！！___________
template <const int sz = 5 * 10000000, typename T = long long> struct IO {
    char reader[sz], writer[sz];
    char *now, *now2 = writer;
    IO() {
        reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
        now = reader;
    }
    inline T read() {
        while(*now && *now <= 32) now++;
        if(*now == '-') {
            now++;
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return -res;
        } else {
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return res;
        }
    }
    inline string read_str() {
        string res;
        while(*now and *now != '\n' and *now != ' ') res += *now++;
        now++;
        return res;
    }
    inline void write(T x, char margin = ' ') {
        if(x == 0) {
            putchar('0');
            putchar(margin);
            return;
        }
        if(x < 0) {
            putchar('-');
            x = -x;
        }
        while(x) {
            *now2 = '0' + x % 10;
            now2++;
            x /= 10;
        }
        do {
            now2--;
            putchar(*now2);
        } while(now2 != writer);
        putchar(margin);
    }
    inline void write_str(string s, char margin = ' ') {
        for(auto c : s) putchar(c);
        putchar(margin);
    }
};
IO io;
inline int read() { return io.read(); }
inline void write(int x) { io.write(x); }
inline void write(int x, char c) { io.write(x, c); }
constexpr int N = 500010;
int c[N];
using T = tuple<int, int, int>;
T q[N];
int ans[N];
int last[N];
int dat[N];

inline void add(int k) {
    for(++k; k < N; k += k & -k) dat[k]++;
}
inline void dec(int k) {
    for(++k; k < N; k += k & -k) dat[k]--;
}
inline int sum(int k) {
    int res = 0;
    for(++k; k > 0; k -= k & -k) res += dat[k];
    return res;
}
int n, Q, now = 1;

// 頑張れ！！
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
// 頑張れ！！

main() {
    n = read(), Q = read();
    rep2(i, 1, n) c[i] = read();
    rep(i, Q) get<1>(q[i]) = read(), get<0>(q[i]) = read() + 1, get<2>(q[i]) = i;
    sort(q, q + Q);
    int now = 1;
    rep(i, Q) {
        for(; now < get<0>(q[i]); ++now) {
            if(last[c[now]]) dec(last[c[now]]);
            last[c[now]] = now;
        }
        ans[get<2>(q[i])] = sum(get<0>(q[i]) - 1) - sum(get<1>(q[i]) - 1) + get<0>(q[i]) - get<1>(q[i]);
    }
    rep(i, Q) write(ans[i], '\n');
}

Measured memory_bytes: 26780
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include <iomanip>

using namespace std;

#define rep(i, s, n) for(int i = s;i<n;i++)
#define repe(i, s, n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<int> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};

template<typename T1, typename T2>
bool pairCompare(const pair<T1, T2> &firstElof, const pair<T1, T2> &secondElof) {
    return firstElof.second > secondElof.second;
}

int mapMaxValue(std::map<ll, int> m) {
    int max = 0;
    for (std::map<ll, int>::iterator it = m.begin(); it != m.end(); it++) {
        if (max < it->second) max = it->second;
    }
    return max;
}

int main(void) {
    ll w, h, x, y;
    cin >> w >> h >> x >> y;

    cout << setprecision(9) << double(w) * double(h) / 2 << " " << (x+x == w && y+y == h) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S, T;
  int point = 0;
  cin >> S >> T;
  for (int i = 0; i < 3; i++)
  {
    if (S.at(i) == T.at(i))
    {
      point++;
    }
  }
  cout << point << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

string sortStr(string s,int mode){
    string tmp[100];

    for(int i=0;i<s.size();i++){
        tmp[i]=s.substr(i,1);
    }

    string res="";
    for(int i=0;i<s.size();i++){
       for(int j=s.size()-1;j>i;j--){
            string t = tmp[j];
            if(mode==0 && tmp[j]<tmp[j-1]){
               tmp[j] = tmp[j-1];
               tmp[j-1] = t;
            }else if(mode==1 && tmp[j]>tmp[j-1]){
               tmp[j] = tmp[j-1];
               tmp[j-1] = t;
            }
       }
       res += tmp[i];
    }
    return res;
 }

int main()
{
    string s,t; cin >> s >> t;
    Yes(sortStr(s,0)<sortStr(t,1))
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

const int mod = 1e9+7;

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

    map<int,ll> factor;
    for(int k=2; k<=n; k++){
        int tmp = k;
        for(int i=2; i<=tmp; i++){
            while(tmp%i==0){
                factor[i]++;
                tmp/=i;
            }
        }
    }
    // for(auto f : factor){
    //     cout << f.first << ":" << f.second << endl;
    // }

    ll ans=1;
    for(auto f : factor){
        ans=((ans%mod)*((f.second+1)%mod))%mod;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
n = int(input())
ans = []

def dfs( s , mx ):
    if len(s) == n:
        ans.append(s)
        return
    else:
        for j in range(mx+1):
            t = chr(j + 97)
            mx2 = ord(max(s+t)) - 96
            dfs( s+t , mx2 )
            
dfs('a' , 1)

for i in ans:
    print(i)

Measured memory_bytes: 63068
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map<int,int>
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define print(x) cout << x << endl
#define ps(x,y) fixed<<setprecision(y)<<x
#define pprint cout<<"Case #"<<tt<<": ";
const int mod = 1e9+7;
const int N = 2e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}

struct Compare {
    bool operator () (pii A, pii B) {
        return A.first > B.first;
    }
};
 struct tri{
   int x,y,z;
 };
 struct cmp{
bool operator ()(tri a,tri b){
    if(a.x==b.x)
        return a.y>b.y;
    return a.x<b.x;

}};
bool comp(pii a,pii b){
    if(a.first>b.first) return true;
    else if(a.first==b.first) return a.second<b.second;
    else return false;

}
int binarySearch(vector<int>nums, int lo, int hi, int target) {
        while (lo < hi) {
            int mid = (lo + hi)/2;
            if (nums[mid] <= target) {
                lo = mid + 1;
            } else {
                hi = mid;
            }
        }
        return lo;
    }
void solve() {

    int t = 1;
    //cin >> t;
   while(t--){
        int l,r,x,i,ans=0;
    cin>>l>>r>>x;
    for(i=l;i<=r;i++){
        if(i%x==0)
            ans++;
    }
    cout<<ans<<endl;

    }
}

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

   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    solve();

    return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int m, f, r, t;
  cin >> m >> f >> r;
  while (true) {
    if (m == -1 && f == -1 && r == -1) {
      break;
    } else if (m == -1 || f == -1) {
      cout << "F\n";
    } else {
      t = m + f;
      if (t >= 80) {
        cout << "A\n";
      } else if (t >= 65) {
        cout << "B\n";
      } else if (t >= 50) {
        cout << "C\n";
      } else if (t >= 30) {
        if (r >= 50) {
          cout << "C\n";
        } else {
          cout << "D\n";
        }
      } else {
        cout << "F\n";
      }
    }
    cin >> m >> f >> r;
  }
  return 0;
}


Measured memory_bytes: 3124
N = int(input())
sX = input()

origin_count = sX.count('1')
one_r_count = origin_count -1
zero_r_count = origin_count +1

one_mod = 0
zero_mod =0
for b in sX:
    if one_r_count != 0:
        one_mod = (one_mod * 2 + int(b) )% one_r_count
    zero_mod = (zero_mod * 2  + int(b) )% zero_r_count

f = [0] * 220000
pop = [0]* 220000

for i in range(1,220000):
    pop[i] = pop[i//2] + i % 2
    f[i] = f[i % pop[i]] + 1

onepow = [1] * 220000
zeropow = [1]* 220000

for i in range(1,220000):
    if one_r_count != 0:
        onepow[i] = onepow[i-1] * 2 % one_r_count
    zeropow[i] = zeropow[i-1] * 2 % zero_r_count

for i in range(1,N+1):
    if sX[i-1] == '1':
        if one_r_count != 0:
            Xi_n = one_mod - onepow[N-i]
            Xi_n %= one_r_count
            print(f[Xi_n]+1)
        else:
            print(0)
    else:
        Xi_n = zero_mod + zeropow[N-i]
        Xi_n %= zero_r_count
        print(f[Xi_n]+1)

Measured memory_bytes: 30096
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
void chmin(ll &x, ll y) { x = min(x, y); }
void chmax(ll &x, ll y) { x = max(x, y); }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    int cnt = 0;
    rep(i, n-1){
        if(s[i] != s[i+1]) cnt++;
    }

    int ans = 0;
    rep(i, n-1){
        if(s[i] == s[i+1]) ans++;
    }

    ans += min(2*k, cnt);
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, x, a;
    cin>>N;
    if(N%1000==0)
    {
        cout<<"0"<<endl;
    }
    else
    {
        a=N%1000;
        x=1000-a;
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const long double pi = 3.14159265358979323846;



void solve() {
  ll n; cin >> n;
  map<string, ll> tc;
  f0r(i, n) {
    string s; cin >> s;
    ++tc[s];
  }
  cout << "AC x " << tc["AC"] << '\n';
  cout << "WA x " << tc["WA"] << '\n';
  cout << "TLE x " << tc["TLE"] << '\n';
  cout << "RE x " << tc["RE"] << '\n';
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll f[11];

ll solve(ll crr, ll n){
  if(crr > n) return 0;
  ll check = crr;
  bool s=false,f=false,t=false;
  ll cnt;
  while(check != 0){
    if(check%10 == 7){
      s = true;
    }
    if(check%10 == 5){
      f = true;
    }
    if(check%10 == 3){
      t = true;
    }
    check /= 10;
  }
  if(s && f && t) cnt = 1;
  else cnt = 0;
  cnt += solve((crr*10)+7, n);
  cnt += solve((crr*10)+5, n);
  cnt += solve((crr*10)+3, n);
  return cnt;
}

int main(){
  ll n;
  cin >> n;
  cout << solve(0, n) << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(int argc, const char * argv[]) {
   
    int n,m;

    scanf("%d %d",&n,&m);
    
    if(n==1 && m==1){
        printf("1\n");
        return 0;
    }
    else if(n==1){
        printf("%d\n",m-2);
        return 0;
    }else if(m==1){
        printf("%d\n",n-2);
    }else{
        long long ans= 0;
        
        ans = (long long)(n-2)*(m-2);
      //  ans += (long long)2*(n-2) + (long long)2*(m-2);
        printf("%lld\n",ans);
    }
    
    return 0;
}


Measured memory_bytes: 128
X, K, D = map(int, input().split())

X = abs(X)

K_main = X // D
K_sub = K - K_main

if (K_sub < 0):
  print(abs(X - D * K))
else:
  answer = abs(X - D * K_main)
  if (K_sub % 2 == 0):
    print(answer)
  else:
    print(abs(answer -D))

Measured memory_bytes: 9192
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

const ll MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    ll ten = 1, eight = 1, nine = 1;
    rep(i, N){
        ten *= 10;
        ten %= MOD;
        eight *= 8;
        eight %= MOD;
        nine *= 9;
        nine %= MOD;
    }
    nine = nine*2 % MOD;
    ll ans = (ten+eight-nine) % MOD;
    ans = (ans+MOD) % MOD;
    
    cout << ans;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;

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

		ll ans = 0;
		for (int bits = 0; bits < (1<<S.size()-1); ++bits) {
				ll x = 0;
				for (int i = 0; i < S.size(); ++i) {
						x += S[i] - '0';
						if (bits & (1<<i)) {
								ans += x;
								x = 0;
						} else {
								if (i == S.size()-1) ans += x;
								else x *= 10;
						}
				}
		}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll n,m,x;
vector<ll>c,res;
vector<vector<ll>>a;
ll ans=1001002003004005006ll;
vector<bool>u;
void solve(ll price,int pos){
    int is=0;
    rep(i,m){
        if(res[i]<x)is=1;   
    }
    if(!is){
        chmin(ans,price);
        return;
    }
    if(pos>=n)return ;
     for(int i=pos;i<n;i++){
        if(u[i])continue;
        u[i]=1;
        rep(j,m){
            res[j]+=a[i][j];
        }
        solve(price+c[i],i+1);
        rep(j,m){
            res[j]-=a[i][j];
        }
        u[i]=0;
    }


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

    cin>>n>>m>>x;
    c.resize(n);
    a.resize(n);
    u.resize(n);
    res.resize(n);
    rep(i,n){
        cin>>c[i];

        rep(j,m){
            ll aij;
            cin>>aij;
            a[i].push_back(aij);
        }
    }
    solve(0ll,0);
    if(ans!=1001002003004005006ll)
    cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s; cin >> s;
	int n = 0;
	for(auto i: s) n += i - '0';
	cout << (n % 9 == 0 ? "Yes" : "No") << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 3952
A, B, K = map(int, input().split())

takahasi_turn = 1
for _ in range(K):
    if takahasi_turn:
        if A % 2 == 1:
            A -= 1
        v = A // 2
        B += v
        A -= v
    else:
        if B % 2 == 1:
            B -= 1
        v = B // 2
        A += v
        B -= v
    takahasi_turn ^= 1
print(*[A, B])


Measured memory_bytes: 9140
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
int main(void){
    int N;
    char W[100][11];
    bool ans = true;
    scanf("%d%*c", &N);
    for (int i = 0; i < N; i++) {
        scanf("%s%*c", W[i]);
        if (i >= 1) {
            if (W[i][0] != W[i-1][strlen(W[i-1])-1]) ans = false;
            for (int j = 0; j < i; j++) if (strcmp(W[j], W[i]) == 0) ans = false;
        }
    }
    printf("%s\n", (ans ? "Yes" : "No"));
    return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#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++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll inf =1000000007;
  ll n; cin >>n;
  ll ans =1;
  rep(i,n){
    ans*=10;
    ans%=inf;
  }
  ll key=1;
  rep(i,n){
    key*=8;
    key%=inf;
  }
  ll key2=1;
  rep(i,n){
    key2*=9;
    key2%=inf;
  }
  ll ans2=ans+key-2*key2;
  ans2%=inf;
  if(ans2<0)ans2+=inf;
  cout<<ans2<<endl;
  
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;

int main(){
    ld N,M; cin>>N>>M;
    priority_queue<ld> q;
    REP(count,N){
        ld a; cin>>a;
        q.push(a);
    }
    REP(count,M){
        ld b = q.top();
        q.pop();
        b /= 2;
        q.push(b);
    }
    ll ans = 0;
    while(!q.empty()){
        ans += (ll)(q.top());
        q.pop();
    }
    cout << ans << "\n";
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int red = 0;
  int blue = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'R')
      red++;
    else
      blue++;
  
  cout << ((red > blue) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
s=input()
K=int(input())

memo=set()
for i in range(len(s)):
  for j in range(1,min(len(s)-i+1,K+1)):
    memo.add(s[i:i+j])
    
memo=list(memo)
memo.sort()
#print(memo)
print(memo[K-1])

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    ll n, m, d; cin >> n >> m >> d;
    if (d == 0) {
        cout << fixed;
        cout << setprecision(7) << (double)((n-d) * (m-1)) / (double)(n*n) << endl;
    } else {
        cout << fixed;
        cout << setprecision(7) << (double)(2 * (n-d) * (m-1)) / (double)(n*n) << endl;
    }

    return 0;
}


    


Measured memory_bytes: 256
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    H = int(input())
    W = int(input())
    N = int(input())

    x = max(H, W)
    a, b = divmod(N, x)
    if b:
        a += 1
    print(a)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> A(n), B(n);
    rep(i, n) cin >> A[i];
    rep(i, n) cin >> B[i];
    LL sum = accumulate(all(A), 0LL) - accumulate(all(B), 0LL);
    if(sum < 0){
        cout << -1 << endl;
        return 0;
    }
    int ans = n;
    priority_queue<LL> p;
    priority_queue<LL, vector<LL>, greater<LL> > q;
    rep(i, n){
        if(A[i] - B[i] > 0) p.push(A[i] - B[i]);
        else if(A[i] - B[i] < 0) q.push(B[i] - A[i]);
        else ans--;
    }
    int f = 0;
    LL x = -1;
    while(!q.empty()){
        LL np = p.top();
        if(f) np = x;
        LL nq = q.top();

        x = np - nq;
        if(x >= 0){
            q.pop();
            if(!f) p.pop();
            if(x > 0){
                f = 1;
            }else{
                f = 0;
            }
        }else{
            if(!f) p.pop();
            q.pop();
            q.push(nq-np);
            x = 0;
            f = 0;
        }
    }
    cout << ans - p.size() << endl;

}


Measured memory_bytes: 2044
#include <iostream>
#include<string>
#include<vector>
 using namespace std;
 int main() {
   long long int a,b,k;
   cin >> a >> b >> k;
   long long int d = a-k;
   if(d>=0){
     cout << d <<" " << b << endl;
   }
   if(d<0) {
     long long int d1 = b+d;
     if(d1>=0){
       cout << 0 << " " << d1 << endl;
     }
     if(d1<0) cout << 0 <<" " << 0 << endl;
   }
 }

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
    int *max;

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

    max = max_element(a, a + n);

    for (int i = 0; i < n; i++) {
        if (&a[i] == max) {
            int tmp = a[i];
            a[i] = 0;
            cout << *max_element(a, a + n) << endl;
            a[i] = tmp;
        } else {
            cout << *max << endl;
        }

    }
}


Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;
 
class Program
{
    static void Main(string [] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        var w = l[0];
        var a = l[1];
        var b = l[2];

        var d = Math.Abs(a - b);
        var result = d > w ? d - w : 0;
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 11220
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int n, m;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;

  int ans = (n - 1) * (m - 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, M = map(int,input().split())
ans = -1
if N == 1:
    kazu = list(range(10))
elif N == 2:
    kazu = list(range(10,100,1))
else:
    kazu = list(range(100,1000,1))

#print(kazu)
neikazu = kazu

for j in range(M):
    s, c = map(int,input().split())
    #print(s,c)
    for i in range(1000):
        if i not in kazu:
            pass
        else:
            if N + 1 - s == 1:
                if i % 10 != c:
                    kazu.remove(i)
                    #print('KKK')
            elif N + 1 - s == 2:
                if (i % 100) //10 != c:
                    kazu.remove(i)
                    #print('JJJ')
            else:
                if i // 100 != c:
                    kazu.remove(i)
                    #print('HHH')
if len(kazu) == 0:
    pass
else:
    ans = kazu[0]


print(ans)


    



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

    int sum=0;
    REP2(i,l,l+n) sum+=i;
    if(l<=0 && l+n-1>=0) cout<<sum<<endl;
    else if(l>0) cout<<sum-l<<endl;
    else cout<<sum-(l+n-1)<<endl;
    
	return 0; 
}

Measured memory_bytes: 256
n,m=map(int,input().split())
e = []

for _ in range(1,m+1):
    a,b=map(int,input().split())
    e.append((a,b))

q = int(input())
cs = [0] * (q+1)
dp = [[0]*11 for _ in range(n+1)]
for i in range(1, q+1):
    v,d,c=map(int,input().split())
    cs[i] = c
    dp[v][d] = i

for d in range(9, -1, -1):
    for i in range(1,n+1):
        dp[i][d] = max(dp[i][d], dp[i][d+1])
    for a,b in e:
        dp[a][d] = max(dp[a][d], dp[b][d+1])
        dp[b][d] = max(dp[b][d], dp[a][d+1])

for i in range(1, n+1):
    print(cs[dp[i][0]])

Measured memory_bytes: 85720
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
using namespace std;

signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    int q;
    cin>>q;
    rep(i,q){
        int b,m,e;
        cin>>b>>m>>e;
        rotate(a+b,a+m,a+e);
    }
    rep(i,n){
        cout<<(i?" ":"")<<a[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3144
def m():
    n, m = map(int, input().split())
    bridge = [1 for _ in range(n)]
    g = []
    for _ in range(m):
        a, b = map(int, input().split())
        g.append((a, b))
    g.sort(key=lambda x: x[1])
    cnt = 0
    for e in g:
        f = 0
        for j in range(e[1]-1, e[0]-1, -1):
            if bridge[j] == 0:
                f = 1
                break
        if f:
            continue
        # if bridge[e[0]:e[1]].count(0):
        #     continue
        bridge[e[1]-1] = 0
        cnt += 1
    return cnt

print(m())

Measured memory_bytes: 60448
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++){
        cin >> W[i];
    }
    
    // 累積和
    vector<int> c_sum(N, 0);
    for(int i = 0; i < N; i++){
        if(i == 0){
            c_sum[i] = W[0];
        }
        else{
            c_sum[i] = c_sum[i - 1] + W[i];
        }
    }
    
    int ans = INT_MAX;
    
    for(int i = 0; i < N - 1; i++){
        int temp = abs(c_sum[i] - (c_sum[N - 1] - c_sum[i]));
        ans = min(ans, temp);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
s = list(raw_input())
q = int(raw_input())

for k in range(q): 
    ls = raw_input().split()
    a = int(ls[1])
    b = int(ls[2])
    if ls[0] == 'print':
        print ''.join(s[a:b+1])
    elif ls[0] == 'reverse':
        if a != 0:
            s[a:b+1] = s[b:a-1:-1]
        else:
            s[a:b+1] = s[b::-1]
    elif ls[0] == 'replace':
        s[a:b+1] = list(ls[3])
    

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

int main(){
  string S;cin >> S;
  int N = S.size();
  if(N%2>0){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0;2*i<N;i++){
    if(S[2*i]!='h'||S[2*i+1]!='i'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

int n, k, q;
int a[2010];

void init() {

}

void input() {
	cin >> n >> k >> q;
	REP(i, n) cin >> a[i];
}

void solve() {
	int res = 1<<30;
	REP(i, n) {
		vector < VI > v;
		VI _v;
		REP(j, n) {
			if (a[j] < a[i]) {
				if (SZ(_v) > 0) {
					v.PB(_v);
					_v.clear();
				}
			} else {
				_v.PB(a[j]);
			}
		}
		if (SZ(_v) > 0) {
			v.PB(_v);
		}

		VI mins;
		for (auto __v : v) {
			sort(ALL(__v));
			for (int j = 0; j <= SZ(__v)-k; j++) mins.PB(__v[j]);
		}
		if (SZ(mins) < q) continue;
		sort(ALL(mins));
		chmin(res, mins[q-1] - mins[0]);
	}
	cout << res << endl;
}

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


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> a(210, 0);
    REP(i, 211){
    	if(i==0) continue;
    	REP(j, 211){
    		if(i*j<210) a[i*j]++;
    	}
    }
    ll res = 0;
    for(int i=1;i<=N;i++){ 
    	if(a[i]==8 && i&1) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import queue

H,W=map(int,input().split())
S=[[] for _ in range(H)]

dx=[0,0,-1,1]
dy=[-1,1,0,0]

for i in range(H):
    S[i]=input()

def bfs(i,j):
    max_d=0
    q=queue.Queue()
    q.put((i,j))
    d=[[0]*W for _ in range(H)]
    while not q.empty():
        loc=q.get()
        for k in range(len(dx)):
            x=loc[1]+dx[k]
            y=loc[0]+dy[k]
            if x>=0 and x<W and y>=0 and y<H:
                if S[y][x]==".":
                    if d[y][x]==0 and not(x==j and y==i):
                        q.put((y,x))
                        d[y][x]=d[loc[0]][loc[1]]+1
                        max_d=max(max_d,d[y][x])
    return max_d

ans=0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            ans=max(bfs(i,j),ans)
        
print(ans)

Measured memory_bytes: 54116
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<int> V(N);
    for(int i = 0; i < N; ++i) cin >> V[i];
    map<int, int> odd, even;
    for(int i = 0; i < N; ++i){
        if(i%2 == 0) even[V[i]]++;
        else odd[V[i]]++;
    }
    priority_queue<pair<int, int> > qOdd, qEven;
    qOdd.emplace(0,0); qEven.emplace(0,0);
    for(auto it : odd) qOdd.emplace(it.second, it.first);
    for(auto it : even) qEven.emplace(it.second, it.first);
    
    if(qOdd.top().second != qEven.top().second) {
        int ans = N - qOdd.top().first - qEven.top().first;
        cout << ans << '\n';
    } else {
        int a = qOdd.top().first;
        int b = qEven.top().first;
        qOdd.pop();
        qEven.pop();
        int c = qOdd.top().first;
        int d = qEven.top().first;
        int ans = min(N - a - d, N - b - c);
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 9300
import heapq
x,y,a,b,c = map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = [ -int(i) for i in input().split()]
P.sort(reverse=True)
P = P[:x]
Q.sort(reverse=True)
Q = Q[:y]
heapq.heapify(P)
heapq.heapify(Q)
heapq.heapify(R)
while R:
    if P[0] >= Q[0]:
        if Q[0] < -R[0]:
            heapq.heapreplace(Q, -heapq.heappop(R))
        else:
            break
    else:
        if P[0] < -R[0]:
            heapq.heapreplace(P,-heapq.heappop(R))
        else:
            break
print(sum(P)+sum(Q))

Measured memory_bytes: 23216
#include<bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define w(x) ll x; cin>>x; while(x--)
#define pi acos(-1)
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define mod 1000000007
#define re(i,n) for(ll i=0;i<n;i++)
#define re1(i,n) for(ll i=1;i<n+1;i++)
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define defi(a,n,k) ll n;cin>>n; ll k;cin>>k;ll a[n];re(i,n){cin>>a[i];}
#define deb(x) cout<<#x<<"="<<x<<endl;
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define nl cout<<endl;
using namespace std;
//18-1326D1 1208B 845C 912B 1009B 1350C 20C 1333C 1234D 1327C 1305B 1304B (or in matrix) 1216-C(26) 21
ll powermod(ll x,ll int y,ll p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
} 
int main()
{
  //cp();
  //w(x)
  de(n);
  ll i=powermod(10,n,mod);
  ll j=powermod(9,n,mod);
  ll k=powermod(8,n,mod);
  cout<<(i%mod-(j)%mod-j%mod+k%mod+2*mod)%mod;
    
}

Measured memory_bytes: 3508
#include<stdio.h>
int main(){
 char AFN[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  char ars[27]="abcdefghijklmnopqrstuvwxyz";
  char s1,s2[1201];
  int a=0,i,j=0,l=0;
  while(scanf("%c",&s1)!=EOF){
    if(s1>=97&&s1<=122){
      for(j=0;j<26;j++){
	if(s1==ars[j]){
	  s2[l]=AFN[j];
	  l++;
	  a++;
	}
      }
    }
    if(s1>=65&&s1<=90){
      for(j=0;j<26;j++){
	if(s1==AFN[j]){
	  s2[l]=ars[j];
	  l++;
	  a++;
	}
      }
    }  
    if(a==0){
      s2[l]=s1;
      l++;
    }
    a=0;
    j=0; 
  }
  for(i=0;i<l;i++){
    printf("%c",s2[i]);
  }
  return(0);
}

Measured memory_bytes: 940
YES = "Yes"
NO = "No" 

N = int(input())

def S(n):
    S = str(n)
    ret = 0
    for i in range(len(S)):
        ret += int(S[i])
    return ret

if N % S(N) == 0:
    print(YES)
else:
    print(NO)

Measured memory_bytes: 61808
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
  int n;
  string s;

  cin >> n >> s;

  int len = s.length();
int ans = 0;
  
  if(len <= n){
      cout << s;
      ans = 1;
  }

  
if(ans == 0){
  for(int i = 0;i < n;i++){
      cout << s.at(i);
  }
    cout << "...";
}

}
   


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

int n,m,d;
char s[maxn],t[maxn];

int gcd(int n,int m){
	if ( !m ) return n;
	return gcd(m,n % m);
}
int check(){
	if ( s[1] != t[1] ) return 0;
	rep(k,1,n - 1){
		int cur1 = k * n / d + 1 , cur2 = k * m / d + 1;
		if ( cur2 > m || cur1 > n ) break;
		if ( s[cur1] != t[cur2] ) return 0;
	}
	return 1;
}
int main(){
	scanf("%d %d",&n,&m);
	scanf("%s%s",s + 1,t + 1);
	d = gcd(n,m);
	if ( check() ) cout<<(ll)n * m / d;
	else cout<<-1<<endl;

}


Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
using namespace std;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())

int main(){
    int A,B;
    double a,b,c,d;
    cin>>A>>B;
    a=A*12.5;
    if(fmod(a,1)!=0)a+=0.5;
    b=(A+1)*12.5;
    c=B*10.0;
    d=(B+1)*10.0;
    if(a<=c && c<b)cout<<(int)c<<endl;
    else if(a>c && a<d)cout<<(int)a<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
# D - .. (Double Dots)
from collections import deque


def main():
    N, M, *AB = map(int, open(0).read().split())

    graph = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(AB)] * 2):
        graph[a].append(b)
        graph[b].append(a)

    # bfs
    depth = [1 << 30] * (N + 1)
    depth[1] = 0
    queue = deque([(1, 0)])
    while queue:
        u, cur_depth = queue.popleft()
        next_depth = cur_depth + 1
        for v in graph[u]:
            if depth[v] > next_depth:
                depth[v] = next_depth
                queue.append((v, next_depth))

    # place signposts
    signposts = [0] * (N + 1)
    for u, cur_depth in enumerate(depth[2:], 2):
        prev_depth = cur_depth - 1
        for v in graph[u]:
            if depth[v] == prev_depth:
                signposts[u] = v
                break
        if not signposts[u]:
            print("No")
            return

    print("Yes")
    print("\n".join(map(str, signposts[2:])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 56636
#include<bits/stdc++.h>
using ll = long long;

int main()
{
    std::string s;
    std::cin >> s;
    std::vector<std::vector<ll>> dp(1000005,std::vector<ll>(2,1000000000000000));
    int n = s.size();
    for(auto &i : s)i -= '0';
    dp[0][0] = 0;
    dp[0][1] = 1;
    for(int i = 0; i < n; i++){
        dp[i + 1][0] = std::min(dp[i + 1][0], dp[i][0] + s[i]); //小 -> 小
        dp[i + 1][1] = std::min(dp[i + 1][1], dp[i][0] + s[i] + 1); //小 -> 大
        dp[i + 1][0] = std::min(dp[i + 1][0], dp[i][1] + (10 - s[i])); //大 -> 小
        dp[i + 1][1] = std::min(dp[i + 1][1], dp[i][1] + (10 - s[i] - 1)); //大 -> 小
    }
    std::cout << dp[n][0] << std::endl;
}

Measured memory_bytes: 55940
#include <iostream>

using namespace std;

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



    int tmp = 0;
    int result = 0;
    for(int i=0; i<3; i++){
        if(test1[i] == 'R'){
            tmp += 1;
            result = tmp;
        }else if(test1[i] == 'S'){
            tmp = 0;
        }
    }

    cout << result << endl;


}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int a[100];
int cells[100][100]; // r * c

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

  ll ans = N - 1;
  for (ll i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      ll j = N / i;
      ans = min(ans, i + j - 2);
    }
  }

  cout << ans << BR;
  return 0;
}

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

int main () {
    int n;
    cin >> n;
    int data[n];

    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    
    int ans = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; j < n-1; j++) {
            for (int k = j+1; k < n; k++) {
                if (data[i]==data[j] || data[j]==data[k] || data[k]==data[i]) {
                    continue;
                }
                if (abs(data[i]-data[j]) < data[k] && data[k] < data[i]+data[j]) {
                    ans ++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
import java.io.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main{

	public static final int SIZE = 1000001;

	public static void main(String [] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int [] a = new int[n];

		for(int i=0;i<n;i++){
			a[i] = Integer.parseInt(st.nextToken());
		}

		Arrays.sort(a);
			
		ArrayList<Pair> ans = new ArrayList<Pair>();
		boolean [] isPrime = new boolean[SIZE];
		for(int i=0;i<n;i++){
			boolean check = true;
			int sqrtn = (int)Math.sqrt(a[i]);		
			for(int j=1;j<=sqrtn && check;j++){
				if(a[i] % j == 0){
					if(isPrime[j]) check = false;
					if(isPrime[a[i] / j]){
						check = false;
						if(!ans.isEmpty() && ans.get(ans.size() - 1).getLeft() == a[i]){
							ans.get(ans.size() - 1).setRight(false); 
						}
					}
				}
			}
			if(check){
				ans.add(new Pair(a[i], true));
			}
			isPrime[a[i]] = true;
		}

		int val = 0;
		for(int i=0;i<ans.size();i++){
			if(ans.get(i).getRight()) val++;
		}
		bw.write(val+"");
		bw.flush();
		bw.close();
		br.close();
	}
}

class Pair{
	int left;
	boolean right;

	public Pair(int left, boolean right){
		this.left = left;
		this.right = right;
	}

	public void setRight(boolean right){
		this.right = right;
	}

	public int getLeft(){
		return this.left;
	}
	
	public boolean getRight(){
		return this.right;
	}
}

Measured memory_bytes: 59316