akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

int n;
ll L;
ll a[200];
ll l[200];
ll S[201];
ll A[5];
ll kai[201], p10[801];
ll conb[201][201];
ll dp[5][201][801];

void init() {
    kai[0] = 1;
    for (ll i = 1; i <= 200; i++) kai[i] = kai[i-1]*i%mod;
    p10[0] = 1;
    for (ll i = 1; i <= 800; i++) p10[i] = p10[i-1]*10%mod;
    conb[0][0] = 1;
    for (int i = 1; i <= 200; i++) {
        for (int j = 0; j <= i; j++) {
            conb[i][j] = conb[i-1][j];
            if (j > 0) conb[i][j] = (conb[i][j]+conb[i-1][j-1])%mod;
        }
    }
    rep(i,201) {
        S[i] = 0;
        rep(j,i+1) {
            S[i] = (S[i] + conb[i][j]*kai[j])%mod;
        }
    }
}

ll solve1() {
    rep(i,n) l[i] = to_string(a[i]).size();
    L = 0;
    rep(i,n) L += l[i];
    memset(A, 0, sizeof(A));
    rep(i,n) A[l[i]] += a[i];

    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= 4; i++) {
        //if (A[i] == 0) continue;
        dp[i][0][0] = 1;
        bool skip = false;
        rep(j,n) {
            if (l[j] == i && !skip) {
                skip = true;
                continue;
            }
            for (int k = n; k >= 1; k--) {
                for (int t = L; t >= l[j]; t--) {
                    dp[i][k][t] = (dp[i][k][t]+dp[i][k-1][t-l[j]])%mod;
                }
            }
        }
        rep(k,n) rep(t,L) dp[i][k][t] %= mod;
    }

/*
    rep(i,n) {
        rep(j,L) {
            cerr << dp[1][i][j] << " ";
        }
        cerr << endl;
    }
*/

    ll ret = 0;
    for (int i = 1; i <= 4; i++) {
        ll tmp = 0;
        rep(j,n) {
            rep(k,L) {
                ll tmp2 = dp[i][j][k]*p10[k]%mod;
                tmp2 = tmp2 * S[n-j-1] % mod;
                tmp2 = tmp2 * kai[j] % mod;
                tmp = (tmp + tmp2) % mod;
            }
        }
        ret = (ret + A[i] * tmp) % mod;
    }
    return ret;
}

void solve() {
    init();
    cin >> n;
    rep(i,n) cin >> a[i];
    sort(a, a+n);
    ll ans = solve1();
    if (a[0] > 0) {
        cout << ans << endl;
        return;
    }
    a[0] = linf;
    sort(a, a+n); n--;
    ans = (ans - solve1() + mod) % mod;
    cout << ans << endl;
}

int main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
    cout.precision(20);
    cerr << fixed;
    cerr.precision(6);
#ifdef LOCAL
    //freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif  
    solve();
    //cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}



Measured memory_bytes: 9916
import sys
from collections import defaultdict

N, K = map(int, input().split())
ans = [0] * ((10 ** 5) + 1)

for i in range(N):
    a, b = map(int, input().split())
    ans[a] += b
cnt = 0
for i in range(10 ** 5 + 1):
    cnt += ans[i]
    if K <= cnt:
        print(i)
        sys.exit()

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll n = s.size();

  vll a(0);
  for (ll i = 0; i < n; i++) {
    char c = s[i];
    ll cnt = 0;
    while (c == s[i] && i < n) {
      i++;
      cnt++;
    }
    a.push_back(cnt);
    i--;
  }

  ll ans = 0;
  for (ll i = 0; i < a.size(); i++) {
    ans += a[i] / 2;
  }
  if (s[0] != s[n - 1]) cout << ans * k << endl;
  else {
    if (a.size() == 1) {
      cout << a[0] * k / 2 << endl;
      return 0;
    }
    a[0] += a.back();
    a.pop_back();
    ll m = 0;
    for (ll i = 0; i < a.size(); i++) {
      m += a[i] / 2;
    }
    cout << ans + m * (k - 1) << endl;
  }
}

Measured memory_bytes: 256
row_c, col_c = [int(x) for x in input().split(" ")]

nums =[]
col_sums = []
for i in range(row_c):
    nums.append([int(x) for x in input().split(" ")])

#calc each col
for i in range(col_c):
    s = 0
    for n in nums:
        s += n[i]
    col_sums.append(s)
col_sums.append(sum(col_sums))

#calc each row
for i, num in enumerate(nums):
    nums[i].append(sum(num))

#outpu
for row in nums:
    print(" ".join(map(str, row)))
print(" ".join(map(str, col_sums)))

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

using namespace std;

