akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

ll dp[20][2][2][2][2][2];

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string N;
    in1(N);

    dp[0][0][0][0][0][0] = 1;

    rep(i, N.size())
    {
        int d = N[i] - '0';

        rep(smaller, 2)
        {
            rep(z, 2) rep(f3, 2) rep(f5, 2) rep(f7, 2)
            {
                for (int j = 0; j <= (smaller ? 9 : d); j++)
                {
                    if ((z == 0 && j == 0) || j == 3 || j == 5 || j == 7)
                    {
                        dp[i + 1][smaller || j < d][z || j != 0][f3 || j == 3][f5 || j == 5][f7 || j == 7]
                            += dp[i][smaller][z][f3][f5][f7];
                    }
                }
            }
        }
    }

    outl(dp[N.size()][0][0][1][1][1] + dp[N.size()][1][0][1][1][1] + dp[N.size()][0][1][1][1][1] + dp[N.size()][1][1][1][1][1]);

    return 0;
}


Measured memory_bytes: 3660
import java.util.*;
import java.util.TreeMap;
import java.util.Map;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();

        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            if(map.containsKey(A[i])){
                map.put(A[i], map.get(A[i]) + 1);
            }
            else{
                map.put(A[i], 1);
            }
        }
        ArrayList<Integer> list = new ArrayList<Integer>();
        for(int key: map.keySet()){
            list.add(map.get(key));
        }

        Collections.sort(list);
        if(list.size()<=K){
            System.out.println(0);
            return;
        }
        int ans = 0;
        for(int i=0; i<list.size()-K; i++){
            ans += list.get(i);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 101924
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll,int> pii;
int N,Q;
ll cnts[1000001];
int main(){
  cin>>N>>Q;
  set<pii> st;
  for(int i=0;i<Q;i++){
    int a,v;
    cin>>a>>v;
    pii p=make_pair(-cnts[a],a);
    st.erase(p);
    cnts[a]+=v;
    st.insert(make_pair(-cnts[a],a));
    pii ans=*st.begin();
    cout<<ans.second<<" "<<-ans.first<<endl;
  }

  return 0;
}

Measured memory_bytes: 14952
#include <stdio.h>

int i, t, y = 1, d[10000] = {1};
long long r;
char s[200001];

int main(n, p) {
  scanf("%d%d%s", &n, &p, s + 1);
  if (10 % p == 0) {
    while(i++<n) {
      if((s[i] - '0') % p == 0)
        r += i;
    }
  }
  else {
    for(; n; n--) {
      t = (t + (s[n] - '0') * y) % p;
      d[t]++;
      y = y * 10 % p;
    }
    for(i = 0; i < p; i++)
      r += (long long) d[i] * (d[i] - 1);
    r /= 2;
  }
  printf("%lld\n", r);
  return 0;
}

Measured memory_bytes: 384
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

mod = 1000000007

"""
# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    S = sys.stdin.readline().rstrip()
    T = sys.stdin.readline().rstrip()

    for _ in range(len(S)):
        if S == T:
            print("Yes")
            exit()
        S = S[1::] + S[0]
    print("No")

Measured memory_bytes: 5328
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define int long long
#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

signed main() {
	string S;
	cin >> S;

	int len = S.length();

	int ans = 0;
	int sum = 0;
	for (int mask = 0;mask < (1 << (len - 1));mask++) {
		for (int i = 0;i < len;i++) {
			sum = sum*10 + (S[i] - '0');
			//cout << sum << endl;
			if ((mask & (1 << i)) || i == len - 1) {
				ans += sum;
				sum = 0;
			}
		}
	}

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

Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main(){
    int n,i,j,a=0,b=0,c ;
    cin >> n ;
    string A[n] ;
    for(i=0;i<n;i++)
        cin >> A[i] ;
    for (i=0;i<n-1;i++){
        for (c=i+1;c<n;c++) {
            if (A[i].size()==A[c].size()) {
                a=0 ;
                for (j=0;j<A[i].size();j++) {
                    if (A[i][j]==A[c][j])
                        a=a+1 ; }
                if (a==j&&a!=0&&j!=0)
                    b=1 ; } }
        if (A[i][A[i].size()-1]!=A[i+1][0])
            b=1 ; }
    if (b==1)
        cout << "No" ;
    else 
        cout << "Yes" ;
    return 0 ; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,ans=0;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin >> p.at(i);
  } 
  sort(p.begin(),p.end());
  for(int i=0; i<k; i++){
    ans += p.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    string s;
    cin >> s;
    int x = 0;
    rep(i,3) {
        if (s[i]-'0' > x) {
            if (i == 0) x = s[i]-'0';
          	else x++;
            if (i != 0) break;
        }
        else if (s[i]-'0' < x) break;
    }
    int ans = 100*x + 10*x + x;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int N,x;
    cin >> N >> x;
    
    if(x == 1 || 2*N-1 == x){
        cout << "No" << endl;
        return 0;
    }else{
        cout << "Yes" << endl;
        
        int pos = 2;
        for(int i = 0; i < (2*N-1 -3)/2; i++){
            if(pos == x)pos++;
            cout << pos << endl;
            pos++;
        }
        
        cout << 1 << endl;
        cout << x << endl;
        cout << 2*N-1 << endl;
        
        for(int i = 0; i < (2*N-1 -3)/2; i++){
            if(pos == x)pos++;
            cout << pos << endl;
            pos++;
        }
        
        
    }
}


Measured memory_bytes: 1536
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int sum = 0;
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            sum += Math.min(2 * x[i], 2 * (k - x[i]));
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    char ss;
    for(int i=0;i<3;i++){
    string s;
    cin>>s;
    if(i==1) ss=s[0];
    }
    cout<<"A"<<ss<<"C"<<endl;
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int i,j,h,w;
    scanf("%d %d",&h,&w);
    char s[h+2][w+2];
    for(i=1;i<=h;i++){
            scanf("%s",s[i]+1);
    }
    for(i=0;i<=h+1;i++){
        s[i][0]='.';
        s[i][w+1]='.';
    }
    for(i=0;i<=w+1;i++){
        s[0][i]='.';
        s[h+1][i]='.';
    }
    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
            if(s[i][j]=='#' && s[i-1][j]=='.' && s[i][j-1]=='.' && s[i+1][j]=='.' && s[i][j+1]=='.'){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 10000000001
#define MOD 1000000007
using namespace std;

bool check(ll x, ll y)
{
  if(x-y>=0)
    return true;
  return false;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,k;
  cin>>n>>k;
  ll a[n];
  for(ll i=0;i<n;i++)
  {
    cin>>a[i];
  }
  ll dp[k+1];
  dp[0]=0;
  for(ll i=1;i<=k;i++)
  {
    bool flag=0;
    for(ll j=0;j<n;j++)
    {
      if(check(i,a[j]))
      {
        flag|=(!dp[i-a[j]]);
      }
    }
    dp[i]=flag;
  }
  if(dp[k])
    cout<<"First";
  else
    cout<<"Second";
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {

        while (true)
        {

            String[] str = Console.ReadLine().Split(' ');

            char[,] ary = new char[int.Parse(str[0]), int.Parse(str[1])];

            if(int.Parse(str[0]) == 0 && int.Parse(str[1]) == 0){
                break;
            }

            for (int i = 0; i < ary.GetLength(0); i++)
            {
                for (int j = 0; j < ary.GetLength(1); j++)
                {
                    ary[i, j] = '#';
                }
            }

            for (int i = 0; i < ary.GetLength(0); i++)
            {
                for (int j = 0; j < ary.GetLength(1); j++)
                {
                    Console.Write(ary[i, j]);
                }
                Console.Write("\r\n");
            }

            Console.Write("\r\n");
        }
    }
}

Measured memory_bytes: 8916
program three_substrings
  integer, parameter :: u = 2000
  character(u) :: a, b, c
  integer :: l, m, n, x = 3*u, i, j
  logical, dimension(-5*u:5*u) :: ab = .false., ac = .false., bc = .false.
  read(*,*) a
  read(*,*) b
  read(*,*) c
  l = len_trim(a)
  m = len_trim(b)
  n = len_trim(c)
  do i = 0, l-1
    do j = 0, m-1
      if (.not.match(a(i+1:i+1),b(j+1:j+1))) ab(i-j) = .true.
    end do
  end do
  do i = 0, l-1
    do j = 0, n-1
      if (.not.match(a(i+1:i+1),c(j+1:j+1))) ac(i-j) = .true.
    end do
  end do
  do i = 0, m-1
    do j = 0, n-1
      if (.not.match(b(i+1:i+1),c(j+1:j+1))) bc(i-j) = .true.
    end do
  end do
  do i = -2*u, 2*u
    do j = -2*u, 2*u
      if (ab(i) .or. ac(j) .or. bc(j-i)) cycle
      x = min(x,max(l,m+i,n+j)-min(i,j,0))
    end do
  end do
  write(*,'(i0)') x
contains
  logical function match(s,t)
    character(1), intent(in) :: s, t
    match = s == "?" .or. t == "?" .or. s == t
  end
end program three_substrings

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

#define Darr(x)           \
    cerr << #x << " = ";  \
    for (auto i : x)      \
        cerr << i << " "; \
    cerr << "\n";
#define ar array
#define pr pair
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i = (a); (s) > 0 ? i < (b) : i > (b); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
    F_ORC(__VA_ARGS__) \
    (__VA_ARGS__)
#define EACH(x, a) for (auto &x : a)

template <class A>
void read(vt<A> &v);
template <class A, size_t S>
void read(ar<A, S> &a);
template <class T>
void read(T &x)
{
    cin >> x;
}
void read(double &d)
{
    string t;
    read(t);
    d = stod(t);
}
void read(long double &d)
{
    string t;
    read(t);
    d = stold(t);
}
template <class H, class... T>
void read(H &h, T &... t)
{
    read(h);
    read(t...);
}
template <class A>
void read(vt<A> &x)
{
    EACH(a, x)
    read(a);
}
template <class A, size_t S>
void read(array<A, S> &x)
{
    EACH(a, x)
    read(a);
}
string to_string(char c)
{
    return string(1, c);
}
string to_string(bool b)
{
    return b ? "yes" : "no";
}
string to_string(const char *s)
{
    return string(s);
}
string to_string(string s)
{
    return s;
}
string to_string(vt<bool> v)
{
    string res;
    FOR(sz(v))
    res += char('0' + v[i]);
    return res;
}

template <size_t S>
string to_string(bitset<S> b)
{
    string res;
    FOR(S)
    res += char('0' + b[i]);
    return res;
}
template <class T>
string to_string(T v)
{
    bool f = 1;
    string res;
    EACH(x, v)
    {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template <class A>
void write(A x)
{
    cout << to_string(x) << " ";
}
template <class H, class... T>
void write(const H &h, const T &... t)
{
    write(h);
    write(t...);
}
void print()
{
    cout << ("\n");
}
template <class H, class... T>
void print(const H &h, const T &... t)
{
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

void deb() { cerr << endl; }

template <typename Head, typename... Tail>
void deb(Head H, Tail... T)
{
    cerr << to_string(H) << " ";
    deb(T...);
}

using ll = long long;

pair<const int, const int> dxdy[4] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};

// Let's Code

const int MxN = (1 << 19) + 1;
ll dp[MxN][19] = {0};
ll cost[19][19];
void solve()
{
    int n,x,t;
    read(n,x,t);
    write(((n/x) + (n%x!=0))*t);

}
//

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // /freopen("output.txt", "w", stdout);
#endif

    int tc = 1;

    //UNCOMMENT FOR TEST CASE
    //cin >> tc;
    FOR(tc)
    {
        //write("Case #", i+1, ": ");
        solve();
    }
}


Measured memory_bytes: 3700
import sys
sys.setrecursionlimit(10**6)

n = int(input())
w = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

total = sum(w)
s1 = 0
s2 = total
ans = abs(s1-s2)

for i in w:
    s1 += i
    s2 -= i
    if abs(s1-s2) < ans:
        ans = abs(s1-s2)
        
print(ans)

Measured memory_bytes: 9100
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

unordered_map<long long, long long> mp;

long long dfs(long long n) {
  if(n == 1) return 1;
  auto it = mp.find(n);
  if(it == mp.end()) {
    long long ans = dfs(n / 2) * 2 + 1;
    mp[n] = ans;
    return ans;
  } else {
    return it->second;
  }
}

void Main() {
  long long h;
  cin >> h;
  cout << dfs(h) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  vector<bool> route1(N + 1);
  vector<bool> route2(N + 1);
  for (int i = 0; i <= N; i++)
  {
    route1[i] = false;
    route2[i] = false;
  }
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    if (a == 1)
      route1[b] = true;
    else if (b == N)
      route2[a] = true;
  }
  string ans = "IMPOSSIBLE";
  for (int i = 1; i <= N; i++)
  {
    if (route1[i] && route2[i])
      ans = "POSSIBLE";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=input()
S=input() 
cnt=0 
y=S.find("ABC")
if y==-1:
    print(0)
else:
    while y!=-1:
        S=S.replace(S[:y],"",1)
        S=S.replace("ABC","",1) 
        y=S.find("ABC")
        cnt+=1 
    print(cnt) 

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, M, R;
  scanf("%d %d %d", &N, &M, &R);
  vector<int> cities(R);
  for (int i = 0; i < R; ++i) { scanf("%d", &cities[i]); }
  vector<vector<int> > cost(N + 5, vector<int>(N + 5, INF));
  for (int i = 0; i < M; ++i) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    cost[a][b] = cost[b][a] = c;
  }
  for (int k = 1; k <= N; ++k) {
    cost[k][k] = 0;
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j <= N; ++j) {
        if (cost[i][k] < INF and cost[k][j] < INF) {
          cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        }
      }
    }
  }

  int ans = INF;
  sort(cities.begin(), cities.end());
  do {
    int sum = 0;
    for (int i = 0; i < R - 1; ++i) {
      sum += cost[cities[i]][cities[i + 1]];
    }
    ans = min(ans, sum);
  } while (next_permutation(cities.begin(), cities.end()));

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 384
from collections import Counter
n = int(input())
array = list(map(int,input().split()))
if len(set(array)) == 1:
    print(n//2)
    exit()
gu = []
ki = []
for i in range(n):
    if i % 2 == 0:
        gu.append(array[i])
    else:
        ki.append(array[i])
gu_c = Counter(gu)
ki_c = Counter(ki)
gu_m = gu_c.most_common()
ki_m = ki_c.most_common()
if gu_m[0][0] != ki_m[0][0]:
    print(n-(gu_m[0][1]+ki_m[0][1]))
elif gu_m[0][1] < ki_m[0][1]:
    print(n-(gu_m[1][1]+ki_m[0][1]))
elif gu_m[0][1] > ki_m[0][1]:
    print(n-(gu_m[0][1]+ki_m[1][1]))
else:
    print(n-(gu_m[0][1]+max(gu_m[1][1],ki_m[1][1])))

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define pb push_back
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<=b;i++)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define test int tc;cin>>tc;while(tc--)
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ff first
#define ss second
#define mpr make_pair
const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}



void solve()
{
    int n,k;cin>>n>>k;
    int a[n];fo(i,n)cin>>a[i];
    sort(a,a+n);
    int ans=0;
    fo(i,min(n,k))
        ans+=a[i];
    cout<<ans<<endl;
}

int main()
{
    fastio
  //  test
        solve();
}


Measured memory_bytes: 3688
while n = gets.to_i
    break if n == 0
    l = []
    n.times {
        a, b = gets.split(" ").map(&:to_i)
        l << [a, b]
    }
    l.sort_by!{|a| a[1]}
    sum = 0
    flg = false
    l.each {|v|
        sum += v[0]
        flg |= sum > v[1]
    }
    puts flg ? "No" : "Yes"
end



Measured memory_bytes: 6860
k = list(map(int, input().split()))
a = list(map(int, input().split()))
kei = sum(a)
a = sorted(a,reverse=True)
re = True
for i in range(k[1]):
  if a[i] < kei / (4*k[1]):
    re = False

if re:
  print('Yes')
else:
  print('No')

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

long long sum(long long);

int main(){

    int n;
    cin>>n;

    cout<<sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15<<endl;



    return 0;
}

long long sum(long long n){

    return n*(n+1)/2;
}

Measured memory_bytes: 3568
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string S;
	scan(N>>S);
	int kurowa[200001]={},sirowa[200001]={};
	rep(i,N){
		kurowa[i+1]=kurowa[i]+(S[i]=='#');
		sirowa[i+1]=sirowa[i]+(S[i]=='.');
	}
	int ans=INF;
	rep(i,N+1){
		ans=min(ans,kurowa[i]-kurowa[0]+sirowa[N]-sirowa[i]);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 2180
#include<bits/stdc++.h>
#define hell (int)(1e9+7)
#define int long long int
#define inf 1000000000000

using namespace std;

struct g{
    bool b[26];
};

vector <g> tree;
string str;

g merger(g l,g r){
    g ans;
    for(int i=0;i<26;i++)
        ans.b[i]=l.b[i]||r.b[i];
    return ans;
}

void build(int node,int s,int e){
    if(s==e){
        memset(tree[node].b,false,sizeof tree[node].b);
        tree[node].b[str[s]-'a']=true;
        return;
    }
    int m=(s+e)/2;
    build(node*2,s,m);
    build(node*2+1,m+1,e);
    tree[node]=merger(tree[node*2],tree[node*2+1]);
}

void update(int node,int s,int e,int id,char val){
    if(s==e){
        str[id]=val;
        memset(tree[node].b,false,sizeof tree[node].b);
        tree[node].b[val-'a']=true;
        return;
    }
    int m=(s+e)/2;
    if(s<=id&&id<=m)
        update(node*2,s,m,id,val);
    else
        update(node*2+1,m+1,e,id,val);
    tree[node]=merger(tree[node*2],tree[node*2+1]);
}

g query(int node,int s,int e,int l,int r){
    g ans;
    memset(ans.b,false,sizeof ans.b);
    if(s>e||s>r||e<l)
        return ans;
    if(l<=s&&e<=r)
        return tree[node];
    int m=(s+e)/2;
    return merger(query(node*2,s,m,l,r),query(node*2+1,m+1,e,l,r));
}

void solve(){
    int n;
    cin>>n>>str;
    tree.resize(4*n);
    build(1,0,n-1);
    int q;
    cin>>q;
    while(q--){
        int t,l,r;
        cin>>t;
        if(t==1){
            char c;
            cin>>l>>c;
            update(1,0,n-1,l-1,c);
        }
        else{
            cin>>l>>r;
            g ans=query(1,0,n-1,l-1,r-1);
            int c=0;
            for(bool x:ans.b)
                c+=x;
            cout<<c<<"\n";
        }
    }
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 51740
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 503
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int n,m;
char s[MN];
bool mp[MN][MN];
int main()
{
	n=in();m=in();
	for (int i=0;i<n;++i){
		scanf("%s",s);
		for (int j=0;j<m;++j) mp[i][j]=(s[j]=='#');
	}
	for (int i=0;i<n;++i){
		for (int j=0;j<m;++j){
			if ((!j)||mp[i][j]) {putchar('#');continue;}
			if (j==m-1) {putchar('.');continue;}
			else if ((~i)&1) putchar('#');else putchar('.');
		}puts("");
	}puts("");
	for (int i=0;i<n;++i){
		for (int j=0;j<m;++j){
			if ((j==m-1)||mp[i][j]) {putchar('#');continue;}
			if (!j) {putchar('.');continue;}
			else if (i&1) putchar('#');else putchar('.');
		}puts("");
	}return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
using namespace std;
const int maxn = 1e6 + 5;
int N, A[maxn], f[maxn];
vector<int> primes;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
void seive() {
    vector<bool> vis(maxn, false);
    for(int i = 2; i < maxn; ++i) {
        if(vis[i] == true) continue;
        for(int j = i; i * j < maxn; ++j) // i * j溢出 
            vis[i * j] = true, f[i * j] = i;
    }
    for(int i = 2; i < maxn; ++i)
        if(vis[i] == false) primes.push_back(i);
}
int main() {
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    seive();
    bool pairPirme = true;
    set<int> visFac;
    for(int i = 0; i < N; ++i) {
        int t = A[i];
        for(int i = 2; i <= sqrt(t); ++i) {
            if(t % i == 0) {
                if(visFac.count(i)) {
                    pairPirme = false;
                    break;
                }
                visFac.insert(i);
                while(t % i == 0) t /= i;
            }

        }
        if(t > 1) {
            if(visFac.count(t)) pairPirme = false;
            visFac.insert(t);
        }
    }
    int t = A[0];
    for(int i = 1; i < N; ++i) {
        t = gcd(t, A[i]);
    }
    bool setPrime = (t == 1);
    if(pairPirme) cout << "pairwise coprime" << endl;
    else if(setPrime) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
}

Measured memory_bytes: 57728
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var n = int.Parse(Console.ReadLine());
    var aho = Console.ReadLine().Split();
    var ans = 1;
    var min = int.Parse(aho[0]);
    for(var i = 0;i<n;i++){
       if(min > int.Parse(aho[i])){
          min = int.Parse(aho[i]);
         ans++;
       }
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 30172
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		// 0 = tomato2, 1 = tomato1, 2 = cream2, 3 = cream1,
		// 4 = basil2, 5 = basil1 ??¨??????
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ans = 0;
		int[] prog = new int[N];
		int[][] table = new int[6][N];
		for(int i = 0; i < K; i++) {
			int A = sc.nextInt() - 1;
			int B = sc.nextInt();
			prog[A] = B;
		}
		switch(prog[0]) {
			case 0:
				table[1][0] = 1;
				table[3][0] = 1;
				table[5][0] = 1;
				break;
			case 1: //tomato1
				table[1][0] = 1;
				break;
			case 2: //cream1
				table[3][0] = 1;
				break;
			case 3: //basil
				table[5][0] = 1;
				break;
		}
		for(int i = 1; i < N; i++) {
			switch(prog[i]) {
				case 0:
					table[0][i] = (table[1][i - 1]); //tomato2
					table[1][i] = (table[2][i - 1] + table[3][i - 1] + table[4][i - 1] + table[5][i - 1]) % 10000; //tomato1
					table[2][i] = (table[3][i - 1]); //cream2
					table[3][i] = (table[0][i - 1] + table[1][i - 1] + table[4][i - 1] + table[5][i - 1]) % 10000; //cream1
					table[4][i] = (table[5][i - 1]); //basil2
					table[5][i] = (table[0][i - 1] + table[1][i - 1] + table[2][i - 1] + table[3][i - 1]) % 10000; //basil1
					break;
				case 1:
					table[0][i] = (table[1][i - 1]); //tomato2
					table[1][i] = (table[2][i - 1] + table[3][i - 1] + table[4][i - 1] + table[5][i - 1]) % 10000; //tomato1
					break;
				case 2:
					table[2][i] = (table[3][i - 1]); //cream2
					table[3][i] = (table[0][i - 1] + table[1][i - 1] + table[4][i - 1] + table[5][i - 1]) % 10000; //cream1
					break;
				case 3:
					table[4][i] = (table[5][i - 1]); //basil2
					table[5][i] = (table[0][i - 1] + table[1][i - 1] + table[2][i - 1] + table[3][i - 1]) % 10000; //basil1
					break;
			}
		}
		for(int i = 0; i < 6; i++) ans += table[i][N - 1];
		System.out.println(ans % 10000);
	}

}

Measured memory_bytes: 19680
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k%2==1){
            ret*=now;
            ret%=mod2;
        }
        now*=now;
        now%=mod2;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    string s;cin>>s;
    ll k;cin>>k;
    int cnt[26];
    fill(cnt,cnt+26,0);
    rep(i,0,s.size()){
        cnt[s[i]-'a']++;
    }
    int cn=0;
    rep(i,0,26){
        if(cnt[i]>0)cn++;
    }
    ll sum=0;
    string t=s;
    rep(i,0,t.size()-1){
        if(t[i]==t[i+1]){
            sum++;
            t[i+1]='.';
        }
    }
    if(cn==1){
        cout<<(s.size()*k)/2<<endl;
        return 0;
    }
    if(s[0]==s[s.size()-1]){
        ll u=0;
        ll uu=0;
        rep(i,0,s.size()){
            if(s[i]==s[0])u++;
            else break;
        }
        rrep(i,s.size()-1,0){
            if(s[i]==s[0])uu++;
            else break;
        }
        sum*=k;
        if(u%2==1&&uu%2==1)sum+=k-1;
        cout<<sum<<endl;
        return 0;
    }
    cout<<sum*k<<endl;
}


Measured memory_bytes: 256
N=int(input())
def answer(i,j):
    i=str(i)
    j=str(j)
    kotae=0
    for k in range(1,N+1):
        if str(k)[0]==i and str(k)[-1]==j:
            kotae+=1
    return kotae
answers=0
for i in range(1,10):
    for j in range(1,10):
        answers+=answer(i,j)*answer(j,i)
print(answers)


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int score[2000][2000];

void solve();

int main(void){
    int H, W; cin >> H >> W;
    string grid[H];
    rep(i, H) cin >> grid[i];
    int row = 0;
    int start = 0;
    bool cont = false;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(grid[i][j] == '#'){
                if(cont){
                    for(int k = start; k < j; k++) score[i][k] = row;
                    cont = false;
                    row = 0;
                }
            }
            else{
                if(!cont){
                    cont = true;
                    start = j;
                }
                row++;
            }
        }
        if(cont){
            for(int k = start; k < W; k++) score[i][k] = row;
            cont = false;
            row = 0;
        }
        start = 0;
    }
    for(int j = 0; j < W; j++){
        for(int i = 0; i < H; i++){
            if(grid[i][j] == '#'){
                if(cont){
                    for(int k = start; k < i; k++) score[k][j] += row;
                    cont = false;
                    row = 0;
                }
            }
            else{
                if(!cont){
                    cont = true;
                    start = i;
                }
                row++;
            }
        }
        if(cont){
            for(int k = start; k < H; k++) score[k][j] += row;
            cont = false;
            row = 0;
        }
        start = 0;
    }

    int ans = 0;
    rep(i, H){
        rep(j, W){
            if(score[i][j] > ans) ans = score[i][j];
        }
    }
    cout << ans-1 << endl;
    return 0;
}

void solve(){}

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

int main(){
	int N,K;
	cin >> N >> K;
	vector<int> p(N);
	for(auto &i:p)cin >> i;
	
	double tmp=0.0;
	for(int i=0;i<K;i++)tmp+=(double)(p[i]*p[i]+p[i])/(2*p[i]);
	
	double ans=tmp;
	for(int i=K;i<N;i++){
		tmp+=(double)(p[i]*p[i]+p[i])/(2*p[i]);
		tmp-=(double)(p[i-K]*p[i-K]+p[i-K])/(2*p[i-K]);
		ans=max(ans,tmp);
	}
	
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 1024
nm = list(map(int, input().split(" ")))
n = nm[0]
m = nm[1]

matrix_A = [list(map(int, input().split(" "))) for i in range(n)]

vector_b = [int(input()) for i in range(m)]

for i in range(n):
    c_i = sum([matrix_A[i][j] * vector_b[j] for j in range(m)])
    print(c_i)

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

using namespace std;

void solve(){
	string s;
	cin>>s;
	long long ret = 0;
	int wh = 0;
	for(int i=s.size()-1;i>=0;--i){
		if(s[i]=='W'){
			++wh;	
		} else {
			ret += wh;
		}
	}
	cout<<ret<<endl;
}
int main(){
	//freopen("input.txt","r",stdin);
	solve();
}

Measured memory_bytes: 640
if __name__ == "__main__":
    N = list(map(int,input().split()))
    K = N[1]
    N = N[0]
    h = list(map(int,input().split()))
    count = 0
    for i in range(N):
        if h[i] >= K:
            count += 1
    print(count)    




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

int main() {
    int N,M,p,w=0;
    string S;
    cin >> N >> M;
    set<int> AC;
    map<int,int> WA;

    rep(i,M) {
        cin >> p >> S;
        if(S == "AC") {
            AC.insert(p);
        } else {
            if(!AC.count(p)) {
                if(WA.count(p))
                    WA.at(p)++;
                else
                    WA[p] = 1;
            }
        }
    }

    for(auto p : WA)
        if(AC.count(p.first))
            w += p.second;
    
    cout << AC.size() << " " << w << endl;
}

Measured memory_bytes: 4992
//
//M-SOLUTIONS 2020
//B
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    string ans="No";

    REP(i, k){
        
        if (a>=b){
            b*=2;
        }else if (b>=c){
            c*=2;
        }

        if ((a<b) && (b<c)){
            ans="Yes";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;

// 0-indexed
struct dsu {
	int n; // number of connected components
	vector<int> par;
	vector<int> sz;

	dsu(int _n) : n(_n), par(n, -1), sz(n, 1) { }

	int getpar(int a) {
		return par[a] == -1 ? a : (par[a] = getpar(par[a]));
	}

	bool merge(int a, int b) {
		a = getpar(a);
		b = getpar(b);
		if (a == b) return false;
		n--;
		if (sz[a] < sz[b]) swap(a, b);
		par[b] = a;
		sz[a] += sz[b];
		return true;
	}
};

template <typename edge_t> ll mst(int n, vector<edge_t> edges) {
	sort(edges.begin(), edges.end());
	dsu conn(n);
	ll res = 0;
	for (const auto& e : edges) {
		int a, b; tie(a, b) = e.second;
		if (conn.merge(a, b)) {
			res += e.first;
		}
	}
	return res;
}

const int MAXN = 2e5;
int N;
int P[MAXN][2];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> P[i][0] >> P[i][1];
	}

	vector<pair<int, pair<int, int>>> edges;
	for (int z = 0; z < 2; z++) {
		vector<int> ord(N);
		iota(ord.begin(), ord.end(), 0);
		sort(ord.begin(), ord.end(), [&](int i, int j) {
			return P[i][z] < P[j][z];
		});
		for (int i = 0; i+1 < N; i++) {
			edges.push_back({P[ord[i+1]][z] - P[ord[i]][z], {ord[i], ord[i+1]}});
		}
	}

	cout << mst(N, edges) << '\n';

	return 0;
}


Measured memory_bytes: 7144
n,l = map(int,input().split())

aji = []
for i in range(1,n+1):
    aji.append(l + i - 1)
if 0 in aji:
    print(sum(aji))
elif aji[0] > 0:
    print(sum(aji) - aji[0])
else:
    print(sum(aji) - aji[-1])


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;



int main(){
    int n, x, l, d = 0, cnt = 1;
    cin >> n >> x;
    for(int i = 0; i < n; i++){
        cin >> l;
        d += l;
        if(d <= x)cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

void dfs(int vs, vector<int>& color, vector<vector<pair<int,int>>>& edge){
    for(auto vew : edge[vs]){
        int ve = vew.first;
        int w = vew.second;
        if(color[ve] >=0 )continue;
        color[ve] = color[vs]^(w&1);
        dfs(ve,color,edge);
    }
}


int main(void){
    int N;
    cin>>N;
    vector<vector<pair<int,int>>> edge(N,vector<pair<int,int>>(0));
    for(int i=0;i<N-1;i++){
        int u,v,w;
        cin>>u>>v>>w;
        u--;v--;
        edge[u].push_back(make_pair(v,w));
        edge[v].push_back(make_pair(u,w));
    }

    vector<int> color(N,-1);
    color[0] = 0;
    dfs(0, color, edge);

    for(auto c:color) cout<<c<<endl;
}

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

#define ll long long
#define P pair<int, int>
#define F first
#define S second

const ll mod = 1000000007LL;

ll n, W, w[105], v[105], dp[105][100005];
void solve() {
  cin >> n >> W;
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= W; j++) {
      dp[i][j] = (i != 0) ? dp[i - 1][j] : 0;
      if (w[i] <= j) {
        dp[i][j] = max(dp[i][j], v[i] + (i != 0 ? dp[i - 1][j - w[i]] : 0));
      }
    }
  }

  cout << dp[n - 1][W];
}

int main(int argc, char const *argv[]) {
/*#ifndef ONLINE_JUDGE
  freopen("practice/input.txt", "r", stdin);
  freopen("practice/output.txt", "w", stdout);
#endif*/

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int T = 1;
  while (T--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 80128
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#define INF 10e10

using namespace std;

//  #define y cout << "yes"<< endl
  #define Y cout << "YES" << endl
  #define y cout << "Yes" << endl
//  #define n cout << "no"<< endl
  #define N cout << "NO" << endl
  #define n cout << "No" << endl
  #define pu(q) cout << q ;
  #define put(q) cout << q << " ";
  #define puts(q) cout << q << endl;
  
  
	int a,b,c,d,e,f,g,h,ans,res;
//	char a,b,c,d,e,f,g,h,ans,res;
//	string a,b,c,d,e,f,g,h,ans,res;
//	double a,b,c,d,e,f,g,h,ans,res;
	
void take(int x);
  
int main(void){
	cin >> a;
	string L;
	cin >> L;
	if(a>=3200){puts(L);
	}else {puts("red");}
	return 0;
}/*
void take(int x){
	if(x==1)
		cin >> a;
	else if(x==2)
		cin >> a >> b;
	else if(x==3)
		cin >> a >> b >> c;
	else if(x==4)
		cin >> a >> b >> c >> d;
	else if(x==5)
		cin >> a >> b >> c >> d >> e;
	else if(x==6)
		cin >> a >> b >> c >> d >> e >> f;
	else if(x==7)
		cin >> a >> b >> c >> d >> e >> f >> g;
	else if(x==8)
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
	return ;
}*/

Measured memory_bytes: 256
using System;

namespace Ex160425_1{
    public class Program{
        public static void Main(string[] args){
            while(true){
                var n = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                if(n[0] == 0 && n[1] == 0) break;

                Array.Sort(n);
                Console.WriteLine("{0} {1}", n[0], n[1]);
            }
        }
    }
}

Measured memory_bytes: 9448
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define pi 3.1415926535897
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define mod1 998244353
#define inf 1000000000000000000
#define endl '\n'
ld arr[3005];
ld dp[3005][3005];
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++)
		cin>>arr[i];
	dp[1][1]=arr[1];
	dp[1][0]=1-arr[1];
	for(ll i=2;i<=n;i++)
	{
		for(ll j=0;j<=i;j++)
		{
			if(j>0)
			dp[i][j]=dp[i-1][j-1]*arr[i]+dp[i-1][j]*(1-arr[i]);
			else
				dp[i][j]=dp[i-1][j]*(1-arr[i]);
		}
	}
	ld ans=0.0;
	for(ll i=(n/2)+1;i<=n;i++)
		ans+=dp[n][i];
	cout<<std::setprecision(20)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 139392
#include<bits/stdc++.h>
using namespace std;
const int N = 210;
int f[2][N][N][N], n, m, a[N][N];
char str[N][N];
bool ok(int x1, int y1, int x2, int y2) {
	int sum = a[x2][y2] - a[x1 - 1][y2] - a[x2][y1 - 1] + a[x1 - 1][y1 - 1];
	if (!sum || sum == (x2 - x1 + 1) * (y2 - y1 + 1)) return 1;
	return 0;
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%s", str[i] + 1);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1] + (str[i][j] == '#');
	for (int i = 1; i <= n; i++)
		for (int j = i; j <= n; j++) {
			for (int k = 1; k <= m; k++) {
				int &z = f[0][i][j][k]; z = max(z, f[0][i][j][k - 1] - 1);
				while (z + k <= m && ok(i, k, j, k + z)) z++;
			}
		}
	if (f[0][1][n][1] == n) {
		puts("0");
		return 0;
	}
	int lim = log2(n * m) + 1, t = 0;
	for (int i = 1; i <= lim; i++, t ^= 1) {
		memset(f[i & 1], 0, sizeof(f[i & 1]));
		for (int len = 0; len < n; len++)
			for (int l = 1, r; l + len <= n; l++) {
				r = l + len;
				for (int k = 1; k <= m; k++) {					
					f[i & 1][l][r][k] = f[t][l][r][k] + f[t][l][r][k + f[t][l][r][k]];
				//	for (int z = l + 1; z <= r; z++)
				//		f[i & 1][l][r][k] = max(f[i & 1][l][r][k], min(f[t][l][z - 1][k], f[t][z][r][k]));
					int L = l + 1, R = r, ans = 0;
					while (L <= R) {
						int mid = (L + R) >> 1;
						int v1 = f[t][l][mid - 1][k], v2 = f[t][mid][r][k];
						ans = max(ans, min(v1, v2));
						if (v1 < v2) R = mid - 1;
						else L = mid + 1;
					}
					f[i & 1][l][r][k] = max(f[i & 1][l][r][k], ans);
				}
			}
		if (f[i & 1][1][n][1] == m) {
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int>H(N);

  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  sort(H.begin(),H.end());
  if(N<=K){
    cout << 0 << endl;
  }
  else{
    long long count=0;
    for(int i=0;i<N-K;i++){
      count += H.at(i);
    }
    cout << count << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n,l;
  cin>>n>>l;
  int EatApple=0;
  if(l>0 && l+n-1>0)
    EatApple=min(l,l+n-1);
  else if(l<0 && l+n-1<0)
    EatApple=max(l,l+n-1);
  int ApplePie=l*n+(n-1)*n/2;
  cout<<ApplePie-EatApple<<endl;
}

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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end() );
  sort(t.begin(), t.end() );
  reverse(t.begin(), t.end() );
    if(s < t){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
namespace IO{
	const int L=1<<15;char ibuf[L|1],*iS=ibuf,*iT=ibuf,obuf[L|1],*oS=obuf,*oT=obuf+L,c,st[66];int tp=0,f;
	inline char gc(){if(iS==iT) iT=(iS=ibuf)+fread(ibuf,sizeof(char),L,stdin);return (*iS++);}
	inline void flush(){fwrite(obuf,sizeof(char),oS-obuf,stdout);oS = obuf;}
	inline void pc(char c){*oS++=c;if(oS==oT) flush();}
	#define gc getchar
	#define pc putchar
	inline ll read(){ll x=0;f=1,c=gc();for(;!isdigit(c);c=gc())if(c=='-')f=-1;for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c&15);return x*f;}
	inline void write(ll x){if(!x) pc('0');if(x<0) pc('-'),x=-x;while(x) st[++tp]=x%10+'0',x/=10;while(tp) pc(st[tp--]);}
	inline void writeln(ll x){write(x);pc('\n');}
	inline void wri(ll x){write(x),pc(' ');}
	struct IOflusher{~IOflusher(){flush();}}_ioflusher_;
}using IO::read;using IO::write;using IO::writeln;using IO::wri;
const int mod = 998244353;
inline int qpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1) ans=1ll*ans*a%mod;
	return ans;
}
int fac[1000099],inv[1000099],ans,n,m;
inline int C(int x,int y){
	assert(x >= y);
	return 1ll * fac[x] * inv[y] % mod * inv[x-y] % mod;
}
inline int INV(int x){
	return qpow(x,mod-2);
}
int main(){
	fac[0] = 1;
	Rep(i,1,1000005) fac[i] = 1ll * fac[i-1] * i % mod;
	inv[1000005] = qpow(fac[1000005],mod-2);
	Dep(i,1000004,0) inv[i] = 1ll * inv[i+1] * (i+1) % mod;
	//assert(inv[0]);
	n = read(),m = read();
	if(n>m) swap(n,m);
/*	for(int i=0;i<=n;++i){
		for(int j=0;j<=m;++j){
			if(i<=j && j!=m)ans = (ans + 1ll * C(i+j,j) * C(n-i+m-j-1,n-i)) % mod;
			if(i>=j && i!=n)ans = (ans + 1ll * C(i+j,j) * C(n-i+m-j-1,m-j)) % mod;
		}
	}*/
/*	for(int i=0;i<=n;++i)
		for(int j=i;j<=m-1;++j)
			ans = (ans + 1ll * C(i+j,j) * INV(n+m-i-j) % mod * (m-j) % mod * C(n+m-i-j,n-i)) % mod;
	for(int i+j=0;i+j<=n+m-1;i+j++){
		for(int i=0,j=i+j-i;i<=n&&j<=m&&i<=j;++i){
			
		}
	}
	
f(i,j) = C(i+j,j) * C(n+m-i-j,n-i)

 (i+j) !  (n+m-i-j)!
---------------------
j! i!  (n-i)!  (m-j)!

	for(int i=0;i<=n-1;++i)
		for(int j=0;j<=i && j<=m;++j)
			ans = (ans + 1ll * C(i+j,j) * C(n+m-i-j-1,m-j)) % mod;*/
		
//C(a-1,b) = C(a,b) * fac[a]
	ans = 1ll * C(n+m,n) * max(n,m) % mod;
//	debug(ans);
//	debug(ans / C(n+m,n));
	for(int i=1;i<=min(n,m);++i){
		ans = (ans + 1ll * C(i+i,i) * C(n-i+m-i,n-i) % mod * ((mod+1)/2)) % mod;
	}
	writeln(1ll * ans * qpow(C(n+m,n),mod-2) % mod);
}

Measured memory_bytes: 8064