akhauriyash/Code-Regression huggingface dataset:
use std::io; // use宣言は関数内にも書けます
use std::str::FromStr;
use std::cmp;

  

macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

#[test]
fn test_1(){
   let expect = solve(5, 3, 3, vec![1, 2, 4]);   
   assert_eq!(1, expect);
}

#[test]
fn test_2(){
   let expect = solve(7, 3, 2, vec![4, 5, 6]);   
   assert_eq!(0, expect);
}

#[test]
fn test_3(){
   let expect = solve(10, 7, 5, vec![1, 2, 3, 4, 6, 8, 9]);   
   assert_eq!(3, expect);
}

fn solve(n: u32, m:u32, x:u32, mut ai:Vec<u32>) -> u32{
    ai.sort();
    let big     = ai.iter()
                    .enumerate()
                    .filter(|&(index, &digit)| digit > x)
                    .count();
    let small   = ai.iter()
                    .enumerate()
                    .filter(|&(index, &digit)| digit < x)
                    .count();

    cmp::min(big as u32, small as u32)
}

fn main() {

    let (n, m, x) = get!(u32, u32, u32);
    let mut ai = vec![1u32];
    
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let ai: Vec<u32> = buf.split_whitespace()
        .map(|n| u32::from_str(n).unwrap())
        .collect();

    let ans = solve(n, m, x, ai);

    println!("{}", ans);   
    
}


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

ans1 = 0
total1 = 0
sign1 = True
for i in a:
    total1 += i
    if sign1 and total1 < 0:
        ans1 += abs(total1) + 1
        total1 = 1
    elif not sign1 and total1 > 0:
        ans1 += abs(total1) + 1
        total1 = -1
    elif sign1 and total1 == 0:
        ans1 += 1
        total1 = 1
    elif not sign1 and total1 == 0:
        ans1 += 1
        total1 = -1
    else:
        pass

    sign1 = not sign1

ans2 = 0
total2 = 0
sign2 = False
for j in a:
    total2 += j
    if sign2 and total2 < 0:
        ans2 += abs(total2) + 1
        total2 = 1
    elif not sign2 and total2 > 0:
        ans2 += abs(total2) + 1
        total2 = -1
    elif sign2 and total2 == 0:
        ans2 += 1
        total2 = 1
    elif not sign2 and total2 == 0:
        ans2 += 1
        total2 = -1
    else:
        pass

    sign2 = not sign2

print(min(ans1, ans2))


Measured memory_bytes: 14468
from copy import deepcopy
N=int(input())
A=[int(i) for i in input().split()]

def chmax(a,b):
    if a[0]<b[1]:
        return b
    elif a[0]<b[0]:
        return(b[0],a[0])
    elif a[1]<b[0]:
        return (a[0],b[0])
    else:
        return a
dp=[(A[i],0) for i in range(1<<N)]
#print(dp)
for i in range(N):
    for j in range(1<<N):
        if (j & (1<<i))==0:
            #print(j,i,j|(1<<i))
            dp[j|(1<<i)]=chmax(dp[j],dp[j|(1<<i)])
#print(dp)
ans =sum(dp[0])
for i in range(1,1<<N):
    t = sum(dp[i])
    ans = max(ans,t)
    print(ans)

Measured memory_bytes: 129340
#include <bits/stdc++.h>
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main(){
  ll n,k; cin >>n >>k;
  ll sum=((k*(2*k-n-2)-n*(n+1)-6)*(k-n-2)/6)%MOD;
  cout <<sum;
return 0;}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cstring>
#include <queue>
using namespace std;
#define ll long long
const int mod = 1e9 + 7;