int main()
{
    char c[105];
    int n,maxn,s;
    int a[30],b[30];
    cin>>n;
    cin>>c;
    for(int i=0;i<n-1;i++)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        s=0;
        for(int j=0;j<=i;j++)
        {
            a[c[j]-'a']=1;
        }
        for(int j=i+1;j<n;j++)
        {
            b[c[j]-'a']=1;
        }
        for(int j=0;j<26;j++)
        {
            if(a[j]==1&&b[j]==1)
                s++;
        }
        maxn=max(maxn,s);
    }
    cout<<maxn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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 main() {
  int h, n;
  cin >> h >> n;
  vector<int> a = vector<int>(n);
  vector<int> b = vector<int>(n);
  rep(i, n) {
    cin >> a[i] >> b[i];
  }
  vector<int> dp = vector<int>(h + 1, INF);
  dp[0] = 0;
  rep(j, n) {
    rep(i, h) {
      int ni = min(h, i + a[j]);
      chmin(dp[ni], dp[i] + b[j]);
    }
  }
  int ans = dp[h];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
program kode_festival
  implicit none
  integer :: n , a(262144), b(131072), m, i, k
  a = 0
  b = 0
  read(*,*) n
  m = 2**n
  do i = 1, m
    read(*,*) a(i)
  end do
  do k = 1, n
    m = m/2
    do i = 1, m
      if (a(2*i-1).eq.a(2*i)) then
        b(i) = a(2*i-1)
      else
        b(i) = max(a(2*i-1),a(2*i))-min(a(2*i-1),a(2*i))
      end if
    end do
    a(1:m) = b(1:m)
  end do
  write(*,'(i0)') a(1)
  stop
end program kode_festival

Measured memory_bytes: 1792
#include <stdio.h>

#define abs(a) (( (a) > 0) ? (a) : -(a))

int main() {
	int n;
  	scanf("%d", &n);
	//printf("%d\n", n);
    int h[n];
  	int S[n]; // ステップiに行き着くまでの最小の和を入れていく
    for (int i = 0; i < n; i++) {
      scanf("%d", &h[i]);
      //printf("%d\n", h[i]);
    }

    S[0] = 0;
    S[1] = abs(h[1] - h[0]);
  	for (int i = 2; i < n; i++) {
      //printf("h[i]: %d, h[i-1]: %d, h[i-2]: %d\n", h[i], h[i-1], h[i-2]);
      int p1 = abs(h[i] - h[i - 1]) + S[i - 1];
      //printf("p1: %d\n", p1);
      int p2 = abs(h[i] - h[i - 2]) + S[i - 2];
      //printf("p2: %d\n", p2);

      S[i] = (p1 > p2) ? p2 : p1;
    }
  	printf("%d\n", S[n-1]);
  
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(void){
    string t, s;
    cin >> s >> t;
 
    int cnt, max = 0;
    for(int i = 0;i <= s.length() - t.length();i++){
        cnt = 0;
        for(int j = 0;j < t.length();j++){
            //cout << s[i + j] << ' ' << t[j] << '\n';
            if(s[i + j] == t[j]){
                cnt++;
            }
        }
        //cout << '\n';
        if(cnt > max){
            max = cnt;
        }
    }
    
    cout << t.length() - max;
    
    return 0;    
}



Measured memory_bytes: 3624
def solve():
    can_positive = False
    if len(P) > 0:
        if k < n: can_positive = True
        else: can_positive = len(M)%2 == 0
    else: can_positive = k%2 == 0

    if can_positive:
        P.sort()
        M.sort(reverse = True)
        a = [P.pop()] if k%2 else [1]
        while len(P) >= 2: a.append(P.pop() * P.pop())
        while len(M) >= 2: a.append(M.pop() * M.pop())
        return a[:k%2] + sorted(a[1:], reverse = True)[:(k-k%2)//2]
    else: return sorted(P+M, key=lambda x: abs(x))[:k]

n, k = map(int, input().split())
P, M = [], [] # plus, minus
for a in map(int, input().split()):
    if a < 0: M.append(a)
    else: P.append(a)
ans, MOD = 1, 10**9 + 7
for a in solve(): ans *= a; ans %= MOD
ans += MOD; ans %= MOD
print(ans)


Measured memory_bytes: 32736
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos;
	ld cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll i, ll z) {
	ll sum = 1;
	for (ll j = max(z, 2LL); j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%Mod;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
//#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a, b, x;
	cin >> x >> a >> b;
	cout << (x - a) % b << endl;
	getchar(); getchar();
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdlib>

using namespace std;

int main()
{
	int n, j = 0;
	long long x[] = { 0, 0 };
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = n - 2; i >= 0; i--) {
		if (a[i] == a[i + 1]) {
			x[j] = a[i];
			i--;	j++;
			if (j == 2) {
				break;
			}
		}
	}
	cout << x[0] * x[1] << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String card = scan.next();
			if (card.equals("-")) break;
			int m = scan.nextInt();
			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				String str = card.substring(0, h);
				card = card.substring(h, card.length());
				card = card + str;
			}
			System.out.println(card);
		}
		
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26404
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    string S;
    cin >> N >> S;

    int cnt;
    REP(i, 1000) {
        int c[3] = {i/100, (i/10) % 10, i%10};
        int f = 0;
        REP(j, N) {
            if (S[j] == ('0' + c[f])) f++;
            if (f == 3) break;
        }
        if (f == 3) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

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

//     int N;
//     cin >> N;
//     string S;
//     cin >> S;

//     set<int> st;
    
//     int T;
//     for(int i = 0; i < N-2; i++) {
//         for (int j = i+1; j < N-1; j++) {
//             for (int k = j+1; k < N; k++) {
//                 T = (int)S[i]*100 + (int)S[j]*10 + S[k];
//                 // cout << T << endl;
//                 if (!st.count(T)) {
//                     st.insert(T);
//                 }
//             }            
//         }
//     }

//     cout << st.size() << endl;

//     return 0;
// }

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <climits>
#include <iostream>
#include <queue>
#include <cstring>
#include <string>

#define Fin(i,f,t) for(int i=f;i<=t;++i)
#define Fde(i,f,t) for(int i=f;i>=t;--i)
#define MAXN 1000
using namespace std;
typedef long long LL;

int main(void)
{
    //freopen("D:\\test.txt","r",stdin);
    //freopen("D:\\tsst.txt","w",stdout);
    int X;
    while(~scanf("%d",&X)){
        LL rig = 100000,lef = 1,mid;
        while(rig>lef){
            mid = (lef+rig)/2;
            if(mid*(mid+1)<2*X)
                lef = mid + 1;
            else
                rig = mid - 1;
        }
        lef = lef-5>=0?lef-5:0;
        Fin(i,lef,lef+10)
            if(i*(i+1)>=2*X){
                printf("%d\n",i);
                break;
            }
    }
    return 0;
}





Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b,c = na()
if a==b and b==c:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
N = int(input())
P = [int(i) for i in input().split()]

count = 0
pre = False
for i in range(1,N+1):
    if P[i-1] == i:
        if pre:
            pre = False
        else:
            count += 1
            pre = True
    else:
        pre = False

print(count)

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

int gcd(int m, int n) { 
    if(n == 0) {
        return m; 
    } 
    else { 
        return gcd(n, m % n); 
    }
}

int main() { 
    int K, sum = 0;
    cin >> K;
    for(int i = 1; i <= K ; i++){
      for(int j = 1; j <= K ; j++){
        for(int l = 1; l <= K ; l++){
          sum = sum + gcd(i, gcd(j, l));
        }
      }
    }
    cout << sum << endl; 
    return 0; 
} 

Measured memory_bytes: 3636
n, m = map(int, input().split())

ab = []
for i in range(n):
    temp = map(int, input().split())
    ab.append(tuple(temp))

cd = []
for j in range(m):
    temp = map(int, input().split())
    cd.append(tuple(temp))


for i in ab:
    temp_ind = -1
    temp = 10 ** 17
    for ind, j in enumerate(cd):
        md = abs(i[0]-j[0])+abs(i[1]-j[1])
        if md < temp:
            temp_ind = ind
            temp = abs(i[0]-j[0])+abs(i[1]-j[1])
    print(temp_ind+1)

Measured memory_bytes: 3064
#include <cstdio>
using namespace std;
static_assert(sizeof(long) >= 8, "sizeof(long) >= 8");
constexpr int mod = 998244353;
int fac[20001], inv[20001];
int dp[10001];
int solve(int x, int y) {
    dp[0] = 1;
    for (int i = 1; i <= x; i++)
        for (int j = 1; j <= y; j++)
            dp[j] = (dp[j] + (long) i * dp[j - 1]) % mod;
    int ans = 0;
    for (int i = 0; i <= y; i++)
        ans = (ans + (long) dp[i] * inv[x + i]) % mod;
    return (long) ans * fac[x] % mod
                      * fac[x] % mod
                      * fac[y] % mod
                      * fac[x + y] % mod;
}
char a[10001], b[10001];
int main() {
    fac[0] = 1;
    for (int i = 1; i <= 20000; i++)
        fac[i] = (long) fac[i - 1] * i % mod;
    inv[20000] = 292343761;
    for (int i = 20000; i >= 1; i--)
        inv[i - 1] = (long) inv[i] * i % mod;

    scanf("%s%s", a, b);
    int x = 0, y = 0;
    for (int i = 0; a[i]; i++)
        if (a[i] == '1')
            (b[i] == '0' ? x : y)++;
    printf("%d\n", solve(x, y));
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
using namespace std;

void reverse(int* num, int i)
{
	for (int j = i-1; j > 0; j--)
	{
		cout << num[j] << " ";
	}
	cout << num[0] << endl;
}

int main()
{
	int num[100] = {};
	int n, i;

	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> num[i];
	}
	reverse(num, i);
	return 0;
}


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

int main() {
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K) cout << S << endl;
    else  {
        for (int i = 0; i < K; i++) {
            cout << S.at(i);
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
const long long INF = numeric_limits<long long>::max();
int main() {
    ll N, M;
    cin >> N >> M;

    map<ll, pair<ll, ll>> answers;

    REP(i, M) {
        ll n;
        string s;
        cin >> n >> s;
        if (s == "WA") {
            if (answers[n].second == 0) {
                answers[n].first++;
            }
        } else {
            answers[n].second = 1;
        }
    }
    ll a = 0;
    ll b = 0;
    for (const auto& m : answers) {
#ifdef SOURCE_TEST
        PS(m.first);
        PS(m.second.first);
        PR(m.second.second);
#endif
        if (m.second.second > 0) {
            a += m.second.second;
            b += m.second.first;
        }
    }

    PS(a);
    PR(b);

    return 0;
}

Measured memory_bytes: 9828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int i2 = (MOD + 1) / 2;
int main()
{
    ll n, k, ans = 0;
    cin >> n >> k;
    for (; k <= n + 1; ++k) {
        ans += ((n + n - k + 1) * k  % MOD - (k - 1) * k % MOD) * i2 % MOD + 1;
        ans %= MOD;
    }
    ans = (ans + MOD) % MOD;
    cout << ans << endl;
}


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

int main()
{
	string s;
	cin >> s;
	bool b = false;
	for (int i=0;i<s.size();++i) {
		if (s[i] == 'A' && i+1<s.size() && s[i+1] == 'C') b = true;
	}
	if (b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int sum = 0;
  for (int i = A; i < B + 1; i++) {
    int a1 = i % 10;
    int a2 = i / 10 % 10;
    
    int a4 = i / 1000 % 10;
    int a5 = i / 10000 % 10;
        
    if (a1 == a5 && a2 == a4) {
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
  
int main () {
    int n,i;
    double sum1=0.0,sum2=0.0;
    while(cin >> n && n!=0){
        sum1=0; sum2=0;
        int b[n];
        for(i=0;i<n;i++){
            cin >> b[i];
            sum1 += b[i];
        }
        for(i=0;i<n;i++){
        sum2 += (sum1/n-b[i])*(sum1/n-b[i]);
        }
        cout << setprecision(20) << sqrt(sum2/n) << endl;
    }
}

Measured memory_bytes: 3200
n = int(input())
flag = True
for i in range(10):
    for j in range(10):
        kuku = i * j
        if n == kuku:
            print("Yes")
            flag = False
            break
    else:
        continue  # yes がみつからずにｊのループが終了したとき次のiループにcontinue
    break  # yesが見つかったらbreakでｊのループ抜け出す。そのあとこのbreakでiのループも抜け出す

if flag:
    print("No")

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll H, W;
  scanf("%lld %lld", &H, &W);
  ll h, w;
  scanf("%lld %lld", &h, &w);

  cout << ((H - h) * (W - w)) << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	var t []byte
	fmt.Scan(&s)
	for i := 0; i < len(s); i++ {
		if s[i] == '0' || s[i] == '1' {
			t = append(t, s[i])
		} else if s[i] == 'B' {
			if len(t) > 0 {
				t = t[:len(t)-1]
			}
		}
	}
	fmt.Println(string(t))
}


Measured memory_bytes: 512
#pragma warning (disable :4996)
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-7
using namespace std;

int n;
string s = "a";
void dfs(char ch) {
	if (s.length() == n) {
		cout << s << endl;
		return;
	}
	for (char c = 'a'; c <= ch+1; ++c) {
		s += c;
		dfs(max(c, ch));
		s.erase(s.end() - 1);
	}
}
int main() {
	cin >> n;
	dfs('a');
}

Measured memory_bytes: 1536
N, K = input().split()
N, K = int(N), int(K)

R, S, P = input().split()
R, S, P = int(R), int(S), int(P)

T = input()


d = {'s':R, 'p':S, 'r': P}

def seq_score(T):
    score = 0
    cnt = 1
    c0 = T[0]
    for c in T[1:]:
        if c == c0:
            cnt += 1
        else:
            score += d[c0] * ((cnt+1) // 2)   
            c0 = c
            cnt = 1

    score += d[c0] * ((cnt+1) // 2)
    return score

score = 0
for k in range(K):
    score += seq_score(T[k::K])

print(score)


Measured memory_bytes: 3316
use std::io::stdin;

fn main() {
    let mut values = String::new();
    {
        let mut input = String::new();
        stdin().read_line(&mut input);
        values = input;
    }
    let mut stack = [0; 2];
    for (i, j) in values.split_whitespace().enumerate() {
        stack[i] = j.parse().unwrap()
    }
    {
        let mut input = String::new();
        stdin().read_line(&mut input);
        values = input;
    }
    let mut sum = 0;
    for i in values.split_whitespace() {
        sum += i.parse::<i32>().unwrap();
    }
    if sum >= stack[0] {
        println!("Yes");
        return
    }
    println!("No");
}

Measured memory_bytes: 4352
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt();
			if (n == 0) break;
			int a = 0, b = 0;
			for (int i = 0; i < n; i++)
			{
				int aCard = sc.nextInt(),
					bCard = sc.nextInt();
				if (aCard > bCard)
				{
					a += aCard + bCard;
				}
				else if (bCard > aCard)
				{
					b += aCard + bCard;
				}
				else
				{
					a += aCard;
					b += bCard;
				}
			}
			System.out.printf("%d %d\n", a, b);
		}
	}
}

Measured memory_bytes: 13000
i = list(map(int, input().split()))
tp = i[0]
ta = i[1]
ap = i[2]
aa = i[3]
while tp > 0 and ap > 0:
  #print("たかはしのこうげき！")
  ap = ap - ta
  #print("たかはしは",ta,"ポイントのダメージをあおきにあたえた！")
  #print("あおきののこりたいりょくは",ap)
  #print("あおきのこうげき！")
  if ap <= 0:
    print('Yes')
    break
  tp = tp - aa
  #print("あおきは",aa,"ポイントのダメージをたかはしにあたえた！")
  #print("たかはしののこりたいりょくは",tp)
  if tp <= 0:
    print('No')
    break
#if tp > 0:
#  print('Yes')
#else:
#  print('No')

Measured memory_bytes: 9192
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define SZ 300000

typedef pair<int, int> pii;

int hh, ww, mm, hcnt[SZ + 1], wcnt[SZ + 1], ans, h[SZ + 1], w[SZ + 1];
map<int, bool> hmap[SZ + 1], wmap[SZ + 1];
vector<pii> v;

int getmax(int a, int b) {return a>b?a:b;}

int main() {
    scanf("%d%d%d", &hh, &ww, &mm);
    for (int i = 0 ; i < mm ; i++) {
        scanf("%d%d", &h[i], &w[i]);
        hcnt[h[i]]++, wcnt[w[i]]++;
        hmap[h[i]][w[i]] = true, wmap[w[i]][h[i]] = true;
    }
    for (int i = 0 ; i < mm ; i++) {
        int tmp = hcnt[h[i]] + wcnt[w[i]] - 1;
        ans = getmax(ans, tmp);
    }
    for (int i = 0 ; i <= hh ; i++) {
        v.push_back(pii(hcnt[i], i));
    }
    sort(v.begin(), v.end());
    for (int i = 0 ; i <= ww ; i++) {
        int tmp = wcnt[i];
        for (int j = hh ; j >= 0 ; j--) {
            if (!wmap[i][v[j].second]) {
                tmp += v[j].first;
                break;
            }
        }
        ans = getmax(ans, tmp);
    }
    printf("%d", ans);
}


Measured memory_bytes: 80068
N, K = map(int, input().split())
S = input()

def solve(S):
    ans = 0
    switch = 0
    for i in range(1,N):
        if S[i]!=S[i-1]:
            switch += 1
    switch = max(0,switch-K*2)
    ans = N-switch-1
    return ans
print(solve(S))

Measured memory_bytes: 3316
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;

string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
	bool operator>(Edge e) {
		return cost > e.cost;
	}
};

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

	string s;
	cin >> s;
	cout << s.substr(0, s.size() - 8) << endl;


	return 0;
}

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

namespace abc139_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();          
            string t = Console.ReadLine();
            
            int sum = 0;
            for (int i = 0; i < 3; i++)
            {
                if (s[i] == t[i])
                {
                    sum++;
                }
            }
            Console.WriteLine(sum);
            Console.ReadLine();
        }
    }
}


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

int main(){
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  pair<int,int> A[Q];
  int B[N+1];
  B[0] = 0;
  B[1] = 0;
  for(int i=1;i<N;i++){
    if(S[i] == 'C' && S[i-1] == 'A'){
      B[i+1] = B[i] + 1;
    }
    else B[i+1] = B[i];
  }
  for(int i=0;i<Q;i++){
    int a, b;
    cin >> a >> b;
    cout << B[b] - B[a] << endl;
  } 
}

Measured memory_bytes: 2176
import java.util.Scanner;

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

        int a = inp.nextInt();
        int b = inp.nextInt();

        int intg = (int) a / b;
        int remainder = (int) a % b;
        double number = (double) a / b;

        System.out.print(intg + " " + remainder + " ");
        System.out.printf("%f", number);
    }
}



