akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    vl A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    cout << accumulate(A.begin(), A.begin() + K, 0ll) << endl;
}

Measured memory_bytes: 3664
// PDF解説
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N; cin >> N;
  int A[200005];
  for (int i = 1; i <= N; i++)
    cin >> A[i];
  
  int L[200005] = {0};
  for (int j = 1; j <= N - 1; j++)
    L[j] = max(L[j - 1], A[j]);
  
  int R[200005];
  R[N + 1] = 0;
  for (int k = N; k >= 2; k--)
    R[k] = max(A[k], R[k+1]);
  
  for (int i = 1; i <= N; i++)
    cout << max(L[i - 1], R[i + 1]) << endl;
  
  return 0;
}

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


int main() {
    long double a,b,h,m;
    static const long double pi=3.141592653589793;
    cin >> a >> b >> h >> m;
    long double ans=a*a+b*b-2*a*b*cos((60*h-11*m)/30/12*pi);
    cout << fixed << setprecision(11) << sqrt(ans) << endl;
}

Measured memory_bytes: 4172
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size() 配列名.Length()
using namespace std;
typedef unsigned long long ll;

int main(void){
	int n, k;
	cin >> n >> k;

	double ans = 0;
	int cnt = 0, num;
	for(int i = 0; i < n; i++){
		cnt = 0;
		num = i + 1;
		while(num < k){
			num *= 2;
			cnt++;
		}
		ans += 1 / pow(2,cnt) / n;
	}
	printf("%.12f", ans);
}


Measured memory_bytes: 256
#include <stdio.h>
#define min(a, b) ((a)>(b) ? (b) : (a))

int main(){
  int n;  scanf("%d", &n);
  long long int ans = 10000000000;
  for(int i=0; i<n; i++){
    long long int a;
    long long int count = 0;
    scanf("%lld", &a);
    while(!(a%2)){
      a /= 2;
      count++;
    }
    ans = min(ans, count);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    char s[1001];
    int i,len;
    while(gets(s)){
        //len=strlen(s);
        for(i=0;i<3;i++){
            if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u'){
                ///printf("%s%s%s\n", s[0],s[1],s[2]);
            }
        }
        printf("%c%c%c\n", s[0],s[1],s[2]);
    }
}


Measured memory_bytes: 1656
n,a,b = map(int,input().split())

p = 10**9 + 7

def pow(a,n,m):
  ans = 1
  while n:
    if n % 2:
      ans *= a
    a *= a
    a = a%m
    n >>= 1
  return ans%m

def x(n,a):
  ans = 1
  for i in range(a):
    ans *= (n-i)
    ans = ans%p
  return ans

def y(n):
  ans = 1
  for i in range(1,n+1):
    ans *= i
    ans = ans%p
  return ans

al = pow(2,n,p)
ap = pow(y(a), p-2,p)
bp = pow(y(b), p-2,p)
ap = ap*x(n,a) % p
bp = bp*x(n,b) % p
if al-ap-bp-1 < 0:
  z = al-ap-bp-1+p
  while z < 0:
    z = z + p
  print(z)
else:
  print(al-ap-bp-1)

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int R,C;
int a[10][10000];
int ans;
int flg[10];

int count(void) {
  int tmp, res = 0;
  for (int j = 0; j < C; j++) {
    tmp = 0;
    for (int i = 0; i < R; i++) {
      if (flg[i] && !a[i][j] || !flg[i] && a[i][j]) tmp++;
    }
    if (tmp < R - tmp) {res += R - tmp;}
    else {res += tmp;}
  }
  return res;
}

void solve(int idx) {
  int res;
  if (idx == R) {
    res = count();
    if (ans < res) ans = res;
    return;
  }
  flg[idx] = 0;
  solve(idx+1);
  flg[idx] = 1;
  solve(idx+1);
}

int main() {
  while (cin >> R >> C) {
    if (!R && !C) break;
    for (int i = 0; i < R; i++)
      for (int j = 0; j < C; j++) cin >> a[i][j];
    ans = 0;
    solve(0);
    cout << ans << endl;
  }

  return 0;
}

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

using lint = long long;

const int maxn = 10000004;

int N, b[maxn], isp[maxn];
lint a[maxn];

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

	fill(a, a+maxn, 1ll);
	fill(isp, isp+maxn, 1);

	cin >> N;

	for (int i=2; i<=N; i++) if (isp[i]) {
		for (int k=1; i*k<=N; k++) {
			if (k>1) isp[i*k] = 0;
			b[k] = ((k%i) ? 1 : b[k/i]) + 1;
			a[i*k] *= b[k];
		}
	}

	lint ans = 0;
	for (int i=1; i<=N; i++) ans += i * a[i];

	cout << ans << '\n';
}

