akhauriyash/Code-Regression huggingface dataset:
program palace
  implicit none
  integer              :: n, t, a, i, idx
  integer, allocatable :: h(:)
  real(8), parameter   :: coeff = 0.006d0
  real(8)              :: tmp, val
  read(*,*) n
  allocate(h(n))
  read(*,*) t, a
  read(*,*) h(:)
  idx = 1
  val = 1.0e8
  do i = 1, n
     tmp = abs(a - (t - coeff*h(i)))
     if (tmp .lt. val) then
        idx = i
        val = tmp
     end if
  end do
  deallocate(h)
  write(*,'(i0)') idx
  stop
end program palace

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<cassert>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<cmath>
#include<string>
#include<sstream>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>
#include<algorithm>

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 1000000000;

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

const int N = 100000;
int main() {
	ios_base::sync_with_stdio(0);
	int a,b,c;
	cin >> a >> b >> c;
	set<int> ans;
	ans.insert(a);
	ans.insert(b);
	ans.insert(c);
	cout << ans.size() <<endl;
  	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n)cin >> a[i];
    sort(a,a+n);
    cout << a[n-1] - a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	char a, b, ans;
	cin >> a >> b;
	if (a == 'H')
		ans = b;
	else
	{
		if (b == 'H')
			ans = 'D';
		else
			ans = 'H';
	}
	cout << ans << endl;

} 

