akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;

double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	long double A,B,C;
	cin>>A>>B;
	cout << fixed << setprecision(0) << floor(A*B) << endl;
}

Measured memory_bytes: 3248
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int K, Q;
    cin >> K >> Q;
    vector<int> D(K), N(Q), X(Q), M(Q);
    rep(i, K) cin >> D[i];
    rep(i, Q) cin >> N[i] >> X[i] >> M[i];

    vector<int> E(K);
    rep(i, Q) {
        rep(j, K) E[j] = D[j] % M[i];
        X[i] %= M[i];

        int zcnt = 0;
        ll q = 0;
        ll r = X[i];
        rep(j, K) {
            int cnt = (N[i] - 1) / K + (j < (N[i] - 1) % K ? 1 : 0);
            //cerr << cnt << endl;
            if (E[j] == 0) {
                zcnt += cnt;
                continue;
            }
            r += (ll)E[j] * cnt;
            q += r / M[i];
            r %= M[i];
        }
        ll ans = N[i] - 1 - zcnt;
        ans -= q;
        write(ans);
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int sum=0;

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

    sort(l.begin(),l.end());

    if(sum-l[n-1]>l[n-1]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}

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


int main(void)
{
	//変数の宣言
	int a,b;
	int ans;
	
	//データの読み込み
	scanf("%d %d",&a,&b);
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	ans = a+b/2;
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 128
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))

hq = []
for a in A:
  heapq.heappush(hq, -a)
  
