akhauriyash/Code-Regression huggingface dataset:
#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 faio(arr) for(int i=0;i<n;i++)cout<<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 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;
  
  string s;

  cin>>s;

  bool f1,f2;

  f1=true;
  f2 = true;

  int a = s[0]-'0'; 
  int b = s[1]-'0';

  int c = 10*a + b;

  // bugv(c);

  if(c>12||c<=0)f1=false; 

  a = s[2]-'0'; 
  b = s[3]-'0';

  c = 10*a + b;

  // bugv(c);

  if(c>12||c<=0)f2=false; 


  if(f1&&f2)cout<<"AMBIGUOUS"<<endl
;  else if(f1) cout<<"MMYY";
   else if(f2) cout <<"YYMM";
   else cout<<"NA";  



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int ans = 0;

void dfs(vvi& g, int N, int depth, int node, vi visited){
    vi v = visited;
    if(find(ALL(visited), node) != visited.end()){
        return;
    }
    if(depth == N){
        ans++;
        return;
    }
    rep(i, N){
        if(g[node][i]){
            v.emplace_back(node);
            dfs(g, N, depth + 1, i, v);
            v.pop_back();
        }
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    if(!M){
        cout << 0 << endl;
        return 0;
    }
    vi a(M), b(M);
    vvi g(N, vi(N, 0));
    rep(i, M){
        cin >> a[i] >> b[i];
        g[a[i]-1][b[i]-1] = 1;
        g[b[i]-1][a[i]-1] = 1;
    }
    vi visited;
    dfs(g, N, 1, 0, visited);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<((a+b)<c ? "No" : "Yes");

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(str(type(var)) + name +":" + " = " + repr(var), file=stderr)
    return

class Tri:

    def __init__(self, h, w):
        self.h = h
        self.w = w
        self.diag = h**2 + w**2

    def __lt__(t1, t2):
        if t1.diag < t2.diag:
            return True
        elif t1.diag > t2.diag:
            return False
        else:
            return t1.h < t2.h

    def __repr__(self):
        return str(self.h) +" " + str(self.w)

    def __str__(self):
        return 0

def main():
    while(1):
        H, W = list(map(int, input().split()))
        if (H + W == 0):
            break
        diag = H**2 + W**2
        tris = []
        for h in range(1, 150):
            for w in range(h+1, 150):
                tris.append((Tri(h,w), h==H and w==W))
        # print(Tri(5, 6) < Tri(1, 8) < Tri(4, 7))
        # print(Tri(5, 6).diag,Tri(1, 8).diag, Tri(4, 7).diag)
        tris = sorted(tris, key=lambda x:x[0])
        # print(tris[:5])
        # for t in tris[:6]:
        #     print(t[0].h, t[0].w, t[0].diag)
        for i in range(len(tris)):
            if tris[i][1] == True:
                print(tris[i+1][0].h, tris[i+1][0].w)


if __name__ == "__main__":
    main()



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

int main() {
int N;
  cin>>N;
 vector<int>line(N,0);
  for(int i=0;i<N;i++){
  cin>>line.at(i);
  }
  int ans=1000101010;
  for(int i=1;i<=100;i++){
    int sum=0;
  	for(int j=0;j<N;j++){
    sum+=(line.at(j)-i)*(line.at(j)-i);
    }
    ans=min(ans,sum);
   }
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  a = a * b;
  if(a < c){
    cout << a << "\n";
    return 0;
  }
  cout << c << "\n";
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	ll ans=1, kj=1e18;
	rep(i, n){
		cin >>a[i];
		if(a[i]==0){puts("0"); return 0;}
	}
	rep(i, n){
		if(ans > kj / a[i])  {puts("-1"); return 0;}
		ans *= a[i];
		if(ans > kj) {puts("-1"); return 0;}
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 3952
using System;
class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            int n = int.Parse(input1[0]);
            int m = int.Parse(input1[1]);
            
            string[] input2 = Console.ReadLine().Split(' ');
            string[] input3 = Console.ReadLine().Split(' ');
            Output Put = new Output();
            long a = Put.Sum(input2, n);
            long b = Put.Sum(input3, m);
            Console.WriteLine(Put.Calu(a,b).ToString());
        }

        public class Output{
            public Output(){

            }
            
            public long Sum(string[] s, int n){
                long Sum=0;
                for (int i = 0; i < n; i++) {
                    Sum += long.Parse(s[i]) * (2 * i - n + 1); 
                }                               
                return Sum;
            }
            public long Calu(long a, long b){
                const int MOD = 1000000007;
                return ((a % MOD) * (b % MOD)) % MOD;
            }
        }
    }

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k; cin >> n >> k;
    int a[n]; FOR(i,0,n-1) cin >> a[i];

    bool dp[2][k+1];

    FOR(x, 0, k) FOR(t, 0, 1) {
        if (t == 0) {
            dp[t][x] = 0;
            FOR(i,0,n-1) if (a[i] <= x) {
                dp[t][x] |= dp[!t][x-a[i]];
            }
        } else {
            dp[t][x] = 1;
            FOR(i,0,n-1) if (a[i] <= x) {
                dp[t][x] &= dp[!t][x-a[i]];
            }
        }
    }

    cout << (dp[0][k] ? "First" : "Second") << '\n';
}



Measured memory_bytes: 512
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    X = list(map(int,input().split()))
    ans = []
    for i in range(100):
        tmp = 0
        for j in range(N):
            tmp += (X[j]-i)**2
        ans.append(tmp)
    print(min(ans))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
class SegmentTree
  def initialize(arr, l = 0, r = arr.size - 1)
    @l = l
    @r = r
    if @l == @r
      @leftmost_close = (arr[l] == ?) ? l : Float::INFINITY)
    else
      c = (l + r) / 2
      @left_child = self.class.new(arr, l, c)
      @right_child = self.class.new(arr, c + 1, r)
      @leftmost_close = [@left_child.leftmost_close, @right_child.leftmost_close].min
    end
  end

  attr_reader :leftmost_close, :l, :r

  def flip(i)
    if @l == @r
      @leftmost_close = (@leftmost_close == Float::INFINITY ? l : Float::INFINITY)
    else
      (i <= @left_child.r ? @left_child : @right_child).flip(i)
      @leftmost_close = [@left_child.leftmost_close, @right_child.leftmost_close].min
    end
  end