int main() {
    ll s;
    cin >> s;
    if (s > 1e9) {
        ll x1 = 1000000000, x2 = 1;
        ll y2 = (s + x1 - 1) / x1;
        ll y1 = x1 * y2 - s;
        cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << " 0 0";
    } else {
        cout << "0 " << s << " 1 0 0 0";
    }
}


Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define UMap        std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    boolean chmax ( llong &a, llong b ) { return a<b ? a=b, true : false; }
    boolean chmin ( llong &a, llong b ) { return b<a ? a=b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int h[110];

    signed call_of_Cthulhu( signed datum ) {

        int cnt = 0;
        int left = 0;
        int n;
        read n;
        for ( int i = 0; i < n; i++ ) {
            read h[i];
            if ( h[i] ) {
                left++;
            }
        }

        while ( left ) {
            for ( int i = 0; i < n; i++ ) {
                if ( h[i] ) {
                    cnt++;
                    for ( int j = i; h[j]; j++ ) {
                        h[j]--;
                        unless(h[j]) left--;
                    }
                    goto hori;
                }
            }
hori:;
        }

        echo cnt fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  vector <int> A(N + 1);
  vector <int> B(N);
  rep(i,N + 1) cin >> A[i];
  rep(i,N) cin >> B[i];

  ll ans = 0;
  rep(i,N){
    //A_iへの攻撃
    ans += min(A[i], B[i]);
    B[i] -= min(A[i], B[i]);
    //A_i+1への攻撃
    ans += min(A[i + 1], B[i]);
    A[i + 1] -= min(A[i + 1], B[i]);
    //B[i] -= min(A[i + 1], B[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
lol mem[1000][1000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s[1000];
  cin >>a>>b;
  mem[0][0]=1;
  for(int n=0;n<a;n++) cin >>s[n];
  for(int n=0;n<a;n++){
      for(int m=0;m<b;m++){
	  if(m!=b-1){
	      if(s[n][m+1]!='#'){
		  mem[n][m+1]+=mem[n][m];
		  mem[n][m+1]%=inf;
	      }
	  }
	  if(n!=a-1){
	      if(s[n+1][m]!='#'){
		  mem[n+1][m]+=mem[n][m];
		  mem[n+1][m]%=inf;
	      }
	  }
      }
  }
  cout <<mem[a-1][b-1]<<'\n';
  return (0);
}


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

int main()
{
    ll n;
    cin >> n;
    ll arr[n+1];
    memset(arr, 0, sizeof(arr));
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j += i)  {
            arr[j]++;
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += i*arr[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 81768
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
  string A,B;
  cin>>A>>B;
  cout<<B<<A<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define INF 1<<30
#define mp make_pair

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

string f(int x) {
	string ret = "";
	while(x) {
		ret = char('0' + x % 10) + ret;
		x /= 10;
	}

	if(ret == "") return "0";
	return ret;
}

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

	vector<int> v(n);
	rep(i, n) cin >> v[i];

	set<string> st;
	for(int i = n-1; i >= 0; i--) {
		string s = "";
		for(int j = i; j >= 0; j--) {
			s = char('0' + v[j]) + s;

			if(s.size() != 1 && s[0] == '0') continue;
			
			st.insert(s);
		}
	}

	int x = 0;
	while(true) {
		if(st.find(f(x)) == st.end()) {
			cout << x << endl;
			break;
		}
		x++;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;

int L = 100;

int A = 0, B = 1;
int ONE = 3;
int P2[31];

void plessy (int k, int i, int j)
{
    // k = i + j
    cout << "+ " << i << " " << j << " " << k << "\n";
    //vr[k] = vr[j] + vr[i];
}

void iffy (int k, int i, int j)
{
    cout << "< " << i << " " << j << " " << k << "\n";
    /*if (vr[i] < vr[j]) vr[k] = 1;
    else vr[k] = 0;*/
}

int mm (int x)
{
    // make huge
    plessy (L, L, x);
    for (int i = 0; i < 30; i++)
        plessy (L, L, L);
    return L++;
}

int mif (int x, int y)
{
    // runs and gives you the res
    int OM = L++;
    iffy (OM, x, ONE);

    int OP = mm (OM);
    int c2 = L++;
    plessy (c2, c2, ONE);

    int yt = L++;
    plessy (yt, y, ONE);
    int res = L++;
    for (int i = 29; i >= 0; i--)
    {
        int ptest = L++;
        plessy (ptest, OP, P2[i]);
        int pr = L++;
        iffy (pr, ptest, yt);
        for (int j = 0; j < i; j++)
            plessy (pr, pr, pr);
        plessy (OP, OP, pr);
        plessy (res, res, pr);
    }
    return res;
}

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

    cout << "18694\n";
    plessy (50, A, B);
    plessy (51, 50, 50);
    iffy (ONE, 50, 51);
    P2[0] = ONE;
    for (int i = 1; i <= 30; i++)
    {
        P2[i] = P2[i-1] + 1;
        plessy (P2[i], P2[i-1], P2[i-1]);
    }

    int rt = L++;
    int yt = L++;
    plessy (yt, A, ONE);
    for (int i = 29; i >= 0; i--)
    {
        int ptest = L++;
        plessy (ptest, rt, P2[i]);
        int pr = L++;
        iffy (pr, ptest, yt);
        int mres = mif (pr, B);
        //cout << i << " " << vr[mres] << " " << vr[ptest] << " " << vr[yt] << "\n";
        for (int j = 0; j < i; j++)
        {
            plessy (mres, mres, mres);
            plessy (pr, pr, pr);
        }
        plessy (rt, rt, pr);
        plessy (2, 2, mres);
        //cout << vr[2] << "\n";
    }

    //for (int i = 0; i < 30; i++)
    //    cout << vr[P2[i]] << "\n";
    //cout << vr[2] << "\n";
}

Measured memory_bytes: 3520
object Main extends App {

  import scala.io.StdIn._
  val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
  val state = Array.tabulate(h){_ ⇒ readLine.trim.toCharArray.map{_ == '#'}}
  val union = Array.tabulate(h){i ⇒ Array.tabulate(w){j ⇒ new UnionFindTree(state(i)(j))}}
  for (i ← 0 until h; j ← 1 until w){
    if (state(i)(j) != state(i)(j - 1)) union(i)(j).merge(union(i)(j - 1))
  }
  for (i ← 1 until h; j ← 0 until w){
    if (state(i)(j) != state(i - 1)(j)) union(i)(j).merge(union(i - 1)(j))
  }
  val searched = new UnionFindTree(true)
  println(
    (for (i ← 0 until h; j ← 0 until w) yield {
      if (searched.isSameUnion(union(i)(j))) {
        0L
      }else{
        val result = union(i)(j).blackCount * union(i)(j).whiteCount.toLong
        union(i)(j).merge(searched)
        result
      }
    }).sum
  )


  class UnionFindTree(isBlack: Boolean){
    private var mBlackCount: Int = if (isBlack) 1 else 0
    private var mParent: Option[UnionFindTree] = None
    private var mSize: Int = 1
    def blackCount: Int = parent.mBlackCount
    def whiteCount: Int = parent.mSize - parent.mBlackCount
    private def parent: UnionFindTree = {
      mParent.map{_.parent} match {
        case None ⇒ this
        case c@Some(p) ⇒
          mParent = c
          p
      }
    }
    def isSameUnion(that: UnionFindTree): Boolean = {
      parent == that.parent
    }
    def merge(that: UnionFindTree): Unit = {
      if (!isSameUnion(that)){
        val p = parent
        val tp = that.parent
        if (p.mSize > tp.mSize){
          tp.mParent = Some(p)
          p.mSize += tp.mSize
          p.mBlackCount += tp.mBlackCount
        }else {
          p.mParent = Some(tp)
          tp.mSize += p.mSize
          tp.mBlackCount += p.mBlackCount
        }
      }
    }
  }
  implicit class Extension[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}

Measured memory_bytes: 58404
//

fun main() {
    abc175a()
}

fun abc175a() {
    val s = readLine()!!
    if (s == "RRR") {
        println(3)
    } else if (s == "RRS" || s == "SRR") {
        println(2)
    } else if (s.contains('R')) {
        println(1)
    } else {
        println(0)
    }
}


Measured memory_bytes: 35756
#include<stdio.h>

void sort(int A[],int N);
void trace(int A[],int N);

void trace(int A[],int N)
{
	int i;
	for(i=0;i<N;i++){
		if(i>0){ printf(" ");
		
		}
		printf("%d",A[i]);
	}
	printf("\n");
}

void sort(int A[],int N)
{
	int i,j,v;
	for(i=1;i<N;i++){
		v=A[i];//??????A[i]???????????£
		j=i-1;
		for(j=i-1;j>=0&&A[j]>v;j--){
			A[j+1]=A[j];
		}
	A[j+1]=v;
	trace(A,N);
		
	}


}

int main()
{
	int N,A[114514];
	int i,k;
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	
	trace(A,N);
	sort(A,N);

	


	return 0;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << " : " << x << endl;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

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

    rep(i, k) {
        cout << s << " ";
    }

    rep(i, n - k) {
        if (s == 1000000000) {
            cout << 1 << " ";
        } else {
            cout << s + 1 << " ";
        }
    }
    cout << endl;

    return 0;
}


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

int main()
{
  ios::sync_with_stdio(false);
  vector<int> d(3);
  cin >> d[0] >> d[1] >> d[2];

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

  cout << d[0] + d[1] << "\n";

  return 0;
}

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

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

  int w, h, n;
  cin >> w >> h >> n;

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

  int xmin = 0;
  int xmax = w;
  int ymin = 0;
  int ymax = h;

  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      xmin = max(xmin, x[i]);
    } else if (a[i] == 2) {
      xmax = min(xmax, x[i]);
    } else if (a[i] == 3) {
      ymin = max(ymin, y[i]);
    } else {
      ymax = min(ymax, y[i]);
    }
  }

  cout << max(xmax - xmin, 0) * max(ymax - ymin, 0) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int h, w;
string a[10];

int main() {
    cin >> h >> w;
    rep(i, h) cin >> a[i];

    int cnt = 0;
    rep(i, h) rep(j ,w) {
        if (a[i][j] == '#') cnt++;
    }
    cout << (cnt == h+w-1 ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int i;
    char a[5]={'a','e','i','o','u'};
    char ch;

    scanf("%c",&ch);

    ////for(i=0;i<5;i++)
    {
        if(ch == a[0] || ch == a[1] || ch == a[2] || ch==a[3] || ch==a[4] ) printf("vowel");
        else printf("consonant");
    }


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    cout << a[n/2]-a[n/2-1] << endl;
}

Measured memory_bytes: 4008
#include <iostream>

using namespace std;
int main()
{
    int N , ans = 0;
    cin >> N;
    string str;
    cin >> str;
    for (int j = 0; j <= N-1; j++)
    {
        if (str[j] != str[j + 1])
        {
            ans++;
        }
    }
    cout << ans << endl;

}




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

int main() {
  int N;
  cin >> N;
  if(N < 2){
    cout << 1 << endl;
  }
  else if (N < 4){
    cout << 2 << endl;
  }
  else if(N < 8){
    cout << 4 << endl;
  }
  else if(N < 16){
    cout << 8 << endl;
  }
  else if(N < 32){
    cout << 16 << endl;
  }
  else if(N < 64){
    cout << 32 << endl;
  }
  else if(N <= 100){
    cout << 64 << endl;
  }
}
  

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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int x = 0, ans = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'I') x++;
    else x--;
    ans = max(ans, x);
  }
  cout << ans;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 3026.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int x;
  scanf("%d", &x);
  x /= 100;

  printf("ai1333");
  for (int i = 0; i < x; i++) putchar('3');
  putchar('\n');

  return 0;
}



Measured memory_bytes: 3220
n=int(input())
cnt={'AC':0,'WA':0,'TLE':0,'RE':0}
for _ in range(n):
  s=input()
  cnt[s]+=1
print('AC','x',cnt['AC']) 
print('WA','x',cnt['WA'])
print('TLE','x',cnt['TLE'])
print('RE','x',cnt['RE'])

Measured memory_bytes: 9200
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int a, b;
/**********************************************/

int main(){
    cin >> a;
    cout << 48-a << endl;
}


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

using namespace std;

const int maxn = 25;

char mat[maxn][maxn];

int ans;

int h, w;

int xh[4] = {0, 0, 1, -1};
int yh[4] = {1, -1, 0, 0};

int mark[maxn][maxn];

void bfs(int x, int y){
    memset(mark, -1, sizeof mark);

    queue<pair<int,int> > fila;

    fila.push({x, y});

    mark[x][y] = 0;

    while(!fila.empty()){
        x = fila.front().first, y = fila.front().second;

        fila.pop();

        for(int i=0; i<4; i++){
            int newx = x + xh[i], newy = y + yh[i];
            if(newx >= 1 and newx <= h and newy >=1 and newy <= w){
                if(mark[newx][newy] == -1 and mat[newx][newy] == '.'){
                    fila.push({newx, newy});
                    mark[newx][newy] = mark[x][y] + 1;
                }
            }
        }
    }

    int mxdist = 0;

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            mxdist = max(mxdist, mark[i][j]);
        }
    }

    ans = max(ans, mxdist);
}

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

    cin >> h >> w;

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

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(mat[i][j] == '.'){
                bfs(i, j);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, input().split(' ')))
