akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        writer.println(Math.max(a + b, Math.max(a - b, a * b)));
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.valueOf(next());
        }

        private long nextLong() {
            return Long.valueOf(next());
        }

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

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

vector<int> dp(100005,-1);


int func(int ind,int n,vector<int> &v)
{
    if(ind==n)
    {
        return 0;
    }
    
    if(dp[ind]!=-1)
    {
        return dp[ind];
    }
    
    //make one jump
    int a= abs(v[ind]-v[ind+1])+func(ind+1,n,v);
    
    //check and make 2 jumps
    int b=1000000005;
    if(ind+2<=n)
    {
        b= abs(v[ind]-v[ind+2])+func(ind+2,n,v);
    }
    
    dp[ind]=min(a,b);
    
    return dp[ind];
}

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    
    cout<<func(0,n-1,v);
    
    return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  vector<int> V(5);
  for(int i=0;i<5;i++)
    cin>>V[i];
  for(int i=0;i<5;i++)
  {
    if(V[i]==0)
      cout<<i+1;
  }
}

Measured memory_bytes: 3616
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
using namespace std;

int main(void){
    string s, t;
    cin >> s >> t;
    int sl = s.size(), tl = t.size();
    int l = sl-tl+1, max = 0;
    for(int i=0; i<l; i++){
        int cnt = 0;
        for(int j=0; j<tl; j++) if(s[i+j] == t[j]) cnt++;
        if(max < cnt) max = cnt;
        if(max == tl) break;
    }
    cout << tl - max << '\n';
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int sed(int N) {
    int a = N;
    int c = 0;
    bool b = true;
    while(b){
        if (a == 0) {
            b = false;
        }
        c += a % 10;
        a /= 10;
    }
    return c;
}
int main() {
    int N, A, B; cin >> N >> A >> B;
    int sum = 0;
    for (int i = 1; i <= N; ++i) if (A <= sed(i) && sed(i) <= B) sum += i;
    printf("%d\n", sum);
}


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

using namespace std;

int main()
{
	int n;
	int a[110];
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	int ans=0;
	for(int i=1; i<n; i++)
	{
		if(a[i]==a[i-1])
		{
			a[i]=1000+i;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890123

ll a,b;
ll s[101010],t[101010];

ll solve2(ll x){
    ll ans=INF;
    auto it=upper_bound(t,t+b,x);
    if(it!=t+b){
        ans=min(ans,abs(x-*it));
    } 
    if(it>t){
        it--;
        ans=min(ans,abs(x-*it));
    }
    return ans;
}

ll solve(ll x){
    ll ans=INF;
    auto it=upper_bound(s,s+a,x);
    if(it!=s+a){
        ans=min(ans,abs(x-*it)+solve2(*it));
    } 
    if(it>s){
        it--;
        ans=min(ans,abs(x-*it)+solve2(*it));
    }
    return ans;
}


ll solve4(ll x){
    ll ans=INF;
    auto it=upper_bound(s,s+a,x);
    if(it!=s+a){
        ans=min(ans,abs(x-*it));
    } 
    if(it>s){
        it--;
        ans=min(ans,abs(x-*it));
    }
    return ans;
}

ll solve3(ll x){
    ll ans=INF;
    auto it=upper_bound(t,t+b,x);
    if(it!=t+b){
        ans=min(ans,abs(x-*it)+solve4(*it));
    } 
    if(it>t){
        it--;
        ans=min(ans,abs(x-*it)+solve4(*it));
    }
    return ans;
}

int main(){
    ll i,j;
    ll q;
    cin>>a>>b>>q;
    for(i=0;i<a;i++) cin>>s[i];
    for(i=0;i<b;i++) cin>>t[i];

    for(i=0;i<q;i++){
        ll x;
        cin>>x;
        cout<<min(solve(x),solve3(x))<<endl;
    }

    return 0;
}

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

#define INF 10000000

int matrixChainOrder(int *);

int a;
int m[100][100],r[100],c[100],p[101];

int main(){
  int i,j,n,re;

  scanf("%d",&n);

  a = n;
 
  for(i = 1;i <= n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }

  re = matrixChainOrder(p);

  printf("%d\n",re);

  return 0;
}

int matrixChainOrder(int *p){
  int n,l,i,j,k,q;

  n = a;
  for(i = 1;i <= n;i++){
    m[i][i] = 0;
  }
  for(l = 2;l <= n;l++){
    for(i = 1;i <= n-l+1;i++){
      j = i + l - 1;
      m[i][j] = INF;
      for(k = i;k <= j-1;k++){

	q = m[i][k] + m[k+1][j] + (p[i-1] * p[k] * p[j]);

	m[i][j] = (int)fmin(m[i][j],q);

      }
    }
  }

  return m[1][n];
}

Measured memory_bytes: 640
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let k: usize = sc.read();

    use std::collections::VecDeque;
    let mut d = VecDeque::<u64>::new();
    for i in 1..10 {
        d.push_back(i);
    }

    for i in 1..k {
        let num = d.pop_front().unwrap();

        if i + d.len() >= 100000 {
            continue;
        }

        let c = num % 10;

        if c != 0 {
            d.push_back(num * 10 + c - 1);
        }
        d.push_back(num * 10 + c);
        if c != 9 {
            d.push_back(num * 10 + c + 1);
        }
    }

    println!("{}", d.pop_front().unwrap());
}


Measured memory_bytes: 2676
n,k = map(int,input().split())
if k > (n-1)*(n-2)/2:
    print(-1)
else:
    ans = []
    for i in range(1,n):
        ans.append([1,i+1])
    L = []
    for i in range(2,n+1):
        for j in range(i+1, n+1):
            L.append([i,j])
    for i in range((n-1)*(n-2)//2-k):
        ans.append(L[i])
    print(len(ans))
    for i in range(len(ans)):
        print(ans[i][0], ans[i][1])


Measured memory_bytes: 4120
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p, int r){
    int x,i,j,t;
    x = A[r];
    i = p-1;
    for(j=p;j<r;j++){
        if(A[j] <= x){
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i+1];
    A[i+1] = A[r];
    A[r] = t;
    return i+1;
}

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


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, q, h, s, d;
int main()
{
	scanf("%lld%lld%lld%lld%lld", &q, &h, &s, &d, &n);
	ll newn = n-n%2;
	ll mn = 1000000000000000000;
	mn = min(mn, q*4*newn);
	mn = min(mn, h*2*newn);
	mn = min(mn, s*1*newn);
	mn = min(mn, d*(newn/2));
	if (n%2)
	{
		ll mn2 = 1000000000000000000;
		mn2 =  min(mn2, s);
		mn2 =  min(mn2, h*2);
		mn2 =  min(mn2, q*4);
		mn+=mn2;
	}
	printf("%lld\n", mn);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
#include <climits>
#include <cstdio>
#include <list>
#include <iomanip>
using namespace std;

#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define si second
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define AS 200001
#define mod 1000000007
char grid[1002][1002];
int solve(int n, int m) {
	int  dp[n + 1][m + 1];
	dp[n][m] = 1;
	for (int i = n; i >= 1; i--) {
		for (int j = m; j >= 1; j--) {
			if (i == n and j == m)
				continue;
			if (grid[i][j] == '#')
				dp[i][j] = 0;
			else
				dp[i][j] = (((i == n) ? 0 : dp[i + 1][j]) + ((j == m) ? 0 : dp[i][j + 1]))%mod;
		}
	}
	return dp[1][1];
}
int main() {
	fastIO
	int n, m;
	cin >> n >> m;
	// vector<vector<char>>grid(n, vector<char>(m, 0));
	NF1(grid, n, m);
	cout << solve(n, m);
}

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

bool posibil(int x1, int y1, int x2, int y2, int t)
{
    t -= abs(x1 - x2) + abs(y1 - y2);
    if (t < 0)
        return false;
    if (t & 1)
        return false;
    return true;
}

int main()
{
    int xlast(0), ylast(0), tlast(0);
    int n, a, b, t;
    cin >> n;

    while (n--) {
        cin >> t >> a >> b;
        if (!posibil(xlast, ylast, a, b, t - tlast)) {
            cout << "No\n";
            return 0;
        }
        xlast = a, ylast = b, tlast = t;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> v(n,0);
    for(int i=0;i<n;i++)
	cin>>v[i];


    //There're something wrong
    //0--n-1
    //0--k
    if(k>n-1) k=n-1;
    int temp;
    vector<int> f(n,0);
    for(int i=1;i<=k;i++){
	int MIN=(2<<30)-1;
	for(int j=0;j<i;j++){
	    temp=v[i]-v[j];
	    if(temp<0) temp=-temp;
	    MIN=MIN<temp+f[j]? MIN: temp+f[j];
	}
	f[i]=MIN;
     // cout<<f[i]<<" ";
    }
    //f[0]--f[k] has been cacluate
    for(int i=k+1;i<n;i++){
	int MIN=(2<<30)-1;
	for(int j=i-k;j<i;j++){
	    temp=v[i]-v[j];
	    if(temp<0) temp=-temp;
	    MIN=MIN<temp+f[j]? MIN: temp+f[j];
	}
	f[i]=MIN;
    //cout<<f[i]<<" ";
    }
    cout<<f[n-1]<<endl;
    return 0;
}

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

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

  int h, w, n;
  int a[1000000];
  cin >> h >> w >> n;
  rep(i, n) cin >> a[i];

  vector<int> l;
  rep(i, n) {
    rep(j, a[i]) l.push_back(i+1);
  }

  rep(i, h) {
    rep(j, w) {
      if (i%2 == 0) {
        cout << l[w*i+j] << " ";
      } else {
        cout << l[w*(i+1)-j-1] << " ";
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

char c[3][4];

int main() {
    REP(i, 2){
        cin >> c[i];
    }
    string res = "NO";
    if(c[0][0]==c[1][2]&&c[0][1]==c[1][1]&&c[0][2]==c[1][0]){
        res = "YES";
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    // 整数の入力
    char N;
    char K;
    int num, count;
    
    num = 0;
    count = 1;
    cin >> K;
    for(int i = 0 ; i <1000000; i ++){
        cin >> N;
        if(K == '0'){
            K = '1';
        }else{
            K = '0';
        }
        if(cin.good() != true)break;
        if(N != K){
            num = num + 1;
        }
        count++;
    }
    cout << min(num,count-num);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	void doIt() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();
			double x4 = sc.nextDouble();
			double y4 = sc.nextDouble();
			double cross = Math.abs((x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1));
			if(cross < 1e-10){
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}
}

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

typedef long long LL;
typedef unsigned long long LONG;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MAXINT = 2147483647;
const int mod = 1000000007;
const long long MAXLONG = 9223372036854775807;
const LL INT32 = (LL(MAXINT) + 1) * 2;
using namespace std;
typedef pair<int, int> PII;
#define ft fisrt
#define sd second
#define eb emplace_back
#define END '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    LL ans = 0;
    cin >> n;
    for (int i = 1; i <= n;++i){
        LL l = i, r = (n / i) * i;
        ans += (l + r) * (r / l) / 2;
        // debug(ans);
    }
    cout << ans << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 3640
a, b, c, d, e, f = map(int, input().split())
a, b = 100*a, 100*b
 
dp = [[0, 0] for _ in range(f+1)]
memo = {(a, 0):0}
dp[a][0] = a
if b <= f:
    dp[b][0] = b
for i in range(1, f):
    if dp[i][0]:
        if i+a <= f:
            dp[i+a][0] = dp[i][0] + a
            dp[i+a][1] = dp[i][1]
        if i+b <= f:
            dp[i+b][0] = dp[i][0] + b
            dp[i+b][1] = dp[i][1]
        if i+c <= f and dp[i][1] + c <= dp[i][0] * e // 100:
            x = dp[i+c][0] = dp[i][0]
            y = dp[i+c][1] = dp[i][1] + c
            memo[(x+y, y)] = y/(x+y)
        if i+d <= f and dp[i][1] + d <= dp[i][0] * e // 100:
            x = dp[i+d][0] = dp[i][0]
            y = dp[i+d][1] = dp[i][1] + d
            memo[(x+y, y)] = y/(x+y)
_, z, y = max([(val, z, y) for (z, y), val in memo.items()])
print(z, y)

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

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

    vector<int> ans;

    REP(i,100001){
        ans.push_back( i*2*c + a*max(0,x-i) + b*max(0,y-i));
    }

    cout << *min_element(ans.begin(), ans.end()) << endl;

    return 0;
}

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

using namespace std;

int main(void) {
	string str;
	cin >> str;
	bool same = false;
	for (int i = 0; !same && i < str.length()-1; ++i) {
		for (int j = i+1; !same && j < str.length(); ++j) {
			if (str[i] == str[j]) {
				same = true;
			}
		}
	}
	if (same) {
		cout << "no" << endl;
	}
	else {
		cout << "yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
# import numpy as np

A_init = 500
B_init = 100
C_init = 50

A_n = int(input())
B_n = int(input())
C_n = int(input())

X = int(input())

cnt = 0
for a in range(A_n+1):
    if A_init * a <= X:
        for b in range(B_n+1):
            if (A_init * a + B_init * b) <= X:
                K = X - (A_init * a + B_init * b)
                if K % 50 == 0 and K / C_init <= C_n:
                    cnt += 1
            else:
                break
    else:
        break
# print(np.count_nonzero([k+[i for i in All_list] == X for k in All_list]))
print(cnt)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
ll prime[100002];
ll exp(ll a,ll b);
void sieve(ll n);
ll gcd(ll a ,ll b);
ll countdigit(ll n);

void solve(){
    ll n; cin >> n;
    ll L[n];
    rep(i,0,n){
        cin >> L[i];
    }
    ll c=0;
    sort(L,L+n);
    rep(i,0,n){
        rep(j,i,n){
            if(i!=j){
                rep(k,j,n){
                    if(k!=j){
                        if(L[k]<L[i]+L[j]&&L[i]!=L[j]&&L[j]!=L[k]){
                            c++;
                        }
                    }
                }
            }
        }    
    }
    cout<<c<<endl;
}
int main()
{
    ll t=1;
    //cin >> t;
    while(t--) {
        solve();
     
    }

}


//
//
//
//
//
// IMPORTANT FUNCTIONS
ll exp(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
void sieve(ll n) {
    for(ll i=0;i<=n;i++) {
        prime[i]=1;
    }
    prime[0]=0;prime[1]=0;
    for(ll i=2;i<=n;i++) {
        if(prime[i]==1) {
            for(ll j=2;i*j<=n;j++) {
                prime[i*j]=0;
            }
        }
    }
}
ll countdigit(ll  n)
{
    return floor(log10(n) + 1);
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  double ans = 0;
  rep(i, n) {
    in(double, x);
    in(string, u);
    if (u == "BTC") {
      x *= 380000;
    }
    ans += x;
  }
  cout << setprecision(20);
  out(ans);
}


Measured memory_bytes: 3748
n, a, b = map(int, input().split())
if a == 0:
    print(0)
elif n <= a :
    print(n)
elif a < n < a+b :
    print(a)
elif n >= a+b:
    m = n-(a+b)
    x = (m//(a+b))*a
    y = (m%(a+b))
    if y <= a:
        print(a + x + y)
    else:
        print(a + x + a)    

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

int main(){
  int N;
  cin >>N;
  int D[N];
  for (int i=0;i<N;i++){
    cin>>D[i];
  }
  for (int i=0;i<N;i++){
    for (int j=i+1;j<N;j++){
      if(D[j]==D[i]){
        D[j]=0;
      }
    }
  }
  int count=0;
  for (int i=0;i<N;i++){
    if(!(D[i]==0)){
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}


  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <stdlib.h>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <stdio.h>
#include <fstream>
#include <time.h>
using namespace std;
const double PI = 3.14159265358979323846;
const long long int MOD = 1000000000 + 7;

struct UnionFind {
    vector<int> parent;

    UnionFind(int N) : parent(N) {
        for (int i = 0; i < N; i++) {
            parent[i] = -1;
        }
    }

    int root(int i) {
        if (parent[i] < 0) {
            return i;
        }
        return (parent[i] = root(parent[i]));
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx != ry) {
            parent[ry] += parent[rx];
            parent[rx] = ry;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int treeSize(int x) {
        

        return -parent[root(x)];
    }
};

long long int modpow(long long int base, long long int pow, long long int mod) {
    if (pow == 1) {
        return base;
    }
    else if (pow == 0) {
        return 1;
    }

    if (pow % 2 == 0) {
        auto temp = modpow(base, pow / 2, mod);
        return (temp * temp) % mod;
    }
    else {
        return base * modpow(base, pow - 1, mod) % mod;
    }
}

long long int moddiv(long long int X, long long int Y, long long int mod) {
    auto fermatDiv = modpow(Y, mod - 2, mod);

    return (X * fermatDiv) % mod;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    long long int answer = modpow(2, n, MOD) - 1;


    long long int aComb = 1;
    for (long long int i = 0; i < a; i++) {
        aComb *= moddiv(n - i, i + 1, MOD);
        aComb %= MOD;
    }


    long long int bComb = 1;
    for (long long int i = 0; i < b; i++) {
        bComb *= moddiv(n - i, i + 1, MOD);
        bComb %= MOD;
    }



    answer += MOD - aComb;
    answer += MOD - bComb;

    cout << answer % MOD << endl;

    
    return 0;
}

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

int N;
int ans[1100] = {0};

int main(){

  int p = 2;
  for(int i = 3; i < 1050 ; p++ ,i += p ){
    for(int j = i ; j < 1050; j += p){
      ans[j]++;
    }
  }

  while(1){
    cin >> N;
    if(N == 0) break;
    cout << ans[N] << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
import sys

l = []
for i in sys.stdin:
    l.append(i.split())

taro = 0
hanako = 0
for i in range(1,len(l)):
    if l[i][1] > l[i][0]:
        hanako += 3
    elif l[i][0] > l[i][1]:
        taro += 3
    else:
        hanako += 1
        taro += 1

print(taro,hanako)


Measured memory_bytes: 5720
#include<stdio.h>
int main(){
	int X,Y,A,B,C,D,P;
	scanf("%d%d%d%d%d",&A,&B,&C,&D,&P);
	X=A*P;
	Y=B;
	if(C<P){
		Y+=(P-C)*D;
	}
	if(X<Y){
		printf("%d\n",X);
	}
	else{
		printf("%d\n",Y);
	}
	return 0;
}

Measured memory_bytes: 2724
#include <stdio.h>


int main()
{

    char a[4];
    scanf("%s", a);

    int j = 0;
    for (int i = 0; i < 3; i++)
    {
        if (a[i] == '7')
        {
            j = 1;
            break;
        }
    }

    if (j == 1)
        printf("Yes");
    else
    {
        printf("No");
    }

    printf("\n");
}

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

int main() {
	long long A;
	string S;
	cin >> A >> S;
	long long B = (S[0] - '0') * 100 + (S[2] - '0') * 10 + (S[3] - '0');
	long long C = A * B;
	C /= 100;
	cout << C << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//FUNCTION

void solve(void)
{
  int N; cin>>N;
  for (int h = 1; h < 3501; h++)
  {
    for (int w = 1; w < 3501; w++)
    {
      int X = N*h*w;
      int Y = 4*h*w - N*h - N*w;
      if(Y == 0)continue;
      if(X%Y == 0)
      {
        int n = X/Y;
        if(n > 0)
        {
          cout<<h<<" "<<n<<" "<<w<<endl;
          return;
        }
      }
    }
    
  }
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


char p(char c){
  if(c=='?') return c;
  if(c=='Z') return 'A';
  return c+1;
}
char m(char c){
  if(c=='?') return c;
  if(c=='A') return 'Z';
  return c-1;
}

string calc(string s){
  ll idx = 0;
  string ret = "";
  ll num = 0;
  while(idx<s.size()){
    if(s[idx]=='['){
      //]を探して再帰
      ll cnt = 0;
      for(int i=idx;i<s.size();i++){
        if(s[i]=='[') cnt++;
        else if(s[i]==']'){
          cnt--;
          if(cnt==0){
            string k = "";
            for(int j=idx+1;j<i;j++) k += s[j];
            string tmp = calc(k);
            reverse(all(tmp));
            ret += tmp;
            idx = i+1;
            break;
          }
        }
      }
    }else if(s[idx]=='-'){
      num--;
      idx++;
    }else if(s[idx]=='+'){
      num++;
      idx++;
    }else{
      char tmp = s[idx];
      if(num>0) for(int i=0;i<num;i++) tmp = p(tmp);
      else for(int i=0;i<abs(num);i++) tmp = m(tmp);
      ret += tmp;
      num = 0;
      idx++;
    }
  }
  return ret;
}
bool solve(){
  string s;std::cin >> s;
  if(s==".") return false;
  string t = calc(s);
  for(int i=0;i<t.size();i++){
    if(t[i]=='?') t[i] = 'A';
  }
  std::cout << t << '\n';
  return true;
}
// ----? みたいなのは?にして良い

int main(int argc, char const *argv[]) {
  while(true) if(!solve()) break;
  return 0;
}



Measured memory_bytes: 3152
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int n;
vector<int> g[100000];
vector<P> vec;
map<P, int> mp;

void dfs(int v, int p, int c) {
  int color = 1;
  REP(i, g[v].size()) {
    if (g[v][i] == p) continue;
    if (color == c) color++;
    mp[P(v, g[v][i])] = color;
    dfs(g[v][i], v, color);
    color++;
  }
}

int main() {
  cin >> n;
  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
    vec.push_back(P(a, b));
  }
  dfs(0, -1, 0);
  int mx = 0;
  REP(i, n - 1) mx = max(mx, mp[vec[i]]);
  cout << mx << endl;
  REP(i, n - 1) cout << mp[vec[i]] << endl;
  return 0;
}

Measured memory_bytes: 14580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

	static int mod;
	static long[] twoPowM1=new long[300_000], twoPowM2=new long[300_000];
	static long[] stepsSmall=new long[300_000];
	
	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		PrintWriter out=new PrintWriter(System.out);
		int n=fs.nextInt();
		char[] line=fs.next().toCharArray();
		int bitCount=0;
		for (char c:line) if (c=='1') bitCount++;
		mod=bitCount-1;
		if (mod>0) {
			twoPowM1[0]=1;
			for (int i=1; i<twoPowM1.length; i++) twoPowM1[i]=add(twoPowM1[i-1], twoPowM1[i-1]);
		}
		mod=bitCount+1;
		twoPowM2[0]=1;
		for (int i=1; i<twoPowM2.length; i++) twoPowM2[i]=add(twoPowM2[i-1], twoPowM2[i-1]);
		
		stepsSmall[0]=0;
		for (int i=1; i<stepsSmall.length; i++) stepsSmall[i]=1+stepsSmall[i%Integer.bitCount(i)];
		
		long valM1=0, valM2=0;
		for (char c:line) {
			mod=bitCount-1;
			if (mod>0) {
				valM1=add(mul(valM1, 2), c-'0');
			}
			mod=bitCount+1;
			valM2=add(mul(valM2, 2), c-'0');
		}
		
		for (int i=0; i<n; i++) {
			int power=n-1-i;
			if (line[i]=='0') {
				//care about valM2
				mod=bitCount+1;
				long newVal=add(valM2, twoPowM2[power]);
				out.println(stepsSmall[(int)newVal]+1);
			}
			else {
				mod=bitCount-1;
				if (mod==0) {
					out.println(0);
				}
				else {
					long newVal=sub(valM1, twoPowM1[power]);
					out.println(stepsSmall[(int)newVal]+1);
				}
			}
		}
		out.close();
	}
	
	static long add(long a, long b) {
		return (a+b)%mod;
	}
	
	static long sub(long a, long b) {
		return ((a-b)%mod+mod)%mod;
	}
	
	static long mul(long a, long b) {
		return (a*b)%mod;
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define w(x)            int x; cin>>x; while(x--)
#define fr(i,a,b)       for(int i = a; i < b; i++)
#define prdouble(x)		cout << fixed << setprecision(10) << x << endl

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

double dp[3000][3000];

double coins(vector<double>&arr, int i, int x)
{
	if (x == 0) return 1;
	if (i == 0) return 0;
	if (dp[i][x] > -0.9) return dp[i][x];
	return dp[i][x] = arr[i] * coins(arr, i - 1, x - 1) + (1 - arr[i]) * coins(arr, i - 1, x);
}

void solve()
{
	int n;
	cin >> n;
	vector<double> arr(n + 1);
	fr(i, 1, n + 1)
	cin >> arr[i];
	memset(dp, -1, sizeof(dp));
	prdouble(coins(arr, n, (n + 1) / 2));
}

int32_t main()
{
	c_p_c();
	solve();
	return 0;
}

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

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

    int ans = c;
    set<int> s;
    while(ans % (a+b) > a){
        if(s.count(ans%(a+b))){
            ans = -1;
            break;
        }
        s.insert(ans%(a+b));
        ans += 60;
    }

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


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 998244353;

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

    ll dp[c + 1][d + 1] = {};
    dp[a][b] = 1;

    repd(j, b + 1, d + 1) {
        dp[a][j] = dp[a][j - 1] * a;
        dp[a][j] %= mod;
    }
    repd(i, a + 1, c + 1) {
        dp[i][b] = dp[i - 1][b] * b;
        dp[i][b] %= mod;
    }
    repd(i, a + 1, c + 1) {
        repd(j, b + 1, d + 1) {
            dp[i][j] = dp[i][j - 1] * i + dp[i - 1][j] * j -
                       (i - 1) * (j - 1) * dp[i - 1][j - 1];
            dp[i][j] = (dp[i][j] + mod * mod) % mod;
        }
    }

    cout << dp[c][d] << endl;
    return 0;
}



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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


LL m = 1e9 + 7;

int main(){
  string s;
  cin >> s;

  int n = s.size();

  string abc = "ABC";

  LL dp[n + 1][4];

  dp[n][3] = 1;
  REP (i, 3) dp[n][i] = 0;

  RREP(i, n) {
    REP (j, 4) {
      if (s[i] == '?') dp[i][j] = dp[i + 1][j] * 3;
      else dp[i][j] = dp[i + 1][j];

      dp[i][j] %= m;

      if (j != 3) {
        if (s[i] == abc[j] || s[i] == '?') dp[i][j] += dp[i + 1][j + 1];
        dp[i][j] %= m;
      }
    }
  }

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


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int s[10],c[10];

int main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        cin>>s[i]>>c[i];
        s[i]--;
    }

    for(int i=0;i<=999;i++){
        stringstream iss; iss << i;
        string t = iss.str();
        if(t.size()!=n) continue;
        bool ok=true;
        rep(j,m){
            int x=t[s[j]]-'0';
            if(x!=c[j]) ok=false;
        }
        if(ok){
            cout<<i<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 5010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll dp[MAXN][MAXN];
string shit;

ll powmod(ll a, ll b){
	ll res=1;
	for (; b; b>>=1, a=a*a%mod) if (b&1) res=res*a%mod;
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	dp[0][0]=1;
	for (int i=1; i+1<MAXN; i++){
		dp[i][0]=(dp[i-1][0] + dp[i-1][1])%mod;
		for (int j=1; j<=i; j++)
			dp[i][j]=(dp[i-1][j-1]*2 + dp[i-1][j+1])%mod;
	}
	
	cin>>n>>shit;
	m=shit.size();
	ans=dp[n][m];
	ans=ans*powmod(2, mod-1-m)%mod;
	cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 120628
<?php
fscanf(STDIN, "%d", $n);
$ac=$wa=$tle=$re=0;
for($i=0;$i<$n;++$i){
  fscanf(STDIN, "%s", $s);
  switch ($s) {
    case "AC":
        $ac=++$ac;
        break;
    case "WA":
        $wa=++$wa;
        break;
    case "TLE":
        $tle=++$tle;
        break;
    case "RE":
        $re=++$re;
        break;
}
}
echo "AC x ".$ac."\n"."WA x ".$wa."\n"."TLE x ".$tle."\n"."RE x ".$re."\n";


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector< vector<int> > f(n);
    rep(i, n){
        f[i].resize(10);
        rep(j, 10){
            cin >> f[i][j];
        }
    }
    vector< vector<int> > p(n);
    rep(i, n){
        p[i].resize(11);
        rep(j, 11){
            cin >> p[i][j];
        }
    }
    int ans = -IINF;
    REP(i, 1, (1 << 10)){
        int tmp = 0;
        rep(j, n){
            int cnt = 0;
            rep(k, 10){
                if(i >> k & f[j][k]){
                    ++cnt;
                }
            }
            tmp += p[j][cnt];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

bool check(int a, int b, int c, int x){
    if(a == b || b == c || c == a){
        return false;
    }

    if(a + b + c == x){
        return true;
    }
    return false;
}

int main(){
    int i, j, k;
    int n, x;
    int ans;

    while(true){
        ans = 0;
        cin >> n >> x;
        if(n == 0 && x == 0){break;}
        for(i = 1;i<=n;i++){
            for(j=1;j<=n;j++){
                for(k=1;k<=n;k++){
                    if(check(i, j, k, x)){
                        ans += 1;
                    }
                }
            }
        }
        cout << ans/6 << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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;}

const int NM = 1010;
const int HM = 10010;
const int INF = 1<<29;
int dp[NM][HM];  //魔力の最小値

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, n; cin>>h>>n;
    rep(i, NM){
        rep(j, HM){
            dp[i][j] = 1e9;
        }
    }
    rep(i, NM){
        dp[i][0] = 0;
    }
    int A[NM], B[NM];
    rep(i, n){
        cin>>A[i] >> B[i];
    }

    for(int i=0; i<=n; i++){
        for(int j=0; j<=h; j++){
            if(j-A[i] >= 0){
                dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]]+B[i]);
            } else {
                dp[i+1][j] = min(dp[i][j], B[i]);
            }
        }
    }
    cout << dp[n][h] << endl;
}

Measured memory_bytes: 39808
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int a[100010];
vector<P> vec;

int main(){
	int n; cin >> n;
	REP(i,0,n) cin >> a[i], vec.push_back({a[i], i});
	vec.push_back({0, n});
	sort(vec.rbegin(), vec.rend());
	
	ll mi = n, li[100010] = {};
	REP(i,0,n){
		mi = min<ll>(mi, vec[i].second);
		li[mi] += (ll)(i+1) * (vec[i].first - vec[i+1].first);
	}
	
	REP(i,0,n) cout << li[i] << endl;
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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() {
  string s; cin >> s;
  REP(i, (int)s.length())if(s[i] == ',') s[i] = ' ';

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))

cnt=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        p=bisect.bisect_right(l,l[i]+l[j]-1)
        cnt+=p-j-1
print(cnt)


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;


void solve() {
	int n, k, q; cin >> n >> k >> q;
	vector<int> a(q);
	rep(i, q) {
		cin >> a[i]; a[i]--;
	}
	vector<int> num(n,k - q);
	rep(i, q) {
		num[a[i]]++;
	}
	rep(i, n) {
		if (num[i] > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	//stop
	return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int n,m;

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

    map<int,int> cnt;
    cin >> n >> m;
    rep(i,m){
      int to, from;
      cin >> from >> to;
      cnt[to]++;
      cnt[from]++;
    }
    for(auto x: cnt){
      if(x.second % 2 == 1){
        cout << "NO" << "\n";
        return 0;
      }
    }
    cout << "YES" << "\n";
    return 0;
}


Measured memory_bytes: 4352
/*
(a&b)|(c&d)|(e&f)
(a|c|e)&(a|c|f)&(a|d|e)&(a|d|f)&(b|c|e)&(b|c|f)&(b|d|e)&(b|d|f)
*/
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[3][10000];
char fi[10000];
char se[10000];
char la[10000];
int sz=0;
int t[26];
int solve(int a){
	if(a==sz)return 1;
	if((fi[a]&32)&&(t[fi[a]-'a']==1))return solve(a+1);
	if(!(fi[a]&32)&&(t[fi[a]-'A']==0))return solve(a+1);
	if((se[a]&32)&&(t[se[a]-'a']==1))return solve(a+1);
	if(!(se[a]&32)&&(t[se[a]-'A']==0))return solve(a+1);
	if((la[a]&32)&&(t[la[a]-'a']==1))return solve(a+1);
	if(!(la[a]&32)&&(t[la[a]-'A']==0))return solve(a+1);
	if((fi[a]^32)==se[a])return solve(a+1);
	if((la[a]^32)==se[a])return solve(a+1);
	if((fi[a]^32)==la[a])return solve(a+1);
	bool ff=false;
	bool sf=false;
	bool lf=false;
	if(!~t[(fi[a]|32)-'a']){
		if(fi[a]>='a')t[fi[a]-'a']=1;
		else t[fi[a]-'A']=0;
		if(solve(a+1))return 1;
		if(fi[a]>='a')t[fi[a]-'a']=0;
		else t[fi[a]-'A']=1;
		ff=true;
	}
	if(!~t[(se[a]|32)-'a']){
		if(se[a]>='a')t[se[a]-'a']=1;
		else t[se[a]-'A']=0;
		if(solve(a+1))return 1;
		if(se[a]>='a')t[se[a]-'a']=0;
		else t[se[a]-'A']=1;
		sf=true;
	}
	if(!~t[(la[a]|32)-'a']){
		if(la[a]>='a')t[la[a]-'a']=1;
		else t[la[a]-'A']=0;
		if(solve(a+1))return 1;
		if(la[a]>='a')t[la[a]-'a']=0;
		else t[la[a]-'A']=1;
		lf=true;
	}
	if(ff)t[(fi[a]|32)-'a']=-1;
	if(sf)t[(se[a]|32)-'a']=-1;
	if(lf)t[(la[a]|32)-'a']=-1;
	
	return 0;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<3;i++)scanf("%s",str[i]);
		sz=a*8;
		for(int i=0;i<a;i++){
			for(int j=0;j<8;j++){
				if(j&1){
					fi[i*8+j]=str[0][i*3+1];
				}else fi[i*8+j]=str[0][i*3+2];
				if(j&2){
					se[i*8+j]=str[1][i*3+1];
				}else se[i*8+j]=str[1][i*3+2];
				if(j&4){
					la[i*8+j]=str[2][i*3+1];
				}else la[i*8+j]=str[2][i*3+2];
			}
		}
		for(int i=0;i<26;i++)t[i]=-1;
		int res=solve(0);
		if(res==0){
			printf("-1\n");
		}else{
			int ans=0;
			for(int i=0;i<26;i++)if(t[i]==1)ans++;
			printf("%d",ans);
			for(int i=0;i<26;i++)if(t[i]==1)printf(" %c",'A'+i);
			printf("\n");
		}
	}
}

Measured memory_bytes: 1096