Measured memory_bytes: 3656
#include<stdio.h>
int main(void){
  int a,b,i,ans;
  scanf("%d %d",&a,&b);
  if((a<=0&&b>=0)||(a>=0&&b<=0)){
    ans=0;
  }else if(a>b){
    i=a-b;
    if(a<0&&i%2==0){
      ans=1;
    }else{
      ans=2;
    }
  }else if(a<b){
    i=b-a;
    if(b<0&&i%2==0){
      ans=1;
    }else{
      ans=2;
    }
  }
  if(ans==0){
    printf("Zero\n");
  }else if(ans==1){
    printf("Negative\n");
  }else{
    printf("Positive\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int q, n, p;
int l, r, d;
int main(){

    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);


    cin>>l>>r>>d;
    if(d == 1){
        cout<<r-l+1;
        return 0;
    }
    if(l == r && r%d==0)
        cout<<1;
    //cout<<(r-l)/d + (((r-l)%d)?1:0);
    else
    cout<<r/d - l/d;

}


Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

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

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


int main()
{
	int s;
	int temp[4];
	cin >> s;
	temp[0] = s / 1000;
	temp[1] = (s - temp[0] *1000) / 100;
	temp[2] = (s - temp[0] * 1000 - temp[1] * 100) / 10;
	temp[3] = (s - temp[0] * 1000 - temp[1] * 100 - temp[2] * 10);

	//cout << temp[0] << ":" << temp[1] << ":" << temp[2] << ":" << temp[3] << endl;

	for(int i = 0;i<3;i++){
		if (temp[i] == temp[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
class Dice
    attr_accessor :top, :front, :right, :left, :back, :bottom

    def initialize(top, front, right, left, back, bottom)
        @top, @front, @right, @left, @back, @bottom \
            = top, front, right, left, back, bottom
    end

    def north
        @top, @front, @bottom, @back \
            = @front, @bottom, @back, @top
    end

    def east
        @top, @right, @bottom, @left \
            = @left, @top, @right, @bottom
    end

    def spin
        @front, @right, @back, @left \
            = @right, @back, @left, @front
    end

    def is_equal?(other)
        for i in 0...6
            (i % 2 == 1)? (self.north): (self.east)
            for j in 0...4
                self.spin
                if (self == other)
                    return true
                end
            end
        end

        return false
    end

    def ==(other)
        @top == other.top && @front == other.front \
            && @right == other.right && @left == other.left \
            && @back == other.back && @bottom == other.bottom
    end
end

dice01 = Dice.new(*(gets.chomp.split.map(&:to_i)))
dice02 = Dice.new(*(gets.chomp.split.map(&:to_i)))

puts ((dice01.is_equal?(dice02))? "Yes": "No")

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

using namespace std;

int main(void){
	int a, b;
	map<string, int> mp;
	scanf("%d", &a);
	for(int i = 0;i < a;++i){
		string s;
		cin >> s;
		mp[s]++;
	}
	cin >> b;
	for(int i = 0;i < b;++i){
		string s;
		cin >>s;
		mp[s]--;
	}
	int r = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        r = max(r, itr->second);    // 値を表示
    }
    cout << r << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 5005
const ll INF = 1e9 + 7;


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




int main() {

	string s;
	cin >> s;

	bool yymm = true;
	bool mmyy = true;

	int num = 0;

	for (int i = 0; i < 2; i++)
	{
		num = num * 10 + s[i] - '0';
	}

	int left = num;

	num = 0;
	for (int i = 2; i < s.size(); i++)
	{
		num = num * 10 + s[i] - '0';
	}

	int right = num;

	if (1 <= right && right <= 12 && 1 <= left && left <= 12)
	{
		cout << "AMBIGUOUS" << endl;
	}
	else
	{
		if (1 <= right && right <= 12)
		{
			cout << "YYMM" << endl;

		}
		else if (1 <= left && left <= 12)
		{
			cout << "MMYY" << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
	

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long int lint;
int main() {
	vector<int>vec(3);
	for (int ia = 0; ia < 3; ia++) {
		cin >> vec.at(ia);
	}
	sort(vec.begin(), vec.end());
	if (vec.at(0) == 5 && vec.at(1) == 5 && vec.at(2) == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}



	


Measured memory_bytes: 256
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0

for i in range(N):
    for j in range(i + 1, N):
        dist = math.sqrt(sum([(x - y) ** 2 for x, y in zip(X[i], X[j])]))
        if dist.is_integer():
            ans += 1

print(ans)

Measured memory_bytes: 3064
temp = ['dream','dreamer','erase','eraser']

Divider = list()
for n in temp:
    Divider.append(n[::-1])

TargetStr = input()[::-1]

EndFlag = True

while EndFlag:
    for n in Divider:
        if TargetStr[:len(n)] == n:
            TargetStr= TargetStr.replace(n,'',1)
            break
    else:
        EndFlag =False

if len(TargetStr) == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long>l(n);
	for (int i = 0;i < n;i++) {
		cin >> l[i];
	}

	int ans = 0;
	for (int a = 0;a < n;a++) {
		for (int b = a + 1;b < n;b++) {
			if (l[a] == l[b]) continue;
			for (int c = b + 1;c < n;c++) {
				if (l[b] == l[c] || l[a]==l[c]) continue;
				if (l[a] + l[b] > l[c] && l[b] + l[c] > l[a] && l[c] + l[a] > l[b]) {
					ans++;
				}
			}
		}
	}

	cout << ans << endl;
	

	return 0;
}

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

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    double rad=c*acos(-1)/180;
    double s=a*b*sin(rad)*0.5;
    double l=a+b+sqrt(a*a+b*b-2*a*b*cos(rad));
    double h=s*2/a;
    printf("%lf\n%lf\n%lf\n",s,l,h);
}


Measured memory_bytes: 3544
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       for(;;) {
          int s=sc.nextInt();
          if(s==0)break;
          int[] l=new int[7];
          while(s-->0) {
              int a=sc.nextInt()/10;
              l[a>6?6:a]++;
          }
          for(int i:l) {
              System.out.println(i);
          }
       }
    }
}


Measured memory_bytes: 184168
while True:
    m,min,max= list(map(int, input().split()))
    if m==0 and min==0 and max==0:
        break;
    P = []
    for i in range(m):
        P.append(int(input()))

    spaceMax=0
    spaceMaxIndex=0
    for i in range(min-1,max):

        if spaceMax <= P[i]-P[i+1]:
            spaceMax=P[i]-P[i+1]
            spaceMaxIndex=i+1
    print(spaceMaxIndex)




Measured memory_bytes: 5620
N, Y = map(int, input().split())
def calc():
    for i in range(N+1):
        for j in range(N+1-i):
            k = N - i - j
            if i * 10000 + j * 5000 + k * 1000 == Y:
                print(i, j, k)
                return 0
    print(-1, -1, -1)

calc()

Measured memory_bytes: 3060
K = int(input())

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


ans = a[K-1]
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int partition(int*,int,int);

int partition(int *A,int p,int r)
{
  int x,y,i,j; /* yは交換用 */

  x = A[r];
  i = p-1;

  for(j=p;j<r;j++){
    if(A[j] <= x) {
      i++;
      y = A[i];
      A[i] = A[j];
      A[j] = y;
    }
  }

  y = A[i+1];
  A[i+1] = A[r];
  A[r] = y;

  return i+1;
}

int main()
{
  int i,n,a;
  int A[100000];

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  a = partition(A,0,n-1);

  for(i=0;i<n;i++) {
    if(i)
      printf(" ");
    if(i == a){
      printf("[");
	}
      printf("%d",A[i]);
    if(i == a){
      printf("]");
	}
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2172
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
ac = Counter(v[::2]).most_common(2)
bc = Counter(v[1::2]).most_common(2)



if ac[0][0] != bc[0][0]:            #奇数列と偶数列の最頻数が同じ要素でない場合
    ans =  n - ac[0][1] - bc[0][1]  #全体の数から書き換える必要がない数（それぞれの最頻値）を引けばよい
else:                               #奇数列と偶数列の最頻数が同じ要素の数の場合
    if len(bc) == 1 or len(ac) == 1:#全部同じ数の場合 
        ans = n // 2
    else: #２番目の最頻数を比較し、大きいほうの列の最も多大きい最頻数ともう一方の列の2番目に大きい最頻数を書き換える
        ans = n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])
print(ans)

Measured memory_bytes: 15588
#include <bits/stdc++.h>
using namespace std;
int main(){
    char s[3];
    char t[3];
    int r=0;
    scanf("%s",s);
    scanf("%s",t);
    for(int i=0;i<3;i++){
        if(s[i]==t[i]){
            r++;
        }
    }
    printf("%d",r);
    return 0;
}

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

int main()
{
    int r, g, b;
    while(~scanf("%d%d%d", &r, &g, &b)){
        printf("%s\n", (r*100+g*10+b)%4?"NO":"YES");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int,int> pii;

vector<int> dijkstra(int s, int n, vector< vector<pii> > &G){
  int INF = 1000000000;  
  priority_queue<pii> wait;
  vector<int> results(n,INF);
  results[s] = 0;
  wait.push(make_pair(0,s));
  while(!wait.empty()){
    int nowpoint = wait.top().second;
    int nowcost = -wait.top().first;
    wait.pop();
    for(int i = 0; i < (int)G[nowpoint].size(); ++i){
      int nextcost = nowcost + G[nowpoint][i].first;
      int nextpoint = G[nowpoint][i].second;
      if(nextcost < results[nextpoint]){
	results[nextpoint] = nextcost;
	wait.push(make_pair(-nextcost,nextpoint));
      }
    }
  }
  return results;
}

int solve(int n, int l, int m, int A, int H, vector< vector<pii> > &G, vector<int> &F){
  int INF = 1000000000;
  int dp[n][n];
  for(int i = 0; i < n; ++i)
    fill(dp[i],dp[i]+n,INF);
  for(int i = 0; i < n; ++i)
    dp[i][i] = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < (int)G[i].size(); ++j){
      int to = G[i][j].second, cost = G[i][j].first;
      dp[i][to] = cost;
      dp[to][i] = cost;
    }
  }
  for(int k = 0; k < n; ++k){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
	dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  vector< vector<pii> > G2(l+2);
  if(dp[A][H] <= m){
    G2[0].push_back(make_pair(dp[A][H],1));
    G2[1].push_back(make_pair(dp[A][H],0));
  }
  for(int i = 0; i < l; ++i){
    if(dp[A][F[i]] <= m){
      G2[0].push_back(make_pair(dp[A][F[i]],i+2));
      G2[i+2].push_back(make_pair(dp[A][F[i]],0));
    }
    if(dp[H][F[i]] <= m){
      G2[1].push_back(make_pair(dp[H][F[i]],i+2));
      G2[i+2].push_back(make_pair(dp[H][F[i]],1));
    }
  }
  for(int i = 0; i < l; ++i){
    for(int j = 0; j < i; ++j){
      int s = F[i], t = F[j];
      if(dp[s][t] <= m){
	G2[i+2].push_back(make_pair(dp[s][t],j+2));
	G2[j+2].push_back(make_pair(dp[s][t],i+2));
      }
    }
  }
  vector<int> ans = dijkstra(0,n,G2);
  return ans[1];
}

int main(){
  int N, M, L, K, A, H;
  int INF = 1000000000;
  while(cin >> N >> M >> L >> K >> A >> H, N){
    vector<int> F;
    int f;
    for(int i = 0; i < L; ++i){
      cin >> f;
      F.push_back(f);
    }
    int X, Y, T;
    vector< vector< pii > > G(N);
    for(int i = 0; i < K; ++i){
      cin >> X >> Y >> T;
      if(T <= M){
	G[X].push_back(pii(T,Y));
	G[Y].push_back(pii(T,X));
      }
    }
    int ans = solve(N,L,M,A,H,G,F);
    if(ans == INF) cout << "Help!" << endl;
    else if(ans <= M) cout << ans << endl;
    else cout << M + (ans-M)*2 << endl;
  }
  return 0;
}

Measured memory_bytes: 3316
// D.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <bitset>

using namespace std;

int main(int argc, char *argv[]) {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	int left = -1, right = N;
	while (right - left > 1) {
		int mid = (left + right) / 2;
		bitset<5001> sum;
		sum[0] = 1;
		for (int i = 0; i < N; ++i) {
			if (i != mid) {
				sum |= sum << A[i];
			}
		}
		int nes = A[mid] >= K;
		for (int i = K - A[mid]; !nes && i < K; ++i) {
			if (sum[i]) {
				nes = 1;
			}
		}
		if (nes) {
			right = mid;
		} else {
			left = mid;
		}
	}
	int ans = left + 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
LL solve(LL h, LL w) {
  if (h % 3 == 0 || w % 3 == 0)
    return 0;
  else {
    LL mi = h * w;
    REPC(i, w/3,(w+1)/2) {
      LL sa = h * i;
      LL sb = h / 2 * (w - i);
      LL sc = (h + 1) / 2 * (w - i);
      LL nmi = max({sa, sb, sc}) - min({sa, sb, sc});
      mi = min(mi, nmi);

      sb = h * ((w - i) / 2);
      sc = h * ((w - i + 1) / 2);
      //DUMP(i,sa, sb, sc);
      nmi = max({sa, sb, sc}) - min({sa, sb, sc});
      mi = min(mi, nmi);
    }
    return mi;
  }
}

int main() {
  int h, w;
  cin >> h >> w;
  cout << min(solve(h, w), solve(w, h)) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

ans = [0 for i in range(n+1)]
for i in range(n,0,-1):
    s = 0
    for j in range(i,n+1,i): s += ans[j]
    if (s - a[i-1])%2 == 0: pass
    else: ans[i] = 1

print(sum(ans))
anss = []
for i in range(n+1):
    if ans[i] == 1: anss.append(i)
print(*anss)




Measured memory_bytes: 14140
package main

import "fmt"

// ABC163D - Sum of Large Numbers (解説提出)
// https://atcoder.jp/contests/abc163/tasks/abc163_d

// MOD is asssupmed to be a prime number 10^9+7 in this library
const MOD = int(1e9) + 7

func madd(a, b int) int {
	return (a + b) % MOD
}
func msub(a, b int) int {
	return (a + MOD - b) % MOD
}
func mmul(a, b int) int {
	return a % MOD * b % MOD % MOD
}
func mdiv(a, b int) int {
	return mmul(a, mpow(b, MOD-2))
}

func mpow(b, n int) int {
	// O(logN)で b^N (% MOD)が求められる
	if n == 0 {
		return 1
	}
	r := mpow(b, n/2)
	r = mmul(r, r) // r = r % MOD * r % MOD
	if n%2 == 1 {
		r = mmul(r, b) // r = r % MOD * b % MOD
	}
	return r
}

func mcmb(n, a int) int {
	// nは大きくてもよい。計算量はO(a)なので、aは10^7程度まで
	if n-a < a {
		a = n - a
	}
	p, q := 1, 1
	for i := 0; i < a; i++ {
		p = mmul(p, n-i) // p = p % MOD * (n-i) % MOD
	}
	for i := 1; i <= a; i++ {
		q = mmul(q, i) // q = q % MOD * i % MOD
	}
	return mdiv(p, q)
}

func sum(l, r int) int {
	return (l + r) * (r - l + 1) / 2
}

func main() {
	var N, K, ans int
	fmt.Scan(&N, &K)
	for i := K; i <= N+1; i++ {
		minx := sum(0, i-1)            // 小さい方からi個選んだ場合(最小値)
		maxx := sum(N-i+1, N)          // 大きい方からi個選んだ場合(最大値)
		t := madd(msub(maxx, minx), 1) // N+1個の中からi個選んだ場合の個数
		ans = madd(ans, t)
	}
	fmt.Println(ans)
}


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


int main () {
  int n,m;
  cin>>n>>m;
  map<int,int>h;
  vector<int>mh(n);
  for(int i=0;i<n;i++){
    int v;
    cin>>v;
    h[i] = v;
    mh.at(i) = 1;
  }

  for (int i=0;i<m;i++){
    int a,b;
    cin >>a>>b;
    if(h.at(a-1) >= h.at(b-1))mh.at(b-1) =0;
    if(h.at(b-1) >= h.at(a-1))mh.at(a-1) =0;
  }
  int cnt =0;
  for(int i=0;i<n;i++){
    cnt += mh.at(i);
  }

  cout<<cnt<<endl;

return 0;
}

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

int main(){
  
  int n;
  cin>>n;
  int a[n+1] , b[n+2];
  for(int i = 1 ; i <= n ; ++i)
    cin>>a[i] , b[a[i]] = i;
                  
   for(int i = 1 ; i <= n ; ++i)
                  cout<<b[i]<<" ";
    cout<<endl;
  
}

Measured memory_bytes: 1536
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
double PI = 3.1415926;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double R;
    cin >> R;
    print(2*R*PI);
    

}

Measured memory_bytes: 3796
X = input().split()
N = int(X[0])
M = int(X[1])
Y = input().split()
Z = []
sum = 0
for i in range(N):
    Z.append(int(Y[i]))
    sum = sum + Z[i]
count = 0
for i in range(N):
    if Z[i] >= sum/(4*M):
        count = count + 1
if count >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    int A, B, C, D;
    string result;
    cin >> A >> B >> C >> D;
    int E, F, G;
    E = A - B;
    F = B - C;
    G = A - C;
    E = abs(E);
    F = abs(F);
    G = abs(G);

    if((D >= E) && (D >= F)) {
        result = "Yes";
    } else if (D >=G){
        result = "Yes";
    } else {
        result = "No";
    }
    cout << result << endl;

}


Measured memory_bytes: 256
a = list(map(int, input().split()))
ans = 0
for i in range(a[0], a[1]+1):
    t = str(i)
    flag = True
    for j in range(len(t)//2):
        if t[j]!=t[len(t)-1-j]:
            flag = False
    ans += 1 if flag else 0
print(ans)


Measured memory_bytes: 3060
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10 , inf = 1<<30;
int n , m;
pii seg[N];

int add[N << 2] , mx[N << 2];
void Add(int c,int l,int r,int L,int R,int x){
    if(L<=l&&r<=R) add[c]+=x,mx[c]+=x;
    else {
        int m=(l+r)>>1;
        if(L<=m) Add(c<<1,l,m,L,R,x);
        if(R>m) Add(c<<1|1,m+1,r,L,R,x);
        mx[c]=max(mx[c<<1],mx[c<<1|1])+add[c];
    }
}
int query(int c,int l,int r,int L,int R){
    if(L<=l&&r<=R) return mx[c];
    else {
        int m=(l+r)>>1;
        int res=-inf;
        if(L<=m) res=max(res,query(c<<1,l,m,L,R));
        if(R>m) res=max(res,query(c<<1|1,m+1,r,L,R));
        return res+add[c];
    }
}


int main(){
    scanf("%d%d",&n,&m);
    rep(i,0,n) scanf("%d%d",&seg[i].fi,&seg[i].se);
    sort(seg,seg+n);
    int ans=max(0,n-m);
    int c=0;
    rep(i,0,m+1) Add(1,0,m+1,i,i,-(m+1-i));
    rep(s,0,m+1) {
        while(c<n&&seg[c].fi<=s){
            Add(1,0,m+1,seg[c].fi+1,seg[c].se,1);
            ++c;
        }
        ans=max(ans,query(1,0,m+1,s+1,m+1)-s);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef pair<int, int> pii;
const int N = 1003, dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
int n, m, front, rear, ans;
struct Node {
	int x, y, dep;
} q[N * N];
bool vis[N][N];
char str[N];
int main(){
	scanf("%d%d", &n, &m);
	for(Rint i = 1;i <= n;i ++){
		scanf("%s", str + 1);
		for(Rint j = 1;j <= m;j ++)
			if(str[j] == '#'){
				vis[i][j] = true;
				q[rear ++] = (Node){i, j, 0};
			}
	}
	while(front < rear){
		Node now = q[front ++];
		ans = max(now.dep, ans);
		for(Rint i = 0;i < 4;i ++){
			int nx = now.x + dx[i], ny = now.y + dy[i];
			if(nx >= 1 && nx <= n && ny >= 1 && ny <= m && !vis[nx][ny]){
				q[rear ++] = (Node){nx, ny, now.dep + 1};
				vis[nx][ny] = true;
			}
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 12928
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;


int n, m, q, ans;
int a[60], b[60], c[60], d[60];
int A[15];
queue<string> que;

int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }
  
  que.push("1");
  while(que.size()) {
    string s = que.front();
    que.pop();
    int len = s.length();
    if (len == n) {
      for (int i = 0; i < n; i++) {
        A[i] = s[i] - '0';
      }
      int sm = 0;
      for (int i = 0; i < q; i++) {
        if (A[b[i]] - A[a[i]] == c[i]) {
          sm += d[i];
        }
      }
      ans = max(ans, sm);
      continue;
    }
    for (int i = s[len-1] - '0'; i <= m; i++) {
      que.push(s+char('0'+i));
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4768
n, m = gets.split(" ").map(&:to_f)
votes = gets.split(" ").map(&:to_f)

sum = votes.inject(:+)

count = 0
votes.each do |vote|
  count += 1 if vote >= (1 / (4 * m) * sum)
end

puts count >= m ? "Yes" : "No" 


Measured memory_bytes: 1788
class Dice:

    __dSNWE ={'S': (4, 0, 2, 3, 5, 1) , 'N': (1, 5, 2, 3, 0, 4),
             'W': (2, 1, 5, 0, 4, 3), 'E': (3, 1, 0, 5, 4, 2)}

    def __init__(self, v): # v [Top, Front, Right, Left, Back, Bottom ]
        self.view = v


    def rotateDice(self, direction):
        self.view = [self.view[i] for i in Dice.__dSNWE[direction]]

d1 = Dice(list(map(int, input().split())))
for d in input():
    d1.rotateDice(d)
print(d1.view[0])

Measured memory_bytes: 7800
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> l,r;
    for(int i = 0;i < m;i++)
    {
        int a,b;
        cin >> a >> b;
        l.push_back(a);
        r.push_back(b);
    }
    sort(l.begin(),l.end(),greater<int>());
    sort(r.begin(),r.end());
    int ans = r.at(0) - l.at(0) + 1;
    if(ans >= 0)
    {
        cout << ans;
    }
    else
    {
        cout << "0";
    }
    
    return 0;
}

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


ll C(int n, int k) {
    vector<ll> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (int i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%MOD;
        inv[i]=MOD-((MOD/i)*inv[MOD%i])%MOD;
        invf[i]=(inv[i]*invf[i-1])%MOD;
    }
    ll cmb=f[n]*(invf[k]*invf[n-k]%MOD)%MOD;
    if (n>=k) return cmb;
    else return 0;
}
ll res(int p,int q){
  ll ret=1;
  int n=p+q;
  int r=min(p,q);
  
  return C(n,r);
}
  

    
  


int main(){
  int x,y;cin>>x>>y;
  int p=2*y-x,q=2*x-y;
  if(p>=0 && q>=0 && p%3==0 && q%3==0){
    p/=3;q/=3;
    cout<<res(p,q)<<endl;
  }
  else
    cout<<0;
  //cout<<binomial(13,4);
  
}

Measured memory_bytes: 15872
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int i,j,k,h,w,min,ans,mat[700][700],max[700][700];
char c;

int main(){
	while(scanf("%d %d",&h,&w)*h*w){
		for(i=0;i<h;i++){
			k=0;
			scanf("\n");
			for(j=0;j<w;j++){
				scanf("%c",&c);
				if(c=='.')k++; else k=0;
				mat[i][j]=k;
			}
		}

		ans=0;
		for(j=w-1;j>=0;j--){
			for(k=h-1;k>=0;k--){
				min=mat[k][j];
				if(min*(h-k)<ans)continue;
				for(i=1;i+k<h;i++){
					if(min>mat[i+k][j])min=mat[i+k][j];
					if(min==0)break;
					if(min*(i+1)>ans)ans=min*(i+1);
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<string, int> cnt;
    rep(i, n) {
        string s;
        cin >> s;
        cnt[s]++;
    }

    for (string s : { "AC", "WA", "TLE", "RE"}) {
        cout << s << " x " << cnt[s] << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=20000050;

int main()
{
	int n,x,t;
	cin>>n>>x>>t;
	int s=n/x;
	if(n%x!=0)
	  s++;
	cout<<(s*t)<<endl;   
}


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

int main(){
    double xa, ya, xb, yb, xc, yc, xd, yd;
    while( cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd ){
        bool ni = (xb < xc || xa > xd || yb < yc || ya > yd);
        if( !ni ) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	vl a(n),b(n);
	rep(i,n) cin >> a[i] >> b[i];
	ll ans = 0;
	ll mn = inf;
	rep(i,n){
		ans += a[i];
		if(a[i] > b[i]) chmin(mn,b[i]);
	}
	if(mn != inf) cout << ans - mn << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

ld a[1001], ans;
int n;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i], ans += (1.0 / a[i]);
   cout << fixed << setprecision (5) << 1.0 / ans;
}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


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

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

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



int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int d, g;
	cin >> d >>g;
	VI p(d), c(d);
	rep(i, d) cin >>p[i] >>c[i];
	int ans = 1<<29;
	rep(i, 1<<d){
		int pt =0, cx =0;
		rep(j, d) if(i>>j &1){
			pt +=c[j];
			pt += (j+1)* p[j] * 100;
			cx += p[j];
		}
		
		if(pt < g){
			repr(j, d-1, 0)if(!(i>>j &1)){
				if(g > pt + (j+1)*100*p[j]){
					pt += (j+1)*100*p[j]; cx += p[j];
				}else{
					int z = (g-pt + (j+1)*100 -1) / ((j+1)*100);
					pt += (j+1)*100*z; cx += z;
				}
				if(pt >= g) break;
			}
		}
		ans = min(ans, cx);
		
	}
	cout << ans <<"\n";
	return 0;
}


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

int main() {
  int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int x, y;
  cin >> x >> y;
  if (a[x] == a[y])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define fix  cout<<std::fixed;
#define mk make_pair
#define N 100005
#define mod 1000000007
#define time  cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
#define IOS        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
    ll k ;string s;
    cin>>k>>s;
    if(s.length()<=k)cout<<s;
    else
    {
        for(int i=0;i<k;i++)cout<<s[i];
            cout<<"...";
    }
    }

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mod 1000000007
#define setpres(x) fixed<<setprecision(x)
using namespace std;
int32_t main()
{
    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int x;
        cin>>x;
        cout<<1-x;
    }
}


Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
using namespace std;
int beg[100100],nex[400100],tto[400100],e;
void putin(int s,int t){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
}
bool vis[100100];
int c[100100];
int dfs(int u){
	if(vis[u]) return 0;
	vis[u]=1;
	int res=1;
	for(int i=beg[u];i;i=nex[i])
		res+=dfs(tto[i]);
	return res;
}
bool color(int u,int co){
	c[u]=co;
	for(int i=beg[u];i;i=nex[i]){
		if(!c[tto[i]]){
			if(!color(tto[i],3-c[u]))
				return 0;
		}
		if(c[tto[i]]==c[u]) return 0;
	}
	return 1;
}
long long getsum(long long x){
	return x*(x-1)/2;
}
int main(){
//	freopen("C.in","r",stdin);
//	freopen("C.out","w",stdout);
	int n,m;
	scanf("%d%d",&n,&m);
	int s,t;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&s,&t);
		putin(s,t);
		putin(t,s);
	}
	int cnta=0,cntb=0,cntc=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			if(dfs(i)==1)
				cntc++;
			else{
				if(color(i,1))
					cnta++;
				else
					cntb++;
			}
			
		}
	}
	long long ans=2*cnta+cntb;
	ans=ans+getsum(cnta)*4+getsum(cntb)*2;
	ans=ans+cnta*(long long)cntb*2;
	ans=ans+cntc*(long long)n*2-cntc*(long long)cntc;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6144
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
x, y, z = 0, 0, 0
for i in range(n) :
  if p[i] <= a : x = x + 1
  elif p[i] <= b : y = y + 1
  else : z = z + 1
if y > z : y, z = z, y
if x > y : x, y = y, x
print(x)

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>

using namespace std;

typedef struct{
  int to;
  int cost;
}edge;
typedef pair<int,int> P;

const int MAX = 101;
const int INF = (1<<25);
vector<edge> V[MAX];
int d[MAX];
int n,k;

void solve(int from){
  fill(d,d+MAX,INF);
  priority_queue<P, vector<P> ,greater<P> > Q;
  d[from] = 0;
  Q.push(P(0,from));
  while(!Q.empty()){
    P p = Q.top();
    Q.pop();
    if(d[p.second] < p.first) continue;
    for(int i = 0; i < V[p.second].size(); i++){
      edge e = V[p.second][i];
      if(d[e.to] > d[p.second] + e.cost){
	d[e.to] = d[p.second]+e.cost;
	Q.push(P(d[e.to],e.to));
      }
    }
  }
}

void init(){
  //fill(d,d+MAX,INF);
  for(int i = 0; i <= n; i++) V[i].clear();
}
int main(){

  while(cin >> n >> k &&n+k){
    init();
    for(int i = 0; i < k; i++){
      int in;
      cin >> in;
      if(in){
	int from,to,cost;
	edge info;
	cin >> from >> to >> cost;
	info.cost = cost;
	info.to = to;
	V[from].push_back(info);
	info.to = from;
	V[to].push_back(info);
      }else{
	int from,to;
	cin >> from >> to;
	solve(from);
	if(d[to] == INF) cout << "-1" << endl;
	else cout << d[to] << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 940
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int a[3][3];
    bool appear[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++) cin>>a[i][j];
    }
    int n; cin>>n;
    int b[n];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<3;i++){
        for(int j=0;j<n;j++){
            appear[i][j] = false;
            for(int k=0;k<n;k++){
                if(a[i][j]==b[k]) appear[i][j] =true;
            }
        }
    }
    string ans="No";
    for(int i=0;i<3;i++){
        if(appear[i][0] && appear[i][1] && appear[i][2]) ans="Yes";
    }
    for(int i=0;i<3;i++){
        if(appear[0][i]&&appear[1][i]&&appear[2][i]) ans="Yes";
    }
    if(appear[0][0] && appear[1][1]&&appear[2][2]) ans="Yes";
    if(appear[0][2]&&appear[1][1]&&appear[2][0]) ans="Yes";
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c,k=input().split()

a=int(a)
b=int(b)
c=int(c)
k=int(k)

if(k==a+b+c):
    print(a-c)
else:
    if(k<=a):
        print(k)
    elif(k-a<b):
        print(a)
    else:
        print(a-(k-a-b))


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll n;
  cin >> n;
  vector<string> a(n);
  rep(i, n)
    cin >> a.at(i);
  
  ll m;
  cin >> m;
  vector<string> b(m);
  rep(i, m)
    cin >> b.at(i);

  ll u,d,score;
  score = 0;
  
  rep(i, n){
    u=0;d=0;
    rep(j, n){
      if(a.at(i) == a.at(j))
        u++;
    }
    rep(j, m){
      if(a.at(i) == b.at(j))
        d++;
    }
    if(score < u-d)
    score = u - d;
  }
  rep(i, m){
    u=0;d=0;
    rep(j, n){
      if(b.at(i) == a.at(j))
        u++;
    }
    rep(j, m){
      if(b.at(i) == b.at(j))
        d++;
    }
    if(score < u-d)
    score = u - d;
  }
  cout << score << endl;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;


int N, M;
int L[100010];
int R[100010];
int sums[100010];

int main(){

    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> L[i] >> R[i];
        sums[R[i]+1]--;
        sums[L[i]]++;
    }
    int tot = 0;
    for(int i = 0; i < 100005; i++){
        if(sums[i] == M){
            tot++;
        }
        sums[i + 1] += sums[i];
    }
    cout << tot << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
using namespace std;
int gcd(int a, int b) {
  if (a == 0 || b == 0) return 0;
  while (a != b)
    if (a > b) a -= b;
    else b -= a;
  return a;
}
int main() {
  int n, a, b = 1;
  cin >> n;
  while (n--) {
    cin >> a;
    b = (a * b) / gcd(a, b);
  }
  cout << b << endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;

int main(){
  	int N;
  	cin >> N;
  	ll A[N];
  	for(int i=0;i<N;i++){
  		cin >> A[i];
  	}

  	ll sum = 0;
  	int sgn = 1;
  	for(int i=0;i<N;i++){
  		sum += sgn*A[i];
  		sgn *= -1;
  	}

  	for(int i=0;i<N;i++){
  		cout << sum << " ";
  		sum -= A[i];
  		sum *= -1;
  		sum += A[i];
  	}
  	cout <<endl;
    
  	return 0;
}


Measured memory_bytes: 2048
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    ll x;
    cin>>x;
    if(x) cout<<"0";
    else cout<<"1";
}

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

class Main
{


	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int value = scan.nextInt();
		int a = value;
		value = scan.nextInt();
		int b = value;
		value = scan.nextInt();
		int c = value;
		
		int[] values = {a,b,c};
		Arrays.sort(values);
		
		System.out.println(String.format("%s %s %s", values[0],values[1],values[2]));
	}

}



Measured memory_bytes: 26408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2])
        cout<<"Yes"<<endl;
    else if(s[2]==s[1] && s[3]==s[2])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
"""貪欲法
"""
def solve():
    N, x = list(map(int, input().split()))
    A = list(map(int, input().split()))

    ans = 0

    total = A[1] + A[0]
    if total > x:
        diff = min(total-x, A[1])
        A[1] -= diff
        ans += diff

    total = A[1] + A[0]
    if total > x:
        diff = total - x
        A[0] -= diff
        ans += diff

    for i in range(2, N):
        total = A[i] + A[i-1]

        if total > x:
            diff = total - x
            A[i] -= diff
            ans += diff
    
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 14812
/*
?????????: Elementary Number Theory - Extended Euclid Algorithm
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_E&lang=jp

19:01:55 ????????????????????§?????????????????¨???????????¨??§??¨?????????????§£???1?????????????????°????????????????????????
19:07:21 ???????§£?????????????????°?????????????????????????°???§?????\????????????
*/

#include <cassert>
#include <iostream>
#include <utility>
using namespace std;
typedef pair<int,int> pii;
pii getOneAns(int a, int b);
int main()
{
	int a,b;
	cin >> a >> b;
	pii p = getOneAns(a,b);
	cout << p.first << " " << p.second << endl;
}

/*
pii(c,d) = getOneAns(a,b)  -------> a*c + b*d = gcd(a,b) 
*/
pii getOneAns(int a, int b)
{
	assert(a>=0 && b>=0);
	if(a < b) { 
		pii p = getOneAns(b,a);
		return pii(p.second, p.first);
	}
	if(b == 0) return pii(1,0);

	pii p = getOneAns(b, a%b);
	int c = p.first, d = p.second; // b*c + (a%b)*d = gcd(a,b) 
	int e = a/b; // a - b*e = a%b
	// b * c  +  (a - b*e) * d = gcd(a,b)
	// b * (c-d*e)  +  a * d = gcd(a,b)
	return pii(d, c-d*e);
}

Measured memory_bytes: 3080
import sys

read=sys.stdin.read

def main():
  q,*lr=map(int,read().split())
  n=10**5
  ansl=[]
  sieve=[1]*(n+1)
  sieve[0],sieve[1]=0,0
  for i in range(2,n):
    if sieve[i]:
      sieve[2*i::i]=[0 for _ in range(2*i,n+1,i)]
  ans=[0]*(n+1)
  for i in range(3,n):
    if sieve[i]==1 and sieve[(i+1)//2]==1:
      ans[i]=ans[i-1]+1
    else:
      ans[i]=ans[i-1]
  for l,r in zip(*[iter(lr)]*2):
    print(ans[r]-ans[l-1])

if __name__=='__main__':
  main()


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)

#define F first
#define S second

typedef pair<li, li> PI;
map<PI, li> cnt;

int main(void)
{
	string n;
	cin>>n;
	li res=0;
	for(auto c : n){
		res += c-'0';
	}
	cout<<(res%9==0 ? "Yes":"No")<<endl;

	return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int n,m,p[20][20],ans=0;
bool k[20],pp[20];
void dfs(int u){
	if(u>n){
		for(int i=1;i<=m;i++){
			int tmp=0;
			for(int j=1;j<=p[i][0];j++) tmp+=k[p[i][j]];
			if(tmp%2!=pp[i]) return;
		}
		ans++;
		return;
	}
	k[u]=0;
	dfs(u+1);
	k[u]=1;
	dfs(u+1);
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&p[i][0]);
		for(int j=1;j<=p[i][0];j++) scanf("%d",&p[i][j]);
	}
	for(int i=1;i<=m;i++) scanf("%d",&pp[i]);
	dfs(1);
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N;
long long mod = 1e9 + 7, dp[1<<17];
bool out[1<<17];
int main() {
	int M;
    cin >> N >> M;
	for(int i=0; i<M; i++) {
		int a;
        cin >> a;
        out[a] = 1;
	}
	dp[0] = 1;
	for(int i=0; i<N; i++) {
		if(!out[i+1]) (dp[i+1]+=dp[i]) %= mod;
		if(!out[i+2]) (dp[i+2]+=dp[i]) %= mod;
	}
	cout << dp[N] << endl;
}


Measured memory_bytes: 1152
import kotlin.math.abs

fun main(args: Array<String>) {
    val (X, N) = readLine()!!.split(" ").map{it.toInt()}
    if(N < 1) {
      println(X)
      return
    }
    val numbers = readLine()!!.split(" ").map { it.toInt() }.sorted()
  
    val lastNum = numbers.last() + 1
    fun absCalc(counter: Int, minNum: Int, nums: List<Int> = numbers, target: Int = X): Int {
        val newMinNum = if (!nums.contains(counter) && abs(target - counter) <= abs(target - minNum)) {
            counter
        } else minNum

        return if (numbers.first() - 1 > counter) newMinNum else absCalc(counter - 1, newMinNum)
    }
    println(absCalc(lastNum, lastNum))
}


Measured memory_bytes: 38944