akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;


//System.out.println();
public class Main implements Runnable { //クラス名はMain

    public static void main(String[] args) {
    	Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }

    public void run() {
    	try {
	    	FastScannerFennecVsMonster sc = new FastScannerFennecVsMonster(System.in);

	        int N = sc.nextInt();
	        int K = sc.nextInt();
	        int h[] = new int[N];
	        long count =0;

	        for(int i=0; i < N; i++) {
	        	h[i] = sc.nextInt();
	        }

	        Arrays.sort(h); // 昇順になる

	        //System.out.println(Arrays.toString(h));

	        for(int i=0; i < N; i++) {
	        	if(i+K > N-1) {
	        		break;
	        	}else {
	        		count += h[i];
	        	}
	        }

	        System.out.println(count);

    	}catch(Exception e) {
    		e.printStackTrace();
    	}

    }
}


//高速なScanner
class FastScannerFennecVsMonster {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerFennecVsMonster(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 55256
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var ABC = [intShift(),intShift(),intShift()];
  var d = intShift();
  
  var max = ABC[0];
  var a = 0;
  for(var i = 1; i < 3; i++){
  	if(max < ABC[i]){
    	max = ABC[i];
      a = i;
    }
  }
  for(var i = 0 ; i < d; i++){
  	ABC[a] *= 2;
  }
  
  return ~~ABC.reduce((a,b)=>a+b);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
5 3 11
1
`);

Measured memory_bytes: 7624
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    double t,r=1,r1=0,r2=0,k=0,a,b,c=0,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    vector<tuple<string,int,
           int>>mp;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>a>>b>>c;
    d=ceil(a/b)*c;
    cout<<setprecision(0)<<fixed<<d<<endl;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    const int BEGIN = 1;
    const int END = 0;
    vector<tuple<int, int, int>> v;
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      v.push_back(make_tuple(a, BEGIN, i));
      v.push_back(make_tuple(b, END, i));
    }
    v.push_back(make_tuple(1 << 29, END, m));
    sort(v.begin(), v.end());
    int cnt = 0;
    set<int> vis;
    for (int i = 0, j = 0; i < v.size(); ++i) {
      int a, b, c;
      tie(a, b, c) = v[i];
      if (b == END && vis.count(c) == 0) {
        if (i + 1 == v.size()) break;
        ++cnt;
        while (j <= i) {
          int x, y, z;
          tie(x, y, z) = v[j];
          vis.insert(z);
          ++j;
        }
      }
    }
    cout << cnt << endl;
  }
  
  return 0;
}


Measured memory_bytes: 7920
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int left = a * b;
  int right = c;
  if (left > right)
    cout << right << endl;
  else if (left <= right)
    cout << left << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] L = new int[N+1];
		L[0] = 0;
		for(int i=1; i<=N; i++) {
			L[i] = sc.nextInt();
		}
		
		int cnt = 0;
		int dis = 0;
		for(int i=0; i<=N; i++) {
			dis += L[i];
			if(X>=dis) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}



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

signed main() {
  int n,k;
  cin >> n >> k;

  vector<int> a(n + 1);
  rep(i,n) cin >> a[i];


  for (int i = 0; i < k; i++) {
    vector<int> b(n + 1);
    for (int j = 0; j < n; j++) {
      int left = max(0, j - a[j]);
      int right = min(n, j + a[j] + 1);
      b[left]++;
      b[right]--;
    }
    bool ok = true;
    for(int j = 0; j < n; j++) {
      b[j + 1] += b[j];
      if(b[j] != n) ok = false;
    }
    for (int j = 0; j < n; j++) {
      a[j] = b[j];
    }
    if(ok) break;
  }

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


Measured memory_bytes: 4764
h,w,k = map(int, input().split())
S = [list(input()) for _ in range(h)]
ans = []
n = 1
cnt = 0
for i in range(h):
    if "#" in S[i]:
        ans = []
        for j in range(w):
            if S[i][j] == "#":
                for _ in range(j+1-len(ans)):
                    ans.append(str(n))
                n += 1
        if len(ans) < w:
            x = ans[-1]
            for _ in range(w-len(ans)):
                ans.append(x)
    if ans:
        for _ in range(i+1-cnt):
            print(" ".join(ans))
            cnt += 1

Measured memory_bytes: 9960
import java.io.PrintStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static boolean debug = true;
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		// write here
		int N=sc.nextInt();
		int M=sc.nextInt();
		int [] map=new int[N+1];
		for(int i=0;i<M;i++){
			map[sc.nextInt()]++;
			map[sc.nextInt()]++;
		}
		for(int i=1;i<map.length;i++)
			System.out.println(map[i]);
		
	}

	private static void print(String string) {
		// TODO Auto-generated method stub
		if (debug)
			System.out.println(string);
	}

	private static void print(int[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(String[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(char[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(double[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(int[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i + " " + j + ":" + data[i]);
				}
				System.out.println();
			}
		}
	}

	private static void print(char[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}

	private static void print(String[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}

	private static void print(double[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}

	public static void inPutData(char[][] c) {
		for (int i = 0; i < c.length; i++) {
			c[i] = sc.nextLine().toCharArray();
		}
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    double r; cin >> r;
    cout << 2*pi*r << endl;
    return 0;
}  


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

int main() {
    int n,q;
    cin >> n >> q;
    vector<char> s(n);
    vector<int> cnt(n);
    int c=0;
    char x;
    cin >> x;
    s[0]=x;
    cnt[0]=0;
    rep(i,1,n) {
        cin >> x;
        s[i]=x;
        cnt[i]=cnt[i-1];
        if (s[i-1]=='A' and s[i]=='C') {
            ++cnt[i];
        }
    }
    int l,r;
    rep(i,0,q) {
        cin >> l >> r;
        cout << cnt[r-1]-cnt[l-1] << '\n';
    }
    return 0;
}



Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc62
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int H = int.Parse(str[0]);
            int W = int.Parse(str[1]);
            for(int i = 0; i < W + 2; i++)
            {
                Console.Write("#");
            }
            Console.WriteLine();
            for(int i = 0; i < H; i++)
            {
                Console.Write("#");
                string pic = Console.ReadLine();
                Console.Write(pic);
                Console.WriteLine("#");
            }
            for (int i = 0; i < W + 2; i++)
            {
                Console.Write("#");
            }
            Console.WriteLine();

        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <inttypes.h>

int N, W;
int w[128], v[128];

int64_t asumikana[128][114514];

int64_t kugyu(int pos, int nokori) {
	int64_t kotae, neko;
	if (pos >= N) return 0;
	if (asumikana[pos][nokori]) return ~asumikana[pos][nokori];

	kotae = kugyu(pos + 1, nokori);
	if (nokori >= w[pos]) {
		neko = kugyu(pos + 1, nokori - w[pos]) + v[pos];
		if (neko > kotae) kotae = neko;
	}
	return ~(asumikana[pos][nokori] = ~kotae);
}

int main(void) {
	int i;
	if (scanf("%d%d", &N, &W) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &w[i], &v[i]) != 2) return 1;
	}
	printf("%" PRId64 "\n", kugyu(0, W));
	return 0;
}


Measured memory_bytes: 73672
def main():
    word = input()
    target = "keyence"
    target_length = len(target)
    answer = "NO"
    if word[:target_length] == target or word[-target_length:] == target:
        answer = "YES"
    else:
        for i in range(1, target_length):
            if word[:i] == target[:i] and word[-target_length + i:] == target[-target_length + i:]:
                answer = "YES"
                break
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
n = int(input())
R = ['S', 'H', 'C', 'D']
T = {'S': [True]*13, 'H': [True]*13, 'C': [True]*13, 'D': [True]*13}
for i in range(n):
    M, N = input().split()
    T[M][int(N)-1] = False
for r in R:
    for j, a in enumerate(T[r], 1):
        if a:
            print(r, j)



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

int main(int argc, char *argv[]){
    int max,min,N;
    int i;
    int j=0;
    int k=0;
    int l=0;
    int array[100];
    char buf[100000000];
    char num[10];
    scanf("%d",&N);
    fgets(buf, 255, stdin);
    scanf("%[^\n]", buf);
    for(i=0; buf[i]!='\0'; i++){
        if(buf[i]==' '){
            array[k] = atoi(num);
            k++;
            for(l=0; l<j; l++){
                num[l]=0;
            }
            j=0;
        }
        else{
            num[j]=buf[i];
            j++;
        }
    }
    array[k] = atoi(num);
    k++;
    for(i=0; i<N; i++){
        if(i==0){
            min=array[0];
            max=array[0];
        }
        else if(array[i]>max){
            max=array[i];
        }
        else if(array[i]<min){
            min=array[i];
        }
    }
    printf("%d\n",max-min);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

// youtube editorial
void solve() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;

  set<int> st;
  for (int i = sz(s) - 1; i >= 0; --i) {
    if (s[i] == 'o') {
      st.insert(i);
      i -= c;
    }
  }
  if (sz(st) != k) {
    return;
  }
  // 前からと後ろから貪欲にやると, i 番目の日の範囲が決まる
  rep(i, sz(s)) {
    if (s[i] == 'o') {
      if (st.count(i)) {
        cout << i + 1 << endl;
      }
      i += c;
    }
  }
}


Measured memory_bytes: 11028
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
q = int(input())

kosu = dict(Counter(a))

ans = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    if b in kosu:
        if c not in kosu:
            kosu[c] = 0
        ans += (c - b) * kosu[b]
        kosu[c] += kosu[b]
        kosu[b] = 0

    print(ans)

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

int H, W;
vector<vector<char> > G;

vector<int> cnt;

int main() {
    scanf("%d %d", &H, &W);

    G = vector<vector<char> >(H, vector<char>(W));
    cnt = vector<int>(26, 0);

    for(int i = 0; i < H; i++) {
        scanf("\n");
        for(int j = 0; j < W; j++) {
            scanf("%c", &G[i][j]);

            cnt[ G[i][j] - 'a' ]++;
        }
    }

    int x = 0;
    int y = 0;
    int z = 0;

    for(int i = 0; i < 26; i++) {
        if(cnt[i] % 2) y++;
        if(cnt[i] % 4 == 3 || cnt[i] % 4 == 2) x++;
    }

    if(H%2 && W%2) {
        if(2*x > H + W - 2 || y > 1) {
            printf("No");
            return 0;
        }
        printf("Yes");
    }
    else if(H%2) {
        if(2*x > W || y > 0) {
            printf("No");
            return 0;
        }
        printf("Yes");
    }
    else if(W%2) {
        if(2*x > H || y > 0) {
            printf("No");
            return 0;
        }
        printf("Yes");
    }
    else {
        if(x > 0 || y > 0) {
            printf("No");
            return 0;
        }
        printf("Yes");
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std ;
typedef long long ll ;
int main()
{
     ll n,a,b,vs,vf,ans,sum;
     cin >> n >> a >> b ;
     sum=a+b;
     vf=n/sum;
     vs=n%sum;
     ans=vf*a;
     sum=min(vs,a);
     ans+=sum;
     cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

const MOD: i64 = 1_000_000_007;

// I solved this after I read the editorial.
fn solve() {
    let n = get();
    let a: Vec<i64> = (0 .. n).map(|_| get()).collect();
    let b: Vec<i64> = (0 .. n).map(|_| get()).collect();
    let mut pool = Vec::new();
    for i in 0 .. n {
        pool.push((a[i], 0));
        pool.push((b[i], 1));
    }
    pool.sort();
    let mut prod = 1;

    let mut libra = 0;
    for (_, v) in pool {
        let mut tmp = 1;
        if v == 0 {
            if libra < 0 {
                tmp = -libra;
            }
            libra += 1;
        } else {
            if libra > 0 {
                tmp = libra;
            }
            libra -= 1;
        }
        prod = prod * tmp % MOD;
    }
    println!("{}", prod);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 18292
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

Counter_S = Counter(S)
Counter_T = Counter(T)
Counter_plus = Counter_S - Counter_T
if len(Counter_plus.values()):
    print(max(Counter_plus.values()))
else:
    print(0)


Measured memory_bytes: 3316
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

const int MAXN = 2e5 + 7;

int t[MAXN], a[MAXN], n;

inline int lb(int x) {
	return x & (-x);
}

void add(int x) {
	for (int i = x; i <= 2 * n; i += lb(i)) t[i]++;
}

int query(int x) {
	int r = 0;
	for (int i = x; i; i -= lb(i)) r += t[i];
	return r;
}

bool check(int mid) {
	CL(t, 0);
	int sum = 0;
	ll cnt = 0;
	add(n);
	rep(i, 1, n) sum += (a[i] >= mid ? 1 : -1), cnt += query(sum + n), add(sum + n);
	return cnt >= 1ll * n * (n + 1ll) / 4ll;
}

int main() {
	scanf("%d", &n);
	int l = INT_MAX, r = INT_MIN, mid;
	rep(i, 1, n) scanf("%d", a + i), l = std::min(l, a[i]), r = std::max(r, a[i]);
	while (l < r) {
		mid = (l + r + 1) / 2;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 1536
import os, sys, re, math

r,g,b,n = input().split(' ')
r,g,b,n = int(r), int(g), int(b), int(n)

ret = 0
ri = 0
while (ri * r <= n):
    rg = 0
    while (rg * g <= n - ri * r):
        if ((n - ri * r - rg * g) % b == 0):
            ret += 1
        rg += 1
    ri += 1

print(ret)


Measured memory_bytes: 40556
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b ;
    if(a==b)cout << 2*a << endl;
    else cout << 2*max(a,b)-1 << endl;

    return 0;
}

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

#define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(v) v.begin(),v.end()
const int MOD =1e9+7;


int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie();
    //If you hack my code , You are gay;
    int x,y;
    cin>>x>>y;
    int b=y-2*x;
    if(b%2) cout<<"No";
    else{
        b/=2;
        if(b<0) cout<<"No";
        else{
            int a=x-b;
            if(a<0) cout<<"No";
            else cout<<"Yes";
        }

    }
    return 0;
}

Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def divisor(n):
        i = 1
        table = []
        while i * i <= n:
            if n % i == 0:
                table.append(i)
                table.append(n // i)
            i += 1
        table = list(set(table))
        return table


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)

    def list(self):
        return self.__q

    def length(self):
        return len(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    S = Scanner.string()
    ans = 0
    N = len(S)
    for i in range(N):
        for j in range(i, N):
            cnt = 0
            for s in S[i:j+1]:
                if not (s == "A" or s == "G" or s == "C" or s == "T"):
                    cnt = -1
                    break
                cnt += 1
            ans = max(ans, cnt)
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 38636
integer N
integer(8),allocatable,dimension(:)::A
integer(8),allocatable,dimension(:)::ans
integer(8) Asum
read*,N
allocate(A(n),ans(N))
read*,A
Asum=sum(A)

do i=1,N/2
  Asum=Asum-A(i*2-1)*2
end do

ans(N)=Asum

ans(1)=A(N)*2-ans(N)

do i=2,N
  ans(i)=A(i-1)*2-ans(i-1)
end do

print*,ans

end

Measured memory_bytes: 4992
#include <stdio.h>
#define N 100

typedef struct{
  int u;
  int k;
  int v[N];
} ADJ;

int main(){
  int n, i, j, l;
  int a[N][N];
  ADJ data[N];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d%d", &data[i].u, &data[i].k);
    for(j = 0; j < data[i].k; j++){
      scanf("%d", &data[i].v[j]);
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < data[i].k; j++){
      for(l = 0; l < n; l++){
	if(data[i].v[j] == data[l].u){
	  a[i][l] = 1;
	}
      }
    }
  }


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

  return 0;
}



Measured memory_bytes: 2068
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>

using namespace std;

struct Rectangle {
  int H;
  int W;
};

int main()
{
  vector<Rectangle> data_set;

  while (true) {
    int H, W;
    cin >> H >> W;

    if (H == 0 && W == 0) {
      break;
    }

    data_set.push_back({H, W});
  }

  for (auto &&i : data_set) {
    for (int h = 0; h < i.H; h++) {
      for (int w = 0; w < i.W; w++) {
        if ((h % 2 == 1 && w % 2 == 0) ||
            (h % 2 == 0 && w % 2 == 1)) {
          cout << ".";
        }
        else {
          cout << "#";
        }
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3156
n = int(input())
alist = list(map(int,input().split(' ')))

from collections import defaultdict

resdict = {}

from collections import Counter

c = Counter(alist)

cdict = dict(c)

# cdict = dict((key, value) for (key, value) in old_cdict.items() if value >= 2)

# print(cdict)

maxi = 0

for k, v in cdict.items():
    maxi += v * (v - 1) // 2

for a in alist:
    num = cdict[a]
    if num in resdict:
        # print('used')
        print(resdict[num])
        continue
    # print('not used')
    if a in cdict:
        cdict[a] -= 1
        temp = 0
        for k,v in cdict.items():
            temp += v*(v-1)//2
        print(temp)
        resdict[num] = temp
        cdict[a] += 1
    else:
        print(maxi)

Measured memory_bytes: 29140
#include <iostream>
#include <string>
#include <map>

using namespace std;


long n;
map<string,long> mp;
string str;


int main() {

  
  cin >> n;
  
  for(int i=0 ; i<n ; i++){
    cin >> str;
    mp[str] += mp[str]+1;   
  }

  cout << mp.size() << endl;
  
  return 0;
}



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

int main(void) {
    int A,B,K;

    cin >> A  >> B >> K;
    set<int> s;
    for(int i=0;i<K;i++) {
        if((A+i) <= B) s.insert(A+i);
        if((B-i) >= A) s.insert(B-i);
    }

    for(auto i:s) {
        cout << i << endl;
    }
    return 0;
}


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

public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int count = 0;
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i < n; i++) {
		    for (int j = i + 1; j <= n; j++) {
		        if (n % 2 == 0) {
		            if (i + j == n + 1) {
		                continue;
		            }
		        } else {
		            if (i + j == n) {
		                continue;
		            }
		        }
		        sb.append(i).append(" ").append(j).append("\n");
		        count++;
		    }
		}
		System.out.println(count);
		System.out.print(sb);
    }
}



Measured memory_bytes: 21588
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

int N;
struct edge{
    vector <int> to;
    vector <int> cost;
};

vector <int> result;
vector <edge> gragh;

void dfs(int now){
    vector <int> next = gragh[now].to;
    vector <int> costs = gragh[now].cost;
    //cout<<"now"<<" "<<now<<" "<<result[now]<<endl;
    //cout<<"next"<<endl;
    //for(int i=0;i<next.size();i++) cout<<next[i]<<" "<<result[next[i]]<<endl;
   // for(int i=1;i<;i++) cout<<cost[i]<<endl;
   // cout<<endl;

    for(int i=0;i<next.size();i++){
        if(result[next[i]] != 1000) continue;
        result[next[i]] = result[now] + costs[i];
      //  cout<<costs[next[i]]<<endl;
        result[next[i]] = result[next[i]] % 2;
       //cout<<'&'<<endl;
        dfs(next[i]);
    }


}



int main(){
    cin>>N;
    if(N==1) {cout<<1<<endl;return 0;}
    if(N==2){cout<<0<<endl;cout<<1<<endl;return 0;}
    result.resize(N+10,1000);
    gragh.resize(N+1);
    result[1] = 1;
    for(int i=1;i<=N-1;i++){
        int u,v,w; cin>>u>>v>>w;
        gragh[u].to.push_back(v);
        gragh[u].cost.push_back(w%2);
        gragh[v].to.push_back(u);
        gragh[v].cost.push_back(w%2);
     //   cout<<'%'<<endl;
    }
   dfs(1);
    
for(int i=1;i<=N;i++){
    cout<<result[i]<<endl;
}

    return 0;
}

Measured memory_bytes: 16384
import Data.List
import Data.Bool

readInt :: String -> Int
readInt = read

main = do
    [n,m,x,y] <- map readInt.words<$>getLine
    xs <- map readInt.words<$>getLine
    ys <- map readInt.words<$>getLine
    putStrLn $ bool "War" "No War" $ solve x y xs ys

solve :: Int -> Int -> [Int] -> [Int] -> Bool
solve x y xs ys = maximum (x:xs) < minimum (y:ys) 

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

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

int main(){
    int h,w;cin >> h >> w;
    queue<int> q;
    rep(i,h)rep(j,w){
        char ch;cin >> ch;
        if(ch == '#'){
            dist[i][j]=0;
            q.push(w*i+j);
        }else dist[i][j] = -1;
    }

    while(q.size()){
        int ind = q.front();
        q.pop();
        int y = ind/w;
        int x = ind%w;
        for(int i = 0;i < 4;i++){
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(ny < 0 || nx < 0 || h <= ny || w <= nx) continue;
            if(dist[ny][nx]!=-1) continue;
            dist[ny][nx] = dist[y][x] + 1;
            q.push(w*ny+nx);
        }
    }
    int ans = 0;
    rep(i,h){
        rep(j,w){
            ans = max(ans,dist[i][j]);
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    string S;
    cin >> S;
    if(S.at(2) == S.at(3) && S.at(4) == S.at(5))cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  
  int n;
  double avg,ans,a[1001];

  while(cin >> n,n){
    
    avg = 0;
    ans = 0;
    for(int i = 0;i < n;i++){
      cin >> a[i];
      avg += a[i];
    }
    avg = avg/n;
    
    for(int i = 0;i < n;i++){
      ans += pow((a[i]-avg),2);
    }

    printf("%.8f\n",sqrt(ans/n));
  }
  
  return (0);
}

Measured memory_bytes: 3192
import sys
sys.setrecursionlimit(int(1e6))
N, M = map(int,input().split())


def func(n):
    """メモ化フィボナッチ"""
    memo = [0]*(n+1)

    def _fib(n):
        if n <= 1:
            return n
        if memo[n] != 0:
            return memo[n]
        memo[n] = _fib(n-1)%1000000007 + _fib(n-2)%1000000007
        return memo[n]

    return _fib(n)

a_p = 0
result = 1
for i in range(M):
  a_c = int(input()) - 1
  
  if a_c + 1 == a_p: 
    print(0)
    quit()
  result = ((func(a_c - a_p + 1)%1000000007) * (result%1000000007))%1000000007
  a_p = a_c + 2
  
result = ((func(N - a_p + 1)%1000000007) * (result%1000000007))%1000000007
print(result)

Measured memory_bytes: 107144
import java.util.Scanner;

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

		for (int i = 0; i < S.length()-1; i++) {
			char c = S.charAt(i);
			char c2 = S.charAt(i+1);
			if (c == c2) {
				System.out.println("Bad");
				return;
			}
 		}
		System.out.println("Good");
	}
}

Measured memory_bytes: 21332
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

typedef  long long ll;
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;}

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
ll profitparpart[10];
int f[110][10]={(0,0)},n=0;
int64_t p[110][15]={(0,0)};
int main(){
    cin>>n;
    for(int a=0;a<n;a++){
        for(int b=0;b<10;b++){cin>>f[a][b];}
        }
    for(int a=0;a<n;a++){
        for(int b=0;b<=10;b++){
            cin>>p[a][b];
        }
    }
    int64_t res= -(1<<30);
    for(int i=1;i<(1<<10);i++){
       int64_t sum=0;
        for(int j=0;j<n;j++){
            int count=0;
            for(int k=0;k<10;k++)
                if((i>>k&1)&&(f[j][k]))count++;
            sum+=p[j][count];
        }
            if(sum>res)res=sum;
    }
    cout<<res<<endl;
    return 0;
}




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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
vector<ll> ret;

int main(){
    int n;
    ll w;
    cin>>n>>w;
    vector<pair<ll,ll>> wv(n);
    for(auto & a :wv)cin>>a.first >>a.second;
    vector<vector<vector<ll>>> dp(n+5,vector<vector<ll>>(n+5,vector<ll>(310)));
    ll w0 = wv[0].first;
    ll ans = 0;
    for(int i=0;i<n;++i){
        ll weight = wv[i].first - w0;
        for(int j=1;j<=n;++j){
            for(int k=0;k<=300;++k){
                dp[i+1][j][k] = dp[i][j][k];
                if(k - weight >=0)dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j-1][k-weight] + wv[i].second); 
                if(w0*j + k <= w)ans = max(ans , dp[i+1][j][k]);
            }
        }
    }
    cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 27648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            int count = -1;
            bool flg = false;
            while (true)
            {
                if (flg)
                {
                    break;
                }
                count++;
                for (int i = 0; i < n; i++)
                {
                    if (inputLongArray[i] % 2 != 0)
                    {
                        flg = true;
                        break;
                    }
                    inputLongArray[i] = inputLongArray[i] / 2;
                }
            }

            Console.WriteLine(count);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
import sys
n, k = list(map(int, sys.stdin.readline().split()))
arr = list(map(int, sys.stdin.readline().split()))

dp = [100000000000] * n

dp[0] = 0
dp[1] = dp[0] + abs(arr[1] - arr[0])

for i in range(2, len(arr)):
	for j in range(1, k + 1):
		if (i - j < 0): continue
		dp[i] = min(dp[i - j] + abs(arr[i - j] - arr[i]), dp[i])

print(dp[len(arr) - 1])



Measured memory_bytes: 52444
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

//int num[1000010];
int num[1000010];
int twice_n[1000010];

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  string s;
  cin >> n >> s;
  bool ok = false;
  ll ans = 1LL;
  REP(i, n){
    num[s[i]-'a']++;
  }
  REP(i,26){
    ans = (ans*(num[i]+1))%MOD;
  }
  cout << ans - 1 << endl;
  
  return 0;
}


Measured memory_bytes: 2512
from collections import deque

S = list(str(input()))
Q = int(input())

d = deque(S)
R = 0

for i in range(Q):
    Query = str(input())
    if len(Query) == 1:
        R = (R+1)%2
    else:
        T,F,C = map(str,Query.split())

        if (R + int(F)) % 2 == 1:
            d.appendleft(C)
        else:
            d.append(C)

if R == 1:
    d.reverse()

for i in range(len(d)):
    print(d[i],end="")

Measured memory_bytes: 104260
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		Stack<Integer> stack = new Stack<>();
		Scanner sc = new Scanner(System.in);
		
		String input = sc.nextLine();
		String[] str = input.split(" ", 0); 
		sc.close();
		
		for(int i = 0; i < str.length; i++) {
			if(str[i].equals("+")) {
				int x = stack.pop();
				int y = stack.pop();
				stack.push(x + y);
			}else if(str[i].equals("-")) {
				int x = stack.pop();
				int y = stack.pop();
				stack.push(y - x);
			}else if(str[i].equals("*")) {
				int x = (int)stack.pop();
				int y = (int)stack.pop();
				stack.push(x * y);
			}else {
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	}
}


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

int main() {
    int N; cin >> N;
    for (int i = 0; i <= 26; i++) {
        for (int j = 0; j <= 13; j++) {
            if (4*i + 7*j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 500
using namespace std;
int f[N],sz[N],fl[N],out[N],in[N];
int n,h,a,b,c,d,x,y;
int get(int x){
	return f[x]==x?x:f[x]=get(f[x]);
}
int main(){
	scanf("%d%d",&n,&h);
	for (int i=-h;i<=h;i++)
		f[i+233]=i+233,sz[i+233]=1;
	for (int i=1;i<=n;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		x=(c==0)?a:-c; y=(d==0)?-b:d;
		++out[x+233]; ++in[y+233];
		x=get(x+233); y=get(y+233);
		if (x==y) sz[x]++;
		else f[x]=y,sz[y]+=sz[x]+1;
	}
	for (int i=1;i<=h;i++)
		if (out[i+233]<in[i+233])
			return puts("NO"),0;
	for (int i=-h;i<=-1;i++)
		if (in[i+233]<out[i+233])
			return puts("NO"),0;
	for (int i=-h;i<=h;i++)
		fl[get(i+233)]|=(in[i+233]!=out[i+233]);
	for (int i=-h;i<=-1;i++)
		if (sz[get(i+233)]>1&&!fl[get(i+233)])
			return puts("NO"),0;
	for (int i=1;i<=h;i++)
		if (sz[get(i+233)]>1&&!fl[get(i+233)])
			return puts("NO"),0;
	puts("YES"); 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ld a,b,h,m;
	cin >> a >> b >> h >> m;
	cout << setprecision(15) << sqrt(a*a+b*b-2*a*b*cos(abs((m/30)*acos(-1)-(h/6+m/360)*acos(-1)))) << endl;
}

Measured memory_bytes: 4164
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
total = -10**10
for i in range(1, 1024):
    x = list(map(int, list(format(i, '010b'))))
    tmp = 0
    for j in range(n):
        a = 0
        for k in range(10):
            a += x[k] * f[j][k]
        tmp += p[j][a]
    total = max(tmp, total)
print(total)

Measured memory_bytes: 3064
// G++ MACro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  vector<ll> v(3);VECCIN(v);sort(ALL(v));
  if(v[0]%2==0||v[1]%2==0||v[2]%2==0){COUT(0);return 0;}
  COUT(v[0]*v[1]);

  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Scc Puzzle
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll n, m;
  cin >> n >> m;

  ll k = min(n, m / 2);
  ll r = m - k * 2;
  if (r > 0) k += r / 4;
  printf("%lld\n", k);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  while(getline(cin,s)&&s!="0"){
    int ans=0,onecnt=0,cnt=0;
    s.push_back(' ');
    for(int i=0;i<s.size();i++){
      if(s[i]==' '){
	if(cnt==1)onecnt++;
	if(cnt<10)ans+=cnt;
	else ans+=10;
	cnt=0;
      }
      else{
	cnt*=10;
	cnt+=s[i]-'0';
      }
    }
    for(int i=0;i<onecnt;i++){
      if(ans+10>21)break;
      ans+=10;
    }
    if(ans>21)ans=0;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3160