akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long A, long long P){
  cout << (3*A+P)/2 << endl;
}

int main(){
  long long A;
  scanf("%lld",&A);
  long long P;
  scanf("%lld",&P);
  solve(A, P);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	int[] a;
	int sum;
	int n;
	int x;
	
	boolean check(){
		for(int i=0;i<x;i++){
			if(a[i]!=i+1) return false;
		}
		return true;
	}
	
	void sort(){
		boolean go;
		for(int i=0;i<n;i++) a[i]--;
		a[n] = n;
		for(int i=0;i<=n+1;i++){
			go = false;
			if(a[i]==0){
				for(int j=i+1;j<=n+1;j++){
					if(a[j]!=0){
						a[i] = a[j];
						a[j] = 0;
						go = true;
						break;
					}
				}
				if(go==false){
					n = i;
					i = n+2;
				}
			}
		}
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			n = sc.nextInt();
			if(n==0) break;
			sum = 0;
			int[] temp = new int[n];
			for(int i=0;i<n;i++){
				temp[i] = sc.nextInt();
				sum += temp[i];
			}
			a = new int[sum+2];
			boolean flag = true;
			int tri = 0;
			for(int i=1;;i++){
				tri += i;
				if(sum==tri){
					x = i;
					break;
				}
				if(sum<tri){
					flag = false;
					break;
				}
			}
			if(flag==false){
				System.out.println("-1");
			}else{
				for(int i=0;i<n;i++) a[i] = temp[i];
				flag = false;
				for(int i=0;i<10000;i++){
					if(check()==true){
						System.out.println(i);
						flag = true;
						break;
					}else{
						sort();
					}
				}
				if(flag==false) System.out.println("-1");
			}
		}
	}
	
	
	public static void main(String[] args) {
		new Main().solve();
	}	
}

Measured memory_bytes: 41448
n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]
ans = 0
for i in range(q):
    for j in range(n):
        if t[i] == s[j]:
            ans += 1
            break
print(ans)


Measured memory_bytes: 6552
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, c[10];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	FOR(i, n) {
		int a;
		cin >> a;
		a = min(a/400, 8);
		c[a]++;
	}
	int cnt = 0;
	FOR(i, 8) {
		if (c[i]) cnt++;
	}
	int mi = (cnt ? cnt : 1), ma = cnt + c[8];
	cout << mi << " " << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL A[123456], kPlus[123456], kTotal[123456];