end

class LazySegmentTree
  def initialize(arr, l = 0, r = arr.size - 1)
    @l, @r = l, r
    @lazy = nil
    if @l == @r
      @min = arr[l]
    else
      c = (l + r) / 2
      @left_child = self.class.new(arr, l, c)
      @right_child = self.class.new(arr, c + 1, r)
      @min = [@left_child.min, @right_child.min].min
    end
  end

  attr_reader :min, :l, :r, :left_child, :right_child, :lazy

  def add(l, x)
    if @l == @r
      @min += x
    elsif l == @l
      if @lazy
        @lazy += x
      else
        @lazy = x
      end
    else
      force
      if l <= @left_child.r
        @left_child.add(l, x)
        @right_child.add(@right_child.l, x)
      else
        @right_child.add(l, x)
      end
      @left_child.force
      @right_child.force
      @min = [@left_child.min, @right_child.min].min
    end
  end

  def force
    return if !@lazy
    x = @lazy
    @lazy = nil
    @min += x
    @left_child.add(@left_child.l, x)
    @right_child.add(@right_child.l, x)
  end

  def rightmost_zero_pos(r)
    force
    return -1 if @min > 0
    return @l if @l == @r
    return @left_child.rightmost_zero_pos(r) if r <= @left_child.r
    ret = @right_child.rightmost_zero_pos(r)
    return @left_child.rightmost_zero_pos(@left_child.r) if ret == -1
    ret
  end

  def rightmost_one_pos(r)
    force
    return -1 if @min > 1
    return @min == 1 ? @l : -1 if @l == @r
    return @left_child.rightmost_one_pos(r) if r <= @left_child.r
    ret = @right_child.rightmost_one_pos(r)
    return @left_child.rightmost_one_pos(@left_child.r) if ret == -1
    ret
  end
end