for i in range(M):
  curr = -heapq.heappop(hq)
  heapq.heappush(hq, -(curr//2))
  
print(-sum(hq))

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long

int main()
{
fastio
  int n,m;
  ll ans=0;
  cin>>n>>m;
  ans=n*(n-1);
  ans+=m*(m-1);
  ans/=2;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast")
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
inline int read() {
    int s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')w = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
    return s * w;
}
#define f(i, l, r) for (int i = l; i <= r; ++i)
#define rf(i, r, l) for (int i = r; i >= l; --i)
#define all(x) (x).begin(), (x).end()
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))
#define mod1(x) ((x >= mod) && (x -= mod))
#define mod2(x) ((x < 0) && (x += mod))

const int inf = 1e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
const int mod = 1e9 + 7;
const int N = 3000 + 10;
const double pi = acos(-1.0);
ll power(ll a, ll b) { ll res = 1; while (b) { if (b & 1)res = res * a % mod; a = a * a % mod; b >>= 1; }return res; }
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
void add(ll& a, ll b) { a += b; mod1(a); mod2(a); }
/*int len, C[N], clen;
int id(int v) {return lower_bound(C + 1, C + len, v) - C;}
void initC() { sort(C + 1, C +1+ clen); len = unique(C + 1, C + 1 + clen) - C - 1; }*/

ll dp[N][N][4];
int v[N][N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef local
    freopen("in.txt", "r", stdin);
    int start = clock();
#endif
    int r, c, k; cin >> r >> c >> k;
    f(i, 1, k) {
        int a, b, c;; cin >> a >> b >> c;
        v[a][b] = c;
    }
    f(i, 1, r)f(j, 1, c) {
        dp[i][j][0] = max({ dp[i - 1][j][1],dp[i - 1][j][3],dp[i - 1][j][2],dp[i][j-1][0] });
        f(k, 1, 3) {
            dp[i][j][k] = max({ dp[i - 1][j][1],dp[i - 1][j][3],dp[i - 1][j][2] }) + v[i][j];
            dp[i][j][k] = max({ dp[i][j][k], dp[i][j - 1][k - 1] + v[i][j] ,dp[i][j-1][k]});
        }
    }
    cout << max({ dp[r][c][1], dp[r][c][2], dp[r][c][3] });

#ifdef local
    int end = clock();
    cout << '\n' << end - start << "ms";
#endif* /
}

Measured memory_bytes: 321008
#include<bits/stdc++.h>
using namespace std;
int n,m,head[100100],cnt,col[100100],tot[3],TE;
typedef long long ll;
ll res;
struct node{
	int to,next,val;
}edge[200100];
void ae(int u,int v){
	edge[cnt].next=head[u],edge[cnt].to=v,edge[cnt].val=1,head[u]=cnt++;
	edge[cnt].next=head[v],edge[cnt].to=u,edge[cnt].val=-1,head[v]=cnt++;
}
bool Dye(int x){
	tot[col[x]]++;
	bool ret=true;
	for(int i=head[x];i!=-1;i=edge[i].next){
		TE+=(edge[i].val==1);
		if(col[edge[i].to]==-1){
			col[edge[i].to]=(col[x]+edge[i].val+3)%3;
			ret&=Dye(edge[i].to);
		}
		else ret&=(col[edge[i].to]==(col[x]+edge[i].val+3)%3);
	}
	return ret;
}
int main(){
	scanf("%d%d",&n,&m),memset(head,-1,sizeof(head)),memset(col,-1,sizeof(col));
	for(int i=1,x,y;i<=m;i++)scanf("%d%d",&x,&y),ae(x,y);
	for(int i=1;i<=n;i++){
		if(col[i]!=-1)continue;
		memset(tot,0,sizeof(tot)),TE=0;
		col[i]=0;
		if(!Dye(i)){res+=1ll*(tot[0]+tot[1]+tot[2])*(tot[0]+tot[1]+tot[2]);continue;}
		if(!tot[0]||!tot[1]||!tot[2]){res+=TE;continue;}
		res+=1ll*tot[0]*tot[1]+1ll*tot[1]*tot[2]+1ll*tot[2]*tot[0];
	}
	printf("%lld\n",res);
	return 0;
} 

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

int main(){
    int n;

    cin >> n;
    int in[n];
    for(int i=0;i<n;i++){
        cin >> in[i];
    }
    int ans = 0;
    int tmp = 0;
    for(int i=0;i<n;i++){
        if(in[i] == i+1){
            tmp ++;
        }
        else{
            ans += (tmp+1)/2;
            tmp = 0;
        }
    }
    ans += (tmp+1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = readInt >>= flip replicateM readInts >>= putStrLn . which "Yes" "No" . ( 3 <= ) . foldl max 0 . map length . filter ( head ) . group . map ( uncurry (==) . mp )	

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

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

const long long MOD = 1000000007;

int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<int>> G(h,vector<int>(w,0));
  vector<vector<int>> c(h,vector<int>(w,0));
  rep(i,h){
    string s;
    cin>>s;
    rep(j,w){
      if(s.at(j)=='#') G.at(i).at(j)=1;
    }
  }
  int t=0,x=0,y=0,ans=0;
  rep(j,w){
    t=0;
    rep(i,h){
      if(G.at(i).at(j)){
        if(t){
          y=i-1;
          int l=y-x+1;
          rep(k,l){
            c.at(i-1-k).at(j) += l;
          }
          t=0;
          continue;
        }
      }
      else if(i==h-1){
        if(t){
          y=i;
          int l=y-x+1;
          rep(k,l){
            c.at(i-k).at(j) += l;
          }
          break;
        }
        else{
          c.at(i).at(j)+=1;
        }
      }
      else if(t==0){
        x=i;
        t=1;
        continue;
      }
    }
  }
  rep(i,h){
    t=0;
    rep(j,w){
      if(G.at(i).at(j)){
        if(t){
          y=j-1;
          int l=y-x+1;
          rep(k,l){
            c.at(i).at(j-1-k) += l-1;
          }
          t=0;
          continue;
        }
      }
      else if(j==w-1){
        if(t){
          y=j;
          int l=y-x+1;
          rep(k,l){
            c.at(i).at(j-k) += l-1;
          }
          break;
        }
        else{
          c.at(i).at(j)+=0;
        }
      }
      else if(t==0){
        x=j;
        t=1;
        continue;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      if(G.at(i).at(j)==0) ans=max(ans,c.at(i).at(j));
    }
  }
  cout<<ans<<endl;
 
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="SUN") cout<<"7"<<endl;
	else if(s=="MON") cout<<"6"<<endl;
	else if(s=="TUE") cout<<"5"<<endl;
	else if(s=="WED") cout<<"4"<<endl;
	else if(s=="THU") cout<<"3"<<endl;
	else if(s=="FRI") cout<<"2"<<endl;
	else if(s=="SAT") cout<<"1"<<endl;
	return 0;
}

Measured memory_bytes: 256
def partition(A, p, r):
    x = A[r][0]
    i = p-1
    for j in range(p, r):
        if A[j][0] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]

    A[i+1], A[r] = A[r], A[i+1]
    return i+1


def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q-1)
        quicksort(A, q+1, r)