int main(){
    
    // 1. 入力情報取得.
    int N, K;
    scanf("%d %d", &N, &K);
    LL pTotal = 0;
    for(int i = 0; i < N; i++){
        scanf("%lld", &A[i]);
        if(A[i] > 0) pTotal += A[i];
    }
    
    // 2. プラスのみの累積和, 符号に依らない累積和 を 保存.
    // ex.
    // kPlus[4]  は, A[0] ～ A[4] で, プラスのものだけを合計.
    // kTotal[4] は, A[0] ～ A[4] を合計.
    kPlus[0] = (A[0] > 0) ? A[0] : 0;
    kTotal[0] = A[0];
    for(int i = 1; i < N; i++){
        // kPlus更新.
        if(A[i] > 0) kPlus[i] += kPlus[i - 1] + A[i];
        else         kPlus[i] =  kPlus[i - 1];
        // kTotal更新.
        kTotal[i] += kTotal[i - 1] + A[i];
    }
    // for(int i = 0; i < N; i++) printf("%lld ", kPlus[i]);
    // printf("\n");
    // for(int i = 0; i < N; i++) printf("%lld ", kTotal[i]);
    // printf("\n");
    
    // 3. スコアの最大値を計算.
    LL ans = 0;
    for(int i = K - 1; i < N; i++){
        LL kp = (i > K - 1) ? kPlus[i]  - kPlus[i - K]  : kPlus[i];
        LL kt = (i > K - 1) ? kTotal[i] - kTotal[i - K] : kTotal[i];
        // K個連続で, 黒色にする場合.
        ans = max(ans, pTotal - kp + kt);
        // K個連続で, 白色にする場合.
        ans = max(ans, pTotal - kp + 0);
    }
    
    // 4. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 2560
/*
I believe on myself and I will achieve
this->author = Fuad Ashraful Mehmet, CSE-UAP
Todo:
https://www.codechef.com/COOK119?itm_campaign=contest_listing
*/
#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define all(o) (o).begin(),(o).end()
#define dbg(o)  cerr<<"at "<<__LINE__<<" response = "<<o<<endl;
#define pb push_back
using namespace std;

const int N=2e5+5;
typedef long long ll;
int n,m,d,k,cs=1;


void HalfDead()
{
      string s;
      int ans=0;
      cin>>s;



      for(int i=0;i<s.size();)
      {
            if(s[i]=='S')
            {
                  i++;
                  continue;
            }
            int cnt=0;
            int idx=i;
            while(s[idx]=='R' and idx<s.size())
            {
                  cnt++;
                  idx++;
            }
            i=idx;
            ans=max(ans,cnt);
      }

      cout<<ans<<endl;
}
int main()
{
      ios_base::sync_with_stdio(0); cin.tie(nullptr);
      int tc=1;
     // cin>>tc;
      while(tc--)
      {
            HalfDead();
      }
      return 0;
}

Measured memory_bytes: 3648
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int flag[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	int n = str.length();
	int L = 0, R = n;
	int l = 0, r = n;
	int ans = n / 2;
	while (l <= r)
	{
		int mid = (l + r) / 2;
		if (L + mid >= R - mid)
		{
			r = mid - 1;
			continue;
		}
		int tot = count(str.begin() + L + mid, str.begin() + R - mid, '0');
		if (tot == 0 || tot == R - mid - L - mid) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	cout << n - ans << endl;
	return 0;
}


Measured memory_bytes: 512
using System;

namespace ABC20191027
{
    class Program
    {
        static void Main(string[] args)
        {
            string st1 = Console.ReadLine();
            string[] s = st1.Split(' ');
            int k = int.Parse(s[0]);
            long x = long.Parse(s[1]);
            if (k * 500 >= x)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

int pri(int j){
  if(j==1)return 0;
  else if(j==2)return 1;
  else if(j%2==0)return 0;
  for(int i=3;i*i<=j;i+=2){
    if(j%i==0)return 0;
  }
  return 1;
}

int main(){
  int n,sum;
  while(1){
    cin>>n;
    if(n==0)break;
    sum=0;
    for(int i=n;;i++){
      if(pri(i)==1)break;
      else sum++;
    }
    for(int i=n;i>=1;i--){
      if(pri(i)==1)break;
      else sum++;
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};




int main(int argc, const char * argv[]) {
    string S;
    ll K;
    cin >> K >> S;
    ll sizeS = S.size();
    if(sizeS <= K){
        cout << S << endl;
        return 0;
    }
    
    vector<char> SS(K);
    for(ll i=0;i<K;i++){
        SS[i] = S[i];
        cout << SS[i];
    }
    cout << "..." << endl;
    
    
    
   return 0;
}



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

int main(){
    int N, M;
    std::cin >> N >> M;
    std::vector< int > A(M);
    std::vector< int > unlock(M, 0);
    std::vector< std::vector< int > > unlock_rev(N);
    for(int i=0; i<M; i++){
        int b;
        std::cin >> A[i] >> b;
        for(int j=0; j<b; j++){
            int c;
            std::cin >> c;
            unlock[i] += (int)std::pow(2.0, N - c);
            unlock_rev[c - 1].push_back(i);
        }
    }
    
    std::vector< int > unlock_deq(1);
    std::vector< int > cost_deq(1);
    unlock_deq[0] = 0;
    cost_deq[0] = 0;
    std::vector< int > unlock_deq_new;
    std::vector< int > cost_deq_new;
    
    for(int i=0; i<N; i++){
        
        int mask_cur = (int)std::pow(2.0, N - i - 1);
        for(int a=0; a<unlock_deq.size(); a++){
            if(unlock_deq[a] & mask_cur){
                unlock_deq_new.push_back(unlock_deq[a] % mask_cur);
                cost_deq_new.push_back(cost_deq[a]);
            }else{
                for(int b=0; b<unlock_rev[i].size(); b++){
                    unlock_deq_new.push_back( (unlock_deq[a] | unlock[unlock_rev[i][b]]) % mask_cur );
                    cost_deq_new.push_back(cost_deq[a] + A[unlock_rev[i][b]]);
                }
            }
        }
        std::vector< int > cost_deq_tmp(mask_cur, 1e9);
        for(int a=0; a<cost_deq_new.size(); a++){
            if(cost_deq_tmp[unlock_deq_new[a]] > cost_deq_new[a]){
                cost_deq_tmp[unlock_deq_new[a]] = cost_deq_new[a];
            }
        }
        
        unlock_deq_new.clear();
        cost_deq_new.clear();
        unlock_deq.clear();
        cost_deq.clear();
        for(int a=0; a<cost_deq_tmp.size(); a++){
            if(cost_deq_tmp[a] != 1e9){
                unlock_deq.push_back(a);
                cost_deq.push_back(cost_deq_tmp[a]);
            }
        }
        
    }
    
    if(cost_deq.size() == 0){
        std::cout << -1 << std::endl;
    }else{
        for(int i=0; i<cost_deq.size(); i++){
            std::cout << cost_deq[i] << std::endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 2036
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define  int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) (int)(x.size())
#define ff first
#define ss second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int32_t main()
{
    IOS;
    int x;
    cin>>x;
    int y=x/100;
    int z=x%100;
    if(5*y>=z)
    {
        cout<<1<<endl;
    }
    else
        cout<<0<<endl;
    return 0;
}


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

using namespace std;

using int64 = long long;

int main() {
  int N, M;
  int64 A[100001] = {};
  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  map< int64, int > mp;
  int64 sum = 0;
  mp[sum]++;
  int64 ret = 0;
  for(int i = 0; i < N; i++) {
    sum += A[i];
    sum %= M;
    ret += mp[sum];
    mp[sum]++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 4992
import sys
from io import StringIO
import unittest

def resolve():
    N = int(input())
    XL = [list(map(int, input().split())) for _ in range(N)]
    XL_re = [[xl[0] - xl[1], xl[0] + xl[1]] for xl in XL]
    XL_re = sorted(XL_re, key=lambda x: x[1])

    cnt = 0
    for i, xl in enumerate(XL_re):
        if i == 0:
            tmp = xl[1]
            cnt += 1
        else:
            if tmp <= xl[0]:
                tmp = xl[1]
                cnt += 1
    print(cnt)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4
2 4
4 3
9 3
100 5"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2
8 20
1 10"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5
10 1
2 1
4 1
6 1
8 1"""
        output = """5"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()



Measured memory_bytes: 88788
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;


int main() {
  ll N, M, A;
  cin >> N >> M;
  for(auto i = 0;i < M;i ++) {
    cin >> A;
    N -= A;
  }
  if (N < 0) {
    cout << -1 << endl;
  } else {
    cout << N << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
import sys
n, m = map(int, sys.stdin.readline().split(' '))
mlt = [0] * n
for i in range(m):
    b, c = map(int, sys.stdin.readline().split(' '))
    b -= 1
    c -= 1
    mlt[b] += 1
    mlt[c] += 1
flag = False
for i in range(n):
    if mlt[i] & 1:
        flag = True
        break
if not flag:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define nl '\n'
#define ar eventsay
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using ll = long long;
using namespace std;
const int MOD = 998244353;
const int N = 1e5;
string events[N+5];

int main(){
    AC
    int n;
    ll A, B, C;
    cin>>n>>A>>B>>C;
    for(int i=0; i<n; i++)
        cin>>events[i];

    char res[n];
    
    for(int i=0; i<n; i++){
        string e = events[i];
        ll oA=A, oB=B, oC=C;

        if(e=="AB"){
            if(A>B){ A--; B++;}
            else if(B>A){ B--; A++;}
            else if(A==1&&B==1&&C==0 && i<n-1){
                string k = events[i+1];
                if(k=="BC") {B++; A--;}
                else{A++; B--;}
            }
            else {A--; B++;}
            if(A>oA)
                res[i] = 'A';
            else
                res[i] = 'B';
        }
        else if(e=="AC"){
            if(A>C) {A--; C++;}
            else if(C>A) {C--; A++;}
            else if(A==1&&C==1&&B==0 && i<n-1){
                string k = events[i+1];
                if(k=="AB"){A++; C--;}
                else{A--; C++;}
            }
            else {A--; C++;}
            if(A>oA)
                res[i] = 'A';
            else
                res[i] = 'C';
        }
        else if(e=="BC"){
            if(B>C) {B--; C++;}
            else if(C>B) {C--; B++;}
            else if(B==1&&C==1&&A==0 && i<n-1){
                string k = events[i+1];
                if(k=="AB"){B++; C--;}
                else{B--; C++;}
            }
            else {B--; C++;}
            if(B>oB)
                res[i] = 'B';
            else
                res[i] = 'C';
        }
        if(A<0 || B<0 || C<0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=0; i<n; i++)
        cout<<res[i]<<endl;
}

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

int main(){
  long n;
  cin >> n;
  
  long p = 0;
  vector<long> prime(n+1);
  vector<bool> isprime(n+1);
  for(long i = 0;i <= n;i++){
    isprime.at(i) = true;
  }
  isprime.at(0) = isprime.at(1) = false;
  for(long i = 2;i <= n;i++){
    if(isprime.at(i) == true){
      prime.at(p++) = i;
      for(long j = 2*i;j <= n;j += i){
        isprime.at(j) = false;
      }
    }
  }
  vector<long> yakusu(n+1);
  for(long i = 2;i <= n;i++){
    for(long j = 0;j < p;j++){
      long k = i;
      while(k % prime.at(j) == 0){
        k /= prime.at(j);
        yakusu.at(prime.at(j))++;
      }
    }
  }
  long kekka = 1;
  for(long i = 2;i <= n;i++){
    kekka = (kekka * (yakusu.at(i) + 1)) % 1000000007;
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
import sys
from itertools import combinations
def input(): return sys.stdin.readline().strip()


def main():
    H, W, D = map(int, input().split())
    place = {}
    for i in range(H):
        A = list(map(int, input().split()))
        for j in range(W):
            place[A[j] - 1] = (i, j)
    magic = [0] * (H * W)
    for n in range(D):
        val = n
        x, y = place[val]
        while val + D < H * W:
            nx, ny = place[val + D]
            magic[val + D] = abs(nx - x) + abs(ny - y) + magic[val]
            val += D
            x, y = nx, ny
    #print(magic)

    Q = int(input())
    ans = 0
    for _ in range(Q):
        l, r = map(int, input().split())
        print(magic[r-1] - magic[l-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 86156
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;


using vi=vector<int>;
using vvi=vector<vi>;


void vvi_alloc(vvi& r, int w, int h, int v=0)
{
	r.resize(h);
	for(auto&re:r) re.assign(w, v);
}


int main(void)
{
	int h, w, q;
	vvi s, sh, sv, c;

	while(scanf("%d%d%d", &h, &w, &q)==3)
	{
		vvi_alloc(s, w, h);
		vvi_alloc(c, w+1, h+1);
		vvi_alloc(sv, w, h);
		vvi_alloc(sh, w, h);

		for(int y=0;y<h;y++)
		{
			for(int x=0;x<w;x++) scanf("%1d", &s[y][x]);
		}

		for(int y=0;y<h;y++)
		{
			for(int x=0;x<w;x++)
			{
				c[y+1][x+1]=c[y+1][x]+s[y][x];
			}
		}

		for(int y=0;y<h;y++)
		{
			for(int x=0;x<=w;x++)
			{
				c[y+1][x]+=c[y][x];
			}
		}

		for(int y=0;y<h;y++)
		{
			for(int x=1;x<w;x++)
			{
				sh[y][x]=sh[y][x-1];
				if(s[y][x]==1 && s[y][x-1]==1) sh[y][x]++;
			}
		}

		for(int x=0;x<w;x++)
		{
			for(int y=1;y<h;y++)
			{
				sv[y][x]=sv[y-1][x];
				if(s[y][x]==1 && s[y-1][x]==1) sv[y][x]++;
			}
		}

/*
for(auto&se:sh)
{
	for(auto see:se) printf("%2d ", see);
	printf("\n");
}
printf("\n");
for(auto&se:sv)
{
	for(auto see:se) printf("%2d ", see);
	printf("\n");
}
printf("\n");
*/
		for(int y=1;y<h;y++)
		{
			for(int x=0;x<w;x++)
			{
				sh[y][x]+=sh[y-1][x];
			}
		}

		for(int y=0;y<h;y++)
		{
			for(int x=1;x<w;x++)
			{
				sv[y][x]+=sv[y][x-1];
			}
		}
/*
for(auto&se:sh)
{
	for(auto see:se) printf("%2d ", see);
	printf("\n");
}
printf("\n");
for(auto&se:sv)
{
	for(auto see:se) printf("%2d ", see);
	printf("\n");
}
printf("\n");
*/
		for(int i=0;i<q;i++)
		{
			int l, t, r, b;
			int c_num=0, sh_num=0, sv_num=0;

			scanf("%d%d%d%d", &t, &l, &b, &r);
			t--;l--;b--;r--;
			c_num=(c[b+1][r+1]-c[b+1][l])-(c[t][r+1]-c[t][l]);

			sh_num=(sh[b][r]-sh[b][l]);
			if(t>0) sh_num-=(sh[t-1][r]-sh[t-1][l]);

			sv_num=(sv[b][r]-sv[t][r]);
			if(l>0) sv_num-=(sv[b][l-1]-sv[t][l-1]);

//			printf("c_num=%d  sh_num=%d  sv_num=%d\n", c_num, sh_num, sv_num);
			printf("%d\n", c_num-sh_num-sv_num);
		}
	}
	return 0;
}


Measured memory_bytes: 64640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double pi = acos(-1);
    double theta=(h/12.0+(m/60.0)/12.0-m/60.0)*2*pi;
    double ans = sqrt(a*a+b*b-2*a*b*cosl(theta));
    printf("%.10lf\n", ans);
    return 0;
}


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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >>D;
    while (A) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3608
# include <stdio.h>

int main(void){
	char a[11],b[11],c[11];
	int ea,eb,ea2,eb2;

	scanf("%s %s %s",a,b,c);

	for(ea=0;ea<11;ea++){
		if(a[ea]=='\0'){
			ea2=ea;
			break;
		}
	}
	for(eb=0;eb<11;eb++){
		if(b[eb]=='\0'){
			eb2=eb;
			break;
		}
	}


	if(a[ea-1]==b[0]){
		if(b[eb-1]==c[0]){
			printf("YES");
			return 0;
		}
	}
	printf("NO");
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  while(n > 9)
  {
    n = n % 10;
  }
  if( n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
  {
    cout << "hon" << endl;
  }else if(n == 3)
  {
    cout << "bon" << endl;
  }else{
    cout << "pon" << endl;
  }
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    long long int arr[n];
    long long int sum=0;
    long long int mn=INT_MAX;
    for(int i=0; i<n; i++)
    {

        cin>>arr[i];
    }
    sort(arr,arr+n);
    int turn=n-1;
    for(int i=n-1; i>=0; i--)
    {
        if(turn<=0)
            break;
        if(i==n-1)
        {
            sum+=arr[i];
            turn--;
            continue;
        }
        if(turn==1)
            sum+=arr[i];
        else
            sum+=(arr[i]*2);
        turn-=2;

    }
    cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 5212
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

#define ll long long

using namespace std;

ll a, b;

set<ll> primes(ll x) {
    ll xx = x;
    set<ll> r = {1};
    for (ll i = 2; i * i <= xx && x != 1; ++i) {
        while (x % i == 0) {
            r.insert(i);
            x /= i;
        }
    }
    r.insert(x);
    return r;
}

int main() {
    cin >> a >> b;
    cout << primes(__gcd(a, b)).size();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    string s;
    getline(cin,s);
    sort(s.begin(),s.end());
    bool ans = true;
    for(int i=0;i<s.size();i=i+2){
        if(s[i]!=s[i+1]){
            ans = false;
        }
    }
    if(ans) cout << "Yes";
    else cout << "No";
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<min(A,B)+min(C,D)<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(15);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
  unsigned long long a,b; cin >> a >> b;
  if (b>a) {
    unsigned long long c = b;
    b = a; a=c;
  }
  if((a-b)&1uLL) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << b+(a-b)/2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
m[10001][2];
D[10002][3];
#define min(a,b)((a)<(b)?(a):(b))
#define min3(a,b,c)min(min(a,b),c)
main(n){
	int x,c;
	scanf("%*d");
	for(;~scanf("%d\n",&n);){
		memset(m,0,sizeof(m));
		for(x=0;x<4*n;x++){
			c=getchar();
			m[(x%(2*n)+1)/2][x/(2*n)]|=(c=='Y');
		}
		D[0][0]=-1;
		D[0][1]=0;
		D[0][2]=1;
		for(x=0;x<=n;x++){
			D[x+1][0]=min3(
				D[x][0]+1+(m[x][1]?3:m[x][0]?1:0),
				D[x][1]+1+(m[x][1]?2:1),
				D[x][2]+1+2);
			D[x+1][1]=min3(
				D[x][0]+1+1+(m[x][1]?1:0),
				D[x][1]+1+(m[x][0]?1:0)+(m[x][1]?1:0),
				D[x][2]+1+1+(m[x][0]?1:0));
			D[x+1][2]=min3(
				D[x][0]+1+2,
				D[x][1]+1+(m[x][0]?2:1),
				D[x][2]+1+(m[x][0]?3:m[x][1]?1:0));
		}
		printf("%d\n",D[n+1][0]);
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>

using namespace std;

main(){
  int i,j,l,temp;
  int n=10;
  int m[10];
  int a[2];
  for(l=0;l<2;l++){
    for(i=0;i<n;i++){
      cin >> m[i];
    }
    for(i=n-1;i>0;i--){
      for(j=0;j<i;j++){
	if(m[j]<m[j+1]){
	  temp=m[j];
	  m[j]=m[j+1];
	  m[j+1]=temp;
	}
      }
    }
    a[l]=m[0]+m[1]+m[2];
  }
  cout << a[0] << ' ' << a[1] << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long int
 
using namespace std;
int main(){
 
ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i;
    cin>>n;
    if(n%2==1)
    cout<<0;
    else
    {
    	 ll count=0,x=10;
    for(i=0;i<n;i++)
    {
    	if(n/x==0)
    	break;
    	count+=n/x;
    	x=x*5;
    	
	}
	cout<<count;
	}
   
    
    
}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  
  rep(i,N-K){
    if(A[i+K]>A[i]){
      cout << "Yes" << endl;
    } else {cout << "No" << endl;}
  }
  return 0;
}

Measured memory_bytes: 4820
n=int(input())
class unionfind:
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def find(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def count(self, x):
        return -self.root[self.find(x)]
    
uf=unionfind(n)
import collections
dx=collections.defaultdict(int)
dy=collections.defaultdict(int)
l=[list(map(int,input().split())) for i in range(n)]
for i,j in enumerate(l,1):
    x,y=j
    if dx[x]:
        uf.unite(dx[x],i)
    else:
        dx[x]=i
    if dy[y]:
        uf.unite(dy[y],i)
    else:
        dy[y]=i
dx=collections.defaultdict(set)
dy=collections.defaultdict(set)
for i,j in enumerate(l,1):
    x,y=j
    dx[uf.find(i)].add(x)
    dy[uf.find(i)].add(y)
ans=0
for i,j in dx.items():
    ans+=len(j)*len(dy[i])-uf.count(i)
print(ans)

Measured memory_bytes: 123224
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		int[] x = new int[m];
		int[] y = new int[m];
		int[] num = new int[n];
		boolean[] red = new boolean[n];

		for (int i = 0; i < m; i++) {
			x[i] = sc.nextInt() - 1;
			y[i] = sc.nextInt() - 1;
		}

		for (int i = 0; i < n; i++) {
			num[i] = 1;
			red[i] = false;
		}
		red[0] = true;

		for (int i = 0; i < m; i++) {
			if (red[x[i]]) {
				red[y[i]] = true;
			}
			num[x[i]]--;
			num[y[i]]++;
			if (num[x[i]] == 0) {
				red[x[i]] = false;
			}
		}

		int count = 0;
		for (int i = 0; i < n; i++) {
			if (red[i]) {
				count++;
			}
		}
		System.out.println(count);

	}

	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 24468
#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 count = 1;
  int break_block = 0;
  for(int i = 0; i < N; i++) { // 数値列を頭から走査していく
    if(A.at(i) == count) {
      count++;
    } else {
      break_block++;
    }
  }
  
  if(break_block == N) {
    cout << -1 << endl;
  } else {
    cout << break_block << endl;
  }
}

Measured memory_bytes: 1024
// Author: πα

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

const int N = 1005, M = 10005;
int cost[N], hp[N], dp[M], n;

int ans(int x)
{
    if(x <= 0)
        return 0;
    if(dp[x])
        return dp[x];
    int ret = INT_MAX;
    for(int i = 0; i < n; ++i)
        ret = min(ret, cost[i] + ans(x - hp[i]));
    return dp[x] = ret;
}

int main()
{
    int w;
    cin >> w >> n;
    for(int i = 0; i < n; ++i)
        cin >> hp[i] >> cost[i];
    cout << ans(w);
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define pb push_back
#define rep(a,b,c) for(int a=(int)b;a<(int)c;a++)
#define repe(a,b,c) for(int a=(int)b;a<=(int)c;a++)
#define repk(a,b,c,k) for(int a=(int)b;a<(int)c;a+=(int)k)
#define comeback std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define int long long int
#define pii pair<int,int>
#define ful(a) a.begin(),a.end()
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
using namespace std;
int em(int x,int n)
{
    if(n==0)
    return 1;
    else if(n%2==0)
    return em((x%mod*x%mod)%mod,n/2);
    else
    return (x%mod*em((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int dp[100009];
signed main()
{
	comeback
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output1.txt","w",stdout);
	#endif*/
		int n,m,i,j,k,l;
		cin>>n>>k;
		int a[n+1];
		for(i=0;i<n;i++)
			cin>>a[i];
		memset(dp,0,sizeof(dp));
		for(i=0;i<=k;i++){
			for(j=0;j<n;j++){
				if(a[j]<=i)
					if(dp[i]==0)
					dp[i]=1^(dp[i-a[j]]);
			}
		}
		if(dp[k])
			cout<<"First"<<"\n";
		else
			cout<<"Second"<<"\n";

		
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    string s; cin >> s;
    int slen = s.length();
    int cnt = 0;
    for(int i = 1; i < slen; ++i) {
        if(s.at(i) != s.at(i-1)) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long p = 1000000007;
long long modsub(long long a, long long b){
	if (a >= b){
		return (a - b) % p;
	} else {
		return p - (b - a) % p;
	}
}
long long modpow(long long a, long long b){
	long long res = 1;
	while (b > 0){
		if (b % 2 == 1) res = res * a % p;
		a = a * a % p;
		b = b / 2;
	}
	return res;
}
long long modinv(long long a){
	return modpow(a,p - 2);
}
long long modbinom(long long n, long long r){
	long long res = 1;
    for (int i = 0; i < r; i++){
        res = res * (n - i) % p;
        res = res * modinv(i + 1) % p;
    }
    return res;
}
int main(){
  long long n,a,b;
  cin >> n >> a >> b;
  //2^n - 1 - nCa - nCb
  cout << modsub(modpow(2,n),modbinom(n,a)+modbinom(n,b)+1);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static int N;
    private static int[] atama = new int[10];
    private static int[] shiri = new int[10];
    private static int[] uho = new int[100];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        N = sc.nextInt();

        for (int A = 1; A <= N; A++) {
            uho[Integer.valueOf(String.valueOf(A).charAt(0) + "" + (A % 10))]++;
        }
        
        int ans = 0;
        for(int i=11; i<100; i++) {
            if(i % 10 == 0) {
                continue;
            }
            
            ans += uho[i] * uho[(i / 10) + (10 * (i % 10))];
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 44500
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<int,int>m;
    set<pair<int,int>>s;
    rep(i,3){
        int temp,temp1;
        cin>>temp>>temp1;
        m[temp]++;
        m[temp1]++;
        s.insert(make_pair(min(temp,temp1),max(temp,temp1)));
    }
    if(s.size()!=3)return NO,0;
    rep(i,4){
        if(m[i+1]>=3)return NO,0;
    }
    YES;
}


Measured memory_bytes: 256
n, m=gets.split.map &:to_i
s=[]
n.times do
    s<< gets.chomp.split.map(&:to_i)
end
t=[]
m.times do
    t<< gets.chomp.split.map(&:to_i)
end

s.each do |a, b|
    u=t.map{|c, d| (a-c).abs+(b-d).abs}
    puts u.index(u.min)+1
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
#define P pair<int, int>
using namespace std;

int main() { 
  ll n;
  cin >> n;
  ll ans = 1e15;
  for(ll i = 1; i * i <= n; i++){
    if(n % i == 0){
      ans = min(ans, (i-1)+(ll)(n/i-1));
      //cout << ans << " " << i << " " << d << endl;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<string,int> P;
signed main(){
  int n,q;
  cin>>n>>q;
  string name[n];
  int time[n];
  for(int i=0;i<n;i++) cin>>name[i]>>time[i];
  int cur=0;
  queue<P> que;
  for(int i=0;i<n;i++) que.push(P(name[i],time[i]));
  while(!que.empty()){
    P p=que.front();que.pop();
    if(p.second<=q){
      cur+=p.second;
      cout<<p.first<<" "<<cur<<endl;
      continue;
    }
    p.second-=q;
    cur+=q;
    que.push(p);
  }
  return 0;
}

Measured memory_bytes: 6856
#include <iostream>

using namespace std;


int main() {
  int n, m;
  cin >> n >> m;
  int k = n / 2;
  int l = k + 1;
  int a = n % 2;

  if (a == 0) {
    for (int i = 0; i < m; i++) {
      if ((n + 2) / 4 == k - i) {
        k--;
      }
      cout << k - i << " " << l + i << endl;
    }
  } else {
    for (int i = 0; i < m; i++) {
    cout << k - i << " " <<  l + i << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 int r;
 cin >> r;
 double pie = 3.14159265358979;
 cout << setprecision(10) << 2 * r * pie << endl;
}

Measured memory_bytes: 3788
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int a,b;
	cin >> a >>b;

	if((a*2-1)>(a+b)){
		cout << a*2-1 << endl;
	}else if((b*2-1)>(a+b)){
		cout << b*2-1 <<endl;
	}else{
		cout << a+b <<endl;
	}

	return 0;
}

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

int A[MAX];
int R[MAX / 2 + 2];
int L[MAX / 2 + 2];
int cnt;

void merge(int *A, int left, int mid, int right) {
    int N1 = right - mid;
    int N2 = mid - left;

    for ( int i = 0; i < N1; ++i ) {
        R[i] = A[mid + i];
    }
    for ( int i = 0; i < N2; ++i ) L[i] = A[left + i];

    R[N1] = 1000000000;
    L[N2] = 1000000000;

    int j = 0,k = 0;

    for ( int i = left; i < right; ++i ) {
        cnt++;
        if ( R[j] <= L[k] ) {
            A[i] = R[j++];
        }
        else {
            A[i] = L[k++];
        }
    }
}

void mergeSort(int *A, int left, int right) {
    int mid;
    if ( left + 1 < right ) {
        mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {
    int n,i;

    cnt = 0;

    cin >> n;
    for ( i = 0; i < n; ++i ) {cin >> A[i];}


    mergeSort(A, 0, n);

    for ( i = 0; i < n; ++i ) {
        if ( i ) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 6976
#include <bits/stdc++.h>
#define ll long long int
#define Mod 1000000007

using namespace std;

void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

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

int main(){
	fastio();
	ll a,b,cnt=0;
	cin>>a>>b;
	ll number=gcd(a,b);
	for(ll i=2;i*i<=number;i++){
		if(number%i==0){
			cnt++;
			while(number%i==0){
				number/=i;
			}
		}
	}
	if(number!=1)cnt++;
	cout<<cnt+1;
}

Measured memory_bytes: 256
from collections import defaultdict,Counter
n=int(input())
a=list(map(int,input().split()))

c=Counter(a)
s=0

for i,m in c.items():
    s+=m*(m-1)//2

for i in range(n):
    print(s-c[a[i]]*(c[a[i]]-1)//2+(c[a[i]]-1)*(c[a[i]]-2)//2)

Measured memory_bytes: 26780
#include<cstdio>
int main()
{
	int N,K,X,Y,sum;
	scanf("%d %d %d %d",&N,&K,&X,&Y);
	if(N <= K)
		sum = X * N;
		else
			sum = K * X + Y * (N - K);
			printf("%d\n",sum);
			return 0;
}

Measured memory_bytes: 128
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
closeH = {}
for x in range(len(H)):
    H[x] = T - H[x] * 0.006
    closeH[x + 1] = abs(A - H[x])
min_G = min(closeH, key=closeH.get)
print(min_G)


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

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
using namespace std;
const ll mod = 1e9 + 7;



//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}






int main()
{
    MohamedMotaz;

    ll k, n, sum = 0;
    cin >> k >> n;
    vector<ll> vec(n);
    f(i, 0, n) cin >> vec[i];
    ll ans = vec[n - 1] - vec[0];

    f(i, 1, n) ans = min(ans , k - vec[i] + vec[i - 1] );

    cout << ans;
    //sort(vec.begin(), vec.end(), greater<ll>());
}








Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int64_t A,B,C;
  cin>>A>>B>>C;
  if(A%2==0||B%2==0||C%2==0){
    cout<<0<<endl;
  }
  else{cout<<min({A*B,A*C,B*C})<<endl;}
  return 0;
}

Measured memory_bytes: 3628
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
    line = "#"
    for i in range(H):
        if i == 0 or i == H - 1:
            print(line * W)
        else :
            print( line + ("." * (W - 2)) + line )
    print()

Measured memory_bytes: 7648
/* 
 * Project: AtCoder Beginners Contest 162 B - FizzBuzz Sum
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/12
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int n;

void solve() {

    long sum = 0;

    for (int i=1;i<=n;i++) {
        if (i % 3 == 0)
            ;
        else if (i % 5 == 0)
            ;
        else
            sum += i;
    }

    cout << sum << endl;
}

int main() {

    cin >> n;

    solve();

}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

/////////////         UnionFind
//    バラバラの要素を結合してグループにまとめる際に使える構造。
//    グループ番号、要素数の取得が可能だが、グループに属する要素の列挙はO(N)かかる。

class UnionFindClass {
public:
	UnionFindClass() {
		N = 0;
		parent = NULL;
		size = NULL;
	}
	~UnionFindClass() {
		if (parent != NULL) {
			delete[] parent;
		}
		if (size != NULL) {
			delete[] size;
		}
	}

	void activate(int n) {// 要素の数N
		N = n;
		parent = new int[N];
		size = new int[N];
		for (int i = 0; i < N; i++) {
			parent[i] = -1;
			size[i] = 1;
		}
	}

	int getParent(int x) {// グループの親の番号を得る
		if (parent[x] == -1) {
			return x;
		}
		else {
			int y = getParent(parent[x]);
			parent[x] = y;
			return y;
		}
	}
	int getSize(int x) {// 自分が属するグループのサイズを得る
		x = getParent(x);
		return size[x];
	}
	bool connect(int x, int y) {// 二つの要素を結ぶ。２グループ間を繋いだ場合trueを返す
		x = getParent(x);
		y = getParent(y);
		if (x == y) { return false; }
		int xsize = getSize(x), ysize = getSize(y);
		if (xsize < ysize) {
			parent[x] = y;
			size[y] += size[x];
			size[x] = 0;
		}
		else {
			parent[y] = x;
			size[x] += size[y];
			size[y] = 0;
		}
		return true;
	}

	//データ
	int N;// 個数
	int* parent;// 親の番号。自分自身が親なら-1。
	int* size;// 親のみ有効。自分のグループのサイズ。
};

int main() {
	int N, M; cin >> N >> M;
	UnionFindClass uf;
	uf.activate(N);
	for (int i = 0; i < M; i++) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		uf.connect(a, b);
	}

	int count = 0;
	for (int i = 0; i < N; i++) {
		if (uf.parent[i] == -1) {
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1024