Measured memory_bytes: 26436
#include <bits/stdc++.h>
using namespace std;
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<58;

// vector v において、x の前方と後方の index を求める
template<class T> int former(const vector<T> &v, T x) {
    return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
template<class T> int latter(const vector<T> &v, T x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int main() {
    int A, B, Q; cin >> A >> B >> Q;
    vector<long long> s(A), t(B);
    for (int i = 0; i < A; ++i) cin >> s[i];
    for (int i = 0; i < B; ++i) cin >> t[i];
    s.push_back(INF); s.push_back(-INF); sort(s.begin(), s.end());
    t.push_back(INF); t.push_back(-INF); sort(t.begin(), t.end());
    
    for (int _ = 0; _ < Q; ++_) {
        long long x; cin >> x;
        long long res = INF;
        
        // 最初に s (前方に行くか後方に行くか場合分け)
        for (int i = 0; i < 2; ++i) {
            long long first = (i ? s[former(s, x)] : s[latter(s, x)]);
            // 次に t (現在地の前後を見る)
            for (int j = 0; j < 2; ++j) {
                long long second = (j ? t[former(t, first)] : t[latter(t, first)]);
                chmin(res, abs(x - first) + abs(first - second));
            }
        }
        // 最初に t (前方に行くか後方に行くか場合分け)
        for (int i = 0; i < 2; ++i) {
            long long first = (i ? t[former(t, x)] : t[latter(t, x)]);
            // 次に t (現在地の前後を見る)
            for (int j = 0; j < 2; ++j) {
                long long second = (j ? s[former(s, first)] : s[latter(s, first)]);
                chmin(res, abs(x - first) + abs(first - second));
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 4320
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
} 

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

pair<int, int> input() {
    int l, r;
    cin >> l >> r;
    l--;
    return P(l, r);
}

void output(const int i, const multiset<int> &st) {
    if (st.size() == 0) puts("-1");
    else cout << *st.begin() + i + 1 << endl;
}

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

    map<int, int> mp;
    multiset<int> st;
    rep(i, W) {
        mp[i] = 0;
        st.insert(0);
    }

    auto calc = [&](int l, int r, map<int, int> &mp, multiset<int> &st) {
        if (r == W) {
            auto itr = mp.lower_bound(l);
            while (itr != mp.end()) {
                int c = itr->second;
                itr = mp.erase(itr);
                st.erase(st.find(c));
            }
            return;
        }

        auto itr = mp.lower_bound(l);
        int res = INF;
        while (itr != mp.end() && itr->first <= r) {
            int x = itr->first, c = itr->second;
            itr = mp.erase(itr);
            st.erase(st.find(c));
            chmin(res, c + r - x);
        }
        if (res != INF) {
            mp[r] = res;
            st.insert(res);
        }
    };

    rep(i, H) {
        auto [l, r] = input();

        calc(l, r, mp, st);

        output(i, st);
    }
}

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

using namespace std;
const int maxn = 1010;
typedef long long ll;

vector <int> G[maxn];
int vis[200050] = {0};
int a[maxn];

int n,m;
int solve(int q)
{
    int lma = n+1, rma = 0;
    int cnt = 0;
    for(int i=q; i>=1; i--)
    {
        if(G[i].size() == 0)
            continue;
        int be = G[i][0], en = G[i][G[i].size()-1];
        if(cnt == 0)
        {
            for(int j=0; j<G[i].size(); j++)
                vis[G[i][j]] = 1;

            for(int j=be; j<=en; j++)
            {
                if(vis[j] == 0)
                    return 0;
                if(a[j] == 0)
                    a[j] = i;
            }
            lma = be;
            rma = en;
            cnt++;
            continue;
        }

        if(G[i].size() == 1)
        {
            // cout<<"haha"<<endl;
            int p = G[i][0];
            if(vis[p] == 1)
                return 0;
            vis[p] = 1;
            continue;
        }

        for(int j=0; j<en; j++)
            vis[G[i][j]] = 1;

        for(int t = be; t < lma ; t++)
        {
            if(vis[t] != 1)
                return 0;
            if(a[t] == 0)
                a[t] = i;
        }
        // cout<<" a lo ha "<<endl;

        for(int t = en; t > rma ; t--)
        {
            if(vis[t] != 1)
                return 0;
            if(a[t] == 0)
                a[t] = i;
        }

        if(lma > be)
            lma = be;
        if(rma <en)
            rma = en;
    }
    return 1;
}
int main()
{
    std::ios::sync_with_stdio(false);

    cin>>n>>m;
    cout<<n*m - (n+m-1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort(all(v))
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );};
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;};



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

  int n;
  cin >> n;
  cout << n * n * n << endl;
  return 0;
}


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

int main()
{
  ll A,B,C; cin>>A>>B>>C;
  int ans =0;

  if (A%2 == B%2 && A%2 == C%2) {
    int max_num = max(max(A, B),C);
    while (A < max_num) {
      A += 2;
      ans ++;
    }
    while (B < max_num) {
      B += 2;
      ans ++;
    }
    while (C < max_num) {
      C += 2;
      ans ++;
    }
    cout << ans << endl;
    return 0;
  }

  int even = 0;
  int odd = 0;
  if (A%2==0) even++;
  else odd++;
  if (B%2==0) even++;
  else odd++;
  if (C%2==0) even++;
  else odd++;

  // 偶奇を揃える
  if (even > odd) {
    if (A%2==0) A++;
    if (B%2==0) B++;
    if (C%2==0) C++;
  } else {
    if (A%2!=0) A++;
    if (B%2!=0) B++;
    if (C%2!=0) C++;
  }
  ans ++;

  int max_num = max(max(A, B),C);
  while (A < max_num) {
    A += 2;
    ans ++;
  }
  while (B < max_num) {
    B += 2;
    ans ++;
  }
  while (C < max_num) {
    C += 2;
    ans ++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int X[N];
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  };
  long long ans = INT_MAX;
  for (int P = 0; P <= 100; P++) {
    long long sum = 0;
    for (int i = 0; i < N; i++) {
      sum += (X[i] - P) * (X[i] - P);
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3560
def solve(field, h, w)
  res = Array.new(h).map {Array.new(w, nil)}
  field.each.with_index do |row, i|
    k = -1
    row.each.with_index do |c, j|
      case c
      when "."
        if k == -1
          res[i][j] = -1
        else
          k += 1
          res[i][j] = k
        end
      when "c"
        res[i][j] = 0
        k = 0
      else
        fail
      end
    end
  end
  res.map {|row| row.join(" ") }.join("\n")
end

h, w = gets.split(" ").map(&:to_i)
field = []
h.times { field << gets.strip.chars }
puts solve(field, h, w)

Measured memory_bytes: 9048
#include <cassert>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <map>
#include <set>
#include <tuple>

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

  size_t N;
  std::cin >> N;
  assert(N <= 100);

  std::vector<double> A(N);
  for (auto& ai: A) std::cin >> ai;

  double res = 0;
  for (auto ai: A) res += 1.0 / ai;
  res = 1.0 / res;

  std::cout << std::fixed << std::setprecision(65200000) << res << std::endl;
}


Measured memory_bytes: 382308
/*
 * atcoder/abc111_3rd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N;
struct Point { ll x, y; };
vector<Point> P;
void solve() {
  cin >> N;
  ll x, y;
  loop(n,0,N) {
    cin >> x >> y; P.push_back({x, y});
  }
  bool isOdd = abs(P[0].x+P[0].y) % 2;
  bool isOk = all_of(P.begin(), P.end(), [&](Point p) {
    return abs(p.x+p.y)%2 == isOdd;
  });
  if (!isOk) {
    cout << -1 << endl;
    return;
  }

  vector<ll> A;
  for (ll i=30; i>=0; i--) A.push_back(1LL<<i);
  if (!isOdd) A.push_back(1);

  int M = A.size();
  cout << M << endl;
  for (auto&&a: A) cout << a << " ";
  cout << endl;

  for (auto&&point: P) {
    ll u = point.x+point.y, v = point.x-point.y;
    for (auto&&a: A) {
      int u_sign = 1, v_sign = 1;
      if (u >= 0 and v >= 0) {
        u_sign = -1; v_sign = -1;
        cout << 'R';
      }
      if (u >= 0 and v < 0) {
        u_sign = -1; v_sign = 1;
        cout << 'U';
      }
      if (u < 0 and v >= 0) {
        u_sign = 1; v_sign = -1;
        cout << 'D';
      }
      if (u < 0 and v < 0) {
        u_sign = 1; v_sign = 1;
        cout << 'L';
      }
      u += a * u_sign;
      v += a * v_sign;
    }
    cout << endl;
  }
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main(){
    int N; cin >> N;
    string A, B, C;
    cin >> A >> B >> C;
    
    int counter = 0;
    rep(i, N){
        if((A[i] != B[i] && B[i] != C[i]) && A[i] != C[i]) counter += 2;
        else if(A[i] != B[i] || (B[i] != C[i] || A[i] != C[i])) counter += 1;
    }
    cout << counter << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define ll long long
typedef int data_t;

int main(){
    int n;
    scanf("%d",&n);
    int a[n],i;
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    int b[n];
    if(n%2==0){
        for(i=0;i<n/2;i++) b[i]=a[n-2*i-1];
        for(i=n/2;i<n;i++) b[i]=a[2*i-n];
    }
    if(n%2==1){
        for(i=0;i<=n/2;i++) b[i]=a[n-2*i-1];
        for(i=(n+1)/2;i<n;i++) b[i]=a[2*i-n];
    }
    for(i=0;i<n;i++) printf("%d ",b[i]);

    return 0;
}


Measured memory_bytes: 3712
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;
ll fib[50];
ll dfs(int n) {
    if (fib[n] > 0) return fib[n];
    if (n == 0 || n == 1) return 1;
    return fib[n] = dfs(n-1) + dfs(n-2);
}
int main(void) {
    int n;
    cin >> n;
    cout << dfs(n) << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  ll N;
  cin >> N ;
  int ans= 30 ;
  for(ll i=1;i<=pow(N,0.5);i++){
    if(N % i == 0){
      ll j= N/i ;
      int sum=0 ;
      while(j>0){
        sum ++;
        j /= 10 ;
      }
      ans = min(ans,sum) ;
    }
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                               \
  ifstream in("atcoder-problems/agc043_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int dp[110][110];

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int H, W;
  cin >> H >> W;

  memset(dp, INF, 110 * 110 * sizeof(int));

  vector<string> s(H);
  rep(i, H) { cin >> s[i]; }

  dp[0][0] = s[0][0] == '#' ? 1 : 0;
  rep(h, H) rep(w, W) {
    rep(k, 2) {
      int nh = h + (k % 2);
      int nw = w + ((k + 1) % 2);
      if (nh >= H || nw >= W) continue;

      int cnt = s[h][w] == '.' && s[nh][nw] == '#';
      dp[nh][nw] = min(dp[nh][nw], dp[h][w] + cnt);
    }
  }

  cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 384
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

S = {i:list(IS()) for i in "abc"} #dict型
player = "a"
while S[player]:
    player = S[player].pop(0)
print(player.upper())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),K = in();
    vector<int> A(N);
    REP(i,N)A[i] = in();
    int place = 0;
    while(1){
        if(A[place] == 1)break;
        place++;
    }
    cout <<  (N + K - 3)/(K - 1)<< "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long INF=1e16+7;
struct edge{long long to, cost;};
typedef pair<long long,long long> P;
struct graph{
  long long V;
  vector<vector<edge> > G;
  vector<long long> d;
  graph(long long n){
    init(n);
  }
  void init(long long n){
    V = n;
    G.resize(V);
    d.resize(V);
    for(int i=1;i<V;i++){
      d[i] = INF;
    }
  }
  void add_edge(long long s, long long t,long long cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }
  void dijkstra(long long s){
    for(int i=0;i<V;i++){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      long long v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
int main(){
  int N;cin>>N;
  graph g(N);
  vector<int>A(N-1);
  vector<int>B(N-1);
  vector<int>C(N-1);
  for(int i=0;i<N-1;i++){
    cin>>A[i]>>B[i]>>C[i];
    g.add_edge(A[i]-1,B[i]-1,C[i]);
    g.add_edge(B[i]-1,A[i]-1,C[i]);
  }
  int Q,K;cin>>Q>>K;
  g.dijkstra(K-1);
  vector<int>x(Q);
  vector<int>y(Q);
  for(int i=0;i<Q;i++){
    cin>>x[i]>>y[i];
    cout<<g.d[x[i]-1]+g.d[y[i]-1]<<endl;
  }
}

Measured memory_bytes: 15284
N,M = gets.chomp.split(' ').map(&:to_i)
votes = gets.chomp.split(' ').map(&:to_i)
border = (votes.inject{|result,item| result + item } / (4 * M).to_f)
over_border_votes = 0
votes.each do |v|
  if v >= border
    over_border_votes += 1
  end
end

if over_border_votes >= M
  puts 'Yes'
else
  puts 'No'
end


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

#define vc vector
#define pb push_back
#define pf push_front
#define pr pair
#define mp make_pair
#define fi first
#define se second
#define uset unordered_set
#define umap unordered_map
#define str string
#define pq priority_queue
#define forn(i, a, b) for(int i = (a); i < (b); i++)
#define forr(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a) forn(i, 0, a)
#define all(x) x.begin(), x.end()
#define rev(x) x.rbegin(), x.end()
#define len(x) (int)x.size()
#define last(x) x[len(x)-1]
#define forall(i, x) for(auto &i : x)
#define endl '\n'

#define int long long
#define pii pr<int, int>
#define vi vc<int>

const int MAX = 1E6;

inline void fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}


signed main()
{
    fastio();
    int n; cin >> n;
    cout << n/2 + n%2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a, b;
bool ans;
int main()
{
	scanf("%d%d", &a, &b);
	ans = false;
	if (a%3==0) ans = true;
	if (b%3==0) ans =true;
	if ((a+b)%3 == 0) ans = true;
	if (ans) printf("Possible\n"); else printf("Impossible");
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll num=x/d;
    //cout<<num<<endl;
    if(num>=k){
       // cout<<x<<" "<<num<<" "<<d<<endl;
        cout<<x-k*d<<endl;
        return 0;
    }
    x-=num*d;
    k-=num;
    if(k%2==1){
        cout<<abs(d-x)<<endl;
    }else{
        cout<<x<<endl;
    }
}


Measured memory_bytes: 3644