akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <deque>
#include <numeric>
#include <set>
using namespace std;

vector<int> z_algorithm(const string& s){
    vector<int> prefix(s.length());
    
    for(int i = 1, j = 0; i < s.length(); ++i){
        if(i + prefix[i - j] < j + prefix[j]){
            prefix[i] = prefix[i - j];
        }
        else{
            int k = max(0, j + prefix[j] - i);
            while(i + k < s.length() && s[k] == s[i + k]){
                ++k;
            }
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (int)s.length();
    
    return prefix;
}

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

    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for(int i = 0; i < n; ++i){
        string t = s.substr(i, n - i);
        vector<int> tmp = z_algorithm(t);

        for(int id = 0; id < n - i; ++id){
            if(tmp[id] <= id){
                ans = max(ans, tmp[id]);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int H,A,count;
	cin >> H >> A;
	for (count = 1; H>A; count++)
	{
		H -= A;
	}
	cout << count << endl;
	return 0;
}


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

using namespace std;

long long int dp[100005][105];

pair<int,int>jinis[105];

void init(){
 memset(dp,-1,sizeof(dp));
}

long long solve(int vleft, int cur, int n){
 if(cur==n){
   if(vleft==0)return 0;
   return (long long)2000000000;
 }
 if(dp[vleft][cur]!=-1)return dp[vleft][cur];
 long long ret1 = 0, ret2 = 0;
  
 ret1 = (long long)jinis[cur].first + solve(max(0,vleft-jinis[cur].second),cur+1,n);
 
  ret2 = solve(vleft, cur+1, n);
  return dp[vleft][cur] = min(ret1,ret2);
}

int main(){
  int n,w;
  cin>>n>>w;
  int hi = 0;
  for(int i = 0; i<n; ++i){
   cin>>jinis[i].first>>jinis[i].second;
    hi = hi+jinis[i].second;
  }
  
  int lo = 0;
  while(lo+1<hi){
     int mid = (lo+hi)/2;
    init();
     if(solve(mid,0,n)<=w)lo = mid;
    else hi = mid;
  }
  long long lw = solve(hi,0,n);
  if(lw<=w){
   cout<<hi<<"\n";
  }
  else{
  		cout<<lo<<"\n";
  }
  //cout<<solve(w,0,n)<<"\n";
  return 0;
}

Measured memory_bytes: 82304
package main

import "fmt"

func main(){
  var n int
  var si string
  
  fmt.Scan(&n)
  S := make(map[string] int)
  for i := 0; i<n; i++{
    fmt.Scan(&si)
    S[si] += 1
  }
  fmt.Println(len(S))
}

Measured memory_bytes: 22124
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Map.Strict as M


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

buildMap :: [BC.ByteString] -> M.Map BC.ByteString Int
buildMap = foldl' (\map word -> M.alter alter word map) M.empty where
    alter Nothing = Just 1
    alter (Just n) = Just $ n + 1

solve :: [BC.ByteString] -> [BC.ByteString]
solve words = let
    dict = buildMap words
    nativelst = M.toAscList dict
    lst@((fk, fn):ltr) = sortOn (negate . snd) nativelst
    filteredList = filter ((== fn) . snd) lst
    in
    fst <$> filteredList


main = do
    n <- readInt
    words <- replicateM n BC.getLine
    let ansList = solve words
    forM_ ansList BC.putStrLn



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

using namespace std;

int main() {
    int num = 0;
    string S,T;
    cin >> S >> T;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) {
            num++;
        }
    }

    cout << num;

    return 0;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main(){
    fast;
    ll n, k, ans;
    cin >> n >> k;
    if(n%k == 0){
        cout << 0;
    }
    else{
        ans = n/k;
        ll dry = k*ans;
        ll ans1 = abs(n-dry);
        ll a = abs(ans1 - k);
        cout << min(ans1, a);
    } 
    return 0;
} 

Measured memory_bytes: 256
// Problem : D - I hate Factorization
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;


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

    long long x;
    cin >> x;
    
    vector<long long> powers;
    long long p = 0, i = 0;
    while (p <= pow(3000, 5)) {
        powers.push_back(p);
        i++;
        p = pow(i, 5);
    }
    for (long i = 0; i < powers.size(); i++) {
        for (long j = i + 1; j < powers.size(); j++) {
            if (powers[j] - powers[i] == x) {
                cout << j << " " << i << "\n";
                break;
            } else if (powers[j] + powers[i] == x) {
                cout << j << " " << -i << "\n";
                break;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 4276
from collections import Counter
N = int(input())
S = list(input())
cnt = Counter(S)
Red, Green, Blue = (cnt['R'], cnt['G'], cnt['B'])
patn = Red*Green*Blue

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        if (2*j - i) >= N:
            break
        elif S[i] != S[j] and S[j] != S[2*j-i] and S[i] != S[2*j-i]:
            cnt += 1
        
print(patn-cnt)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int N; cin >> N;
	vint X(N), Y(N);
	vector<pair<double, int>> data;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
		if (X[i] == 0 && Y[i] == 0) continue;
		data.push_back(make_pair(atan2(Y[i], X[i]), i));
	}
	sort(begin(data), end(data));
	int n = data.size();
	for (int i = 0; i < n; i++) {
		data.emplace_back(data[i].first + 2 * M_PI, data[i].second);
	}
	
	int j = 1;
	ll maxv = 0;
	for (int i = 0; i < n; i++) {
		while (j < i + n && data[j].first - data[i].first < M_PI + 1e-12) j++;
		ll x = 0, y = 0;
		for (int k = i; k < j; k++) {
			x += X[data[k].second], y += Y[data[k].second];
			chmax(maxv, x*x + y*y);
		}
	}

	cout << fixed << setprecision(12) << sqrt(maxv) << endl;
	return (0);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main()
{


    int n;
    cin>>n;

    map<int64_t, int> number; 
    for(int64_t i=0;i<n;i++){
        int64_t a;
        cin>>a;

        if(number.count(a))
            number.erase(a);
        else
            number[a]=1;
    }

    cout<<number.size()<<endl;

    return 0;
}  

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

int n, b[200];

int main(){
  cin >> n;
  rep(i, n - 1) cin >> b[i];
  b[n - 1] = 1e9;
  int sum = 0;
  rep(i, n - 1){
    sum += min(b[i], b[i + 1]);
  }
  sum += b[0];
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
(N, M), *A = $<.map{|l| l.split.map &:to_i }

p (1..N).bsearch{|m|
  j = [0] * N
  g = [false] * M
  loop do
    c = [0] * M
    N.times do |i|
      c[A[i][j[i]]-1] += 1
    end
    t = c.index{|x| x > m}
    break true unless t
    g[t] = true
    N.times do |i|
      j[i] += 1 while j[i] < M && g[A[i][j[i]]-1]
    end
    break false if j.any?{|x| x >= M}
    #p m,c,g,j
  end
}


Measured memory_bytes: 8700
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
	PrintWriter out;
    StringTokenizer st;
    BufferedReader br;
 	
 	class Pair implements Comparable<Pair>
	{
	    int f;
	    int s;
 
	    Pair(int t, int r) {
	       f = t;
	       s = r;
	    }
	    public int compareTo(Pair p)
	    {
	    	if(this.f!=p.f)
	    		return this.f-p.f;
 
	    	return this.s-p.s;
	    }
 	}
 // 	class Sort implements Comparator<String> 
	// { 
	//     public int compare(String a, String b) 
	//     { 
	//     	return (a+b).compareTo(b+a);
	//     } 
	// }
 
	String ns() {
        while (st == null || !st.hasMoreElements()) {
 
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }
 
    int nextInt() {
        return Integer.parseInt(ns());
    }
 
    long nextLong() {
        return Long.parseLong(ns());
    }
 
    double nextDouble() {
        return Double.parseDouble(ns());
    }
	
	int upperBound(long a[],long key)
	{
		int l=0,r=a.length-1;
		int i=-1;
 
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid]<key)
				l=mid+1;
 
			else{
				i=mid;	
				r=mid-1;
			}
			
		}
		return i;
	}
	int lowerBound(Pair[] a , long key)
	{
		int l = 0, r = a.length- 1;
		int i = -1;
 	
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid].f<key)
			{
				i=mid;
				l=mid+1;	
			}
 
			else
				r=mid-1;
			
		}
		return i;
	}
 
	long power(long x,long y)
	{
	    long ans=1;
	    
	    while(y!=0)
	    {
	        if(y%2==1) ans=(ans*x)%mod;
	        x=(x*x)%mod;
	        y/=2;
	    }
	    return ans%mod;
	}
	
 
	int mod= 1000000007;
	long gcd(long x ,long y)
	{
		if(y==0)
			return x;
		return gcd(y,x%y);
	}
 
	// ArrayList a[];
	// int vis[],cnt=0;
	// void dfs(int ver)
	// {
	// 	ArrayList<Integer> l=a[ver];
	// 	if(l.size()==1)
	// 		cnt++;
	// 	for(int v:l)
	// 	{
	// 		if(vis[v]==0){
	// 			vis[v]=vis[ver]+1;
	// 			dfs(v);
	// 		}
	// 	}
	// }
 
 	int countSetBits(long n) 
    { 
        int count = 0; 
        while (n > 0) { 
            n &= (n - 1); 
            count++; 
        } 
        return count; 
    }

	void solve() throws IOException{
		char s[] = ns().toCharArray();
		char t[] = ns().toCharArray();
		int n = s.length;
		int cnt = 0;
		for(int i = 0; i < n; i++){
			if(s[i] != t[i])
				cnt++;
		}
		out.println(cnt);
	}
 
 
	
    void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
		solve();
		out.flush();
 
		out.close();
	}
 
	public static void main(String args[]) throws IOException {
		new Main().run();
	}
  
}


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