if __name__ == "__main__":
    import sys
    from operator import itemgetter
    n = int(input())
    cards1, cards2 = [], []
    for i, card in enumerate((l.strip()) for l in sys.stdin):
        cards1.append(card)
        cards2.append((int(card[2:]), i))

    quicksort(cards2, 0, n-1)
    print("Stable" if all(i1 < i2 for (n1, i1), (n2, i2) in zip(cards2, cards2[1:]) if n1 == n2)
          else "Not stable")
    print(*(cards1[i] for i in map(itemgetter(1), cards2)), sep="\n")


Measured memory_bytes: 26356
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
using namespace __gnu_pbds;

template <class T> using ordered_set =
tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  vector <int> pref(n);
  pref[0] = a[0];
  for (int i = 1; i < n; ++i)
    pref[i] = pref[i - 1] + a[i];
  map <int, int> was;
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    ret += was[pref[i]];
    if (pref[i] == 0)
      ++ret;
    ++was[pref[i]];
  }
  cout << ret;
  return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if(l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) continue;
                bool isok = true;
                if(!(abs(l[i]-l[j]) < l[k] && l[k] < l[i]+l[j])) isok = false;
                if(!(abs(l[i]-l[k]) < l[j] && l[j] < l[i]+l[k])) isok = false;
                if(!(abs(l[k]-l[j]) < l[i] && l[i] < l[k]+l[j])) isok = false;

                if(isok) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

signed main() {
  ll N, A, B;
  cin >> N >> A >> B;
  if ((B - A) % 2 == 0) {
    cout << (B - A) / 2 << endl;
  } else {
    cout << min(A - 1, N - B) + 1 + (B - A - 1) / 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		BigDecimal l = new BigDecimal(scan.next());
		l = l.divide(new BigDecimal("3"), 6, RoundingMode.HALF_UP);

		System.out.println(l.multiply(l).multiply(l));
	}
}

Measured memory_bytes: 24276
using System;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var arg1 = Console.ReadLine().Split(" ");
            var arg2 = Console.ReadLine().Split(" ");
            var n = long.Parse(arg1[0]);
            var m = long.Parse(arg1[1]);
            var result = -1L;
            for (var i = 0; i <= 101; i++)
            {
                for (var j = 1; j <= m; j++)
                {
                    if (long.Parse(arg2[j - 1]) == i) goto NEXT;
                }
                if (Math.Abs(n - result) > Math.Abs(n - i)) result = i;
                NEXT:;
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 27556
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n;
    string s;
    cin>>n>>s;
    int x=0,ans=0;
    for(auto it:s){
        if(it=='I') ++x;
        else --x;
        ans=max(ans,x);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int N,count,count2;
  cin >> N;
  count2 = 30;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    while(a%2 == 0){
      count++;
      a /= 2;
    }
    if(count < count2)count2 = count;
    count = 0;
  }
  cout << count2 << endl;
}


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

int main() 
{
    string S;
    cin >> S;
    
    if (S[0] == '7' || S[1] == '7' || S[2] == '7') {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    vector<double> A(N);
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] = 1./A[i];
    }
    double ans = 0;
    for(int i = 0; i < N; ++i) ans += A[i];
    ans = 1./ans;
    printf("%.10f",ans);
    return 0;
}


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

int main()
{
  long long int i,j,n,k,w,x,y,z;
  string s1,s2,s3;
  cin>>s1>>s2;
  n=s1.size();
  w=s2.size();
  vector<vector<long int>>v(n+1,vector<long int>(w+1,0));
  for(i=1;i<=n;i++)
  {
   for(j=1;j<=w;j++)
   {
    if(s1[i-1]==s2[j-1])
     v[i][j]=1+v[i-1][j-1];
    else
     v[i][j]=max(v[i-1][j],v[i][j-1]);
   }
  }
  i=n;
  j=w;
  while(1)
  {
   if(j==0||i==0)
     break;
   else
    {
     if(s1[i-1]==s2[j-1])
     {
      s3.push_back(s1[i-1]);
      i--;
      j--;
     }
     else if(v[i][j-1]>v[i-1][j])
      j--;
     else
      i--;
    }
  }
  reverse(s3.begin(),s3.end());
  cout<<s3;
 return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a,b,c,d; cin>>a>>b>>c>>d;
    int x = c-a;
    int y = d-b;
    printf("%d %d %d %d\n",c-y,d+x,a-y,b+x);
}


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