n, q = gets.split.map(&:to_i)
a = gets.chomp.split("")
b = [0]
a.each do |c|
  if c == ?(
    b << b[-1] + 1
  else
    b << b[-1] - 1
  end
end
b.shift

seg1 = SegmentTree.new(a)
seg2 = LazySegmentTree.new(b)
q.times do
  i = gets.to_i - 1
  if a[i] == ?(
    a[i] = ?)
    seg1.flip(i)
    seg2.add(i, -2)
    j = seg1.leftmost_close
    puts j + 1
    seg1.flip(j)
    seg2.add(j, 2)
    a[j] = ?(
  else # a[i] == ?)
    a[i] = ?(
    seg1.flip(i)
    seg2.add(i, 2)
    zero = seg2.rightmost_zero_pos(i)
    j = nil
    if zero == -1
      j = seg2.rightmost_one_pos(i) + 1
    else
      one = seg2.rightmost_one_pos(i)
      if zero + 1 < one
        j = one + 1
      else
        j = zero + 2
      end
    end
    puts j + 1
    seg1.flip(j)
    seg2.add(j, -2)
    a[j] = ?)
  end
end


Measured memory_bytes: 146440
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let (n, k): (usize, usize) = {
        let mut split = buf.split_whitespace();
        (split.next().unwrap().parse().unwrap(), split.next().unwrap().parse().unwrap())
    };
    let result: usize = (k + 1..n + 1).map(|b| {
        n / b * (b - k) + (n % b).saturating_sub(k.saturating_sub(1))
    }).sum();
    writeln!(output, "{}", result).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "5 2\n",
            "7\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "10 0\n",
            "100\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "31415 9265\n",
            "287927211\n",
        );
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define repds(i,a,b) for(int i=a+1;i<=b;i++)
#define rep(i,N) repd(i,0,N)
#define reps(i,N) repds(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};
//--------------------------------------//
int k;

double s(ll n){
	ll _n=n;
	int r=0;
	while(n!=0){
		r+=(n%10);
		n/=10;
	}
	return (double)_n/r;
}
int main(){
	cin>>k;
	int c=0;
	ll n=0;
	ll p=1;
	rep(i,k){
		n+=p;
		if(s(n)<=s(n+p)) cout<<n<<endl;
		else if(n==2199999999) 
		{n-=(2*p);p*=10;i--;}
		else {n-=p;p*=10;i--;}
	}
	/*for(ll i=99999999;i<3000000000;i+=100000000){
		printf("%lld:%.2f\t\n",i,s(i));
		c++;
		if(c%5==0) cout<<endl;
	}*/
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

    int n = s.size();
    int m = t.size();

    using S = pair<int, pair<int, int>>;

    vector<vector<S>> dp(n + 1, vector<S>(m + 1, make_pair(0, make_pair(-1, -1))));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = make_pair(dp[i][j].first + 1, make_pair(i, j));
            } else {
                dp[i + 1][j + 1] = max(make_pair(dp[i][j + 1].first, make_pair(i, j + 1)), make_pair(dp[i + 1][j].first, make_pair(i + 1, j)));
            }
        }
    }

    string ans;

    auto p = make_pair(n, m);
  
    while(true) {
        auto q = dp[p.first][p.second].second;

        if (q == make_pair(-1, -1)) {
            break;
        }
     
        if (p.first == q.first + 1 && p.second == q.second + 1) {
            ans += s[q.first];
        }

        p = q;
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;
}


Measured memory_bytes: 105984
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    println(problem160a(s))
}

fun problem160a(s: String): String {
    return if (s[2] == s[3] && s[4] == s[5]) "Yes" else "No"
}

Measured memory_bytes: 31272
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n,W;
    cin>>n>>W;
    long long val[n],wt[n];
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    long long dp[n+1][W+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=W;j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else
            {
                if(wt[i-1]<=j)
                    dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
                else
                    dp[i][j]=dp[i-1][j];
            }
            //cout<<dp[i][j]<<" ";
        }
    }
    cout<<dp[n][W];
}

Measured memory_bytes: 82476
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int A[100100]={},N,K,Q,a;

int main(){
    cin>>N>>K>>Q;
    rep(i,Q){
        cin>>a;
        a--;
        A[a]++;
    }
    rep(i,N){
        if(K-Q+A[i]>0)out("Yes");
        else out("No");
    }
    
}


Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
  int A[6];
  int q,w,x,xx,y,yy,m,S,i,l;
  S = 0;

  for(w=0;w<6;w++){
    scanf("%d",&A[w]);
   }

  x = 100;
  y = 100;
  for(i=0;i<4;i++){
    if(x > A[i]){
      x = A[i];
      xx = i;
    }
  }

  for(l=4;l<6;l++){
    if(y > A[l]){
      y = A[l];
      yy = l;
    }
  }

  for(m = 0;m < 6;m ++){
    if(xx != m && yy != m){
      S += A[m];
    }
  }

  printf("%d\n",S);

  return 0;
}



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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