#define INF 1000100000

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

    int n,k;
    cin>>n>>k;

    vector<int> h(n);

    for(int i=0;i<n;i++)cin>>h[i];

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

    int mi=INF;

    for(int i=0;i<n-k+1;i++)
    {
        mi=min(mi,h[i+k-1]-h[i]);
    }

    cout<<mi<<"\n";

    return 0;
}


Measured memory_bytes: 3728
#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int n;
  scanf("%d",&n);
  if( n <= 111) printf("111");
  else if( n <= 222) printf("222");
  else if( n <= 333) printf("333");
  else if( n <= 444) printf("444");
  else if( n <= 555) printf("555");
  else if( n <= 666) printf("666");
  else if( n <= 777) printf("777");
  else if( n <= 888) printf("888");
  else if( n <= 999) printf("999");

  return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
int main()
{
	char a[100000],x;
	int i,j,t;
	scanf("%s",a);
	i=strlen(a);
	x=a[i/2+(i%2!=0)-1];
	for(j=i/2-1;j>=0;j--)if(a[j]!=x||a[i-1-j]!=x)break;
	t=i-j-1;
	printf("%d\n",t);
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, m := scanInt(), scanInt()
	type shop struct{ p, s int }
	s := make([]shop, n)
	for i := 0; i < n; i++ {
		s[i].p, s[i].s = scanInt(), scanInt()
	}
	sort.Slice(s, func(i, j int) bool { return s[i].p < s[j].p })

	count := 0
	sum := 0
	for i := 0; i < n; i++ {
		if v := count + s[i].s; v >= m {
			sum += s[i].p * (m - count)
			break
		} else {
			count = v
			sum += s[i].p * s[i].s
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 5024
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<f64> = (0..n).map(|_| read::<f64>()).collect();

    let mut sum = 0.0;
    for i in 0..n {
        sum += 1.0 / a[i];
    }
    println!("{}", 1.0 / sum);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
  int m,n,i,j,in;
  int koho[100],maxv,maxn;

  while(scanf("%d %d",&n,&m)&&n!=0&&m!=0){
    for(i=0;i<m;i++) koho[i]=0;
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
        scanf("%d",&in);
        koho[j]+=in;
      }
    }
    for(i=0;i<m;i++){
      maxv=-1;
      maxn=-1;
      for(j=0;j<m;j++){
        if(koho[j]>maxv){
          maxv=koho[j];
          maxn=j;
        }
      }
      koho[maxn]=-1;
      printf("%d",maxn+1);
      putchar(i==m-1 ? '\n' : ' ');
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
	int m, a, b, p, q, max;
	int primeTable[1300];
	int index = 0;
	for (int i = 2; i < 10000; i++)
	{
		for (int j = 0; j < index; j++)
		{
			if (i % primeTable[j] == 0)
				goto BREAK_1;
		}
		primeTable[index] = i;
		index++;
	BREAK_1:;
	}
	for (; (scanf("%d %d %d", &m, &a, &b) && m != 0); printf("%d %d\n", p, q))
	{
		p = q = max = 0;
		for (int i = 0; primeTable[i] < 320; i++) //319*319=101761
		{
			for (int j = i; j < index; j++)
			{
				if (primeTable[i] * primeTable[j] > m)
					break;
				if ((double)primeTable[i] / (double)primeTable[j] >= (double)a / (double)b && primeTable[i] * primeTable[j] > max)
				{
					p = primeTable[i];
					q = primeTable[j];
					max = p * q;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2028
package main

import (
	"fmt"
	"strings"
)

func main() {
	var str string
	fmt.Scan(&str)

	str = strings.Replace(str, "dream", "A", -1)
	str = strings.Replace(str, "erase", "B", -1)
	str = strings.Replace(str, "Aer", "", -1)
	str = strings.Replace(str, "Br", "", -1)
	str = strings.Replace(str, "A", "", -1)
	str = strings.Replace(str, "B", "", -1)

	if str == "" {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 2860
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string str;
   ll i,k;
    cin>>str>>k;
  ll sz=str.size();
    if(sz==1) cout<<str[0]<<endl;
    else{
     if(str[0]!='1') cout<<str[0]<<endl;
     else if(str[0]=='1'){

       ll  cnt=0;
         for(i=1;i<sz;i++)
         {
             if(str[i]!='1')
                {
                    cnt=i;
                     break;
                }
         }
         if(k<=cnt) cout<<1<<endl;
         else cout<<str[cnt]<<endl;
     }
     }


    return 0;
}


Measured memory_bytes: 256
n, d = map(int, input().split())
nlist = [list(map(int, input().split())) for _ in range(n)]
d = d**2
ans = 0
for i in nlist:
    kyori = i[0]**2 + i[1]**2
    if kyori <= d:
        ans += 1
print(ans)

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

struct poi {
	int x, y;
	poi operator -(poi p) {
		return {x - p.x, y - p.y};
	}
	bool operator <(poi p) const {
		return tie(x, y) < tie(p.x, p.y);
	}
	int cross(poi p) {
		return x * p.y - y * p.x;
	}
};
int xmul(poi a, poi b, poi c) {
	return (b - a).cross(c - a);
}

using vp = vector <poi>;
vp convex(vp v) {
	sort(v.begin(), v.end()); vp r;
	for(int i = 0; i < v.size(); i ++) {
		while(r.size() > 1 &&
			xmul(*++r.rbegin(), v[i], *r.rbegin()) > 0)
			r.pop_back();
		r.push_back(v[i]);
	}
	int d = r.size();
	for(int i = (int)v.size() - 2; i >= 0; i --) {
		while(r.size() > d &&
			xmul(*++r.rbegin(), v[i], *r.rbegin()) > 0)
			r.pop_back();
		if(i != 0) r.push_back(v[i]);
	}
	return r;
}

int main() {
	ios :: sync_with_stdio(false);
	int n; cin >> n; vp v;
	for(int i = 0; i < n; i ++) {
		int x, y; cin >> x >> y;
		v.push_back({x, y});
	}
	v = convex(v);

	rotate(v.begin(), min_element(v.begin(), v.end(), [](poi a, poi b) {
		return tie(a.y, a.x) < tie(b.y, b.x);
	}), v.end());
	cout << v.size() << '\n';
	for(poi p : v)
		cout << p.x << ' ' << p.y << '\n';
	return 0;
}

Measured memory_bytes: 5596
from collections import deque
dxy = [[0, 1], [1, 0], [-1, 0], [0, -1]]


def which(x, y, map):
    if(map[x][y] != "." ):
        return (True, 0)
    else:
        Q = deque()
        W, H = len(map[0]), len(map)
        map[x][y] = "#"
        Q.append((x, y))
        # 0は未定,1なら黒、2なら白, ３は無効
        Black, White = False, False
        res = 1
        while(len(Q) != 0):
            now = Q.popleft()
            for d in dxy:
                tx, ty = now[0]+d[0], now[1]+d[1]
                # 色判定もする
                if 0 <= tx <= H-1 and 0 <= ty <= W-1:
                    if map[tx][ty] == ".":
                        map[tx][ty] = "#"
                        res += 1
                        Q.append((tx, ty))
                    elif map[tx][ty] == "B":
                        Black = True
                    elif map[tx][ty] == "W":
                        White = True
    # 黒かどうかと、レス、無効ならTrue 0
    return (Black, res) if Black ^ White else (True, 0)




while(True):
    # .だけBFSする、Wにしかぶつからないで全部いけたらW
    W, H = [int(n) for n in input().split()]
    V = [[False for _ in range(W)]for __ in range(H)]
    if W+H == 0:
        break
    map = ["" for _ in range(H)]
    for i in range(H):
        map[i] = list(str(input()))
    b = 0
    w = 0
    for i in range(H):
        for j in range(W):
            Black, cnt = which(i, j, map)
            if Black:
                b += cnt
            else:
                w += cnt
    # for i in range(H):
    #     print(map[i])
    print(b, w)



Measured memory_bytes: 6012
#include"bits/stdc++.h"
using namespace std;

#define ll long long
#define INF INT_MAX/3
#define pi 2*acos(0.0)
#define eps 1e-14

const int MAX_N = 1e+3;
const int MAX_M = 1e+2;
int K, S;

void input()
{
	cin >> K >> S;
}

void solve() {
	int x[3000];
	int y[3000];
	int z[3000];
	for (int i = 0; i <= K; i++) {
		x[i] = i;
		y[i] = i;
		z[i] = i;
	}
	static int yz[6300000];
	for (int a = 0; a <= K; a++) {
		for (int b = 0; b <= K; b++) {
			yz[a*(K + 1) + b] = y[a] + z[b];
		}
	}
	int ans = 0;
	for (int a = 0; a <= K; a++) {
		for (int b = 0; b <= K; b++) {
			if (binary_search(x, x + K + 1, S - yz[a*(K + 1) + b]))
				ans++;
		}
	}
	cout << ans << endl;

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

Measured memory_bytes: 24704
#include"bits/stdc++.h"
using namespace std;
bool a[1000000010];
long long n,m;
int main(){
	cin>>n;
	m=sqrt(n);
	long long ans=0;
		for(int i=1;i<=m;i++){
			if(n%i==0){
				ans=i-1+(n/i)-1;
			}
		}
		if(ans!=0)printf("%lld",ans);
		else printf("%lld",n-1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n , b;
cin>>n>>b;
int cnt = 0;
while(n != 0){
 n=n/b;
 cnt++;
}
cout<<cnt<<endl;
}



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

int main() 
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string S;
  cin >> S;
  int r = 0;
  for (auto s : S)
  {
    if (s=='o') r++;
  }
  cout << 700 + 100*r << endl;
  return 0;
}



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

int main(){
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
n,m,s,t= map(int, input().split())
a= [list(map(int, input().split())) for i in range(m)]
b = [[] for i in range(n)] # 円のグラフ
c = [[] for i in range(n)] # スヌークのグラフ

for i in range(m):
    b[a[i][0]-1].append((a[i][1]-1,a[i][2]))
    b[a[i][1]-1].append((a[i][0]-1,a[i][2]))

for i in range(m):
    c[a[i][0]-1].append((a[i][1]-1,a[i][3]))
    c[a[i][1]-1].append((a[i][0]-1,a[i][3]))

from heapq import heappush, heappop

def dijkstra(edges, size, source):
    # edge=探索するグラフ
    # size=グラフの点の数
    # source=スタート点
    distance = [float('inf')] * size
    distance[source] = 0
    visited = [False] * size
    pq = []
    heappush(pq, (0, source))
    while pq:
        dist_v, v = heappop(pq)
        visited[v] = True
        for u, weight in edges[v]:
            if not visited[u]:
                new_dist = dist_v + weight
                if distance[u] > new_dist:
                    distance[u] = new_dist
                    heappush(pq, (new_dist, u))
    return distance

x=dijkstra(b,n,s-1)
y=dijkstra(c,n,t-1)
ans=[0]*n
w=float('inf')
for i in range(n):
    v=x[n-1-i]+y[n-1-i]
    w=min(v,w)
    ans[n-1-i]=w

for i in range(n):
    print(10**15-ans[i])

Measured memory_bytes: 128600
//Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define ff              first
#define ss              second
#define SZ(x)           ((int)(x).size())
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

int main(){
    cpp();
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else{
        cout<<"ABC"<<endl;
    }
    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  ll a, b;
  cin >> a >> b;
  if (a <= 0 && b >= 0) {
    cout << "Zero" << endl;
    return 0;
  }
  if (a > 0) {
    cout << "Positive" << endl;
    return 0;
  }
  ll num = b - a + 1;
  if (num % 2) {
    cout << "Negative" << endl;
    return 0;
  }
  else {
    cout << "Positive" << endl;
    return 0;
  }
}
    


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<utility>
using namespace std;
bool o[60][60];
queue< pair< int , int > >q;
int ans=1e9,cnt[60][60],finx,finy,suma;  char a[60][60];
void check(int x,int y)
{
    o[x][y]=true;
}

void bfs(int x,int y)
{
    o[1][1]=1;
    while(!q.empty())
    {
        pair< int ,int > temp = q.front();
        int x= temp.first;
        int y=temp.second;
        q.pop();
        if (x==finx&&y==finy)break;
        if (a[x+1][y]=='.'&&!o[x+1][y]&&(x!=finx||y!=finy))cnt[x+1][y]=cnt[x][y]+1,q.push({x+1,y}),check(x+1,y);
        if (a[x-1][y]=='.'&&!o[x-1][y]&&(x!=finx||y!=finy))cnt[x-1][y]=cnt[x][y]+1,q.push({x-1,y}),check(x-1,y);
        if (a[x][y+1]=='.'&&!o[x][y+1]&&(x!=finx||y!=finy))cnt[x][y+1]=cnt[x][y]+1,q.push({x,y+1}),check(x,y+1);
        if (a[x][y-1]=='.'&&!o[x][y-1]&&(x!=finx||y!=finy))cnt[x][y-1]=cnt[x][y]+1,q.push({x,y-1}),check(x,y-1);

    }
if (!o[finx][finy])cout<<-1<<endl;
else
cout<<suma-cnt[finx][finy]-1<<endl;
exit (0);
}
int main()
{
    cin>>finx>>finy;
    for (int i=1;i<=finy;i++)a[0][i]='#';
    for (int i=1;i<=finx;i++)a[i][0]='#';
    for (int i=1;i<=finy;i++)a[finx+1][i]='#';
    for (int i=1;i<=finx;i++)a[i][finy+1]='#';


    for (int i=1;i<=finx;i++)
    for (int j=1;j<=finy;j++)
    {
        scanf(" %c",&a[i][j]);
        if (a[i][j]=='.')suma++;
    }

    q.push({1,1});
    bfs(1,1);

return 0;
}


Measured memory_bytes: 256
// Lec09-B Shuffle
#include<iostream>
#include<queue>
int main(){
  std::queue<char> q;
  std::string str;
  int n, h;
  while(std::cin >> str){
    if(str[0] == '-') break;
    for(int i=0; i<str.length(); i++) q.push(str[i]);
    for(std::cin >> n; n; n--) for(std::cin >> h; h; h--) q.push(q.front()), q.pop();
    while(!q.empty()) std::cout << q.front(), q.pop();
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3124
use std::cmp::*;
use std::io::*;

fn dfs(i: usize, l: usize, r: usize, a: &Vec<i64>, memo: &mut Vec<Vec<i64>>) -> i64 {
    if memo[l][r] != 0 {
        return memo[l][r];
    }
    if l == r {
        return 0;
    }
    if i % 2 == 0 {
        let mut res = -(1i64 << 60);
        res = max(res, dfs(i + 1, l + 1, r, &a, memo) + a[l]);
        res = max(res, dfs(i + 1, l, r - 1, &a, memo) + a[r - 1]);
        memo[l][r] = res;
        return res;
    } else {
        let mut res = 1i64 << 60;
        res = min(res, dfs(i + 1, l + 1, r, &a, memo) - a[l]);
        res = min(res, dfs(i + 1, l, r - 1, &a, memo) - a[r - 1]);
        memo[l][r] = res;
        return res;
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut memo: Vec<Vec<i64>> = vec![vec![0; n + 1]; n + 1];
    println!("{}", dfs(0, 0, n, &a, &mut memo));
}


Measured memory_bytes: 90492
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int x1, y1, x2, y2; 
  cin >> x1 >> y1 >> x2 >> y2;

  cout << x1-(y2-y1)+(x2-x1) << " " << y1+(x2-x1)+(y2-y1) << " " << x1-(y2-y1) << " " << y1+(x2-x1) << "\n";

  return 0;
}

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

static const int MAX = 8000;
const int ORIGIN = 16000;
bool dp[2][MAX][MAX*4];
vector<int> jump[2];

int main(){
    string s;
    int x, y;
    cin >> s >> x >> y;
    bool flag = false;
    int cnt = 0;
    for(auto c : s){
        if(c == 'T'){
            jump[flag].push_back(cnt);
            flag = !flag;
            cnt = 0;
        } else {
            cnt++;
        }
    }
    jump[flag].push_back(cnt);

    if(!jump[0].empty()) dp[0][0][ORIGIN + jump[0].front()] = true;
    else dp[0][0][ORIGIN] = true;
    if(!jump[1].empty()) dp[1][0][ORIGIN + jump[1].front()] = dp[1][0][ORIGIN - jump[1].front()] = true;
    else dp[1][0][ORIGIN] = true;
    for(int i = 0; i < 2; i++){
        for(int j = 1; j < jump[i].size(); j++){
            for(int k = ORIGIN-MAX; k <= ORIGIN+MAX; k++){
                dp[i][j][k] = dp[i][j-1][k-jump[i][j]] || dp[i][j-1][k+jump[i][j]];
            }
        }
    }
    if(dp[0][max(0, (int)jump[0].size()-1)][ORIGIN+x] && dp[1][max(0, (int)jump[1].size()-1)][ORIGIN+y]){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

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

int main(){
    using namespace std;
    int n, m ;
    cin >> n ;
    vector<int> v;
    //cout << v.empty() << endl;
    for(int i{0}; i<n; i++){
        cin >> m;
        v.push_back(m);
    }
    cout << v[n-1];
    for(int j{1}; j<n; j++){
        cout << " " << v[n-j-1] ;
    }
    cout << endl;
    return 0;
}


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

const int maxn = 3e3+5;
int N;
double p[maxn], dp[maxn][maxn];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>N;
    for(int i = 0; i< N; i++){
        cin>>p[i];
    }

    memset(dp, 0, sizeof(dp));
    
    dp[1][0] = 1-p[0];
    dp[1][1] = p[0];
    for(int i = 1; i < N; i++)
        for(int j = 0; j<= i+1; j++){
            dp[i+1][j] += dp[i][j]*(1-p[i]);
            if(j>=1)dp[i+1][j] += dp[i][j-1]*p[i];
        }
    double ans = 0;
    for(int i = N/2+1; i<=N; i++){
        ans += dp[N][i];
    }
    cout<<fixed<<setprecision(9)<<ans<<endl;
    return 0;
}





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

typedef long long ll;

void printArray(vector<int> arr) {
	for (int a: arr) cout << a << " ";
	cout << '\n';
}

int w[101];
int v[101];

int main() {
	std::ios_base::sync_with_stdio(false);
	int n, W;
	cin >> n >> W;
	for (int i = 0; i<n; i++) cin >> w[i] >> v[i];
	vector<vector<ll>> dp(n+1, vector<ll>(W+1, 0));
	for (int i = 1; i<=n; i++){
		for (int j = 1; j<=W; j++) {
			dp[i][j] = dp[i-1][j];
			if (w[i-1] <= j) dp[i][j] = max(dp[i-1][j-w[i-1]] + (ll)v[i-1], dp[i][j]);
		}
	}
	cout << dp[n][W] << '\n';
}



Measured memory_bytes: 82948
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

typedef  long long ll;
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;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];

int main(){
    int h,k;
    cin>>h>>k;
    string s[h];
    int ans[h][k];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }

    for(int i=0;i<h;i++)for(int j=0;j<k;j++)ans[i][j]=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<k;j++){
            if(s[i].at(j)=='#'){
                ans[i][j]=-100;
                for(int a=-1;a<=1;a++){
                    for(int b=-1;b<=1;b++){
                        if((i+a>=0)&&(i+a<=h-1)&&(j+b>=0)&&(j+b<=k-1)&&ans[i+a][j+b]>=0){
                            ans[i+a][j+b]++;
                        }
                    }
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<k;j++){
            if(ans[i][j]>=0)
            cout<<ans[i][j];
            else
            cout<<"#";
        }
        cout<<endl;
    }

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=1e5+9;
int main()
{
   int n,x;
   vector<pair<int,int>>v;
   cin>>n;
   for(int i=1;i<=n;i++){ 
       cin>>x;
       v.push_back({x,i});
   }
   sort(v.begin(),v.end());
   for(int i=0;i<n;i++){ 
       cout<<v[i].second<<" ";
   }
   
   
    return 0;
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

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

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                int x;
                cin>>x;
                if(x==0) cout<<1;
                else cout<<0;
        }
        return 0;
}

Measured memory_bytes: 3648
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC095_A solver = new ABC095_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC095_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            int cnt = 0;
            for (char c : str.toCharArray()) {
                if (c == 'o') {
                    cnt++;
                }
            }

            out.print(700 + cnt * 100);
        }

    }
}



Measured memory_bytes: 22996
# ABC-140-B
N = int(input())
A = list(map(int, input().split()))
A = list(map(lambda x: x - 1, A))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

satisfy = 0

for i in range(N):
    food = A[i]
    satisfy += B[food]
    if i >0 and A[i] == A[i-1] + 1:
        satisfy += C[food-1]
        
print(satisfy)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		if(A <= C && C <= B) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    lint a[n];
    rep(i, n){
        string s;
        cin >> s;
        if(count_if(s.begin(), s.end(), [](char x){return x == '.';})){
            lint tmp = 0;
            int cnt = 0;
            bool flag = false;
            for(auto c: s){
                if(c == '.') flag = true;
                else{
                    tmp = tmp * 10LL + c-'0';
                    cnt += flag;
                }
            }
            rep(_, 9 - cnt) tmp *= 10;
            a[i] = tmp;
        }
        else a[i] = stoll(s) * (mod - 7);
    }

    pii cnt[n];
    rep(i, n){
        cnt[i] = {0, 0};
        lint t = a[i];
        while(t % 2 == 0){
            t /= 2;
            ++cnt[i].fi;
        }
        t = a[i];
        while(t % 5 == 0){
            t /= 5;
            ++cnt[i].se;
        }
    }

    int sum[60][60];
    rep(i, 60)rep(j, 60) sum[i][j] = 0;
    rep(i, n){
        ++sum[cnt[i].fi][cnt[i].se];
    }
    rrep(i, 60)rFor(j, 60, 1) sum[i][j-1] += sum[i][j];
    rrep(j, 60)rFor(i, 60, 1) sum[i-1][j] += sum[i][j];

    lint ans = 0;
    rep(i, n){
        int p = max(0, 18 - cnt[i].fi);
        int q = max(0, 18 - cnt[i].se);
        ans += sum[p][q];
        ans -= (min(cnt[i].fi * 2, cnt[i].se * 2) >= 18);
    }
    printf("%lld\n", ans / 2);
}

Measured memory_bytes: 6872
n=int(input())
A=[[0 for col in range(3)]for row in range(n)]
#S=[list(input().split())for i in range(n)]
for i in range(n):
  s,p=input().split()
  A[i][0],A[i][1],A[i][2]=s,p,i+1
#A.sort(key=lambda x:x[1])
A.sort(key=lambda x:(x[0],-int(x[1])))
for i in range(n):
  print(A[i][2])

Measured memory_bytes: 3064
c = [list(map(int,input().split())) for _ in range(3)]
if c[1][0] - c[0][0] == c[1][1]-c[0][1] == c[1][2]-c[0][2] and c[2][0] - c[1][0] == c[2][1]-c[1][1] == c[2][2]-c[1][2] and c[0][1] - c[0][0] == c[1][1]-c[1][0] == c[2][1]-c[2][0] and c[0][2] - c[0][1] == c[1][2]-c[1][1] == c[2][2]-c[2][1]:
    print("Yes")
else:
    print("No")


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

using namespace std;

int main() {
    int n,m; cin>> n;
    vector<string> v(n);
    set<string> st;
    for(int i=0;i<n;++i){cin>> v[i];st.insert(v[i]);}
    cin>> m;
    vector<string> k(m);
    for(int i=0;i<m;++i){cin>> k[i];st.insert(k[i]);}
    int ans=INT_MIN;
    for(set<string> :: iterator it=st.begin();it!=st.end();++it){
        int cont=0;
        for(int i=0;i<n;++i){
            if(*it==v[i])cont++;
        }
        for(int i=0;i<m;++i){
            if(*it==k[i])cont--;
        }
        ans=max(ans,cont);
    }
    if(ans<0)cout<<0;
    else cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
while true do
  input = STDIN.gets
  h_w = input.split(" ")
  h = h_w[0].to_i
  w = h_w[1].to_i
  if (h == 0) && (w == 0)
    break
  end
  for i in 1 .. h do
    for j in 1 .. w do
      if i == 1 || i == h || j == 1 || j == w then
        print "#"
      else
        print "."
      end
    end
    print "\n"
  end
  print "\n"
end

Measured memory_bytes: 8716
#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);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

vector<int> to[100005];

int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> ans(n, INF);
    ans[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int u : to[v]) {
            if (ans[u] != INF) continue;
            ans[u] = v+1;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 10196
import java.util.*;
 
public class Main {
 
	static Main instance = new Main();
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        
        if(h == 1){
          System.out.println(1);
          return;
        }else{
          long n = 1;
          long ans = 0;
          while(true){
            if(h > 1){
              ans+=n;
              n = n*2;
              h = h/2;
            }else{
              ans+=n;
              break;
            }
          }
          
           System.out.println(ans);
        }
	}
}

Measured memory_bytes: 35704
import Data.Char

main = do
  (n:a:b:_) <- getLine >>= return . map read . words :: IO [Int]

  print $ sum $ filter (\x -> let y = f x in a<=y && y<=b) [1..n]
  where
    f x = sum $ map (\c -> ord c - ord '0') (show x)


Measured memory_bytes: 1020
import math
def solve():
    a, b, n = map(int, input().split())

    if n < b:
        return math.floor(a*n/b) - a*math.floor(n/b)
    elif n >= b:
        return math.floor(a*(b-1)/b) - a*math.floor((b-1)/b)



print(solve())


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int a,l;
    cin >> a >> l;
    if(l==0) return 0;
    map<int,int> se;
    se[a]=0;
    string s;
    int ma,mi;
    int t;
    for(int i=0;1;i++){
      s=to_string(a);
      t=s.length();
      for(int j=0;j<l-t;j++) s.push_back('0');
      // cout << s << endl;
      sort(all(s),greater<char>());
      ma=stoi(s);
      sort(all(s));
      mi=stoi(s);
      a=ma-mi;
      if(se.find(a)!=se.end()){
        cout << se[a] SP a SP i+1-se[a] << endl;
        break;
      }
      se[a]=i+1;
    }
  }
  return 0;
}



Measured memory_bytes: 3144