int N,K;
string S;

int main() {
  cin >> N >> K >> S;
  int cnt = 0;
  rep(i,N-1) if (S[i] == 'R' && S[i+1] == 'L') cnt++;
  int L = 0, R = 0;
  if (S[0] == 'L') L = 1;
  if (S[N-1] == 'R') R = 1;

  int unhappy = 0;
  if (K < cnt) {
    unhappy = (cnt - K) * 2 + L + R;
  } else if (K == cnt) {
    if (L + R == 2) {
      unhappy = 2;
    } else {
      unhappy = 1;
    }
  } else {
    unhappy = 1;
  }
  cout << N - unhappy << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int i, dice[7];
	char order[101];

	for (i = 1; i < 7; i++)
		scanf("%d", &dice[i]);

	scanf("%s", order);

	for (i = 0; order[i] != '\0'; i++){

		dice[0] = dice[1];

		switch (order[i]){

		case 'E':
			dice[1] = dice[4];
			dice[4] = dice[6];
			dice[6] = dice[3];
			dice[3] = dice[0];
			break;

		case 'N':
			dice[1] = dice[2];
			dice[2] = dice[6];
			dice[6] = dice[5];
			dice[5] = dice[0];
			break;

		case 'S':
			dice[1] = dice[5];
			dice[5] = dice[6];
			dice[6] = dice[2];
			dice[2] = dice[0];
			break;

		case 'W':
			dice[1] = dice[3];
			dice[3] = dice[6];
			dice[6] = dice[4];
			dice[4] = dice[0];
			break;

		}
	}

	printf("%d\n", dice[1]);

	return 0;
}


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

using namespace std;

