akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

										`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	l := nextInt()
	r := nextInt()
	d := nextInt()

	ans := r/d - (l-1)/d

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)

}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func printArray(a []int) {
	for i := 0; i < len(a); i++ {
		if i >= 1 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, a[i])
	}
	fmt.Fprintln(out)
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}

// 挿入ソート配列
type slist struct {
	l []int
}

func makeSlist() slist {
	return slist{[]int{}}
}

func (s *slist) add(a int) {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	if pos < len(s.l) {
		s.l = append(s.l[:pos+1], s.l[pos:]...)
		s.l[pos] = a
	} else {
		s.l = append(s.l, a)
	}
}
func (s slist) contains(a int) bool {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	return pos < len(s.l) && s.l[pos] == a
}


Measured memory_bytes: 1804
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
	var line = input[0].split(" ");
	var max = parseInt(line[0]);
	var sum = parseInt(line[1]);
	var ans = 0;
	var maxover3 = Math.ceil(sum/3);
	var remain = 0;
	for(var i = 0; i <= maxover3;i++){
		remain = sum - i;
		for(var j = i;j<=max;j++){
			var k = remain - j;
			if(k>=j&&k<=max){
				if(i===j&&i===k){
					ans++;
					 	      //console.log(String(i)+" "+String(j)+" "+String(k));
				} else if(i===j||i===k||k===j){
					ans+=3;
					 	      //console.log(String(i)+" "+String(j)+" "+String(k));
				} else {
					ans+=6;
					 	     //console.log(String(i)+" "+String(j)+" "+String(k));
				}
			}

		}
	}
	console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int MMAX=10;
const int QMAX=50;
int B[MMAX];
int a[QMAX],b[QMAX],c[QMAX],d[QMAX];
int N,Q;

int calcscore(void){

    int anstmp=0;
    int A[N];
    for(int i=0; i<N; i++){
        if(i==0){
            A[i]=1+B[i];
        }else{
            A[i]=A[i-1]+B[i];
        }
    }

    for(int i=0; i<Q; i++){
        //cout << "Aai-Abi ci " << A[a[i]-1]-A[b[i]-1] << " " << c[i] << endl;
        if( A[b[i]-1]-A[a[i]-1]==c[i] ){
            anstmp += d[i];
            //cout << "anstmp-> " << anstmp << endl;
        }
    }
    /*
    cout << "A: ";
    for(int i=0; i<N; i++){
        cout << A[i] << " ";
    }
    cout << "anstmp " << anstmp << endl;*/  

    return anstmp;
}

int dfs(int m, int n, int depth){ // m items distributed with n people

    int anstmp=0;
    if(n==0){
        B[depth]=0;

        anstmp = calcscore();
        return anstmp;
    }else{
        int ret=0;
        for(int i=0; i<m; i++){
            B[depth]=i;
            ret = dfs(m-i,n-1,depth+1);
            anstmp = max(anstmp,ret);
        }
        return anstmp;
    }
}

int main(){
    int M;
    cin >> N >> M >> Q;

    for(int i=0; i<Q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    int ans = dfs(M,N,0);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

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


#define all all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;

typedef long long ll;

// struct cho{
// 	int a;
// 	int x;
// 	int y;
// }


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

		if(h==0) break;
		int ah=150,aw=150;
		int at=150*150+150*150;
		for(int x=1;x<151;x++){
			for(int y=x-1;y>0;y--){
				if(h==y&&w==x) continue;
				
				ll t = x*x+y*y;

				if(h*h+w*w <= t){
					at = ah*ah+aw*aw;
					if(h*h+w*w == t){
						if(h >= y) continue;
					}
					if(t < at){
						ah = y;
						aw = x;
					}else if(t == at){
						if(ah > y){
							ah = y;
							aw = x;
						}
					}
				}

				
			}
		}
		cout << ah << " " << aw <<endl;

	}
	return 0;
}

Measured memory_bytes: 2976
#define s(p)!strstr(a,"th"#p)
char*c;main(i,a){for(;~scanf("%[^\n] ",a);puts(a))for(;s(is)&&s(at)&&s(e);)for(c=a;*c;c++)*c<97||(*c=(*c+8)%26+97);c=0;}

Measured memory_bytes: 0
#include <bits/stdc++.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-1; ++i){
      cin >> C[i];
  }
    
  int ans = 0;
  for(int i = 0; i < N; ++i){
    ans += B[A[i]-1];
    if(i > 0 && A[i-1] + 1 == A[i]){
        ans += C[A[i] - 2];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N;
    cin >> N;
    string dir; 
    cin >> dir;

    int dp[N];
    if (dir[0] == 'E') dp[0] = 1;
    else dp[0] = 0;
    for (int i = 1; i < dir.size(); i++) {
        if (dir[i] == 'E') dp[i] = dp[i-1] + 1;
        else dp[i] = dp[i-1];
    }

    int ref[N];

    for (int i = 0; i < N; i++) {
        if (i == 0) ref[i] = dp[N-1] - dp[0];
        else ref[i] = dp[N-1] - dp[i] + i - dp[i-1];
    }

    sort(ref, ref+N);

    cout << ref[0] << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/


int main(){
  int n;
  cin >> n;
  vector<pair<int,P>> x(n);
  rep(i,n){ cin >> x[i].S.F >> x[i].S.S >> x[i].F; }
  sort(x.rbegin(),x.rend());

  int ansx=-1,ansy=-1,ansh=-1;
  rep(i,101)rep(j,101){
    int htmp = x[0].F+abs(i-x[0].S.F)+abs(j-x[0].S.S);
    bool flag=true;
    rep(k,n){
      if(htmp == x[k].F+abs(i-x[k].S.F)+abs(j-x[k].S.S) || (x[k].F==0&&(htmp-abs(i-x[k].S.F)-abs(j-x[k].S.S)<=0))){
        continue;
      } else { flag=false; break; }
    }
    if(flag){ansx=i;ansy=j;ansh=htmp; break; }
  }
  cout << ansx << " " << ansy << " " << ansh << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define umap unordered_map

ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}

// h!=0
// H = h1 + |x1-cx| + |y1-cy|
// H = h2 + |x2-cx| + |y2-cy|

int main(){
  ll N; cin>>N;
  ll x[N];
  ll y[N];
  ll h[N];
  REP(i,N){
    cin >>x[i]>>y[i]>>h[i];
  }
  bool flag = false;
  for(ll cx=0;cx<101;cx++){
    for(ll cy=0;cy<101;cy++){
      ll H=-1;
      ll H_temp;
      flag = true;
      REP(i,N){
        H_temp = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
        if(h[i]!=0){
    	  if(H==-1){H = H_temp; i=-1; continue; }
          else if(H_temp!=H){flag = false;break;}
        }else{
          if(H==-1){continue;}
          else if(H > abs(x[i]-cx) + abs(y[i]-cy)){flag =false;break;}
        }
      }
      if(flag){printf("%ld %ld %ld\n",cx,cy,H); break;}
    }
    if(flag){break;}
  }
  
}


Measured memory_bytes: 256
// Problem : K - Stones
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_k
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define mii map<ll, ll>
#define pii pair<ll, ll>
#define pb push_back
#define fi first
#define se second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()

const ll inf=0x3f3f3f3f3f3f3f3f;
const ll N = 1e5 + 5;
ll dp[N] = {0};
//dp[i] ->1 if first wins

int main() {
    SPEED;
    ll n, k;
    cin>>n>>k;
    vi v(n);
    for(ll i = 0; i < n; i++) {
    	cin>>v[i];
    }
    for(ll i = 0; i <= k; i++) {
    	for(ll x:v) {
    		if(x <= i && !dp[i - x]) {
    			dp[i] = 1;
    		}
    	}
    }
    if(dp[k])cout<<"First";
    else cout<<"Second";
    return 0;
}

Measured memory_bytes: 4372
n = int(input())
s = input()

cnt = [[False] * 10 for _ in range(11)]
ans = set()
for c in s:
    v = int(c)
    for i in range(10):
        for j in range(10):
            if cnt[i][j]:
                ans.add(i*100+j*10+v)
    for i in range(10):
        if cnt[10][i]:
            cnt[i][v] = True
    cnt[10][v] = True
print(len(ans))


Measured memory_bytes: 44476
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

const int N=1e5+5;

ll apple[3*N];

bool cmp(ll a,ll b){
    return a>b;
}

int main(){
	
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    
    for(int i=0;i<a;i++){
        cin>>apple[i];
    }
    
    sort(apple,apple+a,cmp);
    
    for(int i=x;i<x+b;i++){
        cin>>apple[i];
    }
    
    sort(apple+x,apple+x+b,cmp);
    
    for(int i=x+y;i<x+y+c;i++){
        cin>>apple[i];
    }
    
    sort(apple,apple+x+y+c,cmp);
    
    ll sum=0;
    
    for(int i=0;i<x+y;i++) sum+=apple[i];
    
    cout<<sum<<endl;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int num[20020020];

int main(){
    fast_io
    
    int r;
    cin>>r;
    cout<<fixed<<setprecision(5)<<r*2*PI<<endl;

    return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
vector<ll> badget(202000,0);
void Main(){
    ll n;cin>>n;
    ll d;cin>>d;
    ll a;cin>>a;
    vector<pair<ll,ll>> x(n);
    For(i,0,n)cin>>x[i].first>>x[i].second;
    sort(ALL(x));
    For(i,0,n){
        if(i>0) badget[i]+=badget[i-1];
        if(x[i].second-badget[i]<=0) continue;
        else{
            ll hp=x[i].second-badget[i];
            ll bakugeki=(hp+a-1)/a;
            ans+=bakugeki;
            auto itr=upper_bound(ALL(x),make_pair(x[i].first+2*d,ll(10000000000)));
            ll right=itr-x.begin();
            ll left=i;
            badget[left]+=bakugeki*a;
            badget[right]-=bakugeki*a;
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll M, D;
    cin >> M >> D;
    ll ans = 0;
    REP(i, M)
    {
        REP(j, D)
        {
            ll m = i + 1;
            ll d = j + 1;
            ll d1 = d % 10;
            ll d2 = d / 10;
            if (d1 >= 2 && d2 >= 2 && d1 * d2 == m)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import           Control.Applicative

minkowski :: Double -> [Double] -> [Double] -> Double
minkowski p xs ys = (** (1/p)) . sum $ zipWith f xs ys
  where
    f x y = abs (x - y) ** p

chebyshev :: [Double] -> [Double] -> Double
chebyshev xs ys = maximum $ zipWith f xs ys
  where
    f x y = abs (x - y)

main :: IO ()
main = do
    getLine
    xs <- fmap read . words <$> getLine :: IO [Double]
    ys <- fmap read . words <$> getLine :: IO [Double]
    print $ minkowski 1 xs ys
    print $ minkowski 2 xs ys
    print $ minkowski 3 xs ys
    print $ chebyshev xs ys



Measured memory_bytes: 4464
use proconio::input;

fn main() {
    unsafe {
        input!(n: usize, k: usize, ijc: [(usize, usize, char); n]);
        let mut g = vec![vec![0; k + 1]; k + 1];
        let mut b_count = 0;
        let mut w_count = 0;
        for &(i, j, c) in &ijc {
            *g.get_unchecked_mut(i % k + 1).get_unchecked_mut(j % k + 1) +=
                if ((i / k + j / k) % 2 == 1) ^ (c == 'W') {
                    w_count += 1;
                    1
                } else {
                    b_count += 1;
                    -1
                };
        }
        for i in 0..k {
            for j in 0..k {
                *g.get_unchecked_mut(i + 1).get_unchecked_mut(j + 1) +=
                    g.get_unchecked(i + 1).get_unchecked(j)
                        + g.get_unchecked(i).get_unchecked(j + 1)
                        - g.get_unchecked(i).get_unchecked(j);
            }
        }

        let mut min = std::i32::MAX;
        let mut max = std::i32::MIN;
        for i in 0..k {
            for j in 0..k {
                let x = g.get_unchecked(k).get_unchecked(k)
                    - g.get_unchecked(i).get_unchecked(k)
                    - g.get_unchecked(k).get_unchecked(j)
                    + 2 * g.get_unchecked(i).get_unchecked(j);
                if x < min {
                    min = x;
                }
                if max < x {
                    max = x;
                }
            }
        }
        println!("{}", std::cmp::max(-min + w_count, max + b_count));
    }
}


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

using namespace std;

int main (){

    long long r,i,n,c=0;

    cin>>n;

    r=log10(n)+1;

    if(r==1) cout<<n<<endl;
    else if(r==2) cout<<"9"<<endl;
    else if(r==3) cout<<9+(n-99)<<endl;
    else if(r==4) cout<<909<<endl;
    else if(r==5) cout<<(n-9090)<<endl;
    else if(r==6) cout<<90909<<endl;

    return 0;

}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	a := getNextInt64(scanner)
	b := getNextInt64(scanner)
	hh := make([]int64, n)

	for i := 0; i < n; i++ {
		hh[i] = getNextInt64(scanner)
	}
	l := int64(-1)
	r := int64(1e9)

	for l+1 < r {
		m := (l + r) >> 1
		cnt := int64(0)
		for i := 0; i < n; i++ {
			if hh[i] <= m*b {
				continue
			}
			cnt += (hh[i]-m*b-1)/(a-b) + 1
		}
		if cnt > m {
			l = m
			continue
		}
		r = m
	}
	fmt.Fprintln(writer, r)
	writer.Flush()
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
#define int ll

signed main()
{
    string s;
    cin >> s;
    ll f1 = (s[0] - '0') * 10 + s[1] - '0';
    ll f2 = (s[2] - '0') * 10 + s[3] - '0';
    if (1 <= f1 && f1 <= 12 && 1 <= f2 && f2 <= 12)
    {
        cout << "AMBIGUOUS";
        return 0;
    }
    if (1 <= f1 && f1 <= 12)
    {
        cout << "MMYY";
        return 0;
    }
    if (1 <= f2 && f2 <= 12)
    {
        cout << "YYMM";
        return 0;
    }
    cout << "NA";
}


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

	public static void main(String[] args){
		//writeInput();
		solve();
		}

	public static void solve(){
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());

		boolean[] isFrom1 = new boolean[N];
		boolean[] isFromN = new boolean[N];

		for(int i = 0;i<M;i++){
			int ai = Integer.parseInt(sc.next());
			int bi = Integer.parseInt(sc.next());
			if(ai==1){
				isFrom1[bi]=true;
			}
			if(bi==N){
				isFromN[ai]=true;
			}
		}
		//System.out.println(M);
		boolean routeExists =false;for(int i=0;i<N;i++)routeExists|=(isFrom1[i]&&isFromN[i]);
		answer(routeExists);
		sc.close();

	}

	public static void answer(boolean b){
		String yes =new String("POSSIBLE");
		String no =new String("IMPOSSIBLE");
		System.out.println(b?yes:no);
	}


/*	public static void writeInput(){
		try{
			File file = new File("c:\\Users\\jugem\\Documents\\pleiades\\input.dat");
			if (checkBeforeWritefile(file)){
				PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
				pw.println("5 5");
				pw.println("1 3");
				pw.println("2 3");
				pw.println("2 4");
				pw.println("4 5");
				pw.println("1 4");
				pw.close();
			}
		}catch(IOException e){
			System.out.println(e);
		}
	}

	public static boolean checkBeforeWritefile(File f){
		return f.exists()?(f.isFile()&&f.canWrite()):false;
	}
*/
}


Measured memory_bytes: 65192
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}



const int MAX_N = 5e3 + 10;
ll d[MAX_N][MAX_N];


int main(){
    int n, m;
    cin >> n >> m;
    vl a(n);
    vector<vl> b(m, vl(n));
    rep(i, n-1) cin >> a[i+1];
    rep(i, n) rep(j, m) cin >>b[j][i];

    rep(i, m) {
        auto& v = b[i];
        vi idx(n);
        rep(i, n) idx[i] = i;
        sort(all(idx), [&](int a, int b) {return v[a] > v[b];});
        set<int> st;
        for(const auto& id : idx) {
            int l = 0, r = n-1;
            auto pre = st.lower_bound(id);
            if(pre != st.begin()) {
                --pre;
                l = *pre;
                ++l;
            }
            auto nxt = st.upper_bound(id);
            if(nxt != st.end()) {
                r = *nxt;
                --r;
            }
            d[l][id] += v[id];
            d[l][r+1] -= v[id];
            d[id+1][id] -= v[id];
            d[id+1][r+1] += v[id];

            st.insert(id);

            // dump(make_pair(l, r));
            // dump(make_pair(id, v[id]));
            // rep(i, n +1) {
            //     rep(j, n+1) cout << " " << d[i][j];
            //     cout << endl;
            // }
        }
    }
    rep(i, n) rep(j, n+1) {
        d[i+1][j] += d[i][j];
    }  
    rep(i, n+1) rep(j, n) {
        d[i][j+1] += d[i][j]; 
    }

    // cout << endl;
    // rep(i, n+1) {
    //     rep(j, n+1) {
    //         cout << " " << d[i][j];
    //     }
    //     cout << endl;
    // }
    rep(i, n-1) {
        a[i+1] += a[i];
    }
    ll ans = 0LL;
    rep(i, n) REP(j, i, n) {
        ans = max(ans, d[i][j] - (a[j] - a[i]));
    } 
    cout << ans << endl;
    return 0;
}

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

int main(){
  long long N, D;
  int C = 0;
  cin >> N >> D;
  for (int i=0; i<N; i++){
    long long X,Y;
    cin >> X >> Y;
    if (((X*X) + (Y*Y)) <= (D*D)){C += 1;}
  }
  cout << C;
}

Measured memory_bytes: 3140
#include <stdio.h>

#define  N    150
#define INF   1000000000
#define NIL   -1
#define WHITE 1
#define BLACK 0

void initializiSingleSource(void);
void dijkstra(void);

int d[N];
int pi[N];
int color[N];
int str[N][N];
int n;

int main(){

  int i;
  int j;
  int u;
  int k;
  int v;
  
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      str[i][j]=-1;
    }
  }
  
  for(i=1;i<=n;i++){
  scanf("%d%d",&u,&k);
   for(j=1;j<=k;j++){
     scanf("%d",&v);
     scanf("%d",&str[u+1][v+1]);
   }
  }
  
  dijkstra();
   
  return 0;
}

void initializiSingleSource(void){

  int v;
  
  for(v=1;v<=n;v++){
    d[v] = INF;
   pi[v] = NIL;
   color[v] = WHITE;
  }
    d[1] = 0;
}

void dijkstra(void){

  int i;
  int u;
  int v;
  int min;

  
  initializiSingleSource();

  while(1){

  min = INF;

  for(i=1;i<=n;i++){
    if(color[i]!=BLACK && d[i] < min){
    min = d[i];
    u = i;
    }
   }
    if(min==INF) break;
    color[u] = BLACK;
  
  for(v=1;v<=n;v++){
    if(color[v]!=BLACK && str[u][v] + d[u] < d[v] && str[u][v]!=-1){
     d[v] = str[u][v];
     d[v] += d[u];
    }
   }
  }

  for(i=1;i<=n;i++){
  printf("%d %d\n",i-1,d[i]);
  }
  
}

Measured memory_bytes: 664
package main

import "fmt"

// 2018-08-01T15:35:44+0800
// 2018-08-01T15:55:34+0800
// 2018-08-01T16:14:00+0800
func main() {
	var A, B, C, X, Y int
	fmt.Scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y)
	if 2*C >= A+B {
		n := X*A + Y*B
		fmt.Println(n)
	} else {
		if X > Y {
			A, B = B, A
			X, Y = Y, X
		}
		// A <= B
		// z = 2*X, Y -= X
		n := C * 2 * X
		Y -= X
		if 2*C >= B {
			n += Y * B
		} else {
			n += C * 2 * Y
		}
		fmt.Println(n)
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)

struct union_find {
	vector<ll> v; // ??????id?????¨???????????????????????´????????¨????????????*(-1)?????¨??????
	union_find(ll n) : v(n, -1) {}
	ll find(ll x) { return (v[x] < 0) ? x : (v[x] = find(v[x])); }
	void unite(ll x, ll y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y];
		v[y] = x;
	}
	bool same(ll x, ll y) { return find(x) == find(y); }
	ll size(ll x) { return -v[find(x)]; }
};

using E = tuple<ll, ll, ll>; // = {cost, u, v}
vector<E> kruskal(vector<E> & es, union_find & uf, ll year, const vector<ll> & h) {
	vector<E> res;
	for (auto e : es) {
		ll cost, u, v;
		tie(cost, u, v) = e;
		if (min(h[u], h[v]) < year) continue;
		if (uf.same(u, v)) continue;
		uf.unite(u, v);
		res.push_back(e);
	}
	return res;
}


int main() {
#ifdef _WIN32
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0); // cin??¨cout?????£????????????
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	while (true) {
		ll n, m;
		cin >> n >> m;
		if (n == 0) break;
		vector<ll> h(n); REP(i, n) cin >> h[i];
		
		vector<E> es(m); REP(i, m) cin >> get<1>(es[i]) >> get<2>(es[i]) >> get<0>(es[i]);
		REP(i, m) {
			get<1>(es[i])--;
			get<2>(es[i])--;
		}
		sort(ALL(es));

		map<ll, ll> years;
		REP(i, n) years[h[i]]++;
		
		union_find uf(n);
		ll cost = 0;
		ll cur_n = 0;
		for (auto it = years.rbegin(); it != years.rend(); ++it) {
			cur_n += it->second;
			auto uf_backup = uf;
			auto v = kruskal(es, uf, it->first, h);
			if (!v.empty() && uf.size(get<1>(v[0])) == cur_n) {
				for (auto e : v) cost += get<0>(e);
			} else {
				uf = union_find(n);
				cost = 0;
			}
		}
		cout << cost << endl;
	}
	return 0;
}

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

const long MOD=1000000007;
int main(){
    long H,W,K;
    cin>>H>>W>>K;
    
    if(W==1){
        cout<<1<<endl;
        return 0;
    }
    
    vector<long> F(W+2);
    F.at(0)=1;
    F.at(1)=1;
    for(int i=2;i<W+2;i++){
        F.at(i)=F.at(i-1)+F.at(i-2);
    }
    
    vector<vector<long>> dp(H+1,vector<long>(W,0));
    dp.at(0).at(0)=1;
    
    for(int h=1;h<=H;h++){
        for(int w=0;w<W;w++){
            {//左
                if(w>0) dp.at(h).at(w)+=dp.at(h-1).at(w-1)*F.at(w-1)*F.at(W-w-1);
            }
            {//右
                if(w<W-1) dp.at(h).at(w)+=dp.at(h-1).at(w+1)*F.at(w)*F.at(W-w-2);
            }
            {//なし
                dp.at(h).at(w)+=dp.at(h-1).at(w)*F.at(w)*F.at(W-w-1);
            }
            dp.at(h).at(w)%=MOD;
        }
    }
    
    cout<<dp.at(H).at(K-1)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>


using namespace std;

int main(){
    int N,sum=0,int_place,power=0,power_1=0;
    float place;
    int min_power;
    cin >> N;
    int X[N];
    for (int i=0;i<N;i++){
        cin >> X[i];
    }
    for (int i=0;i<N;i++){
        sum=sum+X[i];
    }

    place=(float)sum/N;
    int_place=ceil(place);
    
    for(int i=0;i<N;i++){
        power=power+(X[i]-int_place)*(X[i]-int_place);
    }

    for(int i=0;i<N;i++){
        power_1=power_1+(X[i]-int_place+1)*(X[i]-int_place+1);
    }

    if(power>power_1){
        min_power=power_1;
    }else {
        min_power=power;
    }
    cout << min_power <<endl;
    return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
template <typename T>
inline T read(){T sum=0,fl=1;int ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
for(;isdigit(ch);ch=getchar())sum=sum*10+ch-'0';
return sum*fl;}
template <typename T>
inline void write(T x) {static int sta[35];int top=0;
do{sta[top++]= x % 10, x /= 10;}while(x);
while (top) putchar(sta[--top] + 48);}
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}
else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;

int main() {
	#ifndef ONLINE_JUDGE
		//freopen("in.txt", "r", stdin);
		//freopen("out.txt","w",stdout);
	#endif
	int n;
	ll sum = 0;
	cin >> n;
	for(int i = 1;i <= n;i++){
		if(i%3==0||i%5==0)continue;
		sum += i;
	}	
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int x = scan.nextInt();
        int y = scan.nextInt();
        String cnt;
        
        int x_group = 0;
        int y_group = 0;
        //1,3,5,7,8,10,12のグループを1,
        //上記でないグループを2とする。
        //2は独立してるのでグループにカウントしない
        
        if( x == 2 || y == 2 )cnt = "No";
        else{
          if( x == 4 || x == 6 || x == 9 || x == 11 ){
            x_group = 2;
          }
          else x_group = 1;
          
          if( y == 4 || y == 6 || y == 9 || y == 11 ){
            y_group = 2;
          }
          else y_group = 1;
          
          if(x_group == y_group)cnt = "Yes";
          else cnt = "No";
        
        }
            
        System.out.println(cnt);
	  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000000
#define mod 1000000007
const int N = 200010 , K = 210;
const double PI = acos(-1);
int n , m , s , t , vis[N] , vi = 0 , dp[2][N];
vector< pair<int,int> > g[N];
long long dist[2][N];

void djikstra(bool B,int src){
	priority_queue < pair<long long ,int > > q;
	q.push(make_pair(0,src));
	vi++;
	while(!q.empty()){
		int node = q.top().second;
		long long cost = q.top().first;
		q.pop();
		if(vis[node] == vi) continue;
		vis[node] = vi;
		dist[B][node] = -cost;
		for(int i=0;i<g[node].size();i++){
			int newnode = g[node][i].first;
			if(vis[newnode] != vi)
				q.push(make_pair(cost-g[node][i].second,newnode));
		}
	}
}

int solve(bool B,int node){
	if(dp[B][node] != -1) return dp[B][node];
	dp[B][node] = 0;
	for(int i=0;i<g[node].size();i++){
		if(dist[B ^ 1][node] + dist[B][g[node][i].first] + g[node][i].second == dist[0][s]){
			dp[B][node] += solve(B,g[node][i].first);
			dp[B][node] %= mod;
		}
	}
	return dp[B][node];
}

int main(){
	scanf("%d%d",&n,&m);
	scanf("%d%d",&s,&t);
	for(int i=0;i<m;i++){
		int u , v, d;
		scanf("%d%d%d",&u,&v,&d);
		g[u].push_back(make_pair(v,d));
		g[v].push_back(make_pair(u,d));
	}
	djikstra(0,t);
	djikstra(1,s);
	memset(dp,-1,sizeof(dp));
	dp[1][s] = 1;
	dp[0][t] = 1;
	solve(0,s);
	solve(1,t);
	long long middist = dist[0][s] / 2;
	bool evenn = (dist[0][s] % 2 == 0);
	int sum = 0;
	int ans = 0;
	for(int node=1;node<=n;node++){
		if(dp[0][node] == -1) dp[0][node] = 0;
		if(dp[1][node] == -1) dp[1][node] = 0;
	}
	for(int node=1;node<=n;node++){
		if(evenn && dist[0][node] == middist){
			int tmp = (long long)sum * dp[0][node] % mod;
			tmp = (long long)tmp * dp[1][node] % mod;
			ans += tmp;
			ans %= mod;
			sum += (long long)dp[0][node] * dp[1][node] % mod;
			sum %= mod;
			continue;
		}
		else if(dist[0][node] > middist) continue;
		for(int j=0;j<g[node].size();j++){
			int newnode = g[node][j].first;
			if(dist[0][newnode] > middist && dist[0][node] + g[node][j].second + dist[1][newnode] == dist[0][s]){
				ans += (long long)((long long)sum * dp[0][node] % mod)* dp[1][newnode] % mod;
				ans %= mod;
				sum += (long long)dp[0][node] * dp[1][newnode] % mod;
				sum %= mod;
			}
		}
	}
	ans += ans;
	ans %= mod;
	cout << ans << endl;
  	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];


  vector<ll> b = a;
  sort(all(b));
  reverse(all(b));

  rep(i, n){
    if(a[i] == b[0]) cout << b[1] << endl;
    else             cout << b[0] << endl;
  }
  



  return 0;
}



Measured memory_bytes: 4736
import math
a,b,x = map(int,input().split())
if x < a**2*b/2:
    y = 2*x/(a*b)
    print (math.degrees(math.atan(b/y)))
else:
    y = 2*(b-x/(a**2))
    print (math.degrees(math.atan(y/a)))

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

int main() {
  int N, M, L; cin >> N >> M >> L;
  const int INF = 1e9 + 10;

  vector<vector<int>> dist(N, vector<int>(N, INF));

  rep(i, N) dist[i][i] = 0;
  rep(i, M) {
    int a, b, t; cin >> a >> b >> t;
    a--; b--;
    dist[a][b] = dist[b][a] = t;
  }
  rep(k, N) rep(i, N) rep(j, N) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  vector<vector<int>> dist2(N, vector<int>(N, INF));

  rep(i, N) dist2[i][i] = 0;
  rep(i, N) rep(j, N) if(dist[i][j] <= L) dist2[i][j] = 1;
  rep(k, N) rep(i, N) rep(j, N) dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);

  int Q; cin >> Q;
  rep(i, Q) {
    int s, t; cin >> s >> t;
    s--; t--;
    if (dist2[s][t] == INF) cout << -1 << endl;
    else cout << dist2[s][t] - 1 << endl;
  }
}

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

int main(){
char day[7][4]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
char input[4];
int i;
  scanf("%s",input);
  for(i=0;i<7;i++){
  	if(strcmp(input,day[i])==0)break;
  }
  printf("%d\n",7-i);
  return 0;
}

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

#ifdef LOCAL
  #include <contest/local.hpp>
#else
  #define LOG(...) do {} while (false)
#endif

#define REP(i,n) for (decltype (n) i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define ALL(x) (x).begin (), (x).end ()

using namespace std;

template <typename Iterator, typename F, typename T>
inline auto combination_impl (Iterator begin, Iterator end, int r, F callback, vector <T> & res) -> void
{
  if (r == 0)
  {
    callback (res);
  }
  else
  {
    for (auto ite = begin; ite < end; ++ ite)
    {
      res.push_back (* ite);
      combination_impl (ite + 1, end, r - 1, callback, res);
      res.pop_back ();
    }
  }
}

template <typename Iterator, typename F>
inline auto combination (Iterator begin, Iterator end, int r, F callback)
{
  using t = decay_t <decltype (* begin)>;
  vector <t> res;
  return combination_impl (begin, end, r, callback, res);
}

using point = vector <int>;

inline auto is_distance_integer (const point & p1, const point & p2)
{
  int64_t dd = 0;
  REP (i, p1.size ())
  {
    auto dx = p1 [i] - p2 [i];
    dd += dx * dx;
  }
  auto d = static_cast <int64_t> (sqrt (dd));
  return d * d == dd;
}

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);
  cout << fixed << boolalpha;
  cerr << fixed << boolalpha;
  
  int n, d;
  cin >> n >> d;
  
 
  vector <point> v;
  REP (i, n)
  {
    point p;
    REP (j, d)
    {
      int x;
      cin >> x;
      p.emplace_back (x);
    }
    v.push_back (move (p));
  }
  
  LOG (v);

  int ans = 0;
  combination (ALL (v), 2, [&] (auto && res) {
    auto && p1 = res [0];
    auto && p2 = res [1];
    LOG (p1);
    LOG (p2);
    if (is_distance_integer (p1, p2))
    {
      ++ ans;
    }
  });
  cout << ans << endl;
}




Measured memory_bytes: 256
require 'set'

ss = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1]
loop do
  n = gets.to_i
  break if n.zero?
  ms = Set.new
  (1..(n-1)).each do |x|
    ms << x**2 % n
  end
  cs = Array.new n/2, 0
  ms.to_a.combination 2 do |a, b|
    x = b - a
    x += n if x < 0
    x = n - x if x > n/2
    cs[x-1] += 1
  end
  puts cs.map {|c| c * 2 }
end

Measured memory_bytes: 9712
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int GCD(int x, int y) {
    return x ? GCD(y % x, x) : y;
}
int LCM(int x,int y){
    return x / GCD(x, y) * y ;
}
signed main(){
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    int l = LCM(c, d);
    int ccount=b/c-(a-1)/c;
    int dcount=b/d-(a-1)/d;
    int lcount=b/l-(a-1)/l;
    cout << (b - a + 1) - (ccount + dcount - lcount) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 998244353
using namespace std;
typedef long long ll;
int main()
{
    int n,m,ans=0;
    cin>>n>>m;
    if(n>=2)
        ans+=n*(n-1)/2;
    if(m>=2)
        ans+=m*(m-1)/2;
    cout<<ans;
    return 0;
}


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

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

void cal(vector<int> A) {
    if(A.size() == n+1) {
        int sum = 0;
        rep(i,q) {
            if(A[b[i]] - A[a[i]] == c[i]) {
                sum += d[i];
            }
        }
        ans = max(ans,sum);
        return;
    }
    
    A.push_back(A.back());
    while(A.back() <= m) {
        cal(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int> (q);
    
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    
    cal(vector<int> (1,1));
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3640
from itertools import product
def main():
    N, M = map( int, input().split())
    costs = [0]*M
    keys = [0]*M
    for i in range(M):
        costs[i], b = map( int, input().split())
        C = list( map( int, input().split()))
        key = 0
        for c in C:
            key += pow(2, c-1)
        keys[i] = key
    K = pow(2,N)
    dp =[10**7]*K
    dp[0] = 0
    for i in range(M):
        key = keys[i]
        cost = costs[i]
        for j in range(K):
            if j != (j | key):
                if dp[j] + cost < dp[j|key]:
                    dp[j|key] = dp[j] + cost
    if dp[K-1] == 10**7:
        print(-1)
    else:
        print(dp[K-1])
if __name__ == '__main__':
    main()


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, M, H, W, h, w;
	string s;
	vector<int64> a, v;
	cin >> H >> W >> h >> w;
	cout << H*W-(h*W+(H-h)*w) << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A = [str(input()) for _ in range(N)]
B = [str(input()) for _ in range(M)]
k=N//M + N%M
def macthing(y,x):
  flag=0
  for p in range(M):
    if A[y+p][x:x+M]!=B[p]:
      flag=1
      break
  if flag==0:
    return True
  else:
    return False

for i in range(k):
  for j in range(k):
    if macthing(i,j):
      print('Yes')
      exit()
print('No')


Measured memory_bytes: 9208
#include<stdio.h>
int main(void)
{
    int h, m, s, h1, m1, s1,x=0,y=0,g=0,i;
    for (i = 0; i < 3; i++)
    {
        scanf("%d %d %d %d %d %d", &h, &m, &s, &h1, &m1, &s1);
        x = h * 3600 + m * 60 + s;
        y = h1 * 3600 + m1 * 60 + s1;
        g = y - x;
        printf("%d %d %d\n", g / 3600, g / 60 % 60, g % 60);
    }
    return 0;
}

Measured memory_bytes: 1764
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	long int n;
	cin>>n;
	long int a[n];
	for( int i=0;i<n;i++)
		cin>>a[i];
	if(n%2==0)
	{
		for( int i=n-1;i>=1;i=i-2)
			cout<<a[i]<<" ";
		for( int i=0;i<n-1;i=i+2)
			cout<<a[i]<<" ";
		cout<<endl;
	}
	else
	{
		for( int i=n-1;i>=0;i=i-2)
			cout<<a[i]<<" ";
		for( int i=1;i<n-1;i=i+2)
			cout<<a[i]<<" ";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int a[200010];

int main()
{
	scanf("%d", &n);
	
	for (int i = 0 ; i < n ; i++) {
		scanf("%d", &(a[i]));
	}
	
	int xOrResult = 0;	
	for (int i = 1 ; i < n ; i++) {
		xOrResult = xOrResult ^ a[i];
	}
	
	printf("%d", xOrResult);
	for (int i = 1 ; i < n ; i++) {
		xOrResult = xOrResult ^ a[i - 1] ^ a[i];
		printf(" %d", xOrResult);
	}
	printf("\n");

	return 0;
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    int A, B, C;
    int K;
    cin >> A >> B >> C;
    cin >> K;
    int c = 0;
    for(;B <= A;c++) {
        B *= 2;
    }
    for(;C <= B;c++) {
        C *= 2;
    }
    if(c <= K) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
#define MOD 1000000007

LL n, a[100000], b[100000], ans[100000], x = 0;


int main() {
	cin >> n;
	for (LL i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = x;
		x = a[i] - x;
	}
	x /= 2;
	cout << x * 2;
	for (LL i = 1; i < n; i++) {
		cout << ' ' << 2 * (b[i] + ((i % 2) == 0 ? x : (-1 * x)));
	}
	cout << endl;
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	
	vector<int> b(n);
	REP(i,n) cin>>b[i];
	
	vector<int> a;
	while(b.size()>0){
		bool jud=true;//不可かどうか.
		for(int i=b.size()-1;i>=0;--i){
			if(i+1==b[i]){
				a.push_back(b[i]);
				b.erase(b.begin()+i);
				jud=false;
				break;//for.
			}
		}
		if(jud){
			cout<<-1<<endl;
			return 0;
		}
	}	
	
	for(int i=n-1;i>=0;--i){
		cout<<a[i]<<endl;
	}
	return 0;
}//agc032_a.復習.

Measured memory_bytes: 256
N, T = [int(i) for i in input().split()]
data_ls = list()
for i in range(N):
  data_ls.append([int(i) for i in input().split()])
data_ls = [i for i in data_ls if i[1] <= T]
if len(data_ls) == 0:
  print("TLE")
else:
  data_ls = sorted(data_ls, key=lambda x:x[0])
  print(data_ls[0][0])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a%2 == 1 && b%2 == 1){
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>			//cout,endl,cin
#include <string>			//string,to_string,stoi
#include <vector>			//vector
#include <algorithm>		//min,max,swap,sort,reverse,lower_bound,upper_bound
#include <utility>			//pair,make_pair
#include <tuple>			//tuple,make_tuple
#include <cstdint>			//int64_t,int*_t
#include <cstdio>			//printf
#include <map>				//map
#include <queue>			//queue,priority_queue
#include <set>				//set
#include <stack>			//stack
#include <deque>			//deque
#include <unordered_map>	//unordered_map
#include <unordered_set>	//unordered_set
#include <bitset>			//bitset
#include <cctype>			//isupper,islower,isdigit,toupper,tolower
#include <math.h>
#include <cstdio>
#include <cstring>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
    char s;
    cin >> s;
    if (isupper(s)) {
        cout << "A" << endl;
    }
    else {
        cout << "a" << endl;
    }
}


Measured memory_bytes: 3628
#include <cstdio>
template<typename T>
void swap(T& a,T& b){
  T temp = a;
  a = b;
  b = temp;
}
int partition(int* A, int p, int r){
  int x = A[r];
  int i = p-1;
  for (int j = p ; j< r ; j++){
    if (A[j] <= x){
      i = i+1;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}

int main(){
  int n;
  int A[100000];
  scanf("%d", &n);
  for(int i=0;i<n;i++)
    scanf("%d", &A[i]);
  int dividedIndex = partition(A, 0, n-1);
  for (int i=0;i<n;i++){
    if (i!=0)
      printf(" ");
    if (i==dividedIndex) printf("[%d]", A[i]);
    else printf("%d", A[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2960
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int x[2][1500001];
int w[1500], h[1500], sw[1501], sh[1501];


int main() {
	//init
	while (1) {
		int n, m;
		scanf("%d%d", &n, &m);
		if (n == 0)break;
		memset(x, 0, sizeof(x));
		for (int i = 0; i < n; i++)scanf("%d", &h[i]);
		for (int i = 0; i < m; i++)scanf("%d", &w[i]);
		for (int i = 0; i < n; i++)sh[i + 1] = sh[i] + h[i];
		for (int i = 0; i < m; i++)sw[i + 1] = sw[i] + w[i];
		for (int i = 0; i < n+1; i++)for (int j = i + 1; j < n+1; j++)x[0][sh[j] - sh[i]]++;
		for (int i = 0; i < m+1; i++)for (int j = i + 1; j < m+1; j++)x[1][sw[j] - sw[i]]++;
		long long int ret = 0;
		for (int i = 1; i < 1500001; i++)ret += x[0][i] * x[1][i];
		printf("%lld\n", ret);
	}
	return 0;
}

Measured memory_bytes: 14404
#define z 1000000
a[z],b[z],n,i=1,x,c;main(){for(;i++<z;)a[i]=i;for(i=-1;i++<z;)if(a[i]){b[x++]=i;for(c=i;c<z;c+=i)a[c]=0;}while(~scanf("%d",&n)){c=0;while(b[c]<=n&&b[c])c++;printf("%d\n",c);}exit(0);}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<numeric>
using namespace std;

int main(){

	int N, L;
        int sum;
	vector<int> vec;
	cin >> N >> L;
 
	for(int i=1; i<=N ; i++ ){
		vec.push_back(i+L-1);
	}
 
	int absmin=99999;
	for(auto itr = vec.begin(); itr != vec.end(); ++itr) {
		if(abs(*itr) < abs(absmin)){ 
			absmin = *itr;
		}
     }
 
 
    sum = accumulate(vec.begin(), vec.end(), 0);
 
 
	if(absmin == 0){
		cout << sum;
	}else if(absmin < 0){
		cout << sum-absmin;
	}else{
		cout << sum-absmin;
	}
 
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ls = sorted(list(map(int, input().split())))
ans = 0

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    for k in range(j + 1, N):
      if ls[i] + ls[j] > ls[k]:
        if ls[i] != ls[j] and ls[j] != ls[k]:
          ans += 1
      else:
        break
        
print(ans)

Measured memory_bytes: 9204