akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];
    
    if(A[0] != 0){
        cout << 0 << endl;
        return 0;
    }
    
    vector<int> cnt(3, 0);
    ll ans = 1;
    ll MOD = 1e9+7;
    for(int i=0; i<N; i++){
        int match = 0;
        // cout << i << " " << cnt[0] << " " << cnt[1] << " " << cnt[2] << endl;

        for(int j=0; j<3; j++){
            if(cnt[j] == A[i]){
                if(match == 0){
                    cnt[j]++;
                }
                match++;
            }
        }
        if(match == 0){
            cout << 0 << endl;
            return 0;
        }else{
            ans = (ans * match)%MOD;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
	int i,j,cnt,n,m;
	while(1) {
		cin>>n>>m;
		if(n==0&&m==0)break;
		if(n<m) swap(n,m);
		cnt=1;
		while(1) {
			n=n%m;swap(n,m);
			if(m==0) break;
			else cnt++;
		}
		cout<<n<<" "<<cnt<<endl;
	}
}
	

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

  int main() {
    int n, f = 0, s = 0;
    
    for (int i = 0; i < 3; i++) {
      cin >> n;
      if (n == 5)
        f += 1;
      if (n == 7)
        s += 1;
    }
    
    if (f == 2 && s == 1)
      cout << "YES" << endl;
    else 
      cout << "NO" << endl;
    return 0;
    
  }

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s: String = sc.cin();
    put!((0..s.len() - 2).map(|i| (s[i..i+3].parse::<i32>().unwrap() - 753).abs()).min().unwrap());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n;cin>>n;
    ll a[n+1];for(ll i=1;i<=n;i++)cin>>a[i];
    ll l=2,r=2;
    for(ll i=n;i>=1;i--){
        ll nl =( (l+a[i]-1)/a[i] )*a[i];
        ll nr =( r/a[i] )*a[i];
        if(nl>nr)return cout<<"-1" , 0;
        l=nl;
        r=nr+a[i]-1;
    }
    cout<<l<<" "<<r;
}

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

using pii = pair<int,int>;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
int one_hot(int x) { return 1 << x; }

pii calc_arg(int dx, int dy) {
    if(dx < 0) {
        dx *= -1;
        dy *= -1;
    }
    int g = __gcd(abs(dx), abs(dy));
    dx /= g;
    dy /= g;
    if(dx == 0) dy = 1;
    else if(dy == 0) dx = 1;
    return make_pair(dx, dy);
}

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

    int N; cin >> N;
    vector<int> X(N), Y(N);
    rep(i, N) cin >> X[i] >> Y[i];
    int ans = 0;
    function<void(int, map<pii, int>&)> dfs = [&] (int used, map<pii, int> &args) {
        if(__builtin_popcount(used) == N) {
            int acc = accumulate(begin(args), end(args), 0, [] (int sum, auto &p) {
                    return sum + p.second * (p.second - 1) / 2;
                });
            set_max(ans, acc);
            return;
        }
        int now = -1;
        rep(i, N) if(not(used & one_hot(i))) {
            now = i;
            break;
        }
        assert(now >= 0);
        used |= one_hot(now);
        rep(i, N) {
            if(not (used & one_hot(i))) {
                pii arg = calc_arg(X[now] - X[i], Y[now] - Y[i]);
                args[arg]++;
                dfs(used | one_hot(i), args);
                if(--args[arg] == 0) args.erase(arg);
            }
        }
    };
    map<pii, int> args;
    dfs(0, args);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()

