akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define LL(x) ll x; scanf("%lld",&x)
#define INPUT(x) cin >> x
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF_INT 2147483647
#define INF_LL 9223372036854775807

typedef long long ll;

int main(){
    string s;
    cin >> s;
    
    bool flag = 1;
    
    RREP2(i,s.size()-1, 1) flag &= (s[i] == '9');
    
    cout << (s[0]-'0') - 1  + (s.size()-1)*9 + flag << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
int r;cin>>r;
cout<<r*r<<endl;
}

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

int main() {
	int a, b, c = 0, d = 0, e = 0;
	cin >> a;
	cin >> b;
	for (int n = 0; n <= 999; n++) {
		c = c + n;
		d = d + e;
		e = n;
		if (d - a == c - b) {
			cout << d - a << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  i64 n;
  std::cin>>n;

  std::vector<std::string> s(n);
  for(auto&& e:s)std::cin>>e;

  std::sort(all(s),[](const std::string& a,const std::string& b){return a.size()<b.size();});

  rep(i,0,n)std::reverse(all(s[i]));

  debug(s);

  struct Node;
  using node_ptr=Node *;
  struct Node{
    node_ptr next[26];
    i64 val[26];
    Node(){
      std::fill(next,next+26,nullptr);
      std::fill(val,val+26,0);
    }
    ~Node(){
      rep(i,0,26){
        if(next[i])delete next[i];
        next[i]=nullptr;
      }
    }
  };

  node_ptr root=new Node();

  i64 ans=0;

  for(const auto& e:s){
    node_ptr now=root;
    i64 itr=0;
    i64 tmp[26];
    std::fill(tmp,tmp+26,0);
    rep(i,0,e.size())tmp[e[i]-'a']++;
    while(now->next[e[itr]-'a']){
      rep(i,0,26)ans+=std::min(1l,tmp[i])*now->val[i];
      tmp[e[itr]-'a']--;
      now=now->next[e[itr]-'a'];
      itr++;
    }
    rep(i,0,26)ans+=std::min(1l,tmp[i])*now->val[i];

    rep(i,itr,e.size()-1){
      node_ptr newnode=new Node();
      now->next[e[i]-'a']=newnode;
      now=newnode;
    }

    now->val[e.back()-'a']++;
  }

  std::cout<<ans<<"\n";

  delete root;
  
  return 0;
}

Measured memory_bytes: 448936
#include <stdio.h>
int main(){
  int max=0, mid=0, min=0;
  int h=0;
  int i=0;
  for(i=0;i<10;i++){
    scanf("%d", &h);
    if(0>h || h>10000){
      printf("error\n");
      return 0;
    }
    if(max<h){
      min=mid;
      mid=max;
      max=h;
    }
    else if(mid<h){
      min=mid;
      mid=h;
    }
    else if(min<h) min=h;
  }
  printf("%d\n%d\n%d\n", max, mid, min);
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long
const int md=1000000007;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
/* VECTORS */
#define pb push_back
#define g(v,i,j) get<i>(v[j])
#define co(v,x) count(v.begin(),v.end(),x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define vi vector<int>
#define vll vector<ll>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater<int>())
/* INPUT/OUTPUT*/
#define pr printf
#define sc scanf
#define pi(a) printf("%d\n",a)
#define pll(a) printf("%lld\n",a)
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
/* LOOPS*/
#define fi(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
using namespace std::chrono;
ll pw(ll a, ll b)
{
    ll c=1,m=a;
    while (b)
    {
        if(b&1) c=(c * m);
        m=(m*m);
        b/=2;
    }
    return c;
}
ll pwmd(ll a,ll b)
{
    ll c=1,m=a;
    while(b)
    {
        if(b&1) c=(c*m)%md;
        m=(m*m)%md;
        b/=2;
    }
    return c;
}
ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll inverse(ll i){
    if(i==1) return 1;
    return (md - ((md/i)*inverse(md%i))%md+md)%md;
}
ll ceel(ll a,ll b)
{
    if(a%b==0) return a/b;
    else return a/b+1;
}
ll my_log(ll n, ll b)
{
    ll i=1;
    ll ans=0;
    while(1)
    {
        if(i>n)
        {
            ans--;
            break;
        }
        if(i==n) break;
        i*=b;
        ans++;
    }
    return ans;
}
bool sortbysec(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{
    return (a.second < b.second);
}
   /* auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr << "Time taken: "
         << duration.count()<< "ms" <<"\n";*/
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
vector<char> capl={'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'};
vector<char> sml={'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'};
string conv(ll a)
{
    string b;
    ll e=2;
    ll c=my_log(a,e);
    c++;
    b='1';
    for(int i=0;i<c-1;i++)
    {
        ll k=a>>(c-2-i);
        if(k&1) b+='1';
        else b+='0';
    }
    if(a==0) return "0";
    return b;
}
ll mysqt(ll a)
{
    ll ans=1;
    while(ans*ans<=a) ans++;
    ans--;
    return ans;
}
bool isprime(int p)
{
    int i=2;
    while(i<=sqrt(p))
    {
        if(p%i==0)
        {
            return false;
        }
        i++;
    }
    return true;
}
int main()
{
    fast;
    int n,a,b;
    vi v;
    cin>>n;
    fi(i,0,n)
    {
        cin>>a>>b;
        if(a==b) v.pb(1);
        else v.pb(0);
    }
    int flag=0;
    fi(i,2,n)
    {
        if((v[i])*(v[i-1])*(v[i-2])==1) flag=1;
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
}












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


using namespace std;

int main() {

	int N, K;
	cin >> N >> K;
	vector<int> A(N);

	

	for (int i = 0; i < K; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			A[a - 1]++;
		}


	}

	int count = 0;
	for (int i = 0; i < A.size(); i++) {
		if (A[i] == 0)count++;

	}

	cout << count;

	return 0;
}

Measured memory_bytes: 3628
use proconio::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
        q: usize,
        bc: [(i64, i64); q]
    }

    const MAX_VAL: usize = 100001;
    let mut counter: [i64; MAX_VAL] = [0; MAX_VAL];
    let mut sum: i64 = 0;
    for i in 0..n {
        counter[a[i] as usize] += 1;
        sum += a[i];
    }

    for (b, c) in bc {
        sum += (c - b) * counter[b as usize];
        println!("{}", sum);

        counter[c as usize] += counter[b as usize];
        counter[b as usize] = 0;
    }
}


Measured memory_bytes: 6904
N = int(input())
List = list(input())
ans = (List.count("R"))*(List.count("G"))*(List.count("B"))

for i in range(1,2000):
  for j in range(N-i*2):
    if {List[j], List[j+i], List[j+2*i]} == {"R","G","B"}:
      ans -=1
print(ans)        
   

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

//?????????
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(27) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //???????????????????????????????????????????????????
std::ifstream ifs("data.txt");
#define put ifs >>
#else //?????£????????????????????§?????????????????????
#define put cin >>
#endif
#pragma endregion
//???????????°??????????????´
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef????????????????????????????¶????????????§?????????
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//??????????????°(???????????????????????§??????)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion

int main() {
	string s1; put s1;
	string s2; put s2;
	int l1 = s1.size();
	int l2 = s2.size();
	int dp[1001][1001];
	rep(i, l1+1) {
		dp[i][0] = i;
	}
	rep(i, l2+1) {
		dp[0][i] = i;
	}
	rep(i, l1) {
		rep(j, l2) {
			int cost = (s1[i] == s2[j]) ? 0 : 1;
			dp[i + 1][j + 1] = min(dp[i][j+1]+1,min(dp[i+1][j]+1,dp[i][j]+cost));
		}
	}
	cout << dp[l1][l2] << endl;
END:
	return 0;
}

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

main() {
  while(1) {
    int N, M, P;
    int data[200];
    int sum;
    cin >> N >> M >> P;
    if(N == 0 && M == 0 && P == 0) break;

    sum = 0;
    for(int i = 1; i <= N; i++) {
      cin >> data[i];
      sum += data[i];
    }
    if(data[M] == 0) cout << 0 << endl;
    else             cout << int( sum*100 * (100-P) / 100.0 / data[M] ) << endl;
  }
}

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

const int MAX = 410;
int done[MAX][MAX];
string s[MAX];

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int h,w;
long long nb, nw;

void dfs(int i, int j){
    // if(done[i][j] > 0) return;
    done[i][j] = 1;
    s[i][j] == '#'? nb++: nw++;
    for(int d=0; d<4; d++){
        int l = i+dx[d];
        int m = j+dy[d];
        if(l<0 || l>=h || m<0 || m>=w) continue;
        if(s[i][j] == s[l][m]) continue;
        if(done[l][m] > 0) continue;
        dfs(l, m);
    }
}

int main()
{
    cin >> h >> w;
    for(int i=0; i<h; i++){
        cin >> s[i];
    }
    
    long long ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            nb = 0;
            nw = 0;
            dfs(i, j);
            ans += nb*nw;
            // cout << i << ", "<< j << ": "<< nb << ", " << nw << endl;
        }
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 18560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

ll dp[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	ll w;
	cin >> n >> w;	
	rep(i, 100001) dp[i] = 1e18;
	dp[0] = 0;
	repn(i, 1, n + 1){
		ll a;
		int b;
		cin >> a >> b;
		for(int j = 1000 * i; j >= b; j--){
			dp[j] = min(dp[j], dp[j - b] + a);
		}
	}
	ll ans = 0;
	rep(i, 100001) if(dp[i] <= w) ans = i;
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;
 

int main(){
   // FILE
   SPEED
  int h,w;
  cin>>h>>w;

   char arr[h][w];

   for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
         cin>>arr[i][j];
      }
   }

   ll dp[h][w];

   dp[h-1][w-1]=1;

   for(int i=w-2;i>=0;i--){
      if(arr[h-1][i]=='#'){
         dp[h-1][i]=0;
      }
      else{
         dp[h-1][i]=dp[h-1][i+1];
      }
   }

   for(int i=h-2;i>=0;i--){
      if(arr[i][w-1]=='#'){
         dp[i][w-1]=0;
      }
      else{
         dp[i][w-1]=dp[i+1][w-1];
      }
   }

   for(int i=h-2;i>=0;i--){
      for(int j=w-2;j>=0;j--){
         if(arr[i][j]=='.')
         dp[i][j]=(dp[i+1][j]+dp[i][j+1])%mod;
         else
         {
            dp[i][j]=0;
         }
      }
   }

   // for(int i=0;i<h;i++){
   //    for(int j=0;j<w;j++){
   //       cout<<dp[i][j]<<" ";
   //    }
   //    cout<<endl;
   // }

   cout<<dp[0][0]<<endl;

}

Measured memory_bytes: 9088
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
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")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    if (a + b) % 2 == 1 {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", (a + b) / 2);
    }
}


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