int main()
{
  vector<int> v;
  int t;

  for ( int i = 0; i < 3; i++ ) {
    cin >> t;
    v.push_back(t);
  }

  sort(v.begin(), v.end());
  cout << v[0] << " " << v[1] << " " << v[2] << endl;

  return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <string.h>

int main() {

 	long long int n;
 	scanf("%lld", &n);
 	
 	char name[20]={};
	n--;
 	for(long long int i=0; n>=0; i++){
		name[i]=(n%26)+'a';
		n/=26;
		n--;	
	 }
	 
  	long long int nn = strlen(name);
	for(long long int i = nn-1; i >= 0; i--){
 	 printf("%c", name[i]);
	}
	
	printf("\n");


    return 0;
}

Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		int n = c.length;
		for(int mask = 0 ; mask < (1<<n) ; mask++) {
			String s = "";
			int temp = 0;
			for(int i = 0 ; i < n ; i++) {
				if(i == 0) {
					s += c[i];
					temp += c[i] - '0';
				} else if((mask&(1<<i)) >= 1) {
					s += "+" + c[i];
					temp += c[i] - '0';
				} else {
					s += "-" + c[i];
					temp -= c[i] - '0';
				}
			}
			if(temp == 7) {
				System.out.println(s + "=7");
				return;
			}
		}
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
using namespace std;


int main(){
    string s;
    map<string, int> m;
    m["SUN"] = 0;
    m["MON"] = 1;
    m["TUE"] = 2;
    m["WED"] = 3;
    m["THU"] = 4;
    m["FRI"] = 5;
    m["SAT"] = 6;
    cin >> s;
    cout << 7 - m[s];

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N,A,B;
  cin >> N >> A >> B;
  if((B-A)%2==0){
    cout << "Alice" << endl;
  }else{
    cout << "Borys" << endl;
  }
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sort)

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  ds <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    n' = n `div` 2
    ds' = sort ds
    (l : m : _) = drop (pred n') ds'
  print (m - l)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 17788
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll N;
    cin>>N;
    vi a(N);
    REP(i,N)cin>>a[i];
    unordered_map<ll,ll> map;
    REP(i,N){
        auto iter=map.find(a[i]);
        if(iter!=map.end()){
            //cout<<a[i]<<":"<<iter->second<<endl;
            iter->second+=1;
        }else{
            map.emplace(a[i],1);
        }
    }
    for_each(begin(map),end(map),[&](auto p){
        //cout<<p.first<<","<<p.second<<","<<a[p.first]<<endl;
        if(p.second>=p.first)ans+=p.second-p.first;
        else ans+=p.second;
    });
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5028
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, a, b) for(int  i = a; i < b; ++i)
using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll ans =1e18;
  for(ll i = 1; i * i <= n; i++){
    if(n % i != 0) continue;
    ll j = n / i;
    ans = min(ans, i + j - 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
//		ArrayList<Integer> ans = new ArrayList<Integer>();
		
		int sum = 0;
		double ave = 0;
		int cnt = 0;
		
		while (true) {
			
			String s = br.readLine();
			if (s == null) break;
			
			cnt++;
			
			StringTokenizer st = new StringTokenizer(s,",");
			int price = Integer.parseInt(st.nextToken());
			int quantity = Integer.parseInt(st.nextToken());
			
			ave += quantity;
			sum += quantity * price;
			
		}
		
		ave /= cnt;
		
		System.out.printf("%d\n%.0f\n",sum, ave);
		
//		for (int a : ans) {
//			System.out.println(a);
//		}
	}
	
}

Measured memory_bytes: 11000
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL inf = 11234567890;
std::vector<std::vector<LL>>dist;

void warshall_floyd(LL V)
{
	for (LL k = 1; k <= V; ++k) for (LL i = 1; i <= V; ++i) for (LL j = 1; j <= V; ++j) dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
}

int main()
{
	LL V, E, T_max;
	in >> V >> E;
	std::vector<LL>u(E), v(E), d(E);
	rep(i, E) in >> u[i] >> v[i] >> d[i];
	in >> T_max;
	std::vector<std::vector<std::pair<LL, LL>>>info(T_max);
	rep(i, T_max)
	{
		LL N_new;
		in >> N_new;
		rep(j, N_new)
		{
			LL new_id, dst;
			in >> new_id >> dst;
			info[i].push_back(std::make_pair(new_id, dst));
		}
	}

	std::vector<std::vector<std::pair<LL, LL>>>G(V + 1);
	dist.resize(V + 1, std::vector<LL>(V + 1, inf));
	rep(i, E)
	{
		G[u[i]].push_back(std::make_pair(v[i], d[i]));
		G[v[i]].push_back(std::make_pair(u[i], d[i]));
		dist[u[i]][v[i]] = dist[v[i]][u[i]] = d[i];
	}
	warshall_floyd(V);

	bool moving = false, reached = false;
	LL now, dst, c;
	std::pair<LL, LL>edge;
	rep(t, T_max)
	{
		LL command = -2;
		if (!moving)
		{
			if (info[t].empty()) command = -1;
			else
			{
				now = 1;
				dst = info[t][0].second;
				c = 0;

				LL minD = inf;
				for (auto e : G[now])
				{
					LL d = dist[now][e.second] + dist[e.second][dst];
					if (d < minD)
					{
						minD = d;
						edge = e;
					}
				}
				moving = true;
				reached = false;
			}
		}
		else
		{
			if (c == edge.second)
			{
				now = edge.first;
				c = 0;
				if (now == 1 && reached)
				{
					moving = false;
					continue;
				}
				if (now == dst)
				{
					dst = 1;
					reached = true;
				}

				LL minD = inf;
				for (auto e : G[now])
				{
					LL d = dist[now][e.second] + dist[e.second][dst];
					if (d < minD)
					{
						minD = d;
						edge = e;
					}
				}
			}
			else
			{
				command = edge.first;
				++c;
			}
		}
		if (command != -2) out << command << std::endl;
		else --t;
	}
}


Measured memory_bytes: 2048
#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;
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  
  string s;
  rep(i, n){
    cin >> s;
    if(s == "AC") AC++;
    else if(s == "WA") WA++;
    else if(s == "TLE") TLE++;
    else RE++;
  }
  
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
  return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {
    
    string S,T,U;
    cin >> S >> T;
    int A,B;
    cin >> A >> B;
    cin >> U;
    if(S == U) A -= 1;
    else B -= 1;
    cout << A << " " << B << endl;
    return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<long long>> a(n, vector<long long>(3));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	long long ans = -LLONG_MAX;
	for(int i = 0; i < (1 << 3); i++) {
		vector<long long> v(n);
		for(int j = 0; j < n; j++) {
			for(int k = 0; k < 3; k++) {
				if(1 & (i >> k)) {
					v[j] += a[j][k];
				}
				else {
					v[j] -= a[j][k];
				}
			}
		}
		sort(v.rbegin(), v.rend());
		long long sum = 0;
		for(int j = 0; j < m; j++) {
			sum += v[j];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
///////////////////////////////////////////////
ll dp[402][402] = {};
	static ll a[402] = {};
	static ll s[402] = {};

ll INF = 1e14;
ll f(int i,int j){
	if (i==j) return dp[i][j] = 0;
	if (dp[i][j] != INF) return dp[i][j];
	FORq(k,i,j-1){
		dp[i][j] = min(dp[i][j],f(i,k) + f(k+1,j) + s[j] - s[i-1]);
	}
	return dp[i][j];
}

int main(){
	int N; SCD(N);

	s[0] = 0;
	FORq(i,1,N){
		cin >> a[i];
		s[i] = s[i-1] + a[i];
	}

	FORq(i,1,N){
		FORq(j,1,N){
			dp[i][j] = INF;
		}
	}

	PRINTLLD(f(1,N));
}


Measured memory_bytes: 1536
s = [input() for i in range(2)]
n = int(s[0].split()[0])
m = int(s[0].split()[1])
a = list(map(int, s[1].split()))

sumVote = sum(a)
border = 1 / (4 * m) * sumVote
select = 0
for item in a:
    if border <= item:
        select += 1
    if select == m:
        print("Yes")
        exit()
print("No")


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    cout << a*b;
    
	return 0;
}



Measured memory_bytes: 3636
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n1 = Number(lines.shift());
  const arr1 = lines.shift().split(' ').map(Number);
  const n2 = Number(lines.shift());
  const arr2 = lines.shift().split(' ').map(Number);

  function memo(func) {
    var cache = {};
    function innerFunc(x, y) {
          if (!cache[[x, y]]) cache[[x, y]] = func(x, y);
          return cache[[x, y]]
    };
    return innerFunc;
  }

  const solve = (i, m) => {
    if (m == 0) return true;
    if (i >= n1) return false;
    return solve(i + 1, m) || solve(i + 1, m - arr1[i]);
  };

  const mapfunc = memo(solve);
  arr2.map(m => mapfunc(0, m) ? 'yes' : 'no').forEach(res => console.log(res));
})();



Measured memory_bytes: 17324
#include <iostream>
#include <cstring>
#include <cmath> 
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;   
int main()  
{ 
    int n,d,x;
    cin>>n>>d>>x;
    int ans=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        ans+=1+(d-1)/a;}
    ans+=x;
    cout<<ans<<endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#include<string.h>
using namespace std;
int main()
{ string s;
  long long int k;cin>>k>>s;
  if((s.length())<=k)
    cout<<s<<"\n";
  else 
    cout<<s.substr(0,k)+"..."<<"\n";
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>

using namespace std;

int main(void){
	int n,k;
	vector <int > ball;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		int data;
		scanf("%d",&data);
		ball.push_back(data);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		ans += 2*(min(ball[i],k-ball[i]));
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  string s; cin >> s;
  ll k; cin >> k;
  char ans = 0;
  bool f = true;
  for(ll i = 0; i < k; i++){
    if(s[i] != '1'){
      f = false;
      ans = s[i];
      break;
    }
  }
  if(f)cout << 1 << endl;
  else cout << ans << endl;
  system("pause");
}


Measured memory_bytes: 504
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	String forecast = sc.nextLine();
	String real = sc.nextLine();
	
	String f[] = forecast.split("");
	String r[] = real.split("");
	
	int cnt = 0;
	for(int i=0; i<3; i++){
		if(f[i].equals(r[i]))
			cnt++;
	}
	
    System.out.println(cnt);
  }
}

