akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long

typedef pair<int, int> P;

int H, W, N;
P ab[100000];
map<P, bool> mp, use;

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

    cin >> H >> W >> N;
    for(int i = 0; i < N; ++i) {
        cin >> ab[i].first >> ab[i].second;
        mp[ab[i]] = true;
    }
    int count[10] = { 0 };
    int dx[] = {1, -1, 0, 0, 1, -1, 1, -1, 0}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1, 0};
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 9; ++j) {
            int nx = ab[i].second + dx[j], ny = ab[i].first + dy[j];
            if(nx < 2 || nx > W - 1 || ny < 2 || ny > H - 1) continue;
            if(use[P(ny, nx)]) continue;
            use[P(ny, nx)] = true;
            int cnt = 0;
            for(int k = 0; k < 9; ++k) {
                int sx = nx + dx[k], sy = ny + dy[k];
                if(mp[P(sy, sx)]) ++cnt;
            }
            ++count[cnt];
        }
    }
    int sum = 0;
    for(int i = 1; i < 10; ++i) sum += count[i];
    count[0] = (H - 2) * (W - 2) - sum;
    for(int i = 0; i < 10; ++i) cout << count[i] << endl;
    return 0;
}

Measured memory_bytes: 214272
# D - equeue
def main():
    N, K, *V = map(int, open(0).read().split())
    lim = min(N, K)
    available_choices = set()

    for l in range(lim + 1):
        for r in range(lim + 1):
            if l + r > lim:
                break

            choice = V[:l] + V[-r:] if r else V[:l]
            cnt_negatives = sum(i < 0 for i in choice)
            cnt_rest = K - (l + r)

            if cnt_negatives > cnt_rest:
                choice.sort()
                available_choices.add(sum(choice[cnt_rest:]))
            else:
                available_choices.add(sum(i for i in choice if i > 0))

    print(max(available_choices))


if __name__ == "__main__":
    main()


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

ks = []
ss = []
for i in range(m):
    s = list(map(int, input().split()))
    k = s.pop(0)
    ks.append(k)
    ss.append(s)

ps = list(map(int, input().split()))

import itertools
combs = itertools.product([1, 0], repeat=n)

res = 0
for comb in combs:
    valid = True
    for i in range(m):
        p = ps[i]
        k = ks[i]
        s = ss[i]
        cnt = 0
        for j in range(k):
            cnt += comb[s[j] - 1]
        if cnt % 2 != p:
            valid = False
            break
    if valid:
        res += 1

print(res)

Measured memory_bytes: 40560
#include<stdio.h>
#include<math.h>

int main(void){

  int N;

  scanf("%d",&N);

  int w[N];
  int i;

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

  int s[N-1];
  int dif[N-1];
  int min;
  int sum = 0;
  s[0] = w[0];

  for(i=0;i<N;i++){
    sum = sum + w[i];
  }

  dif[0] = sum - s[0] - s[0];

  for(i=1;i<N;i++){
    s[i] = s[i-1] + w[i];
    dif[i] = sum - s[i] - s[i];
    if(dif[i]<0){
      dif[i] = -dif[i];
    }
  }
  min = dif[0];

  for(i=0;i<N-1;i++){
    if(min>dif[i]){
      min = dif[i];
    }
  }

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

return 0;

}