int main(void){
    int n,k;
    cin>>n>>k;
    map<int,int> mp;
    rep(i,n){
        int a;
        cin>>a;
        mp[a]++;
    }
    vector<int> v;

    for(auto x : mp){
        v.push_back(x.second);
    }
    sort(all(v));
    int m = v.size();
    int sum = 0;
    rep(i,m-k){
        sum += v[i];
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 10748
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define TRACE

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

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",(long long)x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll fmod(ll x){if (x<mod) return x;return x%mod;}
ll mul(ll a, ll b, ll c){
	ll ret=0;while(b){if (b%2) ret=(ret+a)%c;a=(a*2)%c;b>>=1;}
    return ret;
}
int modpow(ll a, ll b){
    ll ret=1;while(b){if (b%2) ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;}
    return (int)ret;
}
inline int inv(int x){ return modpow(x, mod-2);}
int isprime[N];
void calc_prime(){
	isprime[1]=1;for(ll i=2;i<N;i++) if (!isprime[i]) for(ll j=i*i;j<N;j+=i) isprime[j]=1;
}
int a[N];
int main(){
    int n, k;sc(n);sc(k);
    fr(i, 1, n) sc(a[i]);
    int lo = 1;
    int hi = mod;
    while(lo<=hi){
        ll cuts = 0;
        int mid = (lo + hi)/2;
        fr(i, 1, n){
            cuts += (a[i]-1)/mid;
        }
        if (cuts <= k) hi = mid-1;
        else lo = mid+1;
    }
    lpr(hi+1);n_l;
    return 0;
}



Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
vector<int>vt;
set<int>st;
map<int,int>mp;
unordered_map<string,int> umap; 
const long long MAX = 1e5;
const long long INF = 1e9;
const double pi = acos(-1);




int main() {

 int a;
 cin>>a;
int r=a%10;
if(r==2 or r==4 or r==5 or r==7 or r==9 )
cout<<"hon"<<endl;
else if(r==0 or r==1 or r==6 or r==8)
cout<<"pon"<<endl;
else if(r==3)
cout<<"bon"<<endl;

}

Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=sc.nextInt();
		}
		
		Arrays.sort(arr);
		
		int sum=0;
		for(int i=0;i<n;i++) {
			
			int k=i+2;
			for(int j=i+1;j<n;j++) {
				
				 while(k<n && arr[i] + arr[j]>arr[k]) {
						k++;
				 }
				
					sum+=(k-1-j);
				
			}
		}
		
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 24360
#include<iostream>
using namespace std;
int main()
{
  int index[100001]={0}, n, q, i, j;
  cin >> n;
  long long int a[n], sum=0, tmp;
  
  for(i=0; i<n; i++)
  {
      cin >> a[i];
      sum += a[i];
      index[a[i]]++;
  }
  
  cin >> q;
  int b[q][2];
  
  for(i=0; i<q; i++)
    for(j=0; j<2; j++)
        cin >> b[i][j];
  
  for(i=0; i<q; i++)
  {
      tmp = index[b[i][0]];
      if(tmp)
      {
          sum = sum - (tmp * (b[i][0]));
          index[b[i][0]] = 0;
          sum = sum + (tmp * (b[i][1]));
          index[b[i][1]] += tmp;
      }
      cout << sum << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=300010,P=1e9+7;
ll n,a[MAXN],cnt[2],d,cnta,cntb,ans;
ll qpow (ll a,ll b,ll p) {
	ll res=1;
	while (b) {
		if (b&1) {res=(res*a)%p;}
		a=(a*a)%p;
		b>>=1;
	}
	return res;
}
int main () {
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) {scanf("%lld",&a[i]);}
	for (int i=0;i<=60;i++) {
		cnt[0]=cnt[1]=0;
		for (int j=1;j<=n;j++) {
			cnt[(a[j]>>i)&1]++;
		}
		ans=(ans+(qpow(2,i,P)*((cnt[0]*cnt[1])%P))%P)%P;
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vint vector<int>

int n,a,b;
string s;

int main() {
    cin>>n>>a>>b;
    cin>>s;
    int c = a+b;

    int p=0, q=0;
    rep(i,n) {
        if(s[i]=='a'){
            if(p < c) {
                puts("Yes");
            }else{
                puts("No");
            }
            p++;
        }else if(s[i]=='b'){
            q++;
            if(p<c and q<=b) {
                puts("Yes");
                p++;
            }else{
                puts("No");
            }
        }else{
            puts("No");
        }
    }


    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;


int main(void) {
    Int s, w;
    cin >> s >> w;
    if (s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
n,a,b,c,d = map(int, input().split())
s = list(input())
s.append(".")
a -= 1
b -= 1
c -= 1
d -= 1

if c > d:
    if "##" not in "".join(s[a+1:c]) and "##" not in "".join(s[b+1:d]) and "..." in "".join(s[b-1:d+2]):
        print("Yes")
    else: print("No")
else:
    if "##" not in "".join(s[a+1:c]) and "##" not in "".join(s[b+1:d]):
        print("Yes")
    else: print("No")

Measured memory_bytes: 6388
n = int(input())

k = 2
count = 1
while k * k <= n:
    m = n
    while m % k == 0:
        m = m / k
    if m % k == 1:
        count += 1
    k += 1

l = 1
while l * l < n - 1:
    if (n - 1) % l == 0:
        count += 1
    l += 1

if n == 2:
    print(1)
else:
    print(count)

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

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;


int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}

//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap
auto pfactor(int n){
  map<int,int> res;
  int t=sqrt(n);
  for(int i=2;i<=t;i++){
    for(;n%i==0;n/=i)res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
vector<int>kai(0);
void kaizyou(vector<int>&kai){
    rep(i,kai.size()){
        kai[i+1]=kai[i]*(i+1)%MOD;
      }
  }
int comb(int a,int b){
  return (kai[a]*gyaku(kai[a-b]))%MOD*gyaku(kai[b])%MOD;
}
////////////////////////////////////////////////////////////////////////
signed main() {
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  rep(i,n)cin>>a[i];

  int l=0,r=1000000001;
  while(r-l>1){
    int m=(l+r)/2;
    int cnt=0;
    rep(i,n){
      cnt+=a[i]/m;
      if(a[i]%m==0)cnt--;
    }
    if(cnt>k){
      l=m;
    }
    else r=m;
  }
  cout<<r<<endl;
  }


Measured memory_bytes: 4816
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("Sunny")) {
            System.out.println("Cloudy");
            return;
        }
        if (s.equals("Cloudy")) {
            System.out.println("Rainy");
            return;
        }
        System.out.println("Sunny");
    }

}


Measured memory_bytes: 21332
a=int(input())
li = [int(input()) for i in range(a)]
li.sort()

def gcd(x,y):
  #x<=y
  if x==y:
    return x
  else:
    if y%x==0:
      return x
    else:
      return gcd(y%x,x)


def lcm(x,y):
  return x*y//gcd(x,y)

ans=li[0]
for i in range(a-1):
  if ans<=li[i+1]:
    ans=lcm(ans,li[i+1])
  else:
    ans=lcm(li[i+1],ans)

print(int(ans))

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

const int MAX=10005;
int state[MAX],N,D[MAX];
vector<pair<int,int>> S[MAX];
priority_queue<pair<int,int>> Q;

void dijkstra(){
    int cnt=1;
    for(int i=0;i<N;i++){
        state[i]=0;
        D[i]=10000000;
    }
    state[1]=1;
    D[1]=0;
    for(int i=0;i<S[1].size();i++){
        Q.push(make_pair(-S[1][i].second,S[1][i].first));
        D[S[1][i].first]=min(D[S[1][i].first],D[1]+S[1][i].second);
    }
    while(1){
        int a=Q.top().second;
            if(state[a]==0){
            Q.pop();
            state[a]=1;
            for(int i=0;i<S[a].size();i++){
                if(state[S[a][i].first]==0){
                    Q.push(make_pair(-(D[a]+S[a][i].second),S[a][i].first));
                    D[S[a][i].first]=min(D[S[a][i].first],D[a]+S[a][i].second);
                }
            }
                cnt++;
        }
        else Q.pop();
        if(cnt==N) break;
    }
    return;
}


int main(){
    
    N=10;
    int H,W;cin>>H>>W;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            int b;cin>>b;
            if(b!=0) S[j].push_back(make_pair(i,b));
        }
    }
    dijkstra();
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int a;cin>>a;
            if(a!=-1) ans+=D[a];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))

ans = 1000

for i in range(n - 1):
    if a[i] < a[i + 1]:
        zzz = ans // a[i]
        ans -= zzz * a[i]
        ans += zzz * a[i + 1]

print(ans)


Measured memory_bytes: 61824
def suma(arr)
  sum = 0
  arr.each do |val|
    sum += val
  end
  return sum
end

N,M = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)
sum= suma(A)
max=[]
SK = sum * (1/(4*M.to_f))
M.times do |i|
  val = 0
  A.each do |j|
    val = [val, j].max unless max.include?(j)
  end
  if val < SK
    break
  else
    max.push(val)
  end
end

if max.size == M
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

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

	ll cnt = 0;
	if(s == "SSS") cout << 0 << endl;
	else if(s == "SSR") cout << 1 << endl;
	else if(s == "SRS") cout << 1 << endl;
	else if(s == "SRR") cout << 2 << endl;
	else if(s == "RSS") cout << 1 << endl;
	else if(s == "RSR") cout << 1 << endl;
	else if(s == "RRS") cout << 2 << endl;
	else if(s == "RRR") cout << 3 << endl;
	return 0;

}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  
  string s,t;
  int min,count=0;
  cin >> s >> t;
  min = (int)t.length();
  for(int i=0; i<((int)s.length()-(int)t.length()+1); ++i){
  	for(int j=0; j<(int)t.length(); ++j){
      if(s[i+j]!=t[j]){
        count++;
      }
    }
    min = (count<min)? count:min;
    count = 0;
  }
  cout << min << endl;
  return 0;
}

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