const long long limit = 1000000000000000000ll;

int main(int n,char**){
    long long *a;
    cin>>n;
    a = new long long[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(!a[i]){
            cout<<0<<endl;
            return 0;    
        }
    }
    long long acc = 1;
    for(int i=0;i<n;i++){
        if(a[i]>limit/acc){ 
            cout<<-1<<endl;
            return 0;  
        }
        acc*=a[i];
    }
    cout<<acc<<endl;
}

Measured memory_bytes: 4364
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, ans = 0;
	string ss;
	cin >> nn >> ss;
	for(int64 ii = 0;ii < nn;ii++)
	{
		if(ss.substr(ii, 3) == "ABC")
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i, n, s) for (int i = (s); i < (n); i++)
#define SIZE 1
using namespace std;
typedef long long int LL;
typedef long double LD;

int main() {
	int N, A[100];
	scanf("%d", &N);
	int sum = 0;
	REP(i, N, 0) {
		scanf("%d", A+i);
		sum += A[i];
	}
	int avg = round((double)sum/N);
	int cost = 0;
	REP(i, N, 0) {
		cost += (avg - A[i]) * (avg - A[i]);
	}
	printf("%d\n", cost);

	return 0;
}



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

int main(){
  int A,B,C;
  cin>>A>>B>>C;

  bool hand=false;
  for(int i=1;i<=B;i++){
    if((A*i)%B==C)
    hand=true;
  }

  if(hand==true)
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n,d;
  cin>>n>>d;
  vector<vecint> x(n, vecint(d,0));
  REP(i,n)REP(j,d) cin>>x[i][j];
  int cnt=0;
  REP(i,n)REP(j,i) {
    int diff=0;
    REP(k,d) {
      diff+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
    }
    bool ok=false;
    REP(k,1000) {
      if (k*k == diff) ok=true;
    }
    if (ok) ++cnt;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int mod=1e9+7;
int n,cnt;
int p(int a,int n)
{
	int ans=1;
	while(n)
	{
		if(n&1) 
			ans=ans*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans;
}
signed main()
{
	map<pair<int,int>,pair<int,int>>m;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		if(!a&&!b)
		{	
			cnt++;
			continue;
		}
		int g=__gcd(a,b);
		a/=g,b/=g;        
		if(b<0) 
			a=-a,b=-b;        
		if(a<=0) 
			m[{b,-a}].second++;
		else 
			m[{a,b}].first++;    
	}
	int ans=1;
	for(auto u:m)
		ans=(ans*(p(2,u.second.first)+p(2,u.second.second)-1+mod)%mod)%mod;
	cout<<(mod+ans+cnt-1)%mod<<endl;
	return 0;
}  

Measured memory_bytes: 19228
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	N := sc.NextInt()
	H := make([]int, N)
	for i := 0; i < N; i++ {
		H[i] = sc.NextInt()
	}
	ans := 0
	for i, h := range H {
		ok := true
		for j := 0; j < i; j++ {
			if H[j] > h {
				ok = false
				break
			}
		}
		if ok {
			ans++
		}
	}
	fmt.Println(ans)
}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func gcd(x, y int) int {
	if y > 0 {
		return gcd(y, x%y)
	}
	return x
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt64() int64 {
	i, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#define P 1000000007

using namespace std;

int n;

char S[200010];

int C[233];

int main() {
    scanf("%d", &n);
    scanf("%s", S + 1);
    for(int i = 1; i <= n; i++) C[S[i]]++;
    long long ans = 1;
    for(int i = 1; i <= 200; i++) ans = ans * (C[i] + 1) % P;
    printf("%lld\n", ((ans - 1) % P + P) % P);
    return 0;
}

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

int main() {
	int N, K;

	cin >> N >> K;

	vector<int> Dk(N, 0);
	int di, Ai;

	for (int i = 0; i < K; i++)
	{
		cin >> di;

		for (int j = 0; j < di; j++)
		{
			cin >> Ai;
			Dk[Ai - 1]++;
		}
	}

	int num = 0;

	for (int i = 0; i < N; i++)
	{
		if (Dk[i] == 0) {
			num++;
		}
	}

	cout << num << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int x;
    std::cin >> x;

    if (x < 1200) {
        std::cout << "ABC" << std::endl;
    } else {
        std::cout << "ARC" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cctype>
#include <cmath>
#include <math.h>
using namespace std;

typedef struct node {
  int key;
  node* next;
  node* prev;
} node_t;
typedef node_t* nodeRef;
node_t testnode;
nodeRef fnode = &testnode;

void ins(int key) {
  nodeRef newnode = (nodeRef)malloc(sizeof(node));
  nodeRef tmp = fnode->next;
  tmp->prev = newnode;
  fnode->next = newnode;
  newnode->next = tmp;
  newnode->prev = fnode;
  newnode->key = key;
}
void del(int key) {
  nodeRef delnode = fnode->next;
  while(1) {
    if(delnode==fnode) break;
    if((delnode->key)==(key)) {
      delnode->prev->next = delnode->next;
      delnode->next->prev = delnode->prev;
      free(delnode);
      break;
    }
    delnode = delnode->next;
  }
}
void delFirst(void) {
  nodeRef tmp = fnode->next;
  fnode->next->next->prev = fnode;
  fnode->next = fnode->next->next;
  free(tmp);
}
void delLast(void) {
  nodeRef tmp = fnode->prev;
  fnode->prev->prev->next = fnode;
  fnode->prev = fnode->prev->prev;
  free(tmp);
}
int main(){

  int n,arg;
  string cmd;
  fnode->next = fnode;
  fnode->prev = fnode;
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> cmd;
    if (cmd=="deleteFirst") {
      delFirst();
    } else if (cmd=="deleteLast") {
      delLast();
    } else if (cmd=="insert") {
      cin >> arg;
      ins(arg);
    } else if (cmd=="delete") {
      cin >> arg;
      del(arg);
    } else {
      cout << "error" << endl;
      return -1;
    }
  }
  nodeRef cur = fnode->next;
  while(1) {
    if(cur==fnode) break;
    if ((cur->next)==fnode) {
      cout << cur->key << endl;
    } else {
      cout << cur->key << " ";
    }
    cur = cur->next;
  }
}



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

int gcd( int a, int b ) {
	return b ? gcd( b, a%b ) : a;
}

int main() {
	ios_base::sync_with_stdio( false );

	int N, X;
	cin >> N >> X;

	vector<int> x( N );
	for( auto& v: x ) { cin >> v; }

	int result = abs( X - x[0] );
	for( int i = 1; i < N; ++i ) {
		result = gcd( result, abs( X - x[i] ) );
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
using namespace std;
int main(){
	int x;
	cin >> x;
	if(!(x%=1000)) x=1000;
	cout << 1000 - x;
	return 0;
}


Measured memory_bytes: 3632
inputs = input().split()
n = int(inputs[0])
l = int(inputs[1])

tastes = []
mintaste = l
for i in range(1, n+1):
  taste = l + i - 1
  tastes.append(taste)
  if abs(taste) < abs(mintaste):
    mintaste = taste

sum = sum(tastes) - mintaste

print(sum)

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


int FindSumOfDigits(int n)
{
	int sum = 0;
	while (n > 0)
	{
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

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

	int total = 0;
	for (int i = 0; i <= N; i++)
	{
		int sum = FindSumOfDigits(i);
		if (sum >= A && sum <= B)
		{
			total += i;
		}
	}

	cout << total << "\n";
	return 0;
}

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

int main(){
 int n, d, x, i, j;
 cin>>n>>d>>x;
 int *a=new int[n];
 for(i=0;i<n;i++){
  cin>>a[i];
  for(j=1;j<=d;j+=a[i])x++;
 }
 cout<<x<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char M[105][105],c,D[5]="NESW";
int H,W,sh,sw,i,j,t[105][105][4],mv[4]={-1,0,1,0},d,nh,nw;
long long int L;
int out(int a,int b){return 0>a||a>=b;}

int f(int b)
{
	for(i=0;i<L;)
	{
		nh=sh+mv[d];nw=sw+mv[(d+1)%4];
		if(out(nh,H)||out(nw,W)||M[nh][nw]=='#')
		{
			d=(d+1)%4;
			continue;
		}
		if(b&&t[sh][sw][d]!=-1)
		{
			L=(L-i)%(i-t[sh][sw][d])+(i-t[sh][sw][d]);
			return 1;
		}
		t[sh][sw][d]=i++;
		sh=nh;sw=nw;
	}
	return 0;
}

int main()
{
	for(;scanf("%d%d%lld\n",&H,&W,&L),H;)
	{
		memset(t,-1,sizeof(t));
		memset(M,0,sizeof(M));
		for(i=0;i<H;i++)
			for(j=0;j<=W;j++)
			{
				c=getchar();
				if('A'<c&&c<'Z')
				{
					d=c=='N'?0:c=='E'?1:c=='S'?2:3;
					sh=i;sw=j;M[i][j]='.';
				}
				else M[i][j]=c;
			}
		if(f(1))f(0);
		printf("%d %d %c\n",sh+1,sw+1,D[d]);
	}
	return 0;
}

Measured memory_bytes: 796
#include<iostream>
#include<vector>
#include<map>
#define P pair<int,int>
using namespace std;
int main(){
int n,m,p;
while(cin>>n>>m>>p,n||m||p){
	int maisu=0,tmp,atari;
	int  ans=0;
	for(int i=0;i<n;i++){
		cin>>tmp;
		maisu+=tmp*100;
		if(i+1==m)atari=tmp;
	}
		//cout<<"p"<<p;
	if(atari==0)ans=0;

	else {
		ans=maisu*100;
		ans-=maisu*p;
		ans=ans/atari;
	}
	cout<<ans/100<<endl;
}
return 0;
}

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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if ((i >= 1 && i <= 9) || (i >= 100 && i <= 999) || (i >= 10000 && i <= 99999)) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

vector<int> edge[100050];
int color[100050];
int painted[100050];

void DFS(int V,int dis,int paint){
    if(painted[V]>=dis || dis<0) return;
    painted[V]=dis;
    if(color[V]==0) color[V]=paint;
    rep(i,edge[V].size()) DFS(edge[V][i],dis-1,paint);
}

int main(void){
    int N,M;
    scanf("%d %d",&N,&M);
    rep(i,N) painted[i]=-1;
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--,b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    int Q;
    cin >> Q;
    int v[Q],d[Q],c[Q];
    reprev(i,Q){
        scanf("%d%d%d",&v[i],&d[i],&c[i]);
        v[i]--;
    }
    rep(i,Q){
        DFS(v[i],d[i],c[i]);
    }
    rep(i,N) printf("%d\n",color[i]);
}


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

int main() {
	// your code goes here
	for (int i = 1; i<=9; i++) {
		for (int j = 1;j<=9;j++) {
			cout << i <<"x"<<j<<"="<<(i*j) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array.Unboxed

dfs :: Int -> Int -> Int -> UArray (Int, Int) Char -> Bool
dfs h w sharps aa = iter [(1, 1, 1)]
  where
    next (i, j) = filter (\n -> p1 n && p2 n) [(i, j+1), (i+1, j)]
      where
        p1 = inRange (bounds aa)
        p2 = (== '#') . (aa !)
    iter [] = False
    iter ((i, j, s):xs)
        | (i, j) == (h, w) && s == sharps = True
        | otherwise                       = iter (ns ++ xs)
      where
        ns = [(k, l, s + 1) | (k, l) <- next (i, j)]

main :: IO ()
main = do
    [h, w] <- fmap read . words <$> getLine :: IO [Int]
    as <- concat <$> replicateM h getLine :: IO String
    let sharps = length $ filter (== '#') as
    let aa = listArray ((1, 1), (h, w)) as :: UArray (Int, Int) Char
    if dfs h w sharps aa
        then putStrLn "Possible"
        else putStrLn "Impossible"

Measured memory_bytes: 892
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int x;
  cin >> x;
  int n = x / 500;
  int m = (x - 500 * n) / 5;
  cout << 1000 * n + 5 * m << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int n;
int a[maxn];
int cnt[maxn];

int main() {
    int n=read();
    for(int i=1; i<=n; ++i) cnt[a[i]=read()]++;
    ll s=0;
    for(int i=1; i<=n; ++i) {
        s+=ll(cnt[i])*(cnt[i]-1)/2;
    }
    for(int i=1; i<=n; ++i) {
        printf("%lld\n", s-ll(cnt[a[i]])*(cnt[a[i]]-1)/2+ll(cnt[a[i]]-1)*(cnt[a[i]]-2)/2);
    }
}

Measured memory_bytes: 3712
ans=[0]*8
group=[]
re=[]
for i in range(8):
    p,t=map(float,input().split())
    group.append([t,int(p)])
group.sort()
ans[0]=group.pop(0)
ans[1]=group.pop(0)
re.append(group.pop(0))
re.append(group.pop(0))
for i in range(8):
    p,t=map(float,input().split())
    group.append([t,int(p)])
group.sort()
ans[2]=group.pop(0)
ans[3]=group.pop(0)
re.append(group.pop(0))
re.append(group.pop(0))
for i in range(8):
    p,t=map(float,input().split())
    group.append([t,int(p)])
group.sort()
ans[4]=group.pop(0)
ans[5]=group.pop(0)
re.append(group.pop(0))
re.append(group.pop(0))
re.sort()
ans[6]=re.pop(0)
ans[7]=re.pop(0)
for i in ans:
    print(i[1],i[0])


Measured memory_bytes: 5596
#include <stdio.h>

#define ARRAY_INIT 0
#define DIV_INIT 0
#define LOOP_INIT 0
#define G_MAX 12

int main( void )
{
	int ulW_Dtc_cnt;
	int *aulW_Dtestcase;
	int ulW_Dshell_p;
	int ulW_Cloop_cnt;
	int ulW_Cloop_sub_cnt;
	int ulW_Csort_cnt = DIV_INIT;
	int ulW_Dm;
	int aulW_DG[ G_MAX ];
	int ulW_Dv;
	int ulW_Dk;

	scanf( "%d", &ulW_Dtc_cnt );
	aulW_Dtestcase = ( int * ) malloc ( sizeof ( int ) * ulW_Dtc_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		scanf( "%d", &aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	ulW_Dm = 1;
	aulW_DG[ 0 ] = 1;
	while( 3 * aulW_DG[ ulW_Dm - 1 ] + 1 < ulW_Dtc_cnt ){
		aulW_DG[ ulW_Dm ] = 3 * aulW_DG[ ulW_Dm - 1 ] + 1;
		ulW_Dm++;
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm / 2; ulW_Cloop_cnt++ ){
		ulW_Dv = aulW_DG[ ulW_Cloop_cnt ];
		aulW_DG[ ulW_Cloop_cnt ] = aulW_DG[ ulW_Dm - 1 - ulW_Cloop_cnt ];
		aulW_DG[ ulW_Dm - 1 - ulW_Cloop_cnt ] = ulW_Dv;
	}

	printf( "%d\n", ulW_Dm );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm; ulW_Cloop_cnt++ ){
		if( ulW_Cloop_cnt == ulW_Dm - 1 ){
			printf( "%d\n", aulW_DG[ ulW_Cloop_cnt ] );
		}
		else{
			printf( "%d ", aulW_DG[ ulW_Cloop_cnt ] );
		}
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm; ulW_Cloop_cnt++){
		for( ulW_Cloop_sub_cnt = aulW_DG[ ulW_Cloop_cnt ]; ulW_Cloop_sub_cnt < ulW_Dtc_cnt; ulW_Cloop_sub_cnt++ ){
			ulW_Dv = aulW_Dtestcase[ ulW_Cloop_sub_cnt ];
			ulW_Dk = ulW_Cloop_sub_cnt - aulW_DG[ ulW_Cloop_cnt ];
			while( ( ulW_Dk >= 0 ) && ( aulW_Dtestcase[ ulW_Dk ] > ulW_Dv ) ){
				aulW_Dtestcase[ ulW_Dk + aulW_DG[ ulW_Cloop_cnt ] ] = aulW_Dtestcase[ ulW_Dk ];
				ulW_Dk -= aulW_DG[ ulW_Cloop_cnt ];
				ulW_Csort_cnt++;
			}
			aulW_Dtestcase[ ulW_Dk + aulW_DG[ ulW_Cloop_cnt ] ] = ulW_Dv;
		}
	}

	printf( "%d\n", ulW_Csort_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		printf( "%d\n", aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	return 0;
}

Measured memory_bytes: 4508
#include <stdio.h>

int main(void)
{
	int l[3];
	int i;
	int n;
	
	scanf("%d", &n);
	while (n){
		for (i = 0; i < 3; i++){
			scanf("%d", &l[i]);
		}
		
		if (l[0] > l[2]){
			l[0] += l[2];
			l[2] = l[0] - l[2];
			l[0] -= l[2];
		}
		if (l[1] > l[2]){
			l[1] += l[2];
			l[2] = l[1] - l[2];
			l[1] -= l[2];
		}
		
		if (l[0] * l[0] + l[1] * l[1] == l[2] * l[2]){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		n--;
	}
	
	return (0);
}

Measured memory_bytes: 1008
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	int ans = INF;
	for(int i=0;i<N;++i){
		int ter;
		cin >> ter;
		int count = 0;
		while((ter&1)==0){
			++count;
			ter>>=1;
		}
		ans = min(ans,count);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;


string S;
size_t cur;

int digit(){
	int res=S[cur++]-'0';
	return res;
}

int  number(){
	int res=digit();
	while(isdigit(S[cur]))
		res=res*10+digit();
	return res;
}

int left(){
	int res=number();
	while(cur<S.size()){
		if(S[cur]=='+'){
			cur++;
			int next=number();
			res+=next;
		}else if(S[cur]=='*'){
			cur++;
			int next=number();
			res*=next;
		}
	}
	return res;
}

int term(){
	int res=number();
	while(cur<S.size()&&S[cur]=='*'){
		if(S[cur]=='*'){
			cur++;
			int next=number();
			res*=next;
		}	
	}
	return res;
}

int exp(){
	int res=term();
	while(cur<S.size()&&S[cur]=='+'){
		if(S[cur]=='+'){
			cur++;
			int next=term();
			res+=next;
		}	
	}
	return res;
}

int main(void){
	cin >> S;
	int  n;
	cin >> n;
	cur=0;
	bool l=(n==left());
	cur=0;
	bool m=(n==exp());
	if(m&l)
		puts("U");
	else if(m)
		puts("M");
	else if(l)
		puts("L");
	else
		puts("I");
	return 0;
}

Measured memory_bytes: 1172
#include <iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int a[26] = {};
  for (int i = 0; i < S.length(); i++)
    a[S[i] - 'a']++;
  for (int i = 0; i < 26; i++)
  {
    if (a[i] == 0)
    {
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
""" AtCoder """

A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i * 500 + j * 100 + k *50 == X:
                ans += 1

print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int B[] = new int[N];
		int answer = 0;

		for (int i = 0; i < N - 1; i++) {
			B[i] = sc.nextInt();
			if (i != 0) {
				if (B[i] < B[i - 1]) {
					answer += B[i];
				} else {
					answer += B[i - 1];
				}
			}
		}

		answer = answer + B[0] + B[B.length - 2];
		System.out.println(answer);
	}
}


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

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

    int A = N / 100;
    int B = N / 10 - A * 10;
    int C = N - A * 100 - B * 10;
	int D = (A + 1) * 100 + (A + 1) * 10 + (A + 1);
    int E = A * 100 + A * 10 + A;
  	
  	if(A < B){
        cout << D << endl;
    }else if(A == B && B < C){
        cout << D << endl;
    }else{
        cout << E << endl;
    }

}

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

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

    int N, M;
    cin >> N >> M;
    unordered_map<int, bool> w;
    for (int i = 1; i < N + 1; i++) w[i] = false;
    vector<long long> dp(100010, 0);
    for (int i = 0; i < M; i++) {
        int tmp;
        cin >> tmp;
        w[tmp] = true;
    }
    dp[0] = 0;
    dp[1] = 1;
    for (int i = 2; i < N + 2; i++) {
        if (w[i - 3] && w[i - 2]) {
            dp[i] = 0;
            continue;
        }
        if (w[i - 3]) {
            dp[i] = dp[i - 1] % MOD;
            continue;
        }
        if (w[i - 2]) {
            dp[i] = dp[i - 2] % MOD;
            continue;
        }
        dp[i] = ((dp[i - 1] % MOD) + (dp[i - 2] % MOD)) % MOD;
    }
    cout << dp[N + 1] << endl;
}

Measured memory_bytes: 5156
n=int(input())
csf=[list(map(int,input().split())) for _ in range(n-1)]
ans=[float("inf") for _ in range(n)]
ans[n-1]=0
for i in range(n-1):
  cnt=csf[i][1]+csf[i][0]
  for j in range(i+1,n-1):
    if csf[j][2]<cnt:
      if cnt%csf[j][2]==0:
        cnt+=csf[j][0]
      else:
        cnt+=csf[j][0]+csf[j][2]-cnt%csf[j][2]
    else:
      cnt+=cnt-csf[j][2]
  ans[i]=cnt
ans=ans[::-1]
for i in range(n-1):
  if ans[i]>ans[i+1]:
    ans[i+1]=ans[i]
for i in ans[::-1]:
  print(i)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)


int main(){
    map<string,set<int> > msv;
    string in;
    int page,i;

    while( cin >> in >> page ){
        if( msv.count(in) ){
            msv[in].insert(page);
        }
        else{
            set<int> tmp; tmp.insert(page);
            msv[in] = tmp;
        }
    }

    foreach(it,msv){
        cout << it->first << endl;
        i = 0;
        foreach(js,it->second){
            if( i > 0 ) putchar(' ');
            printf("%d",*js);
            i++;
        }
        puts("");
    }

    return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int
main()
{
    int n,x,t;
    cin >> n >> x >> t;

    int a,b;
    a = n / x;
    b = n % x;

    if(b==0)
        cout << a * t << endl;
    else
        cout <<  (a * t) + t << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int n;
int s[11][3];
int dx[6][3]={
	0,1,2,
	0,2,1,
	1,0,2,
	1,2,0,
	2,0,1,
	2,1,0,
};
int table[12][50000];
int dp[12][50000];
int resf,rest;

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(dp,-1,sizeof(dp));
		memset(table,0,sizeof(table));
		resf=0;
		rest=36000;
		for(int i=0;i<n;i++){
			scanf("%d %d %d",&s[i][0],&s[i][1],&s[i][2]);
			for(int j=0;j<6;j++){
				for(int k=0;k<60;k++){
					int ss=(s[i][dx[j][0]]+k)%60;
					int tt=(s[i][dx[j][1]]+k)%60;
					int uu=(s[i][dx[j][2]]+k)%60;
					if(ss%5!=tt/12)continue;
					table[i][(ss/5)*3600+tt*60+uu]=1;
				}
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<12*60*60;j++){
				if(table[i][j]==1)dp[i][j]=j;
				if(j>=1)dp[i][j]=max(dp[i][j],dp[i][j-1]);
			}
		}
		for(int i=0;i<12*60*60;i++){
			int f=i;
			for(int j=0;j<n;j++){
				f=min(f,dp[j][i]);
			}
			if(f==-1)continue;
			if(rest-resf>i-f){
				resf=f;
				rest=i;
			}
		}
		printf("%02d:%02d:%02d %02d:%02d:%02d\n",resf/3600,(resf%3600)/60,resf%60,rest/3600,(rest%3600)/60,rest%60);
	}
	return 0;
}

Measured memory_bytes: 5732
import java.util.*;
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();
      int max = Math.max(a,Math.max(b,c));
      System.out.println(a+b+c-max);
    }
}

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

int main(){
	int N, i, j;
	scanf("%d", &N);
	double *p = (double *)malloc(sizeof(double) * (N + 1));
	for(i = 1; i <= N; i++){
		scanf("%lf", &p[i]);
	}
	double **dp = (double **)malloc(sizeof(double *) * (N + 1));
	for(i = 0; i <= N; i++){
		dp[i] = (double *)malloc(sizeof(double) * (N + 1));
		for(j = 0; j <= N; j++){
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for(i = 1; i <= N; i++){
		for(j = 0; j <= N; j++){
			if(j == 0){
				dp[i][j] = (1 - p[i]) * dp[i - 1][j];
			}
			else{
				dp[i][j] = p[i] * dp[i - 1][j - 1] + (1 - p[i]) * dp[i - 1][j];
			}
		}
	}
	double ans = 0;
	for(i = 0; i <= N; i++){
		if(i > N - i){
			ans += dp[N][i];
		}
	}
	printf("%.20lf\n", ans);
	return 0;
}

Measured memory_bytes: 70528
#include<iostream>
#include<string>
#include<algorithm>
#include<set>

using namespace std;
int main()
{
    string s;
    cin >> s;

    string c[4] = {"maerd", "remaerd", "esare", "resare"};
    reverse(s.begin(), s.end());

    bool can = true;
    for(int i=0; i<s.size();){
        bool can2 = false;
        for(int j=0;j<4;j++){
            string d = c[j];
            if(s.substr(i,d.size()) == d){
                can2 = true;
                i += d.size();
                break;
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }

    if(can) cout <<"YES";
    else cout << "NO";

    return 0;

}

Measured memory_bytes: 512
import math
n, k = map(int, input().split())

p = 0
for i in range(n):
  if (i+1 < k):
    tp = math.ceil(math.log2(k/(i+1)))
    p = p + 1 / (2 ** tp)
  else:
    p = p + 1

p = p / n
print(p)



Measured memory_bytes: 2940