akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
const char mp4[101][101]={
".....",
".abcc",
".abdd",
".ccab",
".ddab"
};
const char mp5[101][101]={
"......",
".aabbc",
".h.jjc",
".hi..d",
".gi..d",
".gffee"};
const char mp6[101][101]={
".......",
".aagh..",
".bbgh..",
"...cckl",
"...ddkl",
".ij..ee",
".ij..ff"
};
const char mp7[101][101]={
"........",
".aa.aa.a",
"...b..ba",
"...b..bc",
".aa.aa.c",
"...b..ba",
"...b..ba",
".aaccaa."
};
int n;
inline void doit(int id,int n) {
	if(id==4) for(res i=1;i<=id;++i) putchar(mp4[n][i]);
	if(id==5) for(res i=1;i<=id;++i) putchar(mp5[n][i]);
	if(id==6) for(res i=1;i<=id;++i) putchar(mp6[n][i]);
	if(id==7) for(res i=1;i<=id;++i) putchar(mp7[n][i]);
}
int main()
{
	read(n);
	if(n==2) return puts("-1"),0;
	if(n==3) return puts("aa.\n..a\n..a"),0;
	int now=n/4-1,m=n-(n/4-1)*4;
	for(res i=1;i<=now;++i)
	for(res k=1;k<=4;++k) {
		for(res j=1;j<=4*(i-1);++j) putchar('.');
		doit(4,k);
		for(res j=1;j<=n-4*i;++j) putchar('.');puts("");
	}
	for(res i=1;i<=m;++i) {
		for(res j=1;j<=n-m;++j) putchar('.');
		doit(m,i);
		puts("");
	}
	return 0;
}
/*
4
abcc
abdd
ccab
ddab
5
"......",
".aabbc",
".h.jjc",
".hi..d",
".gi..d",
".gffee"
6
".......",
".aagh..",
".bbgh..",
"...cckl",
"...ddkl",
".ij..ee",
".ij..ff"
7
"........",
".aa.aa.a",
"...b..ba",
"...b..bc",
".aa.aa.c",
"...b..ba",
"...b..ba",
".aaccaa."
*/
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,ans=0,mod=1000000007;
  cin >> n;
  if(n==3) {
    cout << 61 << endl;
    return 0;
  }
  vector<char> ji={'a','c','g','t'};
  vector<vector<long>> aaa(100,vector<long>(256));
  for(long i=0;i<256;i++) {
    if(ji[i%4]=='a') if(ji[i/4%4]=='g') if(ji[i/16%4]=='c') continue;
    if(ji[i%4]=='a') if(ji[i/4%4]=='c') if(ji[i/16%4]=='g') continue;
    if(ji[i%4]=='g') if(ji[i/4%4]=='a') if(ji[i/16%4]=='c') continue;
    if(ji[i/4%4]=='a') if(ji[i/16%4]=='g') if(ji[i/64%4]=='c') continue;
    if(ji[i/4%4]=='a') if(ji[i/16%4]=='c') if(ji[i/64%4]=='g') continue;
    if(ji[i/4%4]=='g') if(ji[i/16%4]=='a') if(ji[i/64%4]=='c') continue;
    if(ji[i%4]=='a') if(ji[i/4%4]=='g') if(ji[i/64%4]=='c') continue;
    if(ji[i%4]=='a') if(ji[i/16%4]=='g') if(ji[i/64%4]=='c') continue;
    aaa[0][i]++;
  }
  for(long i=0;i<n-4;i++) {
    for(long j=0;j<256;j++) {
      for(long k=0;k<4;k++) {
        if(ji[j/16%4]=='a') if(ji[j/64%4]=='g') if(ji[k]=='c') continue;
        if(ji[j/16%4]=='a') if(ji[j/64%4]=='c') if(ji[k]=='g') continue;
        if(ji[j/16%4]=='g') if(ji[j/64%4]=='a') if(ji[k]=='c') continue;
        if(ji[j/4%4]=='a') if(ji[j/16%4]=='g') if(ji[k]=='c') continue;
        if(ji[j/4%4]=='a') if(ji[j/64%4]=='g') if(ji[k]=='c') continue;
        aaa[i+1][j/4+k*64]=(aaa[i+1][j/4+k*64]+aaa[i][j])%mod;
      }
    }
  }
  for(long i=0;i<256;i++) {
    ans=(ans+aaa[n-4][i])%mod;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3812
from collections import deque
x,y,z,k = map(int,input().split())
a = sorted(list(map(int,input().split())),reverse=True)
b = sorted(list(map(int,input().split())),reverse=True)
c = sorted(list(map(int,input().split())),reverse=True)
ans = []
for i in range(x):
    for j in range(y):
        for m in range(z):
            if (i+1)*(j+1)*(m+1) <= k:
                ans.append(a[i]+b[j]+c[m])
            else:
                break

ans.sort(reverse=True)
for i in range(k):
    print(ans[i])


Measured memory_bytes: 9052
import sys
from collections import deque
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

n=int(input().rstrip())
a=[list(map(int,input().split())) for _ in range(2)]
ans=0
print(max([sum(a[0][:i+1])+sum(a[1][i:]) for i in range(n)]))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

void solve(){
  ll n; cin>>n;
  vector<pll> PI(n);
  rep(i,n){
    ll p; cin>>p;
    PI[i]=make_pair(p,i);
  }
  sort(PI.rbegin(),PI.rend());

  ll ans=0;
  multiset<ll> S{-1,-1,n,n};
  foreach(tup,PI){
    ll p,i; tie(p,i)=tup;
    auto it1=S.insert(i);
    auto it2=it1;
    ll l0=*(--it1), l1=*(--it1);
    ll r0=*(++it2), r1=*(++it2);
    ans+=p*((i-l0)*(r1-r0)+(l0-l1)*(r0-i));
  }
  
  cout<<ans<<"\n";
}

Measured memory_bytes: 6528
def f(t):
    print("{:02d}:{:02d}:{:02d}".format(t//3600,(t%3600)//60,(t%3600)%60))
if __name__=="__main__":
    while 1:
        h,m,s=map(int,input().split())
        if h<0:break
        t=7200-h*3600-m*60-s
        f(t)
        f(t*3)

Measured memory_bytes: 7692
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
int N;
pii micro[300001];

bool check(int n){
    if(n==0)return true;
    multiset<int> s;
    ll sum=0;
    for(int i=0;i<N;i++){
        // ツづ慊つセnツ古つ暗按可コ
        if(i<n){
            s.insert(micro[i].second);
            sum+=micro[i].second;
        }
        else{
            int maxNum=*(--s.end());
            if(maxNum>micro[i].second){
                s.erase(s.find(maxNum));
                s.insert(micro[i].second);
                sum+=micro[i].second;
                sum-=maxNum;
            }
        }
        if(i>=n-1){
            // nツ古つづ個閉スツ凝渉づーツ仰づ淞づ、ツ湘ーツ個渉づーツ鳴楪つスツつキツつゥツ計ツ算
            ll base=(ll)(micro[i].first)*n;
            if(sum<=base)return true;
        }
    }
    return false;
}

int main(){

    cin>>N;
    for(int i=0;i<N;i++)cin>>micro[i].second>>micro[i].first;
    sort(micro,micro+N,greater<pii>());
    int ub=N+1;
    int lb=0;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(check(mid))lb=mid;
        else ub=mid;
    }
    cout<<lb<<endl;

    return 0;
}

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

int main() {
  int N;
  scanf("%d", &N);
  vector<int64_t> A(N + 1);
  A.at(0) = 2;
  A.at(1) = 1;
  
  for (int i = 0; i < N - 1; i++) {
    A.at(i + 2) = A.at(i + 1) + A.at(i);
  }
  
  printf("%lld \n", A.at(N));
}


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

int main() {
  char a;
  cin>>a;
  if(a=='a'||a=='e'||a=='i'||a=='u'||a=='o'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#define ll long long
using namespace std;
const int maxn = 1e5 + 5;
int main()
{


    int n;
    cin>>n;
    if(n % 2 == 0)
    {
        cout<<n<<endl;
    }
    else
    {

        cout<<n * 2<<endl;  
    }
    return 0;
}


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

int main() {
    int N;
    int n[250];
    int res =0;
    cin >> N;
    for(int i=0;i<N;i++) cin >> n[i];
    while(true){
        bool kisuu_ari = false;
        for(int i=0;i<N;i++){
            if(n[i]%2!=0) kisuu_ari=true;
            else n[i]=n[i]/2;
        }
        if(kisuu_ari)break;
        res++;
    }   
    cout << res << endl;     
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define con continue
#define ub upper_bound
#define lb lower_bound


using namespace std;

ll pow1( ll a , ll b)
{

    if(b==1) return a ;
    ll x= pow1(a,b/2);
    x= x%mod*x%mod ;

    x=x%mod ;
    if(b%2==0) return x ;
    return (x*a%mod)%mod;
}



int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll n ;
     cin >> n ;
      if(n==1 )
      {

          cout << 0 << endl;


      }
    else
    {
         ll ans  = pow1(10,n)%mod;
     ans=  (ans%mod -  pow1(9,n)%mod + mod)%mod ;
      ans=  (ans%mod -  pow1(9,n)%mod + mod)%mod ;
      ans=  (ans%mod  +pow1(8,n)%mod)%mod ;
     cout << ans << endl;
    }
}


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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    int a, b, c, d; cin >> a >> b >> c >> d;

    int l = a + b;
    int r = c + d;

    if (l > r) {
        puts("Left");
    } else if (l == r) {
        puts("Balanced");
    } else {
        puts("Right");
    }
}

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

int main() {
  int N;
  cin >> N;
  string S;
  
  for (int i = 0; i < N; i++) {
	cin >> S;
    
    if (S == "Y") {
      break;
    }
  }
  
  if (S == "Y") {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

int A, B;

int main() {
    cin >> A;
    cin >> B;
    int c = A - B;
    int d = A + B;
    int e = A * B;
    if (c < d and e < d){
        cout << d;
    } else if (d <= c and e <= c) {
        cout << c;  
    } else if (c <= e and d <=  e) {
        cout << e;
    } 
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int n = in.nextInt();
            out.print((int) Math.pow(n, 3));
        }

    }
}



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

int main()
{
	char c;
	cin >> c;
	if (c <= 'Z' && c >= 'A')
	{
		cout << 'A'<<endl;
		
		//cout << c << " is uppercase, so we should print A." << endl;
	}
	else if (c <= 'z' && c >= 'a')
	{
		cout << 'a'<<endl;
		//cout << c << " is lowercase, so we should print a." << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
a = [int(i) for i in readline().split()]
sa = sorted(a)

for i in range(n):
    for j in range(i+1,n):
        r = a[:]
        r[i], r[j] = r[j], r[i]
        
        if sa == r:
            print("YES")
            exit()

if a == sa:
    print("YES")
else:
    print("NO")


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    VI v(n + 2, 0);
    REP(i, n) cin >> v[i + 1];
    
    VI v_sum_left(n + 2), v_sum_right(n + 2);
    REP(i, n + 1) v_sum_left[i + 1] = v_sum_left[i] + v[i + 1];
    FORR(i, n + 1, 1) v_sum_right[i - 1] = v_sum_right[i] + v[i - 1];

    // REP(i, n + 2) cerr << v_sum_left[i] << " ";
    // cerr << ln;
    // REP(i, n + 2) cerr << v_sum_right[i] << " ";
    // cerr << ln;

    
    int ans = 0;
    FOR(left, 0, n) {
        VI neg_bag;
        FOR(i, 1, left)if(v[i] < 0) neg_bag.push_back(abs(v[i]));
        FORR(right, n + 1, left + 1) {
            if(v[right] < 0) neg_bag.push_back(abs(v[right]));
            
            int return_cnt = k - (left + n - right + 1);
            if(return_cnt < 0) continue;
            int neg_sum = 0;
            sort(ALL(neg_bag), greater<int>());
            REP(j, min(return_cnt, (int)neg_bag.size())) neg_sum += neg_bag[j];
            ans = max(v_sum_left[left] + v_sum_right[right] + neg_sum, ans);
            // cerr << left << " " << right << " " << v_sum_left[left] + v_sum_right[right] << " " << neg_sum << ln;
        } 
    }
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
using namespace std;
string play="aaaaaaaaaa", str;
int main() {
    set<string> used;
    int i=0;
    while (true) {
        bool end=false;
        for (int j=1; j<8; j++) {
            for (int k=0; k<26; k++) {
                play[j]='a'+k;
                if (used.find(play)==used.end()) {
                    cout<<"?"<<play<<endl;
                    fflush(stdout);
                    used.insert(play);
                    cin>>str;
                    if (used.find(str)!=used.end()||str[0]!='a') {
                        end=true;
                        break;
                    }
                    used.insert(str);
                    play[0]=str[str.length()-1];
                }
            }
            if (end) break;
        }
        if (end) {
            puts("!OUT");
            break;
        }
    }
}

Measured memory_bytes: 0
#include <iostream>
#define int long long
#include <string>
signed main(){
  int N;
  int bef,aft;
  std::string ans="Yes";
  std::cin>>N;
  for (int i=0;i<N;i++){
    if(i==0){
      std::cin>>bef;
    }else{
      std::cin>>aft;
      if(aft>=bef+1){
        bef=aft-1;
      }else if(aft==bef){
        bef=aft;
      }else{
        ans="No";
        break;
      }
    }
  }
  std::cout<<ans<<std::endl;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
	int H,W;
	while(1){
		std::cin >> H >> W;
		
		if(H == 0 && W ==0){break;}

		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if((i+j)%2 == 0){std::cout << "#";}
				else if((i+j)%2 == 1){std::cout << ".";}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
}

Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define SREP(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int n, m;
	char s[100][11],t[100][11];
	int ans[100] = { 0 };
	scanf("%d", &n);
	REP(i, n) {
		scanf("%s", s[i]);
	}
	scanf("%d", &m);
	REP(i, m) {
		scanf("%s", t[i]);
	}
	REP(i, n) {
		REP(j, n) {
			if (!strcmp(s[i], s[j]))ans[i]++;
		}
		REP(j, m) {
			if (!strcmp(s[i], t[j]))ans[i]--;
		}
	}
	int max = 0;
	REP(i, n) {
		if (max < ans[i])max = ans[i];
	}
	PRINTD(max);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

int main(){
  ll q, h, s, d, n; 
  cin >> q >> h >> s >> d >> n;
  
  q = 4*q; h = 2*h; 

  ll m = min(q, min(h, s)), ans = 0;

  if(2*m <= d){
    ans = n * m;
  }
  else{
    ans = (n / 2)*d + ((n % 2)? m: 0);
  }

  cout << ans << endl; 

  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()

    return (n+m-1) // m


print(main())





Measured memory_bytes: 6740
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    double a,b,x;
    int n;
    cin >> a >> b;
    x = (a + b) / 2.0;
    n = 1000-int(1000.0-x);
    cout << n << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int n;
	cin >> n;
	int ans=0;
	if (n % 10 == 9)ans += 1;
	else { ans += 9; }
	n /= 10;
	if (n % 10 == 9)ans += 10;
	else { ans += 90; }
	n /= 10;
	if (n == 9)ans += 100;
	else { ans += 900; }
	cout << ans;
	ed;
	return 0;
}


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

int main() {
	
	int a, b;
	cin >> a >> b;
	if(a%2 == 1 && b%2 == 1){
		puts("Yes");
	}else{
		puts("No");
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, c = 1;
        while (true) {
            a = sc.nextInt();
            if (a == 0) break;
            System.out.println("Case " + (c++) + ": "  + a);
        }
    }
}


Measured memory_bytes: 41076
import heapq as h
n,m=map(int, input().split())
a=[list(map(int, input().split())) for _ in range(n)]
a.sort(key=lambda x:x[0])
hq=[]
x=0;d=0
for i in range(1,m+1):
  while d<n and a[d][0]<=i:
    h.heappush(hq,-a[d][1])
    d+=1
  if len(hq):
    x+=-h.heappop(hq)
print(x)

Measured memory_bytes: 31924
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
int flag[130] = {};

int main() {
    char c;
    string s;

    cin >> s;

    while (!s.empty()) {
        c = s[0];
        s.erase(0,1);
        flag[(int)c] = 1;
    }

    for (char i = 'a'; i <= 'z'; i++) {
        if (flag[(int)i] == 0) {
            cout << i << '\n';
            return 0;
        }
    }

    cout << "None\n";
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <cassert>

int n, m;
std::vector <std::vector <std::pair <int, int>>> edge;
std::vector <int> dis;
std::vector <std::set <int>> vis;

int main () {
	std::cin >> n >> m;
	edge.resize (n);
	dis.assign (n, 1e9);
	vis.resize (n);
	while (m--) {
		int p, q, c;
		std::cin >> p >> q >> c;
		--p, --q;
		edge[p].push_back ({q, c});
		edge[q].push_back ({p, c});
	}
	std::set <std::pair <int,int>> q;
	q.insert ({0,0}); dis[0] = 0;
	while (!q.empty()) {
		int u = q.begin()->second, d = q.begin()->first;
		u = -u;
		assert (d == dis[u]);
		q.erase (q.begin());
		for (auto v : edge[u]) {
			int w = vis[u].count (v.second) ^ 1;
			if (dis[v.first] > dis[u] + w) {
				q.erase ({dis[v.first], -v.first});
				dis[v.first] = dis[u] + w;
				vis[v.first].clear ();
				vis[v.first].insert (v.second);
				q.insert ({dis[v.first], -v.first});
			} else if (dis[v.first] == dis[u] + w) {
				vis[v.first].insert (v.second);
			}
		}
	}
	if (dis[n-1] == 1e9) dis[n-1] = -1;
	std::cout << dis[n-1] << "\n";

	return 0;
}

Measured memory_bytes: 25332
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        char[] charArrays = a.toCharArray();

        int max = 0;
        for (int i=0; i<charArrays.length; i++) {
            StringBuilder sb = new StringBuilder();
            for (int j=i; j<charArrays.length; j++) {
                if (!isACGT(charArrays[j])) {
                    break;
                }
                sb.append(charArrays[j]);
                String ret = sb.toString();
                if (max < ret.length()) {
                    max = ret.length();
                }
            }
        }

        System.out.println(max);
    }

    public static boolean isACGT(char c) {
        String s = String.valueOf(c);
        switch (s) {
            case "A":
                return true;
            case "C":
                return true;
            case "G":
                return true;
            case "T":
                return true;
            default:
                return false;
        }
    }
}


Measured memory_bytes: 21712
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int N;
    cin >> N;
    double T, A;
    cin >> T >> A;
    vector<double> height(N), diff(N);
    for (int i = 0; i < N; i++) {
        cin >> height.at(i);
    }
    double ideal_height = (T - A) / 0.006;
    
    for (int i = 0; i < N; i++) {
        diff.at(i) = labs(height.at(i) - ideal_height);
    }
    
    int index = 0;
    int min = diff.at(0);
    for (int i = 0; i < N; i++) {
        if (min > diff.at(i)) {
            index = i;
            min = diff.at(i);
        }
    }
    
    cout << index + 1 << endl;
    
    return 0;
}


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

int main()
{
    long long int a, b, c;
    while(scanf("%lld%lld", &a, &b)!=EOF)
    {
        c = a + b;
        if(c<10)
        {
            printf("1\n");
        }
        else if(c>9 && c<100)
        {
            printf("2\n");
        }
        else if(c>99 && c<1000)
        {
            printf("3\n");
        }
        else if(c>999 && c<10000)
        {
            printf("4\n");
        }
        else if(c>9999 && c<100000)
        {
            printf("5\n");
        }
        else if(c>99999 && c<1000000)
        {
            printf("6\n");
        }
        else if(c>999999 && c<10000000)
        {
            printf("7\n");
        }
    }
    return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int>p(n);
	for (int& x : p)cin >> x;
	sort(p.begin(), p.end());
	p[p.size() - 1] /= 2;
	cout << accumulate(p.begin(), p.end(), 0) << endl;
}


Measured memory_bytes: 256
from collections import Counter as C

_ = input()
a = C([int(x) for x in input().split()])

b = []
for k, v in a.items():
    b.extend([k] * (v // 2))
else:
    if 2 <= len(b):
        b.sort()
        print(b[-1] * b[-2])
    else:
        print(0)

Measured memory_bytes: 21952
import java.io.*;
import java.util.*;

public class Main{


	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		String []x=sc.next().split("/");
		int m=Integer.parseInt(x[1]);
		if(m>4 || Integer.parseInt(x[2])>30)
			out.println("TBD");
		else
			out.println("Heisei");
		
		out.close();
	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 22740
def solve(s)
  s2 = s.each_char.map do |c|
    i = c.ord
    if i < 'a'.ord || i > 'z'.ord
      c
    else
      a = i + 1
      a = 'a'.ord if a > 'z'.ord
      a.chr
    end
  end.join
  if s2.split(/[. ]/).select{|w| w == "the" || w == "this" || w == "that"}.size > 0
    s2
  else
    solve(s2)
  end
end

gets(nil).chomp.split("\n").each do |s|
  puts solve(s)
end

Measured memory_bytes: 6108
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	REP(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int count = a.size();
	REP(i, a.size()-1) {
		if (a[i] == a[i + 1]) {
			count -= 2;
			i++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
int a[105]={0};
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		int x;
		cin>>x;
		while(x--){
			int xx;
			cin>>xx;
			a[xx]++;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]==0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<pair<int, int> > a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i].first;
		b[i].second = i;
	}
	sort(a.begin(), a.end());           // 从小到大排序 
	sort(b.begin(), b.end());
	for (int i = 0; i < n; i++) {
		if (a[i].first > b[i].first) {
			cout << "No\n";
			return 0;
		}
	}
	for (int i = 1; i < n; i++) {
		if (a[i] <= b[i - 1]) {
			cout << "Yes\n";
			return 0;
		}
	}
	vector<int> to(n);
	for (int i = 0; i < n; i++) {
		to[a[i].second] = b[i].second;
	}
	int cur = 0;
	int cnt = 0;
	do {
		cur = to[cur];
		cnt++;
	} while (cur != 0);
	cout << (cnt >= (n - 1) ? "No\n" : "Yes\n");
	return 0;
}

Measured memory_bytes: 2176
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define T3I tuple<int, int, int>
#define x first
#define y second
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

ll n, p;

void solve2(int n)
{
    string s;
    cin >> s;
    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        if((s[i]-'0')%2 == 0) {
            ans += i+1;
        }
    }
    cout << ans << endl;
}

void solve5(int n)
{
    string s;
    cin >> s;
    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        if(s[i] == '0' || s[i] == '5') {
            ans += i+1;
        }
    }
    cout << ans << endl;
}

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

    cin >> n >> p;
    if(p == 2) {
        solve2(n);
        return 0;
    }else if(p == 5) {
        solve5(n);
        return 0;
    }
    string s;
    cin >> s;
    vector<ll> dex(n);
    dex[0] = 1;
    for(int i = 1; i < n; ++i) {
        dex[i] = dex[i-1]*10%p;
    }
    map<ll, ll> cnt;
    ll ans = 0;
    ll cur = 0;
    for(int i = n-1; i >= 0; --i) {
        cur = dex[n-1-i]*(s[i]-'0')%p+cur;
        cur %= p;
        ++cnt[cur];
    }
    cur = 0;
    for(int i = n-1; i >= 0; --i) {
        cur = dex[n-1-i]*(s[i]-'0')%p+cur;
        cur %= p;
        if(cur == 0) {
            ans += cnt[cur];
            --cnt[cur];
        }else {
            --cnt[cur];
            ans += cnt[cur];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2580
s = input().strip()

d = {
    'a': 0,
    'b': 0,
    'c': 0,
    'd': 0,
    'e': 0,
    'f': 0,
    'g': 0,
    'h': 0,
    'i': 0,
    'j': 0,
    'k': 0,
    'l': 0,
    'm': 0,
    'n': 0,
    'o': 0,
    'p': 0,
    'q': 0,
    'r': 0,
    's': 0,
    't': 0,
    'u': 0,
    'v': 0,
    'w': 0,
    'x': 0,
    'y': 0,
    'z': 0,
}

for c in s:
    d[c] += 1

for c in sorted(d.keys()):
    if d[c] == 0:
        print(c)
        exit(0)

print('None')


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	static final int COIN = 500;

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();
		if (COIN * x >= y) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main() {
  int n;long long ans = -2000000001,min;
  cin >> n >> min;
  for(int i = 1;i < n;i++){
    long long r;
    cin >> r;
    if(ans < r-min) ans = r-min;
    if(r < min) min = r;
  }
  cout << ans << endl;
}



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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    bool flag = 0;
    rep(i, b)
    {
        if (a * i % b == c)
            flag = 1;
    }

    flag == 1 ? OP("YES") : OP("NO");
    return 0;
}

Measured memory_bytes: 256
import math

n, k = map(int, raw_input().split(" "))

if n >= k:
    base = float(n - k + 1) / float(n)
else:
    base = 0

sum = base

for i in range(1, min(k, n + 1)):
    l = math.ceil(math.log(float(k) / float(i), 2))
    # print("i=%d l=%d" % (i, l))
    sum += (1.0 / float(n)) * (0.5 ** l)

print(sum)


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

int main() {
  int n, k;
  vector<int> h;
  cin >> n >> k;

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a >= k) {
      ans++;
    }
  }

  cout << ans << endl;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;
int modpow(int a, int p) {
	if (p == 0) return 1;
	int res = modpow(a, p / 2);
	res = (res * res) % MOD;
	if (p & 1) res = (res * a) % MOD;
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int K;
	cin >> K;
	int N = 3;
	vector<vector<int> > X(K + 1);
	for (int i = 1; i <= K; i++) {
		for (int j = i + i; j <= K; j += i) {
			X[j].push_back(i);
		}
	}
	int res = 0;
	vector<int> A(K + 1);
	for (int i = K; i > 0; i--) {
		int x = modpow(K / i, N);
		A[i] = (A[i] + x) % MOD;
		res = (res + A[i] * i) % MOD;
		for (int &j : X[i]) {
			A[j] = (A[j] + MOD - A[i]) % MOD;
		}
	}
	cout << res << endl;
}

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

struct card {
	int m;
	char str[201];
	int h[100];
};

void shuffle(struct card *s){
	int i,j;
	char copy[201]="\0";
	for (i = 0; i < s->m; i++){
		strncpy(copy,&s->str[0], s->h[i]);
		sprintf(s->str, "%s%s",&s->str[s->h[i]],copy); //str[i]~+str[0]~str[i-1]
		j = 0;
		while (copy[j] != '\0'){ //copyの初期化
			copy[j] = '\0';
			j++;
		}
	}
}

int main(void){
	struct card s[10];
	int i=0,j;
	while (1){
		if (i > 10)
			break;

		scanf("%s", &s[i].str);
		if (s[i].str[0] == '-')
			break;
		scanf("%d", &s[i].m);
		for (j = 0; j < s[i].m; j++){
			scanf("%d", &s[i].h[j]);
		}
		i++;
	}

	int n = i;
	for (i = 0; i < n; i++){
		shuffle(&s[i]);
		printf("%s\n", s[i].str);
	}


	return 0;
}


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

int main() {
    int n = 0;
    int i, j;
    int a[200020] = {0};
    int x = 0;
    scanf("%d", &n);

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

    for (j = 0; j < n; j++) {
        printf("%d ", (x ^ a[j]));
    }
}



Measured memory_bytes: 3312
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    needs = [2, 5, 5, 4, 5, 6, 3, 7, 6]
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())), reverse=True)

    dp = [-1]*(N+1)
    # 初期条件
    dp[0] = 0

    # ループ
    for a in A:
        na = needs[a-1]
        for i in range(N+1):
            if i-na >= 0:
                if dp[i-na] == -1:
                    continue
                dp[i] = max(dp[i], dp[i-na]*10+a)

    print(dp[N])


resolve()

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

const int MAX_N=100001;

int is_prime[MAX_N];

void sieve(int n) {
  rep(i, n+1) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  rep(i, n) {
    if (i<2) continue;
    if (is_prime[i]) {
      for (int j=2*i; j<=n; j+=i) is_prime[j]=false;
    }
  }
  return ;
}

int main() {
  int q; cin>>q;
  vector<int> l(q),r(q);
  rep(i, q) cin>>l[i]>>r[i];

  sieve(MAX_N);
  int sum[MAX_N];
  sum[0]=sum[1]=0;
  rep(i, MAX_N) {
    if (i<2) continue;
    if (is_prime[i]&&is_prime[(i+1)/2]) {
      sum[i]=sum[i-1]+1;
    } else sum[i]=sum[i-1];
  }
  rep(i, q) {
    int tmp=sum[r[i]]-sum[l[i]-1];
    cout<<tmp<<endl;
  }
  return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

vector<int> quauter(int n, int m) {    
    vector<int> ans(n);
    rp(i, 0, n) {
        ans.at(i) = m % 4;
        m /= 4;
    }
    return ans;
}

int main() {
    int n, a, b, c;
    scanf("%d%d%d%d", &n, &a, &b, &c);
    vector<int> l(n);
    rp(i, 0, n) scanf("%d", &l.at(i));
    int ans = mod;

    for(int i = 0; i < 1<<2*n; i++) {
        int res = 0;
        vector<int> s = quauter(n, i);
        vector<int> instant(4);
        rp(j, 0, n) {
            if(s.at(j)){ //s.at(j)が1,2,3のとき、j番目の竹（l.at(j))をa,b,cを作るために使う場合を考える
                if(instant.at(s.at(j))) { //すでに他の竹がj番目の竹と同じところに使われることになっていたとき、
                    res += 10; //合成することになる
                }
                instant.at(s.at(j)) += l.at(j);
            }
        }
        if(instant.at(1) && instant.at(2) && instant.at(3)) {
        //各竹を作るために必要な竹は決まったので、あとは１ずつ調整
            res += abs(a - instant.at(1));
            res += abs(b - instant.at(2));
            res += abs(c - instant.at(3));
            chmin(ans, res);
        }
    }
    printf("%d", ans);
    return 0;
}

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

int culc_GCD(int a, int b);

int main()
{
	int a, b;		//??¬?´???°????±????????????¨??????2???
	int result;		//a,b?????¬?´???°
	
	//2????????\???
	cin >> a >> b;
	
	if(a >= b)
	{
		result = culc_GCD(a, b);
	}
	else
	{
		result = culc_GCD(b, a);
	}
	
	cout << result << endl;

}

/**/
/**/
/**/
int culc_GCD(int a, int b)
{
	int temp;
	while (b != 0)
	{
		temp = a;
		a = b;
		b = temp % b;
	}
	
	return a;

}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

const ll MAX = 200010;//設定して

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

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

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

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  COMinit();
  ll n,k,ans=0;cin>>n>>k;
  V<ll> v(n);
  rep(i,0,n)cin>>v[i];
  sort(all(v));

  rep(i,0,n){
    if(i>=k-1){
      ans+=v[i]*COM(i,k-1);
      ans%=mod;
    }

    if(k-1<=n-1-i){
      ans+=(mod-v[i])*COM(n-1-i,k-1);
      ans%=mod;
    }
  }
  cout<<ans<<ENDL;


}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 5760
#include <stdio.h>
#include <math.h>
int main(){
    int N,D;
    scanf("%d %d",&N,&D);
    int X[N][D];
    for(int i=0; i<N; i++){
        for(int j=0; j<D; j++){
            scanf("%d",&X[i][j]);
        }
    }
    
    int count = 0;
    int distance2=0;
    double distance=0;
    for(int i=0; i<N-1; i++){
        for(int k=i+1; k<N; k++){
            for(int j=0; j<D; j++){
                distance2 = pow(((double)(X[i][j]-X[k][j])),2)+distance2;
            }
            distance = sqrt(distance2);
            if(ceil(distance)==floor(distance)){
                count++;
            }
            distance = 0;
            distance2 = 0;
        }
    }
    printf("%d\n",count);
    return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main()
{
	int n;
	cin >> n;

	vector<vector<int>> a(2, vector<int>(n));
	vector<vector<int>> dp(2, vector<int>(n));

	for (int y = 0; y < 2; y++)
	{
		for (int x = 0; x < n; x++)
		{
			cin >> a[y][x];
		}
	}

	for (int x = 0; x < n; x++)
	{
		if (x == 0) dp[0][x] = a[0][x];
		else
		{
			dp[0][x] = dp[0][x - 1] + a[0][x];
		}
	}

	for (int x = 0; x < n; x++)
	{
		if (x == 0) dp[1][x] = dp[0][x] + a[1][0];
		else
		{
			dp[1][x] = max(dp[0][x] + a[1][x], dp[1][x - 1] + a[1][x]);
		}
	}

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


Measured memory_bytes: 256
n, m, x = [int(i) for i in input().split()]
cc = []
aa = []
for _ in range(n):
    c, *a = [int(i) for i in input().split()]
    cc.append(c)
    aa.append(a)
ans = 10 ** 18
for i in range(2 ** n):
    ri = [0] * m
    co = 0
    for j in range(n):
        if (i >> j) & 1 == 1:
            co += cc[j]
            for k in range(m):
                ri[k] += aa[j][k]
    
    for j in ri:
        if j < x:
            break
    else:
        ans = min(ans, co)

if ans == 10 ** 18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9224
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl
#define mp make_pair
#define fir first
#define sec second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;

char str[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

int main() {

	scanf("%s",str + 1);
	int n = strlen(str + 1);
	int cnt = 0; ll ans = 0;
	for(int i = 1;i <= n;i ++) {
		if(str[i] == 'A') cnt++;
		else if(str[i] == 'B' && str[i + 1] == 'C') ans += cnt,i ++;
		else cnt = 0;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 3e5 + 5;

int n , m;
vector<int> adj[maxn];
int res[maxn];
int bit[maxn];

void update(int x,int y){
    for( ; x <= m ; x += x & -x){
        bit[x] += y;
    }
}

int query(int x){
    int res = 0;
    for( ; x > 0 ; x &= x - 1){
        res += bit[x];
    }
    return res;
}

int main(){
    if(fopen(taskname".INP","r")){
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    cin >> n >> m;
    for(int i = 1 ; i <= n ; ++i){
        int l , r;cin >> l >> r;
        adj[r - l + 1].pb(l);
    }
    for(int i = m ; i >= 1 ; --i){
        res[i] = res[i + 1] + adj[i + 1].size();
    }
    for(int i = 1 ; i <= m ; ++i){
        for(int c : adj[i]){
            update(c , 1);
            update(c + i , -1);
        }
        for(int j = i ; j <= m ; j += i){
            res[i] += query(j);
        }
        cout << res[i] << '\n';
    }
}



Measured memory_bytes: 12160
n, k = map(int, input().split())
list_A = list(map(int, input().split()))
a = list_A.index(1) + 1
ans = 0
cnt = 0
amari = 0
if a == 1:
    ans += 0
else:
    ans += (a-1)//(k-1)
    if (a-1)%(k-1) != 0:
        ans += 1
        cnt += 1
        amari += (a-1)%(k-1)

if a == n:
    ans += 0
else:
    ans += (n-a)//(k-1)
    if (n-a)%(k-1) != 0:
        ans += 1
        cnt += 1
        amari += (n-a)%(k-1)

if cnt == 2 and amari <= k-1:
    ans -= 1

print(ans)

Measured memory_bytes: 14008
#include <iostream>
#include <string>

int main()
{
    std::string S;
    std::cin >> S;
    if (*S.rbegin() == 's') {
        S += "es";
    }
    else {
        S += "s";
    }
    std::cout << S << std::endl;

    return 0;
}


Measured memory_bytes: 3620
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A_all = []
for i in range(K):
    d = int(readline())
    A = list(map(int,readline().split()))
    A_all += A
set(A_all)
cnt = 0
for i in range(1,N+1):
    if i not in A_all:
        cnt +=1
print(cnt)

Measured memory_bytes: 9160
#include <stdio.h>
int main(void){
    // Your code here!

 int a, b, c; 
     int tmp; 
     scanf("%d %d %d", &a, &b, &c); 
     if(a>b){ 
         tmp=a; 
         a=b; 
        b=tmp; 
     } 
     if(b>c){ 
        tmp=b; 
        b=c; 
         c=tmp; 
     } 
     if(a>b){ 
         tmp=a; 
         a=b; 
         b=tmp; 
     } 
     printf("%d %d %d\n", a, b, c); 
     return 0; 
}


Measured memory_bytes: 2104
import java.util.*;

class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      int[] p = new int[N];
      int sacrifice = 0;
      int sum = 0;
      
      for(int i=0;i<N;i++){
        p[i] = sc.nextInt();
      }
      
      for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
          if(p[i] > p[j]){
            sacrifice = p[i];
            p[i] = p[j];
            p[j] = sacrifice;
          }
        }
      }
      
      for(int i=0;i<K;i++){
        sum += p[i];
      }
      
      System.out.println(sum);
	}
}

Measured memory_bytes: 38848
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> A(n), B(n), C(n);
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < n; i++) cin >> B[i];
    for (int i = 0; i < n; i++) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    vector<long long> D(n);
    for (int i = 0; i < n; i++) {
        int x = B[i];
        auto itr = lower_bound(A.begin(), A.end(), x);
        int index = distance(A.begin(), itr);
        if(i==0) D[i] = index;
        else D[i] = D[i-1] + index;
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int x = C[i];
        auto itr_b = lower_bound(B.begin(), B.end(), x);
        int nb = distance(B.begin(), itr_b);
        if(nb == 0) continue;
        ans += D[nb-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176