def In(): return int(input())
def InS(): return input()

N, K = InMap()
P = InMap()

Res = [0]*(N - K + 1)
tmp = sum(P[0:K])
for i in range(K, N):
    Res[i-K] = tmp
    tmp -= P[i-K]
    tmp += P[i]
Res[-1] = tmp
print((max(Res) + K) / 2)


Measured memory_bytes: 25060
require "prime"
x = gets.chomp.to_i
x.downto (1) do |i|
    ans = i.prime_division
    size = ans.size
    #size = ans.map(&:to_s).size
    count = 0
    if size == 1 && ans[0][1] != 1 && x >= 4
        puts i
        break
    elsif size >= 2 
        count = 0
        me = ans[0][1] 
        ans.each do |i|
            if me == i[1] && me != 1 
                count += 1
            end
        end
        if count == size
            puts i
            break
        end
    elsif x < 4
        puts "1"
        break
    end
end


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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> a) {
  ll cnt = 0;
  rep(i, N) {
    if (i % 2 == 0 && a.at(i) % 2 == 1) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 3712
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string s;
int x,y;

string ans = "No";

void solve(){
	//Fが各どれくらい連続しているかをmove_distに格納
	//例えばFTFFTFFFなら move_dist={1,2,3}とする
	vector<int> move_dist;
	int numof_F = 0;//連続で何回Fが出たか
	for(int i=0;i<s.size();i++){
		if(s[i]=='F'){
			numof_F++;
		}else{
			move_dist.push_back(numof_F);
			numof_F = 0;
			continue;
		}
		if(i==s.size()-1) move_dist.push_back(numof_F);
	}

	vector<int> vertical;//縦方向への動き
	vector<int> horizontal;//横方向への動き
	//デフォルトではx軸正の方向を向いているため
	//move_dist[0]は必ずx軸正の方向に進む
	x -= move_dist[0];
	for(int i=1;i<move_dist.size();i++){
		//縦方向への動き
		if(i%2==1){
			if(move_dist[i]>0) vertical.push_back(move_dist[i]);
		}
		//横方向への動き
		if(i%2==0){
			if(move_dist[i]>0) horizontal.push_back(move_dist[i]);
		}
	}

	//i回目で座標x=jに到達可能ならば
	//reach_x[i].insert(j)とする
	vector<set<int>> reach_x(horizontal.size()+1);
	reach_x[0].insert(0);
	//ばらまくイメージ
	for(int i=0;i<horizontal.size();i++){
		for(int now_x : reach_x[i]){
			if(now_x + horizontal[i] <= 8000) reach_x[i+1].insert(now_x + horizontal[i]);
			if(now_x - horizontal[i] >= -8000) reach_x[i+1].insert(now_x - horizontal[i]);
		}
	}
	if(reach_x[horizontal.size()].lower_bound(x)==reach_x[horizontal.size()].end()) return;
	if(*(reach_x[horizontal.size()].lower_bound(x))!=x) return;

	//i回目で座標y=jに到達可能ならば
	//reach_y[i].insert(j)とする
	vector<set<int>> reach_y(vertical.size()+1);
	reach_y[0].insert(0);
	//ばらまくイメージ
	for(int i=0;i<vertical.size();i++){
		for(int now_y : reach_y[i]){
			if(now_y + vertical[i] <= 8000) reach_y[i+1].insert(now_y + vertical[i]);
			if(now_y - vertical[i] >= -8000) reach_y[i+1].insert(now_y - vertical[i]);
		}
	}
	if(reach_y[vertical.size()].lower_bound(y)==reach_y[vertical.size()].end()) return;
	if(*(reach_y[vertical.size()].lower_bound(y))!=y) return;

	ans = "Yes";
}

int main(){
    cin >> s;
    cin >> x >> y;
 
    solve();

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

Measured memory_bytes: 188160
ary1 = []
ary2 = []
ans1 = 0
ans2 = 0

n, *ary0 = $<.map &:to_i

ary0.sort!
ary1[0] = ary0[0]
ary2[0] = ary0[-1]

for i in 0 .. n-2

  case i%4
  when 0
    ary1.unshift( ary0[-(i/4*2+1)] )
    ary2.unshift( ary0[i/4*2] )
  when 1
    ary1 << ary0[-(i/4*2+2)]
    ary2 << ary0[i/4*2+1]
  when 2
    ary1.unshift( ary0[i/4*2+1] )
    ary2.unshift( ary0[-(i/4*2+2)] )
  when 3
    ary1 << ary0[i/4*2+2]
    ary2 << ary0[-(i/4*2+3)]
  end

end

for i in 0 .. n-2
  ans1 += ( ary1[i+1] - ary1[i] ).abs
  ans2 += ( ary2[i+1] - ary2[i] ).abs
end

puts ans1 > ans2 ? ans1 : ans2


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

int main(){
	int n;
	std::vector<int> aList;
	std::cin>>n;

	aList.resize(n);
	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	long long ans= 0;

	for(int i=0; i<n; i++)
		for(int j=i+1; j<n; j++)
			ans+= aList[i]* aList[j];

	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
#define rep(i,m) for(int i=0;i<(n);i++)
using namespace std;
const int MAX = 100005;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
  int n; cin >> n;
  cout << n * n * n;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
int main() {
    deque<ll> dque;
    ll n;
    cin>>n;
    REP(i,n){
        ll a;
        cin>>a;
        if(i%2==0)dque.push_front(a);
        else dque.push_back(a);
    }
    if(n%2==0)reverse(dque.begin(),dque.end());
    REP(i, n){
        cout<<dque.front()<<" ";
        dque.pop_front();
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define maxn 200005
#define ll long long
#define ld double
#define mod 998244353
using namespace std;

int main()
{
	int n, a, b;
	cin>>n>>a>>b;
	cout<<min(a, b)<<" "<<max(0, a + b - n)<<endl;
	return 0;
 } 

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

typedef long long ll;
#define vi vector<int>
#define mii map<int,int>

int main() {
	int n;
	string ans = "No";
	cin >> n;
	while(n > 0){
		int d = n%10;
		n /= 10;
		if(d == 7) {
			ans = "Yes";
			break;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int q;
  cin>>q;
  for(int _=0;_<q;_++){
    int64_t a,b;
    cin>>a>>b;
    if(a==1&&b==1){
      cout<<0<<endl;
      continue;
    }
    int64_t l=0;
    int64_t r=max(a,b);
    int64_t h;
    while(r-l>1){
      h=(l+r)/2;
      if(h*h>=a*b)
        r=h;
      else
        l=h;
    }
    cout<<l*2-(min(a,b)<=l?1:0)-((a*b-1)/l==l?1:0)<<endl;
  }
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
		
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int h = sc.nextInt();
			int w = sc.nextInt();
			if(h==0 && w==0) break;
			
			char[][] map = new char[h][w];
			for(int i=0;i<h;i++) map[i] = sc.next().toCharArray();
			
			ArrayList<int[]> list = new ArrayList<int[]>();	
			int cnt = 0;
			
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(map[i][j]!='.'){
						cnt++;
						char c = map[i][j];
						map[i][j] = '.';
						list.add(new int[]{i, j});
						while(!list.isEmpty()){
							ArrayList<int[]> next = new ArrayList<int[]>();
							for(int[] xy : list){
								int y = xy[0];
								int x = xy[1];
								
								if(x!=0 && map[y][x-1]==c){
									map[y][x-1] = '.';
									next.add(new int[]{y, x-1});
								}
								if(x!=w-1 && map[y][x+1]==c){
									map[y][x+1] = '.';
									next.add(new int[]{y, x+1});
								}
								if(y!=0 && map[y-1][x]==c){
									map[y-1][x] = '.';
									next.add(new int[]{y-1, x});
								}
								if(y!=h-1 && map[y+1][x]==c){
									map[y+1][x] = '.';
									next.add(new int[]{y+1, x});
								}
							}
							list = next;
						}
					}
				}
			}
			System.out.println(cnt);
		}
	}	
}

Measured memory_bytes: 23080
import sys
import bisect
A,B,Q = [int(n) for n in input().split()]
# N = int(input())
INF = 10 **18
s = [0]*A
t = [0]*B
s = [-INF] + [int(input()) for n in range(A)] + [INF]
t = [-INF] + [int(input()) for n in range(B)] + [INF]

for i in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N,P;
    string S;
    cin >> N>>P;

    vector<ll> A(N);
    REP(i, N)
        cin >> A.at(i);

        ll dp[N + 1][2];

    /*REP(i,N){
        REP(j,2){
            dp[i][j] = 0;
        }
    }*/

    if(A.at(0)%2==0){
        dp[0][0]=2;
        dp[0][1] = 0;
    }
    else{
        dp[0][1]=1;
        dp[0][0] = 1;
    }

    REPS(i,N-1){
        if(A.at(i)%2==0){
            dp[i][0] = 2 * dp[i - 1][0];
            dp[i][1] = 2 * dp[i - 1][1];
        }
        else{
            dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
            dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
        }
    }

    cout << dp[N - 1][P] << endl;
}



Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
connection = [[] for _ in range(N)]
children = [[] for _ in range(N)]
arrival_order = []
mod = 10 ** 9 + 7
hasReached = [0] * N
dp_white = [1] * N
dp_black = [1] * N
q = deque([])
q.append(0)

for i in range(N - 1):
	x, y = map(int, input().split())
	x -= 1
	y -= 1
	connection[x].append(y)
	connection[y].append(x)
	
ans = 0

while len(q) > 0:
	now_node = q.popleft()
	arrival_order.append(now_node)
	hasReached[now_node] = 1
	for next_node in connection[now_node]:
		if hasReached[next_node] == 0:
			q.append(next_node)
			children[now_node].append(next_node)

for i in reversed(arrival_order):
	for j in children[i]:
		dp_black[i] *= dp_white[j]
		dp_black[i] %= mod
		dp_white[i] *= (dp_black[j] + dp_white[j])
		dp_white[i] %= mod
		
print((dp_black[0] + dp_white[0]) % mod)


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

namespace AtCoderPre
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            double[] num = new double[N];
            double[] num_re = new double[N];

            for (int i = 1; i <= N; i++)
            {
                num[i-1] = double.Parse(s[i-1]);
                num_re[i-1] = 1 / num[i-1];
            }

            double sum = 1/num_re.Sum();
            Console.WriteLine(sum);


        }

    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout<<(xx)<<endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;
//=============================================================

int N,M,Q;
vector<pii> rail;
vector<pii> question;
int ntb[501][501] = {};
void input()
{
    cin>>N>>M>>Q;
    rail = vector<pii> (M);
    rep(i,M){
        cin>>rail[i].first>>rail[i].second;
    }
    question = vector<pii> (Q);
    rep(i,Q){
        cin>>question[i].first>>question[i].second;
    }
}


void solve()
{
    sort(rail.begin(),rail.end());

    for (auto x : rail) {
        int f = x.first;
        int s = x.second;
        ntb[f][s]++;

        // for (int i=0; i <= (s-f) ; ++i){
        //     ntb[f][f+i]++;
        // }
    }


    // cout<<"ntb:"<<endl;
    // rep(i,20){
    //     rep(j,20){
    //         cout<< ntb[i][j] << " ";
    //     }
    //     cout<<endl;
    // }

    int rs[501][501] = {};

    for (int i=1; i<=N; ++i){
        for (int j=1; j<=N; ++j){
            ntb[i][j] += ntb[i][j-1];
        }
    }
    for (int i=1; i<=N; ++i){
        for (int j=1; j<=N; ++j){
            ntb[i][j] += ntb[i-1][j];
        }
    }


    for (auto q : question){
        int ans ;
        int f = q.first;
        int s = q.second;
        ans = ntb[s][s] + ntb[f-1][f-1] - ntb[f-1][s] - ntb[s][f-1];
        cout<<ans<<endl;
    }



}


//=================================================
signed main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 4224
#include <iostream>

int main() {
    int a, b, k;
    std::cin >> a >> b;
    if (a > b) std::swap(a, b);
    if ((b - a) % 2 != 0) {
        std::cout << "IMPOSSIBLE" << std::endl;
        return 0;
    }
    std::cout << ( (b + a) / 2 ) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int>a(N),b(N),c(N);
    for (int i=0;i<N;i++)
    {
        cin >> a[i];
    }
    for (int i=0;i<N;i++)
    {
        cin >> b[i];
    }
    for (int i=0;i<N;i++)
    {
        cin >> c[i];
    }
    long long sumstage=0,suma=0,sumc=0;
    auto itra=a.begin(),itrc=c.begin();
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    for (int i=0;i<N;i++)
    {
        suma=0;sumc=0;
        itra=lower_bound(a.begin(),a.end(),b[i]);
        itrc=upper_bound(c.begin(),c.end(),b[i]);
        itra--;
        if (b[i]>*itra)
        {
            itra++;
            suma=distance(a.begin(),itra);
        }
        if (*itrc>b[i]) sumc=distance(itrc,c.end());
        sumstage+=suma*sumc;
    }
    cout << sumstage << endl;
    return 0;
}

Measured memory_bytes: 1408
s=gets.chomp
k=gets.to_i
zord="z".ord
ret=[]
s.each_char do |c|
    need=(zord-c.ord+1)%26
    if k >= need
        ret.push("a")
        k-=need
    else
        ret.push(c)
    end
end
ret[-1]=(ret[-1].ord + k%26).chr
puts ret.join

Measured memory_bytes: 20332
#include <iostream>
#include <map>
#include <algorithm>    
#include <vector>       
#include <set>
#include <utility>  
#include <cstring>
#include <stdio.h>
#include <limits.h>
#include <queue>
#include <algorithm> 
#define MAX_DOUBLE  40000000000.0 
#include <math.h> 
#include <unistd.h>

using namespace std;

int res[100100];


int main(){
	int n,k;
	cin>>n>>k;
	
	vector<int> vec;
	
	for(int i = 0; i<n; i++){
		int a;
		cin>>a;
		vec.push_back(a);
	}
	
	for(int i = 0; i<=k; i++){
		bool can = false;
		for(int j = 0; j<n; j++){
			if(vec[j]>i) break;
			if(res[i-vec[j]] == 0) can = true; 
		}
		
		res[i]=can;
	}
	
	if(res[k] == 1){
		cout<<"First";
	}else{
		cout<<"Second";
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

string s;
ll ans = 0;
vector<char> dic = {'3', '5', '7'};

void dfs(ll keta, ll now, bool flag, string res){
    if(now == keta){
        //判定     
        bool flag3 = false, flag5 = false, flag7 = false;   
        rep(i, res.size()){
            if(res[i] == '5'){
                flag3 = true;
            }
            if(res[i] == '3'){
                flag5 = true;
            }
            if(res[i] == '7'){
                flag7 = true;
            }
        }
        if(flag3 == true && flag5 == true && flag7 == true){
            ans++;
        }
    }else{
        if(flag){
            ll tmp = s[now] - 48;
            
            for(ll j = 0; j < 3; j++){
                ll tmp_dic = dic[j] - 48;
                //cout << "tmp " << tmp << " " << tmp_dic << endl; 
                if(tmp == tmp_dic){
                    dfs(keta, now+1, true, res+dic[j]);
                }else if(tmp > tmp_dic){
                    dfs(keta, now+1, false, res+dic[j]);
                }
            }
        }else{
            for(ll j = 0; j < 3; j++){
                dfs(keta, now+1, false, res+dic[j]);
            }
        }
    }
}

int main() {
    cin >> s;
    ll n = stoll(s);

    ll keta = 0;
    ll tmp = n;
    while(tmp != 0){
        keta++;
        tmp /= 10;
    }

    if(keta < 3){
        cout << 0 << endl;
        return 0;
    }

    string res = "";
    for(ll i = 3; i <= keta; i++){
        if(i == keta){
            dfs(i, 0, true, res);
        }else{
            dfs(i, 0, false, res);
        }
        
    }
    

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;

int main(){
    AC
    int a, b, c, k;
    cin>>a>>b>>c>>k;
    if(k<=a+b)
        cout<<(k<=a ? k : a)<<endl;
    else
        cout<<a-(k-(a+b))<<endl;

}

Measured memory_bytes: 3584
/*raghav0307 - Raghav Gupta*/

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

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long ll;

int main(){
	fast_io();
	int a, b, t;
	cin >> a >> b >> t;
	cout << b * (int)(t/a) << "\n";
	return 0;
}

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

using namespace std;

const int Distance[8][8] = { 
	{ 0, 00, 00, 00, 00, 00, 00, 00 },
	{ 0, 00, 06, 13, 18, 23, 43, 58 }, 
	{ 0, 06, 00, 07, 12, 17, 37, 52 }, 
	{ 0, 13, 07, 00, 05, 10, 30, 45 }, 
	{ 0, 18, 23, 43, 00, 05, 25, 40 }, 
	{ 0, 23, 17, 10, 05, 00, 20, 35 }, 
	{ 0, 43, 37, 30, 25, 20, 00, 15 },
	{ 0, 58, 52, 45, 40, 35, 15, 00 }, 
};

const int Money[8][8] = {
	{ 0,  000, 000,  000,  000,  000,  0000, 0000 },
	{ 0,  000, 300,  500,  600,  700,  1350, 1650 },
	{ 0,  300, 000,  350,  450,  600,  1150, 1500 },
	{ 0,  500, 350,  000,  250,  400,  1000, 1350 },
	{ 0,  600, 450,  250,  000,  250,  850,  1300 },
	{ 0,  700, 600,  400,  250,  000,  600,  1150 },
	{ 0, 1350, 1150, 1000, 850,  600,  000,  500  },
	{ 0, 1650, 1500, 1350, 1300, 1150, 500,  000  },
};

const int TimeMin = 17 * 60 + 30;
const int TimeMax = 19 * 60 + 30;

int main() {
	int d, a, hd, md, ha, ma, timeD, timeA, sum;

	while (cin >> d, d) {
		cin >> hd >> md;
		cin >> a >> ha >> ma;
		sum = Money[d][a];
		timeD = hd * 60 + md;
		timeA = ha * 60 + ma;
		if ( Distance[d][a] <= 40 && (timeD>=TimeMin && timeD<=TimeMax || timeA>=TimeMin && timeA<=TimeMax) ) {
			sum /= 2;
			if (sum % 50 != 0) {
				sum += 50 - sum % 50;
			}
			
		}
		cout << sum << endl;
	}

	return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b); for(ll i=(a); i<=ll(b); i++) 
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
const ll MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
//int:~2e9   小数:double



int main(){
  int n;
  cin >>n;
  vector<vector<int>> c(9,vector<int>(9))
  FOR(i,1,9){
    FOR(j,1,9){
      int count=0;
      FOR(k,1,n){
        int tmp=k;
        while(tmp>=10) tmp /=10;
        if(k%10==j&&tmp==i) count++;
      }
      c[i-1][j-1]=count;

    }
  }
  int ans=0;
  FOR(i,1,9){
    FOR(j,1,9){
      ans+=c[i-1][j-1]*c[j-1][i-1];
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	cout<<n<<":";
	for(int i=2;i*i<=n;i++){
		while(n%i==0){
			cout<<" "<<i;
			n/=i;
		}
	}
	if(n!=1)cout<<" "<<n;
	cout<<endl;
}




Measured memory_bytes: 3216
using System;
class aoj
{
    static void Main()
    {
        string a = Console.ReadLine();
        string[] b = a.Split(' ');
        string[] e = new string[1024];
        int f = 0;
        for(int i = 0; i < b.Length; i++)
        {
            if (b[i] != null)
            {
                string[] c = b[i].Split(',');
                for (int j = 0; j < c.Length; j++)
                {
                    if (c[j] != null)
                    {
                        string[] d = c[j].Split('.');
                        for(int z = 0; z < d.Length; z++)
                        {
                            if (d[z] != null)
                            {
                                int g = d[z].Length;
                                if (g >= 3 && g <= 6)
                                {
                                    e[f] = d[z];
                                    f++;
                                }
                            }
                        }
                    }
                }
            }
        }
        for(int i = 0; i < f; i++)
        {
            if (i == 0)
                Console.Write(e[i]);
            else
                Console.Write(" " + e[i]);
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 8660
#include<bits/stdc++.h>
#define ll long long int
#define pi  acos(-1.0)

using namespace std;

int main()
{

    double a,b,h,m,x,y,diff;
    cin>>a>>b>>h>>m;

    x=h*(360/12.00);
    y=m*(360/60.00);

    double extra = (m/60.00)*(360/12.00);
    x+=extra;

    diff=abs(x-y);
    diff=diff*pi/180.00;
    double ans=sqrt(a*a+b*b-2*a*b*cos(diff));
    cout<<fixed<<setprecision(20)<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4224