Measured memory_bytes: 140368
H, W = map(int,input().split())
A = [list(map(int, input().split())) for _ in range(H)]

move = []
temp = []
for h in range(H):
    if h % 2 == 0:
        for w in range(W - 1):
            if A[h][w] % 2 == 0:
                continue
            
            A[h][w] -= 1
            A[h][w+1] += 1
            move.append((h, w, h, w + 1))
        
        if h != H - 1:
            w = W - 1
            if A[h][w] % 2 == 0:
                continue
            
            A[h][w] -= 1
            A[h + 1][w] += 1
            move.append((h, w, h + 1, w))
    else:
        for w in range(W - 1, 0, -1):
            if A[h][w] % 2 == 0:
                continue
            
            A[h][w] -= 1
            A[h][w-1] += 1
            move.append((h, w, h, w - 1))
        
        if h != H - 1:
            w = 0
            if A[h][w] % 2 == 0:
                continue
            
            A[h][w] -= 1
            A[h + 1][w] += 1
            move.append((h, w, h + 1, w))

print(len(move))
for m in move:
    print("{} {} {} {}".format(m[0] + 1, m[1] + 1, m[2] + 1, m[3] + 1))


Measured memory_bytes: 24352
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i
ans = 'Yay!'
[a,b,c,d,e].each do |x|
  [a,b,c,d,e].each do |y| 
    if (x - y).abs > k
     ans = ':('
    end
  end
end
puts ans

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define EPS 1e-8
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
    return os << "(" << P.fi << "," << P.se << ")";
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
    os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
template <typename T>
T power_mod(T base, int exp, int mod = MOD) {
    T res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
template <typename T>
T power(T base, int exp) {
    T res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, MOD - 2);
}

/******************************** template ********************************/
#define N 200010
unordered_set<int> ss;

int main() {
    int n;
    cin >> n;
    int tmp;
    for (int i = 0; i < n; ++i) {
        cin >> tmp;
        ss.insert(tmp);
    }
    cout << ss.size();

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int x,y,z;
    cin>>x>>y>>z;
    //bac
    //cab

    cout<<z<<" "<<x<<" "<<y<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long res = 0;

        long div = n / (a+b);
        res = div * a;
        res += Math.min(n % (a+b), a);

        System.out.println(res);
    }



}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> l(N);
  for (int i = 0; i < N; ++i) cin >> l.at(i);

  sort(l.begin(), l.end(), greater<int>());
  
  int sum = 0;
  for (int i = 0; i < K; ++i) sum += l.at(i);
  
  cout << sum << endl;
}

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