Measured memory_bytes: 21716
# 2020/08/09
# AtCoder Grand Contest 002 - A

# Input
n, m = map(int,input().split())
rlist = [0] * (n+1)
wlist = [1] * (n+1) 
rlist[1] = 1
wlist[1] = 0

# Calc
for i in range(m):
    x, y = map(int,input().split())
    if rlist[x] >= 1:
        rlist[y] = rlist[y] + 1
        # if rlist[x] == 1 and wlist[x] == 0:
        if wlist[x] == 0:
            rlist[x] = rlist[x] - 1
        else:
            wlist[x] = wlist[x] - 1
    else:
        wlist[y] = wlist[y] + 1
        wlist[x] = wlist[x] - 1

ans = 0
for i in range(n+1):
    if rlist[i] >= 1:
        ans = ans + 1

# Output
print(ans)


Measured memory_bytes: 10284
#include<stdio.h>
int main(){
  int n,m,i,j,a,min=1e9;
  scanf("%d %d",&n,&m);
  for(i=0;i<(1<<n);i++){
    a=1;
    for(j=0;j<n;j++){
      if(i&(1<<j))a*=2;
      else        a+=m;
    }
    if(min>a)min=a;
  }
  printf("%d\n",min);
  return 0;
}


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

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

    string n;
    cin >> n;
    for (int i = 0; i < 3; i++) {
        if (n[i] == '7') {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

template<typename T>
std::vector<int> kmp(const T& target) {
	std::vector<int> result(target.size());
	if (result.size() == 1) {
		result[0] = -1;
		return result;
	}
	int longest_prefix{ 0 };
	result[0] = -1; result[1] = 0;
	for (auto i = 2; i < target.size(); ++i) {
		while (longest_prefix >= 0 && target[i - 1] != target[longest_prefix]) {
			longest_prefix = result[longest_prefix];
		}
		result[i] = ++longest_prefix;
	}
	return result;
}
template<typename T>
std::vector<int> match_position(const T& word, const T& target) {
	const auto shift = kmp(target);
	int it = 0;
	std::vector<int> result;
	for (auto iw = 0; iw < word.size(); ++iw) {
		while (it >= 0 && word[iw] != target[it]) {
			it = shift[it];
		}
		if (++it == target.size()) {
			result.push_back(iw - it + 1);
			it = shift.back();
			while (it >= 0 && word[iw] != target[it]) {
				it = shift[it];
			}
			++it;
		}
	}
	return result;
}
int main() {
	std::string word, target; std::cin >> word >> target;
	for (auto pos : match_position(word, target)) {
		std::cout << pos << '\n';
	}
}


Measured memory_bytes: 8352
from collections import Counter

N, P = map(int, input().split())
S = input()

c = 0

if P == 2 or P == 5:
    for i,v in enumerate(S):
        if int(v) % P == 0:
            c += (i+1)

else:
    T = [0]*(N+1)
    d = 1
    for i,v in enumerate(S[::-1]):
        a = (int(v) * d + T[i])% P
        T[i+1] = a
        d *= 10
        d %= P
    count = Counter(T)

    c = sum(x * (x -1) / 2 for x in count.values())

print(int(c))

Measured memory_bytes: 11992
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuripair_sort(int N, int A[], int B[]) {
	const int b = 8;
	int tmp[300001], tmp2[300001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

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


	int N = getint();
	int A[300000], B[300000], C[300000], A0[100000];
	ll S[100001];
	S[0] = 0;
	ll kari = 0;
	int saishou = 1e9;
	int saidai = 0;
	rep(i, 3 * N) {
		A[i] = getint();
		B[i] = i;
	}
	rep(i, N) S[0] += A[i];
	for (int i = N; i < 2 * N; i++) A0[i - N] = A[i];
	for (int i = 2 * N; i < 3 * N; i++) kari += A[i];
	
	pakuripair_sort(3 * N, A, B);
	rep(i, 3 * N) C[B[i]] = i;

	memset(B, 0, sizeof(B));
	rep(i, N) {
		B[C[i]] = 1;
		chmin(saishou, C[i]);
	}

	for (int i = N; i < 2 * N; i++) {
		if (saishou < C[i]) {
			B[C[i]] = 1;
			while (!B[saishou]) saishou++;
			B[saishou] = 0;
			S[i - N + 1] = S[i - N] + A0[i - N] - A[saishou];
		}
		else S[i - N + 1] = S[i - N];
	}

	memset(B, 0, sizeof(B));
	for (int i = 2 * N; i < 3 * N; i++) {
		B[C[i]] = 1;
		chmax(saidai, C[i]);
	}

	ll kotae = S[N] - kari;
	for (int i = 2 * N - 1; i >= N; i--) {
		if (saidai > C[i]) {
			B[C[i]] = 1;
			while (!B[saidai]) saidai--;
			B[saidai] = 0;
			kari += A0[i - N] - A[saidai];
		}
		chmax(kotae, S[i - N] - kari);
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 7424
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using Order_Set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff

long long BigMod(unsigned long long x, unsigned long long  y, long long  MOD)
{
    long long  res = 1;
    x = x % MOD;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % MOD;

        y = y>>1;
        x = (x*x) % MOD;
    }
    return res;
}

long long  Inverse_Modulo(long long  a,long long  MOD)
{
    return BigMod(a,MOD-2,MOD);
}

long long N,K, MD = 1000000007;
vector<long long> Arr, nCk;

int main()
{
    long long i,j,k,l,tst=0,ans=0, csno=0;
    cin>>N>>K;

    for(i=0; i<N; i++) cin>>k, Arr.push_back(k);

    sort(Arr.begin(),Arr.end());

    nCk.push_back(1);
    for(i=K; i<=N; i++)
    {
        k = (nCk.back()*i)%MD;
        k= (k*Inverse_Modulo(i-K+1,MD))%MD;
        nCk.push_back(k);
    }

    for(i=0; i<N; i++)
    {
        if(i>=K-1) ans = (ans+(Arr[i]*nCk[i-K+1])%MD)%MD;
        //cout<<ans<<' ';
        if(i+K-1<N) ans = (MD+ans-(Arr[i]*nCk[N-i-K])%MD)%MD;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 1908
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		char[]n = stdIn.next().toCharArray();
		if(n[0]=='7'||n[1]=='7'||n[2]=='7') {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		
	}

}


Measured memory_bytes: 35696
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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, k;
	cin >> n >> k;
	map<ll, ll> mp;
	
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		mp[a] += b;
	}
	ll sum = 0, ans;
	for (auto x : mp) {
		sum += x.second;
		if (sum >= k) {
			ans = x.first;
			break;
		}
		
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4224
import sys
from collections import Counter
 
def main():
    input = sys.stdin.readline
    
    n = int(input())
    m = [int(i) for i in input().split()]
    
    #偶数列 奇数列
    even = [m[i] for i, _ in enumerate(m) if i % 2 == 0]
    odd = [m[i] for i, _ in enumerate(m) if i % 2 == 1]
    
    #頻値を取り出す
    even_c = Counter(even).most_common()
    odd_c = Counter(odd).most_common()
    
    ans = -1
    
    #print(even_c)
    #print(odd_c)
    #print(len(even_c))
    
    #最頻値の比較
    if even_c[0][0] != odd_c[0][0]:
        ans = len(m) - (even_c[0][1] + odd_c[0][1])
    
    #偶数列と奇数列の最頻値の数字が同じかつ、全て同じ数字じゃない
    elif even_c[0][0] == odd_c[0][0] and len(even_c) > 1:
        ans1 = len(m) - (even_c[0][1] + odd_c[1][1])
        ans2 = len(m) - (even_c[1][1] + odd_c[0][1])
        ans = ans1 if ans1 <= ans2 else ans2
    
    #全て同じ
    else:
        ans = even_c[0][1]
        
    #出力
    print(ans)
    
if __name__ == '__main__':
    main()
   

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

bool comp(pair<int, int> lhr, pair<int, int> rhr) {
  return lhr.first < rhr.first;
}

int main() {
  int N;
  cin >> N;
  pair<int, int> red[100], blue[100];
  for(int i=0 ; i<N ; i++) {
    int a, b;
    cin >> a >> b;
    red[i].first = a;
    red[i].second = b;
  }
  for(int i=0 ; i<N ; i++) {
    int c, d;
    cin >> c >> d;
    blue[i].first = c;
    blue[i].second = d;
  }

  sort(blue, blue+N, comp);

  int ans = 0;
  for (int i=0 ; i<N ; i++) {
    int max_y_idx = -1;
    for (int j=0 ; j<N ; j++) {
      if (max_y_idx == -1) {
        if (red[j].first < blue[i].first && red[j].second < blue[i].second && red[j].first != -1) max_y_idx = j;
      } else {
        if (red[j].second > red[max_y_idx].second && red[j].first < blue[i].first && red[j].second < blue[i].second && red[j].first != -1) max_y_idx = j;
      }
    }
    if (max_y_idx != -1) {
      red[max_y_idx].first = -1 ;
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]
  C = readline()

  pair = 0
  for i in 1:N-1
    if C[i]=='W' && C[i+1]=='R'
      pair += 1
    end
  end
  if pair == 0
    println(0)
    return
  end

  c = 0
  a=1
  b=N
  while true
    for i in a:N
      if C[i] == 'W'
        a=i
        break
      end
    end
    for j in b:-1:1
      if C[j] == 'R'
        b= j
        break
      end
    end
    if a < b
      c+=1
      a+=1
      b-=1
    else
      break
    end
  end
  println(c)



end

main()

Measured memory_bytes: 189856