int k;
ll ans = 0;

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>k;
    for(int a = 1; a <= k; a++) for(int b = 1; b <= k; b++) for(int c = 1; c <= k; c++) ans += __gcd(__gcd(a, b), c);
    cout<<ans<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    while(1){
        string s;
        int t;
        cin >> t >> s;
        if(t==0) break;
        
        int num = atoi(s.c_str());
        int len = s.length();
        int ans=-1, smax=0;
        bool rejected = false;
        for(int i=0; i< (1<<(len-1)); i++){
            int n = num;
            int sum = 0;
            for(int j=0; j<len; j++){
                if((1<<j) & i){
                    int sep = n/pow(10,len-j-1);
                    sum += sep;
                    n -= sep*pow(10,len-j-1);
                }
            }
            sum += n;
            if(sum==smax){
                rejected = true;
            }
            if(sum<=t && sum>smax){
                smax = sum;
                ans = i;
                rejected = false;
            }
        }

        if(ans == -1){
            cout << "error" << endl;
        }else if(rejected){
            cout << "rejected" << endl;
        }else{
            cout << smax << " ";
            for(int i=0; i<len; i++){
                cout << s[i];
                if((1<<i) & ans) cout << " ";
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3372
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int m,int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(m,n / 2);
	x *= x;
	if (n % 2 == 1)x *= m;
	return x;
}
ll max(ll a, ll b) {
	if (a < b)return b;
	else return a;
}

int main() {
	int a;
	cin >> a;
	cout << a / 3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)

/////////////////////////////////////////////////////////

void Main(){
  int N; cin >> N;
  vector<int> F(N);
  rep(i, 0, N){
    int tmp = 0;
    rep(j, 0, 10){
      int flag; cin >> flag;
      tmp |= flag << j;
    }
    F[i] = tmp;
  }
  vector<vector<int>> P(N, vector<int>(11));
  rep(i, 0, N) rep(j, 0, 11) cin >> P[i][j];

  ll max = -INF;
  rep(open, 1, 1 << 10){
    ll sum = 0;
    rep(shop, 0, N){
      int hoge = open & F[shop];
      int cnt = 0;
      while(hoge > 0){
        cnt += hoge % 2;
        hoge /= 2;
      }
      sum += P[shop][cnt];
    }
    if(sum > max) max = sum;
  }
  cout << max << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


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

int main() {
  int a, b; cin >> a >> b;

  if(a < b) {
    for(int i=0; i<b; ++i) cout << a;
  }
  else for(int i=0; i<a; ++i) cout << b;
  cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

typedef long long ll;
const int N = 2010;
const int M = 200010;
const int mod = 1e9 + 7;

ll ans, f[N << 1][N << 1], fac[N * 5], inv[N * 5];
int n, a[M], b[M];

ll pow(ll a, int b)
{
    ll ans = 1;
    for(; b; b >>= 1)
    {
        if (b & 1) ans = ans * a % mod;
        a = a * a % mod;
    }
    return ans;
}

ll C(int x, int y) {return fac[x] * inv[y] % mod * inv[x - y] % mod;}

int main()
{
    fac[0] = 1; FOR(i, 1, 4 * N) fac[i] = fac[i - 1] * i % mod;
    inv[4 * N] = pow(fac[4 * N], mod - 2); for(int i = 4 * N - 1; ~i; --i) inv[i] = inv[i + 1] * (i + 1) % mod;

    scanf("%d", &n);
    FOR(i, 1, n) scanf("%d%d", &a[i], &b[i]);
    FOR(i, 1, n) ++f[N - a[i]][N - b[i]];
    FOR(i, 1, 2 * N - 1) FOR(j, 1, 2 * N - 1)
        f[i][j] = (f[i][j] + f[i - 1][j] + f[i][j - 1]) % mod;
    FOR(i, 1, n) ans = (ans + f[N + a[i]][N + b[i]]) % mod;
    FOR(i, 1, n) ans = (ans - C(2 * (a[i] + b[i]), 2 * a[i]) + mod) % mod;
    ans = ans * pow(2LL, mod - 2) % mod;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128128
from collections import deque

h, w = map(int, input().split())
maze = []
for i in range(h):
    s = input()
    maze.append(list(s))
# 最短経路の道筋以外は全て黒にしていい
# dotの数の合計-スタートからゴールまでの最短経路で答えを求める
dotsum = 0
for row in maze:
    for j in row:
        if j == ".":
            dotsum += 1

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
dp = [[-1] * (w + 1) for i in range(h + 1)]
dp[0][0] = 0

pos = deque([[0, 0, 0]])
dotroute = 0

while len(pos) > 0:
    x, y, depth = pos.popleft()
    if x == w - 1 and y == h - 1:
        dotroute = depth + 1
        break
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx < w and 0 <= ny < h and maze[ny][nx] == "." and dp[ny][nx] == -1:
            dp[ny][nx] = dp[y][x] + 1
            pos.append([nx, ny, depth + 1])
if dotroute == 0:
    print(-1)
else:
    print(dotsum - dotroute)

Measured memory_bytes: 41072
using System;

    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var K = int.Parse(Console.ReadLine());
            var sum = 1;
            for(var i = 0;i<N;i++)
            {
                if(sum<K)
                {
                    sum *= 2;
                    continue;
                }
                sum += K;
            }
            Console.WriteLine(sum);
        }
    }

Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

int calc(int i, int m, int n, vector< vector<int> >& a, vector<int>& X, vector<int>& Y, vector<bool>& p, vector<int>& memo) {
	if (i > m) return INT_MIN;
	if (i == n) return p[n];
	if (memo[i] < INT_MAX) return memo[i];
	int x = X[i], y = Y[i];
	int j, maxi = INT_MIN;
	j = a[y - 1][x - 1]; maxi = max(maxi, calc(j, m, n, a, X, Y, p, memo));
	j = a[y - 1][x]; maxi = max(maxi, calc(j, m, n, a, X, Y, p, memo));
	j = a[y - 1][x + 1]; maxi = max(maxi, calc(j, m, n, a, X, Y, p, memo));
	return memo[i] = maxi + p[i];
}

int main() {
	vector<bool> p(1000001, true);
	p[1] = false;
	for (int i = 2; i <= 1000000; i++)
		if (p[i])
			for (int j = i * 2; j <= 1000000; j += i)
				p[j] = false;
	vector< vector<int> > a(2000, vector<int>(2000, INT_MAX));
	vector<int> X(1000001), Y(1000001);
	int x = 1000, y = 1000, dir = 2;
	for (int i = 1; i <= 1000000; i++) {
		a[y][x] = i;
		X[i] = x; Y[i] = y;
		x += dx[dir]; y += dy[dir];
		dir = (dir + 3) % 4;
		int _x = x + dx[dir], _y = y + dy[dir];
		if (a[_y][_x] < INT_MAX) dir = (dir + 1) % 4;
	}
	for (;;) {
		int m, n; cin >> m >> n;
		if (m == 0) break;
		int maxi = 0, j = 0;
		vector<int> memo(m + 1, INT_MAX);
		for (int i = 1; i <= m; i++) {
			if (!p[i]) continue;
			int z = calc(i, m, n, a, X, Y, p, memo);
			if (z > 0 && z >= maxi) {
				maxi = z;
				j = i;
			}
		}
		cout << maxi << ' ' << j << endl;
	}
}

Measured memory_bytes: 28788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using ll = long long;
using namespace std;

int main() {
    ll H,W; cin >> H >> W;

    ll ans = H * W;
    
    ll s[3];

    for(int i=0;i<2;i++){
        for(ll h=1;h<H;h++){
            //縦割り
            s[0] = h * W;
            s[1] = (H-h) * (W / 2);
            s[2] = H * W - (s[0] + s[1]);
            sort(begin(s),end(s));
            ans = min(ans, s[2] - s[0]);

            //横割り
            s[0] = h * W;
            s[1] = ((H - h) / 2) * W;
            s[2] = (H * W) - (s[0] + s[1]);
            sort(begin(s),end(s));
            ans = min(ans, s[2] - s[0]);

        }
        swap(H,W);
    }
    cout << ans << endl;

    return 0;
}





Measured memory_bytes: 256
D, G = map(int, input().split())
table = []
for i in range(D):
    p,c = map(int, input().split())
    table.append((i+1,p,c))
ans = 10**3
for i in range(1<<D):
    count = 0
    score = 0
    remain = []
    for j in range(D):
        d,p,c = table[j]
        if i & (1<<j):
            score += 100*(d)*p+c
            count += p
        else:
            remain.append((d,p,c))
    if score < G:
        remain.sort(reverse=True)
        d,p,c = remain[0]
        while score < G and p > 0:
            score += 100*d
            count += 1
            p -= 1
    if score >= G:
        ans = min(ans,count)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
  int a,b,c,x,i,count=0;

  scanf("%d%d%d",&a,&b,&c);

  if(a>b){
    x=a;
    a=b;
    b=x;
  }

  for(i=a; i<=b; i++){
    if(c%i==0) count+=1;
  }

  printf("%d\n",count);

  return 0;

}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n;cin>>n;vector<double> a(n);ain(i,n,a);
  //caricurate
  vsort(a);
  rep(i,n-1){
    a[i+1]=(a[i]+a[i+1])/2.00000;
  }
  //output
  cout<<a[n-1]<<endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
using namespace std;
typedef  pair<int,int> pii;
const int N = 10010;
int n,m;
int vis[N];
priority_queue<pii> q;
vector<int> ve;
int main(){
    int a,b;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i){
        scanf("%d%d",&a,&b);
        q.push(pii(b,a));
    }
    for(int i=1;i<=m;++i)   ve.push_back(i);
//for(auto i:ve){
//    printf("%d ",i);
//}
    int ans = 0;
    while(!q.empty()){
        pii cur = q.top();
        q.pop();
        if(cur.second>m)    continue;
//printf("%d ",m-cur.second);
        auto pos = lower_bound(ve.begin(),ve.end(),cur.second);
        if(pos==ve.end())   continue;
//printf("find! %d\n",*pos);
        ve.erase(pos);
        ans += cur.first;
    }
    printf("%d\n",ans);
    return 0;
}


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

long long s;
long long solve(long long, long long);

int main()
{
	scanf("%lld", &s);
	printf("%lld\n", solve(1, 1));

	return 0;
}

long long solve(long long digit, long long set)
{
	if (digit * 10 > s)
	{
		int pre{1};
		long long sum{}, ten_pow{};
		for (ten_pow = 10; set; ten_pow *= 10)
		{
			if (set & 1)
			{
				sum += s % ten_pow / pre;
				pre = ten_pow;
			}
			set >>= 1;
		}
		return sum;
	}
	return solve(digit * 10, set << 1) + solve(digit * 10, (set << 1) + 1);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char ss[500000];
char s[500000];
int wei[500000];
int abs(int a){
	if (a<0) return -a;return a;
}
int main(){
	
	int l,n,sum,i;
	scanf("%s",s+1);
	s[0]='.'; 
	l=strlen(s);
	n=0;
	for (i=1;i<l;i++){
		if (s[i]!='x') {
			n++;
			ss[n]=s[i];
	        wei[n]=i;
		}
	}
	for (i=1;i<=n;i++) if (ss[i]!=ss[n-i+1]) {printf("-1\n");return 0;}
	sum=0;
	wei[0]=0;
	wei[n+1]=l;
	for (i=0;i<=(n-1)/2;i++) 
	sum=sum+abs(wei[i+1]-wei[i]-1-(-wei[n-i]+wei[n+1-i]-1));
	printf("%d\n",sum); 

}

Measured memory_bytes: 768
#include <stdio.h>
#define N 100

int main(){
  int n,i,j;
  int tmp,key;
  int A[N];
  
  scanf("%d",&n);
  for(i=0 ; i<n ; i++) scanf("%d",&A[i]);

  for(i=1 ; i<=n ; i++){
    for(j=0 ; j<n-1 ; j++){
      printf("%d ",A[j]);
    }
    printf("%d",A[n-1]);
    printf("\n");
    
    key = A[i];
    j = i - 1;
    while(j>=0 && key<A[j]){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
  }
  return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string x1,x2;
    cin>>x1>>x2;
    int ans=x2.size();
    for(int i=0;i<=x1.size()-x2.size();i++){
        int diff=0;
        for(int j=0;j<x2.size();j++){
            if (x2[j]!=x1[j+i]){
                diff++;
            }
        }
        ans=min(ans,diff);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

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

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

int calc(int a, int r) {
  return a*(100 + r)/100;
}

int main() {
  int x, y, s;
  int i, j;
  while (1) {
    scanf("%d%d%d ", &x, &y, &s); 
    if (!x && !y && !s) break;
    int res = 0;
    for (i=1; i<s; i++)
      for (j=i; j<s; j++) {
        int z = calc(i,x) + calc(j,x);
        if (z==s) res = max(res, calc(i,y) + calc(j,y));
      }
    printf("%d\n", res);
  }

	return 0;
}

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

class Program
{
    //const int MOD = 1000000007;
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        int max = 101010;
        Scanner cin = new Scanner();
        int r = cin.NextInt();
        Console.WriteLine(3 * r * r);

    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define MAX 100005
#define INF 1001001001

struct ITEM {
  int v;
  int w;
  char t;
  ll d;
  string s;
  ITEM(int v, int w, char t, ll d, string s) : v(v), w(w), t(t), d(d), s(s) {}
  bool operator<(ITEM it) {
    if (v != it.v) return v < it.v;
    if (w != it.w) return w < it.w;
    if (t != it.t) return t < it.t;
    if (d != it.d) return d < it.d;
    return s < it.s;
  };
};
ostream& operator<<(ostream& os, const ITEM& it) {
  return os << it.v << " " << it.w << " " << it.t << " " << it.d << " " << it.s;
}

int main(int, char**)
{
  int n;
  cin >> n;
  vector<ITEM> a;
  rep(i,n) {
    int v, w;
    char t;
    ll d;
    string s;
    cin >> v >> w >> t >> d >> s;
    a.emplace_back(v,w,t,d,s);
  }

  sort(a.begin(), a.end());
  for (auto e : a) cout << e << endl;

  return 0;
}



Measured memory_bytes: 12336
import math
N, M = (int(i) for i in input().split())

c = [1]
for i in range(1,math.ceil(math.sqrt(M))):
    if M%i == 0 :
        if i <= M//N and M//i > M//N:
            c.append(i)
        if i <= M//N and M//i <= M//N:
            c.append(M//i)
        else:
            continue
c = sorted(c)
print(c[-1])


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, -1)
#define RREP(i, n, k) for(auto i = n; i != k; i--)

#define debug(x) cerr << #x << " " << x << endl
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define spc << " " <<

#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define eb emplace_back
#define np next_permutation

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;
template<class T>using VV = vector<vector<T>>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

int main() {
   set<int> s;
   int n; cin >> n;
   rep(i, n) {
      int ni; cin >> ni; s.insert(ni);
   }

   int ans = 0;
   int q; cin >> q;
   rep(i, q) {
      int qi; cin >> qi;
      if (find(s.cbegin(), s.cend(), qi) != s.cend()) ans++;
   }

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



Measured memory_bytes: 3144
using System;
 
class Program{
	static void Main(){
		int[] n = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

		Array.Sort(n);

		Console.WriteLine(n[4] + " " + n[3] + " " + n[2] + " " + n[1] + " " + n[0]);
    }
}

Measured memory_bytes: 9272
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long y = 100;
    long ans = 0;

    for(int i=1 ; i<=10000 ; i++){
      y = (long)(y*(1.01));
      if(y>=x){
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35816
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int a, b;
            while ((a = scanner.nextInt()) != 0 && (b = scanner.nextInt()) != 0) {
                for (int i = 0; i < a; i++) {
                    for (int j = 0; j < b; j++) {
                        if (i == 0 || i == a - 1 || j == 0 || j == b - 1) {
                            System.out.print("#");
                        } else {
                            System.out.print('.');
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }
        }
    }
}

Measured memory_bytes: 37436
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

ll calc(ll n) {
  if (n % 4 == 0) return n;
  if (n % 4 == 1) return 1;
  if (n % 4 == 2) return n + 1;
  return 0;
}

int main() {
  ll A, B;
  cin >> A >> B;
  cout << (calc(B) ^ calc(A - 1)) << endl;
  return 0;
}

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

int main() {
	//入力
	int N;
	cin >> N;

	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	//処理
	int rep = 0;
	while (true) {
		bool exist_odd = false;
		for (int i = 0; i < N; i++) {
			if (A.at(i) % 2 != 0) exist_odd = true;
		}

		if (exist_odd)break;

		for (int i = 0; i < N; i++) {
			A.at(i) /= 2;
		}

		rep++;
	}
	cout << rep << endl;

}

Measured memory_bytes: 256
import math

while True:
	cnt = int(input())
	if cnt == 0:
		break
	
	li = list(map(int, input().split()))

	ave = sum(li) / cnt
	n_var = 0.0
	
	for i in range(cnt):
		n_var += ( li[i] - ave )**2
	
	var = n_var / cnt
	
	print('{0:.8f}'.format(math.sqrt(var)))

Measured memory_bytes: 7732
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        in.nextLine();
        Card[] cards = new Card[n];
        for (int i = 0; i < n; i++) {
            String color = in.next();
            int num = Integer.parseInt(in.next());
            cards[i] = new Card(color, num);
        }
        Card[] qS = cards.clone();
        Card[] mS = cards.clone();
        quickSort(qS, 0, n - 1);
        mergeSort(mS, 0, n);
        boolean stable = true;
        for (int i = 0; i < n; i++) {
            if (qS[i] != mS[i]) {
                stable = false;
            }
        }
        if (stable) {
            System.out.println("Stable");
        } else {
            System.out.println("Not stable");
        }
        for (int i = 0; i < n; i++) {
            System.out.println(qS[i].color + " " + qS[i].num);
        }
    }

    public static void quickSort(Card[] cards, int p, int r) {
        if (p < r) {
            int q = partition(cards, p, r);
            quickSort(cards, p, q - 1);
            quickSort(cards, q + 1, r);
        }
    }

    public static int partition(Card[] cards, int p, int r) {
        Card x = cards[r];
        int i = p - 1;
        for (int j = p; j < r; j++) {
            if (cards[j].num <= x.num) {
                i++;
                swap(cards, i, j);
            }
        }
        swap(cards, i + 1, r);
        return i + 1;
    }

    public static void swap(Card[] cards, int x, int y) {
        Card temp = cards[x];
        cards[x] = cards[y];
        cards[y] = temp;
    }

    public static void mergeSort(Card[] cards, int left, int right) {
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            mergeSort(cards, left, mid);
            mergeSort(cards, mid, right);
            merge(cards, left, mid, right);
        }
    }

    public static void merge(Card[] cards, int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;
        Card[] L = new Card[n1];
        Card[] R = new Card[n2];
        for (int i = 0; i < n1; i++) {
            L[i] = cards[left + i];
        }
        for (int i = 0; i < n2; i++) {
            R[i] = cards[mid + i];
        }
        int i = 0, j = 0, k = left;
        while (i < n1 && j < n2) {
            if (L[i].num <= R[j].num) {
                cards[k++] = L[i++];
            } else {
                cards[k++] = R[j++];
            }
        }
        while (i < n1) cards[k++] = L[i++];
        while (j < n2) cards[k++] = R[j++];
    }

}


class Card {
    public String color;
    public int num;

    public Card(String color, int num) {
        this.color = color;
        this.num = num;
    }
}


Measured memory_bytes: 87488
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    int c1 = 0, c2 = 0;
    for(int i = 0; i < S.length(); i++){
      if(S.charAt(i) == '0'){
        c1++;
      }else{
        c2++;
      }
    }
    System.out.println(Math.min(c1,c2)*2);
  }
}

Measured memory_bytes: 25792
# various sushi
import heapq
N, K = map(int, input().split())
que = []
for i in range(N):
    t, d = map(int, input().split())
    que.append((t, d))

que.sort(key=lambda x: -x[1])
NOW = que[:K]

N_set = set()

sums = 0

cnt = [0 for i in range(N+1)]  # ねたxに何個いるか
ng,ok,sub = [], [], []
heapq.heapify(ng)
heapq.heapify(ok)
heapq.heapify(sub)

for index, value in NOW:
    sums += value
    cnt[index] += 1
    heapq.heappush(ng, (value, index))
    N_set.add(index)
while ng:
    value, index = heapq.heappop(ng)
    if cnt[index] > 1:
        heapq.heappush(ok, (value, index))
        cnt[index] -= 1
    elif cnt[index] == 1:
        heapq.heappush(sub, (value, index))

ng = sub

# ng とっちゃダメなやつ
# ok とってもいいやつ

S = len(N_set)
ans = S**2+sums


# これより更新することはあるか？

for i in range(K, N):
    taste, value = que[i]
    if taste in N_set:
        pass
    else:
        #taste not in N_set
        if ok:
            min_value, m_taste = heapq.heappop(ok)
            sums -= min_value
            sums += value
            S += 1
            cnt[taste] += 1
            N_set.add(taste)
            cnt[m_taste] -= 1
            heapq.heappush(ng, (value, taste))
            ans = max(ans, S**2+sums)

print(ans)

Measured memory_bytes: 84056
S = list(input())
N = len(S)

l = [0] * 2019
temp = 0
e = 1
for i in range(N-1, -1, -1):
    temp += int(S[i]) * e
    temp %= 2019
    l[temp] += 1
    e *= 10
    e %= 2019

ans = l[0]

for i in range(0, 2019):
    ans += l[i] * (l[i]-1) // 2

print(ans)

Measured memory_bytes: 10600