int main() {
  
  int r, g, b;
  cin >> r >> g >> b;
  int N;
  N = 100 * r + 10 * g + b;
  
  if(N % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int cx=0,cy=0;
    int curt=0;
    int n;
    cin>>n;
    bool ok=1;
    for(int i=0;i<n;i++)
    {
        int t,x,y;
        cin>>t>>x>>y;
        int d=abs(x-cx)+abs(y-cy);
        if(((d&1)!=((t-curt)&1))||d>t-curt)
            ok=0;
        curt=t;
        cx=x,cy=y;
    }
    if(ok) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n;
int arr[N];
bool check(int idx){
    long long cur = 0;
    for(int i = 1 ; i <= idx ; ++i){
        cur += arr[i];
    }
    for(int i = idx + 1 ; i <= n ; ++i){
        if(arr[i] <= 2 * cur){
            cur += arr[i];
        }
        else{
            return 0;
        }
    }
    return 1;
}
int main(){
    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d" , arr + i);
    }
    sort(arr + 1 , arr + 1 + n);
    int l = 1;
    int r = n;
    while(l < r){
        int mid = l + r >> 1;
        if(check(mid)){
            r = mid;
        }
        else{
            l = mid + 1;
        }
    }
    printf("%d\n" , n - l + 1);
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;

int H, W;
#define MAX_H 50
#define MAX_W 50

char maze[MAX_H][MAX_W];
int d[MAX_H][MAX_W];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> H >> W;
	int numWhite = 0;
	rep(y, 0, H) rep(x, 0, W) {
		cin >> maze[y][x];
		d[y][x] = INF;
		if(maze[y][x] == '.') numWhite++;
	}

	queue<P> q;
	q.push(make_pair(0, 0));
	d[0][0] = 0;

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

	while(q.size()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		if(x == (W - 1) && y == (H - 1)) break;

		rep(i, 0, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];

			if(0 <= nx && nx < W && 0 <= ny && ny < H && maze[ny][nx] != '#' && d[ny][nx] == INF) {
				d[ny][nx] = d[y][x] + 1;
				q.push(make_pair(nx, ny));
			}
		}
	}
	if(d[H - 1][W - 1] == INF) cout << -1 << endl;
	else {
		numWhite -= 2;
		int ans = numWhite - (d[H - 1][W - 1] - 1);
		cout << ans << endl;
	}


}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a=0;
  int b=0;
  int n=0;
  int out=1;
  scanf("%d",&a);
  scanf("%d",&b);
  while(out < b){
    out--;
    out += a;
    n++;
  }
  printf("%d",n);
  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str1 = br.readLine();
		String str2 = br.readLine();

		Loop:{
			for (int i = 0; i < str1.length(); i++) {
				StringBuilder sb = new StringBuilder(str2.length());
				for (int j = 0; j < str2.length(); j++) {
					sb.append(str1.charAt((i + j) % str1.length()));
				}
				if (sb.toString().equals(str2)) {
					System.out.println("Yes");
					break Loop;
				}
			}
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17076
def main():
    s = list(input())
    n = len(s)
    for i in range(n//2):
        if s[i] == s[-(i+1)]:
            continue
        else:
            print('No')
            return
    s1 = s[:n//2]
    for i in range(len(s1)//2):
        if s1[i] == s1[-(i+1)]:
            continue
        else:
            print('No')
            return

    s1 = []
    s1 = s[n//2 + 1:]
    for i in range(len(s1)//2):
        if s1[i] == s1[-(i+1)]:
            continue
        else:
            print('No')
            return

    print('Yes')

if __name__=='__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main (){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if (A+B > C+D){
    cout << "Left" <<endl;
  }
  else if (A+B == C+D){
    cout << "Balanced" <<endl;
  }
  else if (A+B < C+D){
    cout << "Right" <<endl;
  }
  
  
}



Measured memory_bytes: 256
N = int(input())
nums = [int(input()) for _ in range(N)]

all_max = max(nums)

new_nums = list(nums)
new_nums.remove(all_max)

second_max = max(new_nums)  # max関数はfor文の中にいれずに、先に2番目の最大値をもとめておく

for num in range(N):
    if nums[num] == all_max:
        print(second_max)
    else:
        print(all_max)

Measured memory_bytes: 14080
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

def prime_factorize(n):
    a = []
    for i in range(1,n+1):
        while i % 2 == 0:
            a.append(2)
            i //= 2
        f = 3
        while f * f <= i:
            if i % f == 0:
                a.append(f)
                i //= f
            else:
                f += 2
        if i != 1:
            a.append(i)
    return a

n=I()
#print(prime_factorize(6))
c=Counter(prime_factorize(n))
st=[74,24,14,4,2]
nums=[]
for y in st:
    count=0
    for x in c.keys():
        if c[x]>=y:
            count+=1
    nums.append(count)
#print(nums)
ans=nums[0]+nums[1]*max(0,(nums[4]-1))+nums[2]*max(0,(nums[3]-1))+nums[3]*max(0,(nums[3]-1))//2*max(0,(nums[4]-2))
print(ans)     

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector <int> vi;
const int MOD = 1e9 + 7;
vi a[10];
int n, m;
void solve(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    vi p(n);
    fo(1, n) p[i - 1] = i;
    int cnt = 0;
    do{
        int flag = 1;
        for(int i = 1; i < n; i++){
            bool ok = false;
            for(int x : a[p[i - 1]]){
                if(x == p[i]){
                    ok = true;
                    break;
                }
            }
            if(!ok){
                flag = 0;
                break;
            }
        }
        cnt += flag;
    }
    while(next_permutation(p.begin() + 1, p.end()));
    cout << cnt;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}



Measured memory_bytes: 256
#include <stdio.h>

#define N 10000
int isPrime(int);

int main()
{
  int i,count=0,n,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    if(isPrime(k)==1)
      count++;
  }
  printf("%d\n",count);
  return 0;
}

int isPrime(int x){
  int i;
  if(x==2)
    return 1;
  else if(x<2 ||x%2==0)
    return 0;

  i = 3;

  while (i*i<=x){
    if(x%i==0)
      return 0;
    i = i+2;
  }
  return 1;
}
    



Measured memory_bytes: 2732
use std::io::*;
use std::str::FromStr;
//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

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

    let mut ret = 0;
    for i in 0..n-1{
        if (x[i+1]-x[i])*a < b{
            ret += (x[i+1]-x[i])*a;
        }else{
            ret += b;
        }
    }
    println!("{}",ret);
}


Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n,a[200010],b[200010];
int main()
{
	n=read(); for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	if(n&1)
	{
		LL ans=0;int mid=n/2+1,f=0,l=2,r=n;
		b[mid]=a[1];
		for(int i=1;i<=n/2;i++)
		{
			if(f) b[mid+i]=a[l++],b[mid-i]=a[l++];
			else b[mid+i]=a[r--],b[mid-i]=a[r--];
			f^=1;
		}
		for(int i=1;i<n;i++) ans+=abs(b[i+1]-b[i]);
		LL tmp=0;l=1;r=n-1;f=1;
		b[mid]=a[n];
		for(int i=1;i<=n/2;i++)
		{
			if(f) b[mid+i]=a[l++],b[mid-i]=a[l++];
			else b[mid+i]=a[r--],b[mid-i]=a[r--];
			f^=1;
		}
		for(int i=1;i<n;i++) tmp+=abs(b[i+1]-b[i]);
		printf("%lld\n",max(ans,tmp));
	}
	else
	{
		LL ans=0;
		int mid,f,l,r;
		mid=n/2,f=1,l=2,r=n-1;
		b[mid]=a[1];b[mid+1]=a[n];
		for(int i=1;i<n/2;i++)
		{
			if(f) b[mid+i+1]=a[l++],b[mid-i]=a[r--];
			else b[mid+i+1]=a[r--],b[mid-i]=a[l++];
			f^=1;
		}
		for(int i=1;i<n;i++) ans+=abs(b[i+1]-b[i]);
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
 
#define rep(i,n) for(int i = 0; i < (int)n; i++)
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

 
int main(void){
  
  //vector<vector<char>> maze(h, vector<char>(w));
  //vector<vector<ll>> warp(h, vector<ll>(w, INF));
  int d,t,s;
  
  cin >> d >> t >> s;
  
  string count;
  
  if(d<=t*s) count = "Yes";
  else count = "No";

  cout << count << endl;
}


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

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

Measured memory_bytes: 3572
C = str(input())

alph = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

for i, j in enumerate(alph):
  if C == j:
    print(alph[i+1])

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)

	ps := primes(110000)
	for !ps[x] {
		x++
	}
	fmt.Println(x)
}

func primes(n int) []bool {
	ps := make([]bool, n+1)
	for i := 2; i <= n; i++ {
		ps[i] = true
	}
	for i := 2; i <= n; i++ {
		if ps[i] {
			for j := i + i; j <= n; j += i {
				ps[j] = false
			}
		}
	}
	return ps
}


Measured memory_bytes: 1880
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb(v) push_back(v)

ll check(vector<pair<ll,ll>>&v,int w,int n)
{    
        ll dp[n+1][w+1];
        
        
          for(int i=0;i<=n;i++)
          {
          	        for(int j=0;j<=w;j++)
          	        {     
          	                    if(i==0 || j==0)
								  dp[i][j]=0;
								 else if(v[i-1].first<=j)
								 {
						             dp[i][j]=max(v[i-1].second+dp[i-1][j-v[i-1].first],dp[i-1][j]) ;  
								  }
								  else
								  {
								    dp[i][j]=dp[i-1][j]; 	
								  } 
								  	
					}
					
		  }
		  return dp[n][w];
        
}
int main() {
	//code
	
     ios_base::sync_with_stdio(false); 
     cin.tie(NULL);
      int n,w;
      cin>>n>>w;
      ll x,y;
      vector<pair<ll,ll>>v;
        f(i,0,n)
        {
        	cin>>x>>y;
        	v.push_back({x,y});
		}
       cout<<check(v,w,n);
       
 return 0;

}



Measured memory_bytes: 79232
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
constexpr int INF = std::numeric_limits<int>::max() / 2;  // 1.073741823e9
constexpr int64 INF64 = std::numeric_limits<int64>::max() / 2;  // 4.611686018427387903e18
constexpr int MOD = 1000000007;

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

  int n; cin >> n;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      if (i * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<climits>
#include<algorithm>

const int INF = INT_MAX;
const int NIL = -1;

int leftMostBit(int x) {
    if(x == 0) return 0;
    x = (x & 0x55555555) << 1 | (x >> 1) & 0x55555555;
    x = (x & 0x33333333) << 2 | (x >> 2) & 0x33333333;
    x = (x & 0x0f0f0f0f) << 4 | (x >> 4) & 0x0f0f0f0f;
    x = (x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x >> 24);
    int deBruijnSequence[32] = {0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14};
    return 31 - deBruijnSequence[((x & -x) * 0x076be629U) >> 27];
}

class RangeMinimumQuery {
    int size_;
    std::vector<int> node_;

    int parent(int node) const {return node == 0 ? NIL : (node - 1) >> 1;}
    int left_child(int node) const {return (node << 1) + 1;}
    int right_child(int node) const {return (node << 1) + 2;}
    int query(int a, int b, int k, int l, int r) const {
        if(b < l || r < a) return INF;
        if(a <= l && r <= b) return node_[k];
        int vl = query(a, b, left_child(k), l, (l + r) / 2);
        int vr = query(a, b, right_child(k), (l + r) / 2 + 1, r);
        return std::min(vl, vr);
    }

public:
    RangeMinimumQuery(int s) {
        size_ = 1 << leftMostBit(s);
        if(size_ != s) size_ <<= 1;
        node_ = std::vector<int>((size_ << 1) - 1, INF);
    }
    int find(int left, int right) const {
        return query(left, right, 0, 0, size_ - 1);
    }
    void update(int index, int value) {
        int i = index + size_ - 1;
        node_[i] = value;
        while((i = parent(i)) != NIL) node_[i] = std::min(node_[left_child(i)], node_[right_child(i)]);
    }
};

#include<iostream>
using namespace std;

enum COMMAND {UPDATE, FIND};

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

    RangeMinimumQuery st(n);

    for(int i = 0; i < q; ++i) {
        int com, x, y;
        cin >> com >> x >> y;
        if(com == UPDATE) {
            st.update(x, y);
        } else {
            cout << st.find(x, y) << endl;
        }
    }
}

Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=1e5+5;
ll n,h[MAXN],nr[MAXN],nl[MAXN],out[MAXN];
char str[MAXN];
vector<ll>v;
void getnr()
{
    ll pre=0;
    for(ll i=1;i<=n;i++)
    {
        if(str[i]!='R')
        {
            pre=i;
        }
        nr[i]=pre;
    }
}
void getnl()
{
    ll post=n+1;
    for(ll i=n;i>=1;i--)
    {
        if(str[i]!='L')
        {
            post=i;
        }
        nl[i]=post;
    }
}
void solve()
{
    n=strlen(str+1);

    getnr();
    getnl();

    for(ll i=1;i<n;i++)
    {
        if(str[i]=='R'&&str[i+1]=='L')
        {
            v.push_back(i);
        }
    }
    for(ll i=0;i<v.size();i++)
    {
        ll now=v[i];
        ll l=nr[now];
        ll r=nl[now+1];
        r--;
        l++;
        ll numr=now-l+1;
        ll numl=r-(now+1)+1;
        ll len=r-l+1,ans1,ans2;
        if(len&1)
        {
            if(numr>numl)
            {
                if(numr&1)
                {
                    ans1=len/2+1;
                    ans2=len/2;
                }
                else
                {
                    ans1=len/2;
                    ans2=len/2+1;
                }
            }
            else
            {
                if(numl&1)
                {
                    ans1=len/2;
                    ans2=len/2+1;
                }
                else
                {
                    ans1=len/2+1;
                    ans2=len/2;
                }
            }
        }
        else
        {
            ans1=ans2=len/2;
        }
        for(ll j=l;j<=r;j++)
        {
            if(j==now)
            {
                out[j]=ans1;
            }
            else if(j==now+1)
            {
                out[j]=ans2;
            }
            else
            {
                out[j]=0;
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        printf("%lld ",out[i]);
    }
    printf("\n");
}
int main()
{
    scanf("%s",str+1);
    solve();
}


Measured memory_bytes: 3448
inf = 0x10101010
def solve(A, strt):
	cost = [inf]*m  
	visited = [False]*m
	cost[strt] = 0
	while 1:
		min = inf 
		next = -1   
		visited[strt] = True 
		for i in range(m):
			if visited[i]: continue
			if A[strt][i]:
				d = cost[strt] + A[strt][i]
				if d < cost[i]:
					cost[i] = d
			if min > cost[i]:	
				min = cost[i]
				next = i
		strt = next 
		if next == -1: break
	return cost
						
while 1:
	n,m = map(int, raw_input().split())
	if n == 0:break
	T = [[0]*m for i in range(m)]
	C = [[0]*m for i in range(m)]
	for i in range(n):
		a,b,c,t = map(int, raw_input().split()) 
		T[a-1][b-1] = T[b-1][a-1] = t 
		C[a-1][b-1] = C[b-1][a-1] = c
	TS = [solve(T,i) for i in range(m)]
	CS = [solve(C,i) for i in range(m)]
	for i in range(input()):
		a, b, q = map(int,raw_input().split())
		if q == 0:
			print CS[a-1][b-1]
		else:
			print TS[a-1][b-1]

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;
int x, a;

int main() {
    cin >> x >> a;
    if (x < a)
        cout << 0 << endl;
    else
        cout << 10 << endl;
    return 0;
}


Measured memory_bytes: 3612
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll ans = 0;
    FOR(i, 1, N+1) {
        ll lo = i;
        ll hi = (N / i) * i;
        ll cnt = hi / i - lo / i + 1;
        ans += (cnt * (lo + hi)) / 2;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3648
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N, K, X, Y;
    
    cin >> N >> K >> X >>Y;

    ll ans = 0;

    if(N >= K){
        ans = X * K;
        N -= K;
        ans += Y * N;
    }else{
        ans = X * N;
    }

    cout << ans << endl;


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

}


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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(decimal.Parse).ToArray();
        var A = vals[0];
        var B = vals[1];
        var N = vals[2];

        decimal x;
        if (N < B)
        {
            x = N;
        }
        else
        {
            x = B - 1;
        }
        var v = Math.Floor(A * x / B) - A * Math.Floor(x / B);

        Console.WriteLine(v);
    }
}

Measured memory_bytes: 28312
import Data.Char
import Data.List

shiftChar :: Char -> Char
shiftChar c
    | 'a' <= c && c <= 'z' = (chr . (\y -> y + ord 'a') . (`mod` 26) . (+ 1) . (\x -> x - ord 'a') . ord) c
    | otherwise = c

shift :: String -> String
shift = map shiftChar

decode :: String -> String
decode xs
    | isInfixOf "the" xs = xs
    | isInfixOf "this" xs = xs
    | isInfixOf "that" xs = xs
    | otherwise = decode $ shift xs

main :: IO ()
main  = getContents
    >>= return . lines 
    >>= return . map decode
    >>= mapM_ putStrLn

Measured memory_bytes: 3984
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int A[200005];

int main(){
    int n;
    cin >> n;
    rep(i,n-1){
        int a;
        cin >> a;
        a--;
        A[a]++;
    }
    rep(i,n){
        cout<<A[i]<<endl;
    }
    return 0;
}



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

ll power (ll a, ll r)
{
	if (r==1) return a;
	else
	{
		ll m;
		m=power(a,r/2);
		if (r%2==0) return m*m%mod;
		else return m*m%mod*a%mod;
	}
}

ll modinv(ll a)
{
	return power(a,mod-2);
}

ll cmb(ll n,ll r)
{
	ll ans=1;
	for (int i=0;i<r;i++)
	{
		ans=(ans*(n-i)%mod*modinv(i+1))%mod;
	}
	return ans;
}

int main()
{
	ll N,M,K; cin >> N>> M >> K;
	ll ans=0;
	for (int m=2;m<M+1;m++)
	{
		ans=(ans+(m-1)*(M-m+1)%mod*N*N%mod)%mod;
	}
	for (int n=2;n<N+1;n++)
	{
		ans=(ans+(n-1)*(N-n+1)%mod*M*M%mod)%mod;
	}
	cout << ans*cmb(N*M-2,K-2)%mod << endl;
	return 0;
}

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

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            flag = 0
            for c in s:
                p = flag == 0 and c == str(i)
                q = flag == 1 and c == str(j)
                r = flag == 2 and c == str(k)
                if p or q or r:
                    flag += 1
            if flag == 3:
                ans += 1
print(ans)


Measured memory_bytes: 47852