Measured memory_bytes: 128
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
vector<int> Graph[202];
string s;
int col[202];
int main(){
    cin >> n;
    REP(i, n){
        cin >> s;
        REP(j, n){
            if(s[j] == '1'){
                Graph[i].emplace_back(j);
            }
        }
    }
    int ans = -1;
    REP(i, n){
        REP(j, n)col[j] = -1;
        col[i] = 1;
        queue<int> q;
        q.push(i);
        bool isok = true;
        while(!q.empty()){
            int p = q.front();
            q.pop();
            for(auto to : Graph[p]){
                if(col[to] == -1){
                    col[to] = col[p] + 1;
                    q.push(to);
                }else{
                    if(abs(col[p] - col[to]) != 1)isok = false;
                }
            }
        }
        if(isok)REP(j, n)ans = max(ans, col[j]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
    // Your code here!
    int N;
    cin >> N;
    int A[210];//最大200個なので余裕を持って210
    
    for(int i = 0; i<N; i++){
        cin >> A[i];
    }
    
    int res = 0;
    
    //操作が行える限り操作を繰り返す
    while(true){//trueの間
        bool exist_odd = false;//A[i]がすべて偶数かどうかを判定するフラグ
        for(int i = 0; i < N; i++){//3回繰り返す
            if(A[i] %2 != 0) exist_odd = true;//奇数があったらフラグを立てる
        }
    
        if(exist_odd)break;//奇数があったらbreak;
    
        //操作を行えるなら操作を実際に行う
        for(int i = 0; i < N ;i++){
            A[i] /= 2;
        }
        ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			double[] vs = Console.ReadLine().Split().Select(double.Parse).ToArray();
			double a = vs[0];
			double b = vs[1];
			double x = vs[2] / a;
			double diff = x / 100000000000;
			double s = a * b / 2;
			bool f = s < x;

			double max = f ? b : a;
			double min = 0;
			double c;
			double deg;
			while (true) {
				c = (max + min) / 2;
				if (f) {
					// 対角より多い
					s = a * c + a * (b - c) / 2;
				} else {
					// 対角より少ない
					s = c * b / 2;
				}

				if (Math.Abs(s - x) < diff) {
					if (f) {
						// 対角より多い
						deg = Math.Atan((b - c) / a) * 180 / Math.PI;
					} else {
						// 対角より少ない
						deg = Math.Atan(b / c) * 180 / Math.PI;
					}
					Console.WriteLine(deg);
					break;
				} else if (s < x) {
					min = c;
				} else {
					max = c;
				}
			}


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
import sys
HK,WK,M = map(int, input().split())
W = [0] * (WK + 1)
H = [0] * (HK + 1)
HW = {}
# 3*10^5

for i in range(M):
    h, w = map(int, input().split())

    H[h] += 1
    W[w] += 1

    HW[(h,w)] = 1

answer = 0
HMAX = max(H)
WMAX = max(W)

HEMAX = H.count(HMAX)
WEMAX = W.count(WMAX)
if HEMAX * WEMAX > M:
    print(HMAX + WMAX)
    sys.exit(0)

HMAXES = [i for i, _ in enumerate(H) if _ == HMAX]
WMAXES = [i for i, _ in enumerate(W) if _ == WMAX]

# 3*10^5
answer = HMAX + WMAX
for h in HMAXES:
    for w in WMAXES:
        if not (h,w) in HW:
            print(answer)
            sys.exit(0)
print(answer-1)

Measured memory_bytes: 177044
#include <stdio.h>
int main(){
int n,l,r,a,b;
while(1){
scanf("%d",&n);
if(n==0)return 0;
a=b=0;
while(n--){
scanf("%d%d",&l,&r);
if(l>r)a+=l+r;
if(r>l)b+=l+r;
if(l==r){
	a+=l;
	b+=r;
}
}
printf("%d %d\n",a,b);
}
}

Measured memory_bytes: 2664
q = int(input())
x = 0
MASK = 2 ** 64 - 1

def x_test(i):
    return int((x & (1 << i)) > 0)
def x_set(i):
    global x
    x |= 1 << i
def x_clear(i):
    global x
    if x & (1 << i):
        x ^= 1 << i
def x_flip(i):
    global x
    x ^= 1 << i
def x_all():
    return int(x & MASK == MASK)
def x_any():
    return int(x & MASK > 0)
def x_none():
    return int(x & MASK == 0)
def x_count():
    return bin(x).count("1")
def x_val():
    return x
    
command = [
    x_test,
    x_set,
    x_clear,
    x_flip,
    x_all,
    x_any,
    x_none,
    x_count,
    x_val
]

for j in range(q):
    t, *cmd = map(int, input().split())
    ans = command[t](*cmd)
    if ans is not None:
        print(ans)


Measured memory_bytes: 5616
n=int(input())
A=[0]+list(map(int,input().split()))+[0]
diff=[abs(A[i]-A[i-1]) for i in range(1,len(A))]
sums=sum(diff)

for i in range(1,n+1):
  # if i==n:
  #   print(sums-abs(A[i]-A[i+1])-abs(A[i-1]-A[i])+abs(A[i-1]-A[i+1]))
  #   exit()
  # elif A[i]<=A[i+1] and ((A[i]>0 and A[i+1]<0) or (A[i]<0 and A[i+1]>0)):
  #   print(sums-abs(A[i]-A[i+1])-abs(A[i-1]-A[i])+abs(A[i-1]-A[i+1]))
  # elif A[i]<=A[i+1]:
  #   print(sums)
  # else:
    print(sums-abs(A[i]-A[i+1])-abs(A[i-1]-A[i])+abs(A[i-1]-A[i+1]))


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 h, w;
    cin >> h >> w;
    map<char, i64> cnt;
    for (i64 i = 0; i < h * w; i++) {
        char a;
        cin >> a;
        cnt[a]++;
    }

    i64 r1 = 0, r2 = 0;
    for (auto& e : cnt) {
        i64 r = e.second % 4;
        switch (r) {
        case 1:
            r1++;
            break;
        case 2:
            r2++;
            break;
        case 3:
            r1++, r2++;
            break;
        }
    }

    i64 c1 = (h % 2) * (w % 2);
    i64 c2 = (h % 2) * (w / 2) + (w % 2) * (h / 2);
    cout << (r1 <= c1 && r2 <= c2 ? "Yes" : "No") << endl;
}

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


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

int main() {
    //
    long long num;
    long long kekka = 9999999999;
    long long tmpKekka = 0;
    long long Min = 999;
    long long Max = 0;

    cin >> num;

    vector<long long> vec(num);

    for (long long i = 0; i < num; i++) {
        cin >> vec.at(i);
        Min = min(Min, vec.at(i));
        Max = max(Max, vec.at(i));
    }

    for (long long i = Min; i <= Max; i++) {
        tmpKekka = 0;
        for (long long j = 0; j < num; j++) { 
            tmpKekka += pow(i - vec.at(j), 2); 
        }

        kekka = min(kekka, tmpKekka);
    }

    cout << kekka;
    //
}


Measured memory_bytes: 3624
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin>>N;
  int h[N];
  rep(i,N){
    cin>>h[i];
  }
  int dp[N];
  rep(i,N){
    dp[i]=INF;
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  rep(i,N-2){
    dp[i+2]=min(dp[i+1]+abs(h[i+2]-h[i+1]),dp[i]+abs(h[i+2]-h[i]));
  }
  cout<<dp[N-1]<<endl;;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	static boolean memo[];
	static boolean ok;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int a, cnt = 0;
		for (int i = 1; i <= n; i++) {
			a = sc.nextInt();
			if (i != a) {
				cnt++;
			}
		}
		if(cnt == 2 || cnt == 0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_set>

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

template <class T>
inline bool chmin(T& a, T b)
{
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T& a, T b)
{
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
T GCD(T x, T y)
{
    return (y ? GCD<T>(y, x % y) : x);
}


int main() {
    int N;
    cin >> N;
    unordered_set<int> us;

    rep(i,N){
        int tmp;
        cin>>tmp;
        if(us.count(tmp)!=0){
            cout<<"NO"<<endl;
            return 0;
        }
        us.insert(tmp);
    }

    cout<<"YES"<<endl;
}



Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> vec;
  for(int i=0; i<N; i++)
  {
    int temp;
    cin >> temp;
    if(0 == count(vec.begin(), vec.end(), temp))
    {
      vec.push_back(temp);
    }
  }
  cout << vec.size() << endl;
}



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

string dp[26][21];
string Z="{";

void init(){
  for(int i=0;i<26;i++){
    for(int j=0;j<=20;j++){
      dp[i][j]=Z;
    }
  }
}

int N,M;
string from[50],to[50];

bool check(int id){
  int sd=from[id][0]-'A';
  
  if( to[id]=="" ){
    //    cout<<"!!"<<endl;
    
    bool res=( dp[sd][0] == Z );
    dp[sd][0]="";
    return res;
  }
  
  string t[21];
  for(int i=0;i<=M;i++)t[i]=Z;
  t[0]="";

  bool allZero=true;
  
  for(int i=0;i<(int)to[id].size();i++){
    char ch=to[id][i];
    if('A'<=ch&&ch<='Z'){
      int target=ch-'A';
      if( dp[target][0] == Z )allZero=false;
      
      for(int j=M;j>=0;j--){
        if( dp[target][0]==Z )  t[j]=Z;
        
        for(int k=j;k>=0;k--){
          if(t[j-k]!=Z && dp[target][k]!=Z){
            t[j]=min(t[j],t[j-k]+dp[target][k]);
          }
        }
      }
      
    }else{
      allZero=false;
      for(int j=M;j>=1;j--){
        if(t[j-1]!=Z)t[j]=t[j-1]+ch;
        else t[j]=Z;
      }
      t[0]=Z;
    }
  }
  
  bool res=false;
  for(int i=1;i<=M;i++){
    if(dp[sd][i]>t[i]){
      dp[sd][i]=t[i];
      res=true;
    }
  }
    
  if( allZero && dp[sd][0]==Z){
    res=true;
    dp[sd][0]="";
  }
  
  return res;
}

int main(){
  while(1){
    cin>>N>>M;
    if(N==0&&M==0)break;
    init();
    for(int i=0;i<N;i++){
      string str;
      cin>>str;
      int index=str.find('=');
      from[i]=str.substr(0,index);
      
      if(index+1 == (int)str.size()){
        to[i]="";
        //        cout<<i<<endl;
      }else{
        to[i]=str.substr(index+1);
      }

      
    }
    
    bool update=true;
    while(update){
      update=false;
      for(int i=0;i<N;i++){
        update=(update||check(i));
      }
      /*

      for(int i=0;i<5;i++){
        cout<<"dp[A]["<<i<<"] = "<<dp[0][i]<<endl;
      }
      for(int i=0;i<5;i++){
        cout<<"dp[B]["<<i<<"] = "<<dp[1][i]<<endl;
      }
      for(int i=0;i<5;i++){
        cout<<"dp[S]["<<i<<"] = "<<dp['S'-'A'][i]<<endl;
      }
      */
    }
    
    string ans = dp[ 'S'-'A' ][ M ];
    if(ans==Z)cout<<'-'<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}
template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
void solve(){
    string S;
    cin >> S;
    ll k;
    cin >> k;
    k--;
    ll i = 0;
    while(S[i] == '1') i++;
    if( i >=k ){
        cout << S[k] << "\n";
    }else{
        cout << S[i] << "\n";
    }
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int n[5];
	int type[][2] = {{0,1},{0,2},{1,0},{1,2},{2,0},{2,1}};
	int res[] = {2,1,1,2,2,1};
	while(cin >> n[0], n[0]) {
		int cnt[3] = {};
		cnt[--n[0]]++;
		rep2(i,1,5) {
			cin >> n[i];
			cnt[--n[i]]++;
		}
		int max = 0, min = 9, max_te = -1, min_te = -1;
		rep(i,3) {
			if(max < cnt[i]) max = cnt[i], max_te = i;
			if(min > cnt[i]) min = cnt[i], min_te = i;
		}
		if(max == 5 || min >= 1){
			rep(j,5) {
				cout << 3 << endl;
			}
		} else {
			rep(i,6) {
				if(max_te==type[i][0] && min_te==type[i][1]) {
					rep(j,5) {
						if(type[i][0]==n[j]) cout << res[i] << endl;
						else cout << 3-res[i] << endl;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll                   long long int
#define ld                   long double
#define scl(n)               scanf("%lld",&n)
#define scd(n)               scanf("%lf",&n)
#define eb                   emplace_back
#define pb                   push_back
#define pf                   push_front
#define ppf                  pop_front
#define ppb                  pop_back
#define pi 		     acos(-1.0)
#define mod                  1000000007
#define eps                  0.0000000001
#define inf                  9000000000000000
#define en                   "\n"

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

    string s, t; cin>>s>>t;
    int c=0;
    for (int i=0; s[i]!='\0'; i++) {
        if (s[i]!=t[i]) c++;
    }
    cout<<c<<en;

    return 0;
}


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

int main()
{
    int l,r,d;
    cin >> l >> r >> d;
    int count=0;
    
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            count++; 
        }
    }
    cout << count ;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<set>
#define DIM 100005
#define f first
#define s second
using namespace std;
int n, x, y, z, a, b, c, i;
long long sum, val[DIM], sol;
pair<int, int> v[DIM];
multiset<int> s;
multiset<int> :: iterator it;
int main(){
    cin>> x >> y >> z;
    n = x + y + z;
    for(i = 1; i <= n; i++){
        cin>> a >> b >> c;
        sum += a;
        v[i].f = a - b;
        v[i].s = b - c;
    }
    sort(v + 1, v + n + 1);
    for(i = n; i > y; i--){
        s.insert(v[i].f + v[i].s);
        if(i <= n - x){
            it = s.begin();
            val[i] = val[i + 1] + *it;
            s.erase(it);
        }
    }
    s.clear();
    for(i = 1; i <= y + z; i++){
        s.insert(v[i].s);
        sum -= v[i].f;
        if(i == y){
            sol = max(sol, sum - val[i + 1]);
        }
        if(i > y){
            it = s.begin();
            sum -= *it;
            s.erase(it);
            sol = max(sol, sum - val[i + 1]);
        }
    }
    cout<< sol;
}


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

// Start of template
//
    #define FOR(i, a, b) for (int i = (a); i < (b); i++)
    #define ROF(i, a, b) for (int i = (b); i > (a); i--)
    #define REP(a) for (int i = 0; i < (a); i++)
    #define pb push_back

    typedef long long ll;
    typedef vector<int> vi;

    const int MOD = 1e9 + 7;

    // to_string methods
    string ts(int n) { return to_string(n); }
    string ts(double n) { return to_string(n); }
    string ts(long double n) { return to_string(n); }
    string ts(long long n) { return to_string(n); }
    string ts(char c) { return to_string(c); }
    string ts(bool b) { return b ? "true" : "false"; }
    string ts(string s) { return s; }

    template <typename T, typename V>
    string ts(pair<T,V> p) {
        return "{" + ts(p.first) + ", " + ts(p.second) + "}";
    }

    template <typename T>
    string ts(T arr[], int len) {
        ostringstream oss;
        oss << "[";
        string delim = "";
        for (int i = 0; i < len; i++) {
            oss << delim << ts(arr[i]);
            delim = ", ";
        }
        oss << "]";
        return oss.str();
    }

    template<typename Container>
    string ts(const Container &v) {
        ostringstream oss;
        oss << "[";
        string delim = "";
        for (const auto &x : v) {
            oss << delim << ts(x);
            delim = ", ";
        }
        oss << "]";
        return oss.str(); 
    }

    template <typename T, typename V>
    string ts(map<T,V> m) {
        ostringstream oss;
        oss << "[";
        string delim = "";
        for (auto&& [first, second] : m) {
            oss << delim;
            oss << "{" << first << ": " << second << "}";
            delim = ", ";
        }
        oss << "]";
        return oss.str(); 
    }

    // IO stuff
    void setI(string s) {
        freopen(s.c_str(), "r", stdin);
    }

    void setO(string s) {
        freopen(s.c_str(), "w", stdout);
    }

    void setIO(string s1, string s2) {
        setI(s1); setO(s2);
    }

    void setUsacoIO(string s) {
        setIO(s + ".in", s + ".out");
    }


// End of template

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

    int a;
    cin >> a;

    cout << (a + a * a + a * a * a) << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <math.h>
 

int main(void)
{

	int  a,b,c;
	double	d,S,L,H,C,PI =3.14159265;
	
	
	scanf("%d %d %d",&a,&b,&c);

	
	C = PI * c/180;
	d = 0.5;

	S =  d * a * b * sin(C);
	
	L = a*a + b*b -2*a*b*cos(C);

	L = sqrt(L);

	L = a + b + L;

	H = sin(C) * b;

	

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

	printf("%f\n",L);

	printf("%f\n",H);



	
	
	return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

class UnionFindTree{
    public:
    ll size;
    // parent, if par[x] = x means root
    vector<ll> par;
    vector<ll> rank;

    UnionFindTree(ll n){
        size = n;
        par = vector<ll>(n);
        rank = vector<ll>(n);

        for(ll i=0;i<size;i++){
            par[i] = i;
            rank[i] = 0;
        }
    }

    // get the root of the tree
    ll find(ll x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] <= rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(ll x, ll y){
        return find(x) == find(y);
    }
};

// DSL_1_A: verified
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, q; cin >> n >> q;
    UnionFindTree uf(n);
    for(int i=0;i<q;i++){
        int com, x, y; cin >> com >> x >> y;
        if(!com){
            uf.unite(x, y);
        }else{
            cout << uf.same(x, y) << endl;
        }
    }
}


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

int main(){
    int N;
    cin >> N;
    vector<int> L;
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        L.push_back(tmp);
    }
    sort(L.begin(),L.end());
    int sum = 0;
    for(int i = 0; i < N-1; i++){
        sum += L[i];
    }
    if(sum>L[N-1]) cout << "Yes" << endl;
    else  cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm> 
using namespace std;
int n, k, a[100005]; 
bool cmp(int x, int y)
{
	return x > y;
}
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + n + 1, cmp);
	int ans = 0;
	for(int i = 1; i <= k; i++)
		ans += a[i];
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<int,int>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 














//int ct[100005][2];
const int N=105;
int n;
//ll w[N],v[N];
int main()
{
    string s,t;cin>>s>>t;
    int n1=s.length(),n2=t.length();
    int dp[n1+1][n2+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n1;i++)
    {
         for(int j=1;j<=n2;j++)
         {
              if(s[i-1]==t[j-1])dp[i][j]=1+dp[i-1][j-1];
              else
              {
                   dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
              }
         }
    }
    vector<char> res;
    int i=n1,j=n2;
    while(i>0&&j>0)
    {
         if(s[i-1]==t[j-1]){
              res.push_back(s[i-1]);i--;j--;
         }
         else if(dp[i-1][j]>dp[i][j-1])i--;
         else j--;
    }
    reverse(res.begin(),res.end());
    for(auto it:res)cout<<it;

     
}
























 

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

int n, m, x[100005], y[100005];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < n; i++)
        cin >> x[i];
    for(int i = 0; i < m; i++)
        cin >> y[i];
    sort(x, x + n);
    sort(y, y + m);
    int rowsum = 0, colsum = 0;
    for(int i = 0; i < n; i++)
    {
        rowsum += ((i - (n - 1 - i)) + MOD) * x[i];
        rowsum %= MOD;
    }
    for(int i = 0; i < m; i++)
    {
        colsum += ((i - (m - 1 - i)) + MOD) * y[i];
        colsum %= MOD;
    }
    rowsum = (rowsum + MOD) % MOD;
    colsum = (colsum + MOD) % MOD;
    cout << (rowsum * colsum) % MOD << "\n";
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 998244353;

const int SZ = 11234567;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

ll two[SZ];


int main2() {
  int N = nextInt();

  ll ng = 0;
  for (int i = N/2 + 1; i <= N; i++) {
    ng += choose(N, i) * two[N - i] % MOD;
    ng %= MOD;
  }

  ll ans = 1;
  REP(i, N) ans = (ans * 3) % MOD;

  ans -= (2 * ng) % MOD;
  ans %= MOD;
  ans += MOD;
  ans %= MOD;

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

int main() {

  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;
  two[0] = 1;
  for (int i = 1; i < SZ; i++) two[i] = two[i-1] * 2 % MOD;

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 351360
package main

import (
	"fmt"
)

func main () {
  var s string
  fmt.Scan(&s)
  
  idx := 0
  for i := len(s)-1; i > 0; i-- {
    if s[i] == 'F' {
    	idx = i
    	break
    }
  }
  fmt.Println(s[0:idx])
}

Measured memory_bytes: 1768
from collections import Counter

N, M = map(int, input().split())
A = [[int(i) for i in input().split()] for _ in range(N)]

for i in range(N) :
    A[i] = A[i][::-1]

def solve() :
    ret = float('inf')
    select = [True] * (M + 1)

    while True :
        c = Counter([A[i][-1] for i in range(N)])
        for k, v in c.items() :
            if v >= ret :
                select[k] = False
                
        ret = min(ret, max(c.values()))
        
        for i in range(N) :
            while not select[A[i][-1]] :
                A[i].pop()
                if len(A[i]) == 0 :
                    return ret
                    
print(solve())
                

Measured memory_bytes: 44764
// It’s always great to set new goals, keep trying, keep training, and then achieve those goals.
#include <bits/stdc++.h>
#define ll long long int
#define f(i,n) for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n;i>=0;i--)
#define endl '\n'
#define pub push_back
#define vf v[i].first
#define vs v[i].second
#define mp make_pair
#define z 998244353   
using namespace std;
ll powMod(ll x,ll y){ll p=1; while(y){if(y%2){p=(p*x)%z;} y/=2; x=(x*x)%z;} return p;}
ll invMod(ll x){return powMod(x,z-2);}
ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}

const int N = (int)2e5 + 100;
set<char> st[N];
ll visited[N];

void solve(){ 
    ll n,k;
    cin>>n;
    ll a[n][3];
    ll dp[n][3];
    
    f(i,n){
        f(j,3){
            cin>>a[i][j];
        }
    }

    f(i,n){
        f(j,3){
            if(i==0){
                dp[i][j] = a[i][j];
            }    
            else {
                ll x = (j+1)%3;
                ll y = (j+2)%3;
                dp[i][j] = max(dp[i-1][x]+a[i][j],dp[i-1][y]+a[i][j]);
            }
            // cout<<dp[i][j]<<" ";
        }
        // cout<<endl;
    }
    ll Max = INT_MIN;
    f(i,3){
        Max = max(Max,dp[n-1][i]);
    }
    cout<<Max<<endl;
}
int main(){
    ios_base::sync_with_stdio(0) ;
    cin.tie(0) ; cout.tie(0) ;

    solve();
    
    return 0;
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 1005;

int n;
char buf[maxn];

int main(){
	scanf("%s", buf);
	n = strlen(buf);
	if(buf[n - 1] == 's')
		printf("%ses\n", buf);
	else
		printf("%ss\n", buf);
	return 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

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

char mp[6][6];

int main() {
  int h,w,k;cin>>h>>w>>k;
  rep(i,h)rep(j,w){
    char c;cin>>c;
    mp[i][j]=c;
  }
  int ans=0;
  // 12ビットのビット列をすべて列挙する
  for (int tmp = 0; tmp < (1 << (h+w)); tmp++) {
    bitset<12> s(tmp);
    int cnt=0;
    rep(i,h)rep(j,w){
      if(s.test(i)||s.test(j+h))continue;
      if(mp[i][j]=='#')cnt++;
    }
    if(cnt==k)ans++;
  }
  cout<<ans;
}

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

using namespace std;
using ll = long long;

ll rec(ll x) {
  if(x == 1) return 1;
  return 1LL + 2LL * rec(x / 2);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n; cin >> n;
  cout << rec(n) << '\n';
  return 0;
}


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

int main() {
  int N, K; cin >> N >> K;
  if (K == 0) { cout << (long long)N * (long long)N << endl; return 0; }
  long long ans = 0;
  for (int b = K + 1; b <= N; b++) {
    ans += (N / b) * (b - K) + max(N % b - K + 1, 0);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace ITP1_10_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] data = input.Split(' ');
            int a = int.Parse(data[0]);
            int b = int.Parse(data[1]);
            int θ = int.Parse(data[2]);

            double sin = Math.Sin(θ*(Math.PI/180));
            double cos = Math.Cos(θ*(Math.PI/180));

            double S = a * b * sin / 2;

            double a2 = Math.Pow(a, 2);
            double b2 = Math.Pow(b, 2);

            double root = Math.Sqrt(a2 + b2 - 2 * a * b * cos);

            double L = a + b + root;

            double h = b * sin;

            Console.WriteLine("{0:F8}", S);
            Console.WriteLine("{0:F8}", L);
            Console.WriteLine("{0:F8}", h);
        }
    }
}



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

#define H 1401
#define W 1401

int A[H+1][W+1];

int getLargestSquare(int h, int w) {
    int largest = 0;
    int s[H+1][W+1];
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (A[i][j] == 1) {
                s[i][j] = 0;
            } else {
                int minS = min(s[i - 1][j], s[i - 1][j - 1]);
                minS = min(minS, s[i][j - 1]);
                s[i][j] = minS + 1;
                if (s[i][j] > largest) {
                    largest = s[i][j];
                }
            }
        }
    }

    return largest * largest;
}

int main() {
    int h, w;
    cin >> h >> w;

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

    for (int i = 0; i < h+1; i++) A[i][0] = 0;
    for (int j = 0; j < w+1; j++) A[0][j] = 0;

    cout << getLargestSquare(h, w) << endl;

    return 0;
}


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

template <class T> void add(T &a, T b) { a = (a + b) % MOD; }
ll dp[10005][2][105];

int main() {
  string K;
  int D;
  cin >> K >> D;
  int N = K.size();
  dp[0][0][0] = 1;
  rep(i, N) rep(j, 2) rep(k, D) {
    int x = j ? 9 : K[i] - '0';
    rep(d, x + 1) add(dp[i + 1][j || d < x][(k + d) % D], dp[i][j][k]);
  }
  ll ans = dp[N][0][0] + dp[N][1][0] - 1;
  if (ans < 0)
    ans += MOD;
  ans %= MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using mint = modint998244353;
//using mint = modint1000000007;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)



vector<mint> ten;
vector<mint> one;


struct S {
    mint val;
    int len;
};

S op(S sl,S sr){
    return {sl.val * ten[sr.len] + sr.val , sl.len + sr.len};
}

S e(){
    return {0,0};
}

using F = int;

S mapping(F f,S s){
    if(f == -1)return s;
    return {f * one[s.len],s.len};
}

F composition(F f,F g){
    if(f == -1)return g;
    return f;
}

F id(){
    return -1;
}


int main() {
    int N,Q;cin >> N >> Q;
    ten.resize(N+1,0);
    one.resize(N+1,0);
    ten[0] = 1;

    rep(i,N)ten[i+1] = ten[i] * 10;
    rep(i,N)one[i+1] = one[i] + ten[i];

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<S>(N,{1,1}));

    rep(_,Q){
        int l,r,d;cin >> l >> r >> d;
        l--;
        seg.apply(l,r,d);

        cout << seg.all_prod().val.val() << endl;
    }
}

Measured memory_bytes: 11444
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() int {
	sc.Scan()
	data, _ := strconv.Atoi(sc.Text())
	return data
}

func main() {
	args := []int{nextLine(), nextLine(), nextLine(), nextLine(), nextLine()}
	arglen := len(args)
	k := nextLine()

	answer(args[arglen-1]-args[0] <= k)
}

func answer(correct bool) {
	if correct {
		fmt.Print("Yay!")
	} else {
		fmt.Print(":(")
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const ll MOD = 998244353;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> il(n, 0);
    vector<ll> d(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> d[i];
        if (i == 0 && d[i] != 0)
        {
            cout << "0";
            return 0;
        }
        ++il[d[i]];
    }
    sort(d.begin(), d.end());
    if (il[0] != 1)
    {
        cout << "0";
        return 0;
    }
    for (int i = 1; i < n; ++i)
    {
        if (!(d[i] == d[i - 1] || d[i] == d[i - 1] + 1))
        {
            cout << "0";
            return 0;
        }
    }
    ll odp = 1;
    for (int i = 2; i < n; ++i)
        if (il[i] != 0)
            for (int j = 0; j < il[i]; ++j)
                odp = (odp * il[i - 1]) % MOD;
    cout << odp;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class _insertionSort {

        // Default Constructor
        public void _insetrionSort() {
        }

        // sort method :: sort given array using insertion Sort
        public static void sort(int[] _A, int _n) {
                for (int i = 1; i < _n; ++i) {

                        // print(_A);
                        int tmp = _A[i];
                        int j = i - 1;
                        while (j >= 0 && _A[j] > tmp) {
                                _A[j + 1] = _A[j];
                                --j;
                        }
                        _A[j + 1] = tmp;
                        print(_A);
                        // System.out.println("i = " + i);
                }

        }

        // print method :: print array
        public static void print(int[] _A) {
                for (int i = 0; i < _A.length; ++i) {
                        System.out.print(_A[i]);
                        if (i != _A.length - 1)
                                System.out.print(" ");
                }
                System.out.println();
        }

}
public class Main {

        public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                ////////////////////////////////////
                int n = 0;
                int[] A;

                n = sc.nextInt();
                sc.nextLine();
                A = new int[n];
                for (int i = 0; i < n; ++i)
                        A[i] = sc.nextInt();

                _insertionSort.print(A);
                _insertionSort.sort(A, n);

                ////////////////////////////////////
                sc.close();
        }

}

Measured memory_bytes: 33692
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    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 COM(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;
}
signed main(void){
    int n, key; cin>>n;
    vector <int> a(n+1); 
    vector <bool>  num(100010) ;
    COMinit();
    int r=0, l=0;
    rep(i, n+1) {cin>>a[i]; if(num[a[i]]) key = a[i]; else num[a[i]] = true; }
    while(a[l] != key) l++;
    int x = n;
    while(a[x] != key) r++, x--;
    
    for(int i=1;i<=n+1;i++){
        int ans1 = COM(n+1, i), ans2 = COM(r+l, i-1);
        cout<<(ans1-ans2+MOD)%MOD<<endl;
    }
}


Measured memory_bytes: 13952
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		double A = in.nextDouble();
		double B = in.nextDouble();
		double ho = in.nextDouble();
		double mi = in.nextDouble();
		
		double rad = 60/mi;
		double radMi = 360/rad;
		double radiHo = (ho*30) + (30/rad);
		
		double radian = 0;
		if(radiHo > radMi){radian = radiHo - radMi;}
		else{radian = radMi - radiHo;}
		
		double result = (A*A) + (B*B) - 2*A*B* Math.cos(Math.toRadians(radian));
		double ans = Math.sqrt(result);
		System.out.println(ans);
		
		
      
	}
}

Measured memory_bytes: 37388
/*input
1
1000
*/

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

int main() {
    int n;
    cin >> n;
    double ans = 0.;
    double a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        ans += 1/a;
    }
    printf("%.6f\n", 1/ans);
}

Measured memory_bytes: 256
from operator import itemgetter

if __name__ == '__main__':
    N = int(input())
    plots = []
    for i in range(2 * N):
        x, y = map(int, input().split())
        if i < N:
            plots.append([x, y, "r"])
        else:
            plots.append([x, y, "b"])

    plots = sorted(plots, key=itemgetter(0))

    t_set = set()
    ans = 0
    for x, y, c in plots:
        if c == "r":
            t_set.add(y)
            continue

        if len(t_set) == 0 or y < min(t_set):
            continue

        ans += 1
        del_y = 0
        for tmp in t_set:
            if y > tmp > del_y:
                del_y = tmp

        t_set.remove(del_y)

    print(ans)


Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_c
# 整数の入力
N, K, Q = map(int, input().split())
L = [0] * N
for i in range(Q):
    A = int(input())
    L[A-1] += 1

for i in range(N):
    print("Yes") if (L[i] - (Q - K)) > 0 else print("No")


Measured memory_bytes: 4680
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

int main(){
    string s;cin>>s;
    if(s=="RRR") cout<<3<<endl;
    else if(s=="RRS"||s=="SRR") cout<<2<<endl;
    else if(s=="SSS") cout<<0<<endl;
    else cout<<1<<endl;
}

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

#define int long long
#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

const int MOD = 1000000007;

const int N = 200005;

int fac[N], ifac[N];

int power(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) res = 1LL * res * x % MOD;
        y >>= 1;
        x = 1LL * x * x % MOD;
    }
    return res;
}

int C(int k, int n) {
    int ans = 1;
    for (int i = 1; i <= k; i++) {
        ans = 1LL * ans * (n + 1 - i) % MOD;
        ans = ans * power(i, MOD - 2) % MOD;
    }
    return ans;
}

main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    ans = power(2, n) - 1 - C(a, n) - C(b, n);
    ans = (ans + 2 * MOD) % MOD;
    cout << ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n;
    cin>>n;
    ll a[n+1],dp[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        dp[i]=0;
    }
    a[0]=0;
    dp[1]=a[1];
    for(int i=2;i<=n;i++)
    {
        if(i>3)
        {
             
             dp[i]=min(abs(a[i]-a[i-2])+dp[i-2],abs(a[i]-a[i-1])+dp[i-1]);
        }
        else if(i==3)
        {
             dp[i]=min(abs(a[i]-a[i-2]),abs(a[i]-a[i-1])+dp[i-1]);
        }
        else
        {
            dp[i]=abs(a[i]-a[i-1]);
        }
    }
    /*for(int i=1;i<=n;i++)
    {
        cout<<dp[i]<<" ";
    }
    cout<<endl;*/
    cout<<dp[n]<<endl;
}
return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
ll a[MAX_N];

int ans;

/////////////////////////////////////////////////////////////
ll gcd(ll a, ll b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
/////////////////////////////////////////////////////////////

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
  }

  ans = gcd(a[0], a[1]);

  for (int i = 2; i < n; ++i) {
    ans = gcd(a[i], ans);
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1024