int main(void){
    // Your code here!
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    ll a=C,b=D;
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    ll x0=C*D/b;
    ll ans=(B-B/C)+B-B/D-(B-B/(x0));
    ll A0=A-1;
    ans-=A0-A0/C+A0-A0/D-(A0-A0/(x0));
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, m; std::cin >> n >> m;
  int x = n + m;
  if (x % 2 == 1) {
    std::cout << "IMPOSSIBLE" << std::endl;
  } else {
    std::cout << x / 2 << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;

namespace A_Security
{
    class Program
    {


        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            char nn;

            int[] s = new int[4];
            for(int i=0;i<4;i++)
            {
                nn = n[i];
                s[i] = (int)nn;
            }

            var flg = false;
            if (s[0] == s[1])
            {
                flg = true;
            }
            if (s[1] == s[2])
            {
                flg = true;
            }
            if (s[2] == s[3])
            {
                flg = true;
            }

            if(flg == true)
            {
                Console.WriteLine("Bad");
            }
            else
            {
                Console.WriteLine("Good");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  if (S.at(0) == S.at(1) && S.at(1) == S.at(2)) {
    cout << "Yes" << endl;
  }
  else if (S.at(1) == S.at(2) && S.at(2) == S.at(3)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

main(){
    int n,m;
    int i,j;

    char (*hyou)[2];
    char c;

    while(scanf("%d",&n)!=EOF){
        if(!n)break;
        hyou=malloc(2*n);
        for(i=0;i<n;i++)
            scanf(" %c %c",&hyou[i][0],&hyou[i][1]);
        scanf("%d",&m);
        for(i=0;i<m;i++){
            scanf(" %c",&c);
            for(j=0;j<n;j++)
                if(c==hyou[j][0]){
                    c=hyou[j][1];
                    break;
                }
            putchar(c);
        }
        puts("");
        free(hyou);
    }
    return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int h,w,k;cin>>h>>w>>k;
    vstr s(h);
    rep(i,h)cin>>s[i];
    vin wnum(h),white(h);//wnumは各列の各ブロックのホワイトの個数 whiteは列で割る前までの各ブロックのホワイトの個数
    int ans=inf;
    int res,cnt;bool can,over;
    rep(i,(1<<h-1)){
        bitset<11> tmp(i);
        res=tmp.count();
        tmp[h-1]=1;
        fill(all(white),0);
        can=true;over=false;
        rep(j,w){
            cnt=0;
            fill(all(wnum),0);
            rep(l,h){
                if(s[l][j]=='1')wnum[cnt]++;
                if(tmp[l]){
                    if(wnum[cnt]>k){
                        can=false;
                        break;
                    }
                    if(white[cnt]+wnum[cnt]>k)over=true;
                    cnt++;
                }
            }
            if(!can)break;
            if(over){
                res++;
                rep(l,cnt)white[l]=wnum[l];
                over=false;
            }
            else rep(l,cnt)white[l]+=wnum[l];
        }
        //if(res==0)cout<<tmp<<endl;
        if(can)ans=min(ans,res);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

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

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, K;

// calc nCk mod p, O(n + log p)
// 1. init(n, p)
// 2. use mod_nck(n, k, p) 
const int MAX_N = 200000;
ll fact[MAX_N + 1], fact_inv[MAX_N + 1];

ll mod_pow(ll x, ll n, ll p) {
  if(n == 0) return 1;
  ll res = mod_pow(x * x % p, n / 2, p);
  if(n & 1) res = res * x % p;
  return res;
}

void init(ll n, ll p) {
  fact[0] = 1;
  for(int i = 0; i < n; i++) {
    fact[i + 1] = fact[i] * (i + 1) % p;
  }
  fact_inv[n] = mod_pow(fact[n], p - 2, p);
  for(int i = n - 1; i >= 0; i--) {
    fact_inv[i] = fact_inv[i + 1] * (i + 1) % p;
  }
}

ll mod_nck(ll n, ll k, ll p) {
  if(n < k) return 0;
  return (fact[n] * fact_inv[k]) % p * fact_inv[n-k] % p;
}

int main(){

  cin >> N >> K;

  init(N, MOD);

  for(int i = 1; i <= K; i++) {
    if(N - K < i - 1) {
      cout << 0 << endl;
      continue;
    }
    cout << mod_nck(K - 1, i - 1, MOD) * mod_nck(N - K + 1, i, MOD) % MOD << endl;
  }


  return 0;
}


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

namespace ConsoleApplication14
{
    //ONLINE JUDGE (ITP1_8_D)

    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string p = Console.ReadLine();

            bool bl = false;
            string str1 = string.Concat(s, s);      //??????????????£????????????
            string str2 = ""; 

            for (int i = 0; i < str1.Length; ++i)
            {
                if (str1.Length - (i + 1) < p.Length)
                {
                    break;
                }

                if (p[0] == str1[i])                
                {
                    str2 = str1.Substring(i, p.Length);         //???????????????????????????????????????????????????

                    if (p == str2)
                    {
                        bl = true;
                        break;
                    }
                }
            }

            if (bl)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 7296
n,x = map(int,input().split())
arr = sorted([int(_) for _ in input().split()])
count = 0
for i in arr[0:n-1]:
    if i <= x:
        count += 1
        x -= i
    else:
        break
if x==arr[n-1]:
    count += 1    
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()

int main(){

    ll N, K;    
    cin >> N >> K;

    string s;
    cin >> s;

    vector<ll> v;
    ll cnt = 0;
    for(ll i = 0; i < N-1; i++){
        cnt ++;
        if(s[i] != s[i+1]){
            v.push_back(cnt);
            cnt = 0;
        }
    }
    cnt ++;
    v.push_back(cnt);
    if(s[0] == '0') v.insert(v.begin(), 0);
    if(*(s.end()-1) == '0') v.push_back(0);

    vector<ll> v_sum(v.size()+1);
    for(int i = 1; i <= v.size(); i++){
        v_sum[i] = v_sum[i-1];
        v_sum[i] += v[i-1];
    }

    for(int i = 0; i < v.size(); i++){
        //cout << v[i];
    }
        //cout << endl;;


    ll ans = 0;
    if(2 * K  > v.size()){
        cout << *(v_sum.end()-1) << endl;
        return 0;
    }
    for(int i = 0; i + 2 * K  + 1< v_sum.size(); i+=2){
        ans = max(v_sum[i + 2 * K + 1] - v_sum[i], ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2164
N = int(input())
A = list(map(int, input().split()))

def insertionSort(A, N):
    for i in range(N-1):
        print(' '.join(repr(e) for e in A))
        v = A[i+1]
        j = i
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
            A[j+1] = v
    print(' '.join(repr(e) for e in A))

insertionSort(A, N)


Measured memory_bytes: 5612
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100+10,dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int a[N][N],n,m,sz[N][N];
string str;
struct P{
    int x,y;
};
void bfs(){
    sz[0][0]=1;
    queue<P>q;
    P p,ne;
    p.x=0;p.y=0;
    q.push(p);
    while(!q.empty()){
        p=q.front();
        q.pop();
        int x=p.x,y=p.y;
        for(int i=0;i<4;i++){
            ne.x=x+dx[i];
            ne.y=y+dy[i];
            if(ne.x>=0&&ne.x<n&&ne.y>=0&&ne.y<m){
                if(sz[ne.x][ne.y]>sz[x][y]+1&&a[ne.x][ne.y]!=1) {
                    sz[ne.x][ne.y]=sz[x][y]+1;
                    q.push(ne);
                }
            }

        }
    }

}
int main() {
    while(~scanf("%d%d",&n,&m)){
        int sum=0;
        for(int i=0;i<n;i++){
            cin>>str;
            for(int j=0;j<m;j++){
                sz[i][j]=10000;
                if(str[j]=='.'){
                    sum++;
                    a[i][j]=0;
                }
                else {
                    a[i][j]=1;
                }
            }
        }
        bfs();
        printf("%d\n",sz[n-1][m-1]==10000?-1:sum-sz[n-1][m-1]);

    }
    return 0;
}


Measured memory_bytes: 256
import math
 
a, b, x = map(int, input().split())
if x == a*a*b:
    p = 0
elif x <= a*a*b/2:
    p = math.degrees(math.atan(b/(2*x/(a*b))))
else:
    p = 90-math.degrees(math.atan(a/2/(b - x/(a*a))))

print(p)

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int K=gi();

       System.out.print(NsinKeta(N,K));

//        if (f) {
//    	    System.out.print("Yes");
//        }else{
//        	 System.out.print("No");
//        }
	}
	
	public static int NsinKeta(int n, int s) {
		if(n==0) return 1;
		
		int i=0;
		while(n!=0) {
			n=Math.floorDiv(n, s);
			i++;
		}
		
		return i;
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int m1 = sc.nextInt();
		int d1 = sc.nextInt();
		int m2 = sc.nextInt();
		int d2 = sc.nextInt();

		if(m1 == 12 && m2 == 1) {
			System.out.println("1");
			return;
		}

		if(m1 < m2) {
			System.out.println("1");
			return;
		}

		System.out.println("0");
	}

}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;
const LL m = 1e9+7;

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

vector<LL> pr;
LL phi[MAXN];

LL po(LL a, LL n){
	if(n==0) return 1;
	LL an = po(a,n/2);
	an = (an*an)%m;
	if(n&1) an = (an*a)%m;
	return an;
}

int main(){
  fio();
  LL n,k; cin>>n>>k;
  LL an = po(k,n);
  for(LL i=2; i<=k; i++){
  	if(phi[i]==0){
  		pr.pb(i);
  		phi[i] = i-1;
  	}
  	an = (an + po(k/i,n)*phi[i])%m;
  	for(auto p:pr){
  		if(i*p>k) break;
  		if(i%p==0){
  			phi[i*p] = (p*phi[i])%m;
  			break;
  		}
  		else{
  			phi[i*p] = (phi[i]*phi[p])%m;
  		}
  	}
  }
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 4488
N = int(input())

T = [0]
XY = [[0,0]]
for i in range(N):
    t, *xy = map(int, input().split())
    T.append(t)
    XY.append(xy)

for i in range(1,N+1):
    tmp_t = T[i] - T[i-1]
    tmp_cnt = abs(XY[i][0] - XY[i-1][0]) + abs(XY[i][1] - XY[i-1][1])
    if tmp_t < tmp_cnt:
        print('No')
        exit()
    else:
        if (tmp_t - tmp_cnt)%2 != 0:
            print('No')
            exit()

print('Yes')


Measured memory_bytes: 27788
s = str(input())

n = s.count('R')

if n == 0:
    print(0)
else:
    if n == 1:
        print(1)
    else:
        m = s.count('RR')
        if m == 0:
            print(1)
        elif m == 1:
            l = s.count('RRR')
            if l == 1:
                print(3)
            else:
                print(2)

Measured memory_bytes: 61660
package main

import "fmt"

func main() {
	var start float64
	start = 100
	var n int
	fmt.Scan(&n)
	for i := 1; i > 0; i++ {
		start *= 1.01
		tmp := int(start)
		if tmp >= n {
			fmt.Println(i)
			break
		}
		start = float64(tmp)
	}
}


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

using namespace std;

void dfs(int u, const vector<vector<pair<int, int>>> &g, vector<int> &vis) {
    vis[u] = 1;
    for (const auto p : g[u]) {
        int v = p.first, c = p.second;
        if (!vis[v]) {
            dfs(v, g, vis);
        }
    }
}
void dfs(int u, const vector<vector<pair<int, int>>> &g, 
         vector<int> &vis, vector<int> &mx) {
    vis[u] = 1;
    for (const auto p : g[u]) {
        int v = p.first, c = p.second;
        if (!vis[v]) {
            mx[v] = mx[u] + c;
            dfs(v, g, vis, mx);
        } else {
            mx[v] = max(mx[v], mx[u] + c);
        }
    }
}
int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);

    int N, M, P;
    cin >> N >> M >> P;
    vector<vector<pair<int, int>>> g(N);
    for (int i = 0; i < M; ++i) {
        int A, B, C;
        cin >> A >> B >> C;
        g[A - 1].emplace_back(B - 1, -(C - P));
    }
    vector<int> rem(N, 0);
    for (int u = 1; u < N; ++u) {
        vector<int> vis(N, 0);
        dfs(u, g, vis);
        if (!vis[N - 1]) {
            rem[u] = 1;
        }
    }
    {
        vector<int> vis(N, 0);
        dfs(0, g, vis);
        for (int u = 1; u < N; ++u) {
            if (!vis[u]) {
                rem[u] = 1;
            }
        }
    }
    
    /*for (int u = 0; u < N; ++u) {
        if (rem[u]) continue;
        vector<int> mx(N, 0), vis(N, 0);
        dfs(u, g, vis, mx);
        if (mx[u] > 0) {
            //cout << u+1 << " " << mx[u] << endl;
            cout << -1 << "\n";
            return 0;
        }
    }
    vector<int> mx(N, 0), vis(N, 0);
    dfs(0, g, vis, mx);
    cout << max(mx[N - 1], 0) << "\n";*/

    vector<int> dist(N, 1'000'000'000), par(N, -1);
    dist[0] = 0;
    for (int i = 0; i < N - 1; ++i) {
        for (int u = 0; u < N; ++u) {
            if (rem[u]) continue;
            for (const auto p : g[u]) {
                int v = p.first, c = p.second;
                if (rem[v]) continue;
                if (dist[u] + c < dist[v]) {
                    dist[v] = dist[u] + c;
                    par[v] = u;
                }
            }
        }
    }
    for (int u = 0; u < N; ++u) {
        if (rem[u]) continue;
        for (const auto p : g[u]) {
            int v = p.first, c = p.second;
            if (rem[v]) continue;
            if (dist[u] + c < dist[v]) {
                cout << -1 << "\n";
                return 0;
            }
        }
    }
    cout << max(-dist[N - 1], 0) << "\n";

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll t,i,j,k,l,n,m;
    cin>>n>>k;
    vector<ll> dp(k+1,0);
    vector<ll> val(n),wt(n);
    for(i=0;i<n;i++)
    cin>>wt[i]>>val[i];
    for(i=0;i<n;i++)
    {
        for(j=k;j>=wt[i];j--)
        dp[j]=max(dp[j],dp[j-wt[i]]+val[i]);
    }
    cout<<dp[k];
    return 0;
}

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

#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

#define len(a) ((int) (a).size())
#define all(a) (a).begin(), (a).end()

int get(int cnt) {
    int res = 1;
    while ((res + 1) * (res + 2) / 2 <= cnt) res++;
    return res;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) {
                cnt++;
                n /= i;
            }
            ans += get(cnt);
        }
    }
    if (n > 1) ans++;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3652
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47348
import java.util.*;
class Main
{
    static String[] s = new String[50];
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextLong();
        long[] p = new long[51], b = new long[51];
        p[0] = 1;
        b[0] = 1;
        for(int i = 1; i <= 50; i++){
            p[i] = p[i-1] * 2 + 3;
            b[i] = b[i-1] * 2 + 1;
        }
        long ans = 0;
        if(x > p[n]){
            System.out.println(b[n]);
            return;
        }
        for(int i = n; i >= 0; i--){
            if(p[i] == x){
                ans += b[i];
                x = 0;
                break;
            }
            else if(p[i] < x){
                ans += b[i] + 1;
                x -= p[i] + 1;
            }
            if(i == 0 && x >= 1) ans++;
            x--;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 25172
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  int N,count=0;
  string S;
  cin >> N >> S;

  for(int i=0;i<N/2;i++){
  if(S[i] == S[N/2+i]){
    count++;
  }
  }
  if(N%2==1){
  cout << "No" << endl;
  return 0;
  }

  if(count == N/2){
  cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using  namespace std ;
#define ll long long int

class segment {
public :

ll n  ;
    vector<ll> arr ;
    void build ( ll n )
    {
        this->n = n+1 ;
    }


    void update( ll plac , ll  val )
    {

        do_up( 1 , 0 , n-1  , plac ,  val   ) ;


    }


    void do_up ( ll cur , ll ini , ll fin , ll loc , ll  val )
    {
        if(arr.size()< cur+1)
        {

            arr.resize(cur+1,  0 ) ;
        }

        if( ini> loc ||  loc>fin )
            return ;

        if(ini == fin && ini == loc )
        {

            arr[cur] = val ;
        }else
        {
            ll tm = ini + fin ;
            tm/=2 ;

            do_up( cur*2 ,  ini ,  tm ,  loc , val ) ;
            do_up( cur*2+1 ,   tm +1 , fin  ,  loc , val ) ;

            arr[cur] = max( arr[cur*2+1 ] ,  arr[cur*2])  ;


        }


    }

    ll val(ll  i )
    {

      return   do_fin( 1 ,  0 , n-1 , i ,i ) ;
    }


   ll  do_fin( ll cur , ll ini , ll  fin , ll lef ,ll rig )
    {

        if( lef  > rig )
            return  0 ;

        if(arr.size()< cur+1)
        {

            arr.resize(cur+1,  0 ) ;
        }

        if(ini == lef && fin==rig)
            return  arr[cur] ;

ll tm = ini +fin ;
tm/=2 ;
            ll l =  do_fin( cur*2 , ini , tm ,  lef , min( tm , rig )  ) ;
            ll r  = do_fin( cur*2+1 , tm+1 , fin ,  max( tm+1 , lef ) ,rig ) ;

            return max( l , r) ;

    }


    ll searc( ll i )
    {

        return do_fin ( 1, 0,   n-1 , 0 , i ) ;
     }

    };



int main()
{

    ll n ;cin>> n ;
    vector<ll> hig ( n) , val(n) ;
    for(ll i =0; i < n ;i++)
        cin>>hig[i] ;
    for(ll i =0; i < n ;i++)
        cin>>val[i] ;
    segment arr ;

    arr.build(1+n ) ;

    ll dp[n] = {0} ;
    for(ll i = 0 ;i <  n ;i++)
    {

        ll hi = hig[i] ;
        ll vla = 0 ;
        if(hi!=0)
        {
            vla = arr.searc( hi-1) ;


        }
        
        
        vla += val[i] ;
        ll ini = arr.val( hi ) ;
        if(ini < vla)
        {

            arr.update( hi,  vla ) ;
        }
        dp[i] = arr.val(hi) ;

    }

    ll maxn = 0 ;
    for(auto i : dp)
        maxn = max(maxn ,  i) ;
    cout<<maxn ;

}


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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'A') {
            int ans = 0;
            for (int j = i + 1; j < s.length(); j++) {
                if (s[j] == 'Z') ans = j - i + 1;
            }
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}

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

int main(){
    int x=0, ans=0, n;
    string s;
    cin >> n >> s;

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

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<int>pos;
    if(s[0]=='0')
    pos.push_back(0);
    int maxa=0;

    for (int i = 0; i < n; ++i) {
        if(s[i]=='1')
        {
            pos.push_back(i);
            while (s[i]=='1')
            {
                i++;
                if(i==n)
                    break;
            }
        }
    }

//    for(auto j=pos.begin();j!=pos.end();j++)
//        cout<<*j<<" ";

//    cout<<endl;
    int count=0,len=0;
    for (int i= 0; i < n; ++i) {
            if(s[i]=='0')
        {
            count++;
//            cout<<i<<endl;
            while (s[i]=='0')
            {
                i++;
                if(i==n)
                    break;
            }
            i--;
        }

        len=i+1;
//        cout<<count<<" ";
        if(count==k)
        {
//            cout<<"working";
            break;
        }
    }

//    cout<<len<<endl;
    maxa=len;
    auto l=pos.begin();
    for (int i = len; i < n; ++i) {
        if(s[i]=='0')
        {
            l++;
            while (s[i]=='0')
            {
                i++;
                if(i==n)
                    break;
            }
            i--;
        }
        if(i==n)
            i--;
        maxa=max(maxa,i+1-*l);
    }

    cout<<maxa;
}

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

template<class T> inline bool chmax(T& a, T b){
  if(a<b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  int N; cin >> N;
  vector<vector<long long> >happy(N,vector<long long>(3));
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      cin >> happy.at(i).at(j);
    }
  }
  vector<vector<long long> >dp(N,vector<long long>(3,-1));
  for(int i=0;i<3;i++){
    dp.at(0).at(i) = happy.at(0).at(i);
  }
  for(int i=1;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j==k) continue;
        chmax(dp.at(i).at(j),dp.at(i-1).at(k) + happy.at(i).at(j));
      }
    }
  }
  cout << max(dp.at(N-1).at(0),max(dp.at(N-1).at(1),dp.at(N-1).at(2))) << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
int main(void)
{
  for(;;){
    int n,pw;
    cin >> n;
    if(!n) return 0;
    cin >> pw;
    set<long double> wss;
    wss.insert(0.0);
    map<double,double>a;
    double tmpanswer=0.0;
    a[0.0]=pw;
    int rnd;
    REP(i,n){
      int vw,pf,vf,th;
      scanf("%d%d%d%d",&vw,&pf,&vf,&th);
      if(th>0){
	a[0.0]+=-1.0*pf*vw/vf;
	tmpanswer+=1.0*th*pf/vf;
      }
      if(th==0&&vw<0){
	a[0.0]+=-1.0*pf*vw/vf;
      }
      if(vw&&th*vw>0){
	long double w=1.0*th/vw;
	wss.insert(w);
	a[w]+=1.0*pf*abs(vw)/vf;
      }      
    }
    vector<long double> ws(wss.begin(),wss.end());
    double answer=tmpanswer;
    REP(i,ws.size()-1){
      tmpanswer+=a[ws[i]]*(ws[i+1]-ws[i]);
      a[ws[i+1]]+=a[ws[i]];
      answer=min(answer,tmpanswer);
    }
    cout << fixed << setprecision(10) << answer << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using Graph = vector<vector<int>>;

int main()
{
    string S;
    cin >> S;
    int len = S.length();
    int N = len / 2;
    int counter = 0;
    rep(i, N)
    {
        if(S[i] != S[len - (i + 1)])
            counter++;
    }
    cout << counter << endl;
}

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

const long long MOD = 1000000007;
const int MAX = 100001;

long long fac[MAX], finv[MAX], inv[MAX];

void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long mod_comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> cnt(26);
    for (int i = 0; i < n; i++) {
        cnt.at(s.at(i) - 'a')++;
    }
    comb_init();
    
    long long cnt_b = 0, x = 1;
    for (int i = 0; i < 26; i++) {
        if (cnt.at(i) >= 2) {
            x *= cnt.at(i) + 1;
            x %= MOD;
        }
        else if (cnt.at(i) == 1){
            cnt_b++;
        }
    }
    
    long long sum1 = 0;
    for (int i = 0; i <= cnt_b; i++) {
        sum1 += mod_comb(cnt_b, i);
        sum1 %= MOD;
    }
    
    long long ans = sum1 % MOD * x % MOD;
    cout << ans - 1 << endl;
}

Measured memory_bytes: 2816
#include<stdio.h>

int main()
{
	int n, m, q, min, max, l, r, table[501][501]{};

	scanf("%d%d%d", &n, &m, &q);
	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d", &l, &r);
		for (int j = r; j < n + 1; ++j)
			table[l][j]++;
	}
	for (int i = 1; i < n + 1; ++i)
	{
		for (int j = i; j < n + 1; ++j)
			table[i][j] += table[i - 1][j];
	}
	for (int i = 0; i < q; ++i)
	{
		scanf("%d%d", &min, &max);
		printf("%d\n", table[max][max] - table[min - 1][max]);
	}

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,b%a);
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int a,b,c;
	cin>>a>>b>>c;
	int cnt=0;
	for(int i=100;i>=1;i--){
		if(a%i==0 && b%i==0)cnt++;
		if(cnt==c){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
ll permutation(ll n,ll r)
{
    ll a=1;
    for(ll i=n-r+1;i<=n;i++)
    {a*=i;a%=MOD;}
    return a;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,h;cin>>n>>h;
    vector<ll>a(n),b(n);
    for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
    sort(all(a));
    sort(all(b));
    reverse(all(a));
    reverse(all(b));
    ll ans=0;
    if(h%a[0]==0)
        ans=h/a[0];
    else
        ans=h/a[0]+1;
    ll useda=ans;
    ll damage=ans*a[0];
    vector<ll>usedb;
    ll cntb=0;
    for(ll i=0;i<min(ans,n);i++){
        if(b[i]>a[0]){
            damage=damage-a[0]+b[i];
            usedb.pb(b[i]);
            cntb++;
            useda--;
        }
        else break;
    }
    while(damage-a[0]>=h&&useda--){
        damage-=a[0];
        ans--;
    }
    ll i=0;
    sort(all(usedb));
    while(i<cntb&&damage-usedb[i]>=h){
        damage-=usedb[i];
        i++;
        ans--;
        if(i>=cntb)break;
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







Measured memory_bytes: 2936
n = int(input())

t = [[0] * 10 for _ in range(10)]
for i in range(1, n+1):
  s = str(i)
  t[int(s[0])][int(s[-1])] += 1

result = 0
for i in range(1, 10):
  for j in range(1, 10):
    result += t[i][j] * t[j][i]
print(result)

Measured memory_bytes: 40300
#include<bits/stdc++.h>
using namespace std;
#define MN 2000
int n,k,q,a[MN+5],c[MN+5];
bool check(int l,int r)
{
	int p=0,i,j,t,s=0;
	for(i=1;i<=n+1;++i)if(a[i]<c[l])
	{
		for(t=0,j=p;++j<i;)if(a[j]<=c[r])++t;
		s+=max(0,min(t,i-p-k));p=i;
	}
	return s>=q;
}
int main()
{
	int i,j,ans=1e9;
	scanf("%d%d%d",&n,&k,&q);
	for(i=1;i<=n;++i)scanf("%d",&a[i]),c[i]=a[i];
	sort(c+1,c+n+1);
	for(i=j=1;i<=n;++i)
	{
		while(j<=n&&!check(i,j))++j;
		if(j<=n)ans=min(ans,c[j]-c[i]);
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-10;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

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

int main() {
	IOS();
	ll n, x;
	cin >> n >> x;
	vector<ll> a(n), s(n + 1, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s[i + 1] = s[i] + a[i];
	}
	ull ans = INF;
	for (int k = 1; k <= n; k++) { // k回往復する
		ull tmp = 0;
		ll cnt  = 1;
		for (int i = n; cnt <= ceil((double)n / k); i -= k) {
			if (cnt == 1) {
				tmp += 5 * (s[i] - s[max(i - k, 0)]);
			} else {
				tmp += (2 * cnt + 1) * (s[i] - s[max(i - k, 0)]);
			}
			cnt++;
		}
		tmp += (n + k) * x;

		//dump(tmp);
		ans = min(ans, tmp);
	}
	dump(ans);
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;

typedef long long ll;

int main(void){
    int n;
    string s;
    cin >> n >> s;

    int first = 0;
    int last = 0;
    int count = 0;

    for (int i = 0; i < n; i++){
        if (s[i] == '('){
            count++;
        }
        else{
            count--;
            if (count == -1){
                count++;
                first++;
            }
        }
    }

    last = count;

    for (int i = 0; i < first; i++){
        cout << '(';
    }
    cout << s;
    for (int i = 0; i < last; i++){
        cout << ')';
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=0,ans=0;
    rep(i,3){
        if(s[i]=='R'){
            n++;
        }
        else{
            n=0;
        }
        ans=max(ans,n);
    }
    cout<<ans<<endl;
}


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

int main() {
    int a = 0, b = 0, c = 0, d = 0;
    for (int i = 0; i < 4; i++) {
        int s;
        cin >> s;
        if (s == 1) a++;
        else if (s == 9) b++;
        else if (s == 7) c++;
        else if (s == 4) d++;
    }

    if (a == 1 && b == 1 && c == 1 && d == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256