akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;

    if(a < b){
        rep(i, b) cout << a;
    }
    else rep(i, a) cout << b;

    cout << endl;
}

Measured memory_bytes: 256
def main():
  n=int(input())
  s=input()
  dp=[[0]*(n+1) for i in range(n+1)]
  for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
      if s[i]==s[j]:
        dp[i][j]=dp[i+1][j+1]+1
  #for i in dp:
  #  print(i)
  
  ans=0
  for i in range(n-1):
    for j in range(i+1,n):
      ans=max(ans,min(j-i,dp[i][j]))
  print(ans)      
        

if __name__=='__main__':
  main()

Measured memory_bytes: 270140
import re
i=input()
a=[".*keyence$","k.*eyence$","ke.*yence$","key.*ence$","keye.*nce$","keyen.*ce$","keyenc.*e$","keyence.*$"]
print(["YES","NO"][len([y for y in [re.match(x,i) for x in a] if y is not None])==0])


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#define int long long
using namespace std;

signed main() {
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < ((1 << (s.size() - 1))); i++) {
		int sum = 0;
		for (int j = 0; j < s.size(); j++) {
			sum = sum * 10 + (s[j] - '0');
			if (((1 << j) & i) || j == s.size() - 1) {
				count += sum;
				sum = 0;
			}
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n, m;
	cin >> n >> m;
	if (n == m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}

Measured memory_bytes: 3592
#include<stdio.h>
#include<string.h>
int main(){
  int k,len,i;
  scanf("%d",&k);
  char s[101];
  scanf("%s",s);
  len=strlen(s);
  if(len<=k)
    printf("%s\n",s);
  else{
    for(i=0;i<k;i++)
      printf("%c",s[i]);
    printf("...\n");
  }
  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int main(){
    long long N;
    cin >> N;

    long long ryuka[90]={2,1};
    for(int i=2; i<=N; i++)
        ryuka[i] = ryuka[i-1]+ryuka[i-2];

    cout << ryuka[N] << endl;

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    
    vector<int> u = {};
    
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        
        bool exist = false;
        for (int j = 0; j < u.size(); j++) {
            if (d == u.at(j)) {
                exist = true;
                break;
            }
        }
        
        if (!exist) u.push_back(d);
    }
    
    cout << u.size() << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
using namespace std;

struct directory{
	map<string,directory*> child;
	map<string,int> file;

	explicit directory(directory *par = 0){
		child.insert(make_pair(".", this));
		child.insert(make_pair("..", par));
	}

	~directory(){
		map<string,directory*>::iterator it;
		for(it = child.begin(); it != child.end(); ++it){
			if(it->first != "." && it->first != ".."){
				delete it->second;
			}
		}
	}
};

char buf[104];
string name;

int find(directory &dir, const string &path){
	const char *p = path.c_str();
	directory *now = &dir;
	int d = 0;

	while(now && p[1]){
		sscanf(p, "/%[^/]%n", buf, &d);
		name = buf;
		p += d;

		if(now->child.count(name)){
			now = now->child[name];
			if(!*p){
				break;
			}
		}
		else if(*p == '/'){
			throw 1;
		}
		else if(now->file.count(name)){
			return now->file[name];
		}
		else{
			throw 2;
		}
	}

	if(!now){
		throw 3;
	}

	name = "index.html";
	if(now->file.count(name)){
		return now->file[name];
	}
	throw 4;
}

int main(){
	int n, m;
	string s, t;
	while(cin >> n >> m, n){
		int d = 0, id = 0;
		directory dir;

		for(int i = 0; i < n; ++i){
			cin >> s;
			const char *p = s.c_str();
			directory *now = &dir;

			while(1){
				sscanf(p, "/%[^/]%n", buf, &d);
				name = buf;
				p += d;
				if(*p != '/'){
					break;
				}

				if(!now->child.count(name)){
					now->child[name] = new directory(now);
				}
				now = now->child[name];
			}
			now->file.insert(make_pair(name, ++id));
		}

		for(int i = 0; i < m; ++i){
			try{
				cin >> s >> t;
				int x = find(dir, s), y = find(dir, t);
				puts(x == y ? "yes" : "no");
			}catch(...){
				puts("not found");
			}
		}
	}
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> a(N);
  for (auto &ai : a)
  {
    cin >> ai;
    ai--;
  }
  int ans = 0;
  vector<bool> ok(N, 0);
  for (int i = 0; i < N; i++)
  {
    if (!ok[i] && a[a[i]] == i)
    {
      ans++;
      ok[i] = true, ok[a[i]] = true;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong n;
	vector<llong> p;

	cin >> n;
	p.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> p[i];

	llong ans = 0;
	for (int i = 1; i < n-1; ++i) {
		vector<llong> c = {p[i-1], p[i], p[i+1]};
		sort(ALL(c));
		if (c[1] == p[i])
			ans++;
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
use io::*;
use std::cmp::min;

fn ok(v: &Vec<i32>) -> bool {
    for &e in v {
        if e >= 2 {
            return false;
        }
    }
    true
}

fn acc(v: &mut Vec<i32>, b: u32, sign: i32) {
    for i in 0..v.len() {
        if b & (1 << i) != 0 {
            v[i] += sign;
        }
    }
}

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let a: Vec<u32> = sc.next_vec(n);

    let mut cnt = vec![0; 22];

    let mut l = 0;
    let mut r = 0;
    let mut ans = 0;

    while l < n {
        while r < n && ok(&cnt) {
            acc(&mut cnt, a[r], 1);
            r += 1;
        }

        // println!("{}: {}", l, r);
        ans += if ok(&cnt) { r } else { r - 1 } - l;

        acc(&mut cnt, a[l], -1);
        l += 1;
    }

    println!("{}", ans);
}

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
// tala
const int N = 1e5 + 10;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b;
	cin >> a >> b;
	if(a < 10 && b < 10)
		cout << a * b << endl;
	else
		cout << -1 << "\n";
}

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

typedef long long ll;

#define        optimize           ios::sync_with_stdio(0); cin.tie(0);
#define PI    acos(-1.0)
#define pb push_back
#define YES cout<<"Yes"<<endl; return 0;
#define NO cout<<"No"<<endl; return 0;
#define RESET(a, b) memset(a, b, sizeof(a))
#define pii pair <int, int>
#define pll pair <ll, ll>
#define setbiti(x) __builtin_popcount(x)
#define setbitll(x) __builtin_popcountll(x)
#define gcd(a, b) __gcd(a, b)

#define        MX        200005
int visited[200];
int main()
{
    optimize
    string str;
    cin>>str;

    for(int i = 0; i < str.size(); i++){
        visited[str[i]]++;
    }
    for(int i = 'a'; i <= 'z'; i++){
        if(visited[i] & 1){
            NO;
        }
    }
    YES;

}


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

template<class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

constexpr int MAX_N = 1e5+100+7;
constexpr int INF = 1e9+7;

int h[MAX_N];
long long dp[MAX_N];

int main() {
  int N, K;
  cin >> N >> K;
  for (int i{}; i < N; ++i) {
    cin >> h[i];
  }

  fill(dp, dp+MAX_N, INF);
  dp[0] = 0;
  for (int i{0}; i < N; ++i) {
    for (int j{1}; j <= K; ++j) {
      if (i+j >= N)
        break;
      chmin(dp[i+j], dp[i] + abs(h[i+j]-h[i]));
    }
  }

  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	
	public int now_x;
	public int now_y;
	
	public Main(){
	}
		
	public int walk(int por_x,int por_y){
		int min = 0;
		int x = por_x - now_x;
		int y = por_y - now_y;
		
		//System.out.println();
		//System.out.println(x+" "+y);
		
		if(x > 0 && y > 0){
            min += Math.min(x, y);
            min += Math.abs(x - y);
        }else if(x < 0 && y > 0){
            x = -x;
            min += x + y;
        }else if(x < 0 && y < 0){
            x = -x;
            y = -y;
            min += Math.min(x, y);
            min += Math.abs(x - y);
        }else if(x > 0 && y < 0){
            y = -y;
            min += x + y;
        }else if(x == 0 && y != 0){
            min += Math.abs(y);
        }else if(x != 0 && y == 0){
            min += Math.abs(x);
        }
        now_x = por_x;
        now_y = por_y;
        
        return min;
	}
	
	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
        int H = sc.nextInt();
        int N = sc.nextInt();
        now_x = sc.nextInt();
        now_y = sc.nextInt();
        int answer = 0;
        for(int i = 0;i < N - 1;i++){
        	int por_x = sc.nextInt();
        	int por_y = sc.nextInt();
        	answer += walk(por_x,por_y);
        	//System.out.println(answer);
        }
        System.out.println(answer);
	}
	
    public static void main(String[] args){
        Main m = new Main();
    	m.doIt();
	}
}

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

int main(){
    int n;
    cin >> n;
    vector <int> vi(n+1,0);
    int p = n-1;
    while (p--){
        int u;
        cin >> u;
        vi[u] += 1;
    }
    for (int i = 1; i <= vi.size() -1; i++){
        cout << vi[i] << "\n";
    }
}

Measured memory_bytes: 4044
n = int(input())

an = list(map(int,input().split()))
bn = list(map(int,input().split()))
cn = list(map(int,input().split()))
sat = sum(bn)

for x in range(n-1):
    if an[x+1] == an[x] + 1:
        sat += cn[an[x]-1]

print(sat)
        

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int a,b,c;
signed main() {
    cin >> a >> b >> c;
    cout << (a-b>c? 0:(c-a+b)) << endl;
}


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

void lcs(string s, string ss, int n , int m){
    int dp[n+1][m+1];

    for(int i = 0; i<n+1; i++)
        dp[i][0] = 0;
    for(int i = 1 ; i<m+1; i++)
        dp[0][i] = 0;


    for(int i = 1; i<=n; i++)
        for(int j = 1; j<=m; j++){
            if(s[i-1] == ss[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }

    int index = dp[n][m];

    char arr[index + 1];
    arr[index] = '\0';
    

    int i = n, j = m;

    while(i > 0 && j > 0)
    {
        if(s[i-1] == ss[j-1])
        {
            arr[index - 1] = s[i - 1];
            i--;
            j--;
            index--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }
    
    cout<<arr<<endl;


}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    string s1, s2;
    cin>>s1 >> s2;

    int len1 = s1.length();
    int len2 = s2.length();

    lcs(s1, s2, len1, len2);
    

    return 0;
}


Measured memory_bytes: 38740
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str=input.readLine();
	String str_ary[]=str.split(" ");
	
	int a[]=new int[str_ary.length];
	for(int i=0;i<str_ary.length;i++)
	    {
		for(int j=0;j<str_ary.length;j++)
		    {
			if(str_ary[i].equals(str_ary[j]))a[i]++;
		    }
	    }
	int max=0;

	
	
	for(int i=0;i<a.length;i++)
	    {
		if(max<a[i])max=i;
	    }
	int x=0,y=0;
	
	int b[]=new int[str_ary.length];
	for(int j=0;j<str_ary.length;j++)
	    {
		b[j]=str_ary[j].length();
		if(x<b[j])
		    {
			x=b[j];
			y=j;
		    }
	    }
	
	
	System.out.println(str_ary[max]+" "+str_ary[y]);
    }
}

Measured memory_bytes: 16896
N=int(input())
C = []
S = []
F = []
for i in range(N-1):
    c,s,f=map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)
def calcTime(loc,time):
    while loc < N-1:
        deltaT = time - S[loc]
        if deltaT < 0:
            time = S[loc] + C[loc]
        elif deltaT % F[loc] == 0:
            time += C[loc]
        else:
            time += F[loc] - (deltaT % F[loc]) + C[loc]
        loc += 1

    return time
for i in range(N-1):
    print(calcTime(i,S[i]))
print(0)

Measured memory_bytes: 3444
N = int(input())
A = [int(i) for i in input().split()]

W = [0] * (N + 1)

for i in range(N):
    W[i + 1] = W[i] + A[i]

x = W[-1] // 2
l = 1
r = N
while l + 1 < r:
    m = (l + r) // 2
    if W[m] < x:
        l = m
    else:
        r = m
print(min(abs(W[-1] - W[l] - W[l]), abs(W[-1] - W[r] - W[r])))



Measured memory_bytes: 26220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
    
        int n;
        cin>>n;
        ll a[n];
        for(int i=0;i<n;++i)cin>>a[i];
        ll summ=0;
        for(int i=0;i<n;++i){
            for(int j=i+1;j<n;++j){
                for(int k=j+1;k<n;++k){
                    if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]){
                        if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i]){
                            if(abs(a[i]-a[j])<a[k] && abs(a[i]-a[k]<a[j]) && abs(a[j]-a[k]<a[i]))summ++;
                        }


                    }
                }
            }
        }
        cout<<summ;









    
    return 0;
}

Measured memory_bytes: 3624
n = int(input())
a = [int(input()) for i in range(n)]
list = [0 for i in range(n)]
for i in range(n):
    if i == 0:
        list[i] = a[i]
    else:
        list[i] = a[list[i-1]-1]
if 2 in list:
    print(list.index(2) + 1)
else:
    print(-1)


Measured memory_bytes: 7852
class Collatz_Problems:
	def __init__(self,n):
		self.n = [n]
	def calc_even_odd(self):
		if self.n[-1] % 2 == 0:
			self.n.append(self.n[-1]/2)
			
		elif self.n[-1] % 2 != 0:
			self.n.append(3*self.n[-1]+1)

	def compare(self):
		for i in range(0,len(self.n)-1):
			if self.n[-1] == self.n[i]:
				return True
        
n = int(raw_input().strip())
num = Collatz_Problems(n)
i = 0
while i != 100:
	num.calc_even_odd()
	if num.compare():
		print(len(num.n))
		break


Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    int a, b;
    cin >> a >> b;
    a += 100 * (a == 1);
    b += 100 * (b == 1);
    if (a < b) {
        cout << "Bob";
    } else if (a > b) {
        cout << "Alice";
    } else {
        cout << "Draw";
    }
    cout << "\n";
}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
void init() {
	iostream::sync_with_stdio(false);

}

#define int ll

int union_tree[200000];
int union_find(int now) {
	if (union_tree[now] == now) return now;
	return union_tree[now] = union_find(union_tree[now]);
}
void union_merge(int a, int b) {
	a = union_find(a);
	b = union_find(b);
	union_tree[a] = b;
}

vector<int> blocks[200000];

set<int> cnter[200000];

void solve() {
	int n, m, k;
	cin >> n >> m >> k;
	REP(i, n) {
		union_tree[i] = i;
	}
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		union_merge(a, b);
		blocks[a].push_back(b);
		blocks[b].push_back(a);
	}
	REP(i, k) {
		int a, b;
		cin >> a >> b;
		a--; b--;		
		blocks[a].push_back(b);
		blocks[b].push_back(a);
	}
	REP(i, n) {
		cnter[union_find(i)].insert(i);
	}
	
	REP(i, n) {
		if (i != 0) cout << " ";
		int go = union_find(i);
		int ans = cnter[go].size() - 1;
		REP(q, blocks[i].size()) {
			ans -= cnter[go].count(blocks[i][q]);
		}
		cout << ans;
	}
	cout << endl;
}

#undef int

int main() {
	init();
	solve();
}

Measured memory_bytes: 27124
#include <stdio.h>
int main(){
	int a,b,c,i;
	a = b = c = 0;
	char s[4];
	scanf("%3s",s);
	for(i=0;i<3;i++){
		if(s[i]=='a') a=+1;
		if(s[i]=='b') b=+1;
		if(s[i]=='c') c=+1;
	}
	if(a == 1 && b == 1 && c == 1) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
//abc162_d.cpp
//Sun Apr 12 20:57:59 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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


	ll raf[n+1];
	ll gaf[n+1];
	ll baf[n+1];
	raf[n] = 0;
	gaf[n] = 0;
	baf[n] = 0;
	for (int i=n-1;i>=0;i--){
		raf[i] = raf[i+1];
		gaf[i] = gaf[i+1];
		baf[i] = baf[i+1];
		if (s[i]=='R'){
			raf[i]++;
		}else if (s[i]=='G'){
			gaf[i]++;
		}else {
			baf[i]++;
		}
	}

	ll ans = 0;
	for (int i=0;i<n-2;i++){
		for (int j=i+1;j<n-1;j++){
			if ((s[i]=='R' && s[j]=='G')||
				(s[i]=='G' && s[j]=='R')
				){
				ans += baf[j+1];
				if (j+(j-i)<n && s[j+(j-i)]=='B'){
					ans--;
				}
			}else if ((s[i]=='R' && s[j]=='B')||
				(s[i]=='B' && s[j]=='R')
				){
				ans += gaf[j+1];
				if (j+(j-i)<n && s[j+(j-i)]=='G'){
					ans--;
				}
			}else if ((s[i]=='G' && s[j]=='B')||
				(s[i]=='B' && s[j]=='G')
				){
				ans += raf[j+1];
				if (j+(j-i)<n && s[j+(j-i)]=='R'){
					ans--;
				}
			}
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int a[100010]={};
	int n, m;
	cin >> n;
	rep(i, n)
	{
		cin >> m;
		a[m]++;
		a[m+1]++;
		a[m+2]++;
	}
	int ans=0;
	rep(i, 100010) ans=max(ans, a[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 998244353
#define INF2 1000000000000000000
#define int long long
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
int dp[3010][3010];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, S;
    cin >> N >> S;
    int A[3010];
    rep(i, N) cin >> A[i];
    dp[0][0] = 1;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= S; ++j) {
            (dp[i+1][j] += dp[i][j] * 2) %= mod;
            if (j >= A[i]) (dp[i+1][j] += dp[i][j-A[i]]) %= mod;
        }
    }
    // rep(i, N + 1) {
    //     rep(j, S + 1) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << dp[N][S] << endl;


    return 0;
}


Measured memory_bytes: 74228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define arrlen(arr) (sizeof(arr)/sizeof(arr[0]))
#define Sort(arr) sort(arr, arr+arrlen(arr))
#define For(i,s,n) for(int i=s;i<n;i++)

int main(){
	int N;
	cin >> N;
	if(N==1){
		cout << 0;
		return 0;
	}
	
	int u[N],v[N],w[N];
	For(i,1,N){
		cin >> u[i] >> v[i] >> w[i];
	}
	
	int color[N];
	For(i,0,N) color[i]=-1;
	color[u[1]-1]=0;
	
	/*cout << endl;
	For(i,1,N){
		cout << u[i] << " " << v[i] << " " << w[i] << endl;
	}
	cout << endl << endl;*/
	
	int count=0;
	while(true){
		For(i,1,N){
			//cout << color[u[i]-1] << endl;
			if(color[u[i]-1]!=-1&&color[v[i]-1]==-1){
				count++;
				if(w[i]%2==0) color[v[i]-1]=color[u[i]-1];
				else color[v[i]-1]=(color[u[i]-1]+1)%2;
			}
			else if(color[v[i]-1]!=-1&&color[u[i]-1]==-1){
				count++;
				if(w[i]%2==0) color[u[i]-1]=color[v[i]-1];
				else color[u[i]-1]=(color[v[i]-1]+1)%2;
			}
			
			/*cout << endl << endl;
			For(i,0,N-1) cout << color[i] << endl;
			cout << endl << endl;*/
			
		}
		//cout << count << endl;
		if(count==N-1) break;
	}
	
	For(i,0,N) cout << color[i] << endl;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define chmin(i, j) i = min(i, j);
#define chmax(i, j) i = max(i, j);
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  vector<int> dd(13);
  for(int i=0;i<n;i++) {
    cin >> d[i];
    dd[d[i]]++;
  }
  bool yes = true;
  for(int i=0;i<dd.size();i++) {
    if(i == 0 && dd[i] > 0) yes = false;
    if(i == 12 && dd[i] > 1) yes = false;
    if(i != 0 && i != 12 &&  dd[i] > 2) yes = false;
  }
  if(!yes) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for(int i=0;i<pow(2, 11);i++) {
    bitset<11> b(i);
    vector<int> around(24);
    for(int j=0;j<13;j++) {
      if(j == 0) around[0] = 1;
      else if(j == 12) {
        if(dd[j]) around[12] = 1;
      }
      else if(dd[j] == 2) {
        around[j] = 1;
        around[24-j] = 1;
      }
      else if(dd[j] == 1) {
        if(b.test(j-1)) around[j] = 1;
        else around[24-j] = 1;
      }
    }
    int prev = 0;
    int tmp = 30;
    for(int j=0;j<24;j++) {
      if(j == 0) continue;
      if(around[j]) {
        chmin(tmp, j - prev);
        prev = j;
      }
    }
    chmin(tmp, 24-prev);
    chmax(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n, k, s = map(int, raw_input().split())
            if (n, k, s) == (0, 0, 0):
                break
            ans = 0
            for elem in itertools.combinations(range(1, n+1), k):
                if sum(elem) == s:
                    ans += 1
            print ans
                    
        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4652
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int N;
  cin >> N;
  set<string> goods;
  rep(i,N) {
    string s;
    cin >> s;
    goods.insert(s);
  }
  cout << goods.size() << endl;

  return 0;
}

Measured memory_bytes: 15604
#include <bits/stdc++.h>
using namespace std;
using item= pair<int64_t, int64_t>;
const int Nmax= 200;

pair<double, bool> solveRelaxation(int i_tmp, const bitset<Nmax> *choice, const vector<item> &data, const int &W){
  double ans= 0;
  double W_remain= W;
  for(int i=0; i<i_tmp; i++){
    if(choice->test(i)){
      ans+= data.at(i).first;
      W_remain-= data.at(i).second;
    }
  }

  bool is_RelaxedAns_feasible= true;
  for(int i=i_tmp; i<data.size(); i++){
    double x_i= min(1.0, W_remain/data.at(i).second);

    is_RelaxedAns_feasible= W_remain==(double)data.at(i).second;
    ans+= data.at(i).first* x_i;
    W_remain-= data.at(i).second* x_i;

    if(W_remain <= 0){ break; }
  }

  return make_pair(ans, is_RelaxedAns_feasible);
}

int64_t best_feasible= INT64_MIN;
int64_t solve(int i_tmp, int64_t V_tmp, int64_t W_tmp, bitset<Nmax> *choice, const vector<item> &data, const int &W){
  const int N= data.size();
  if(i_tmp==N){
    best_feasible= max(best_feasible, V_tmp);
    return V_tmp;
  }
  else{
    int64_t RelaxedAns; bool is_RelaxedAns_feasible;
    tie(RelaxedAns, is_RelaxedAns_feasible)= solveRelaxation(i_tmp, choice, data, W);

    if(is_RelaxedAns_feasible){ return RelaxedAns; }
    if(RelaxedAns < best_feasible){ return INT64_MIN; }

    int64_t ans1= INT64_MIN;
    int64_t ans0= INT64_MIN;
    // i_tmp番目のアイテムを選ぶ方の枝を探索
    if(W_tmp+ data.at(i_tmp).second <= W){
      choice->set(i_tmp);
      ans1= solve(i_tmp+1, V_tmp+ data.at(i_tmp).first, W_tmp+ data.at(i_tmp).second, choice, data, W);
      best_feasible= max(best_feasible, ans1);
    }
    // i_tmp番目のアイテムを選ばない方の枝を探索
    choice->reset(i_tmp);
    ans0= solve(i_tmp+1, V_tmp, W_tmp, choice, data, W);
    best_feasible= max(best_feasible, ans0);

    return max(ans1, ans0);
  }
}

int main(){
  int N,W;
  cin >> N >> W;

  vector<item> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i).second >> data.at(i).first;
  }

  auto comp= [](item a, item b){
    return a.first* b.second > b.first* a.second;
  };
  sort(data.begin(), data.end(), comp);

  bitset<Nmax> choice;

  cout << solve(0, 0, 0, &choice, data, W) << endl;
}

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

char s [30];
bool vis[200];
int main()
{
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++)
    {
        char c=s[i];
        if(!vis[c])
            vis[c]=true;
        else{
            printf("no");
            return 0;
        }
    }
    printf("yes");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define MN 201000

int a[MN];
long long f[MN][3];
long long s[MN];

int main()
{
	int n; scanf("%d", &n);
	long long ans = 1e18;
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]), s[i] = s[i - 1] + a[i];
	for(int i = 1; i <= n; i++)
	{
		f[i][0] = std::min(f[i - 1][0], s[i - 1]) + (a[i] == 0 ? 2 : ((a[i] & 1) ? 1 : 0));
		f[i][1] = std::min(f[i - 1][0], std::min(f[i - 1][1], s[i - 1])) + (a[i] == 0 ? 1 : ((a[i] & 1) ? 0 : 1));
		f[i][2] = std::min(f[i - 1][1], f[i - 1][2]) + (a[i] == 0 ? 2 : ((a[i] & 1) ? 1 : 0));		
		ans = std::min(ans, std::min(std::min(f[i][0], f[i][1]), std::min(f[i][2], s[i - 1])) + s[n] - s[i]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 7424
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
	// freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    int n,a,b;
    while(cin>>n>>a>>b)
    {
    	if(n==1)
    	{
    		if(a!=b)
    		{
    			cout<<0<<endl;
    		}else
    		{
    			cout<<1<<endl;
    		}
    	}else
    	{
    		if(a<=b)
    		{
    			if(n==2)
    			{
    				cout<<1<<endl;
    				continue;
    			}
    			ll ans=1ll*(n-2)*b-1ll*(n-2)*a+1ll;
    			cout<<ans<<endl;
    		}else
    		{
    			cout<<0<<endl;

    		}
    	}
    }
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll T;
    cin >> T;
    vector<ll> A(N,0);
    for(ll i=0;i<N;++i)cin>>A[i];
    set<ll> S,R;
    ll Max=-INF;
    for(ll i=N-1;i>=0;--i){
        if(!S.empty()){
            chmax(Max,*(prev(S.end()))-A[i]);
        }
        S.insert(A[i]);
    }
    
    ll ans=0;
    for(ll i=N-1;i>=0;--i){
        if(!R.empty()&&*(prev(R.end()))-A[i]==Max)ans++;
        R.insert(A[i]);
    }

    prt(ans)


    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define N 500005
#define int long long
using namespace std;
int n,pos=1,tot,ans,op[N],a[N],b[2][N],len[2],res[2];
void solve(){
	for(int i=1;i<b[pos][1];i++) op[++tot]=1;
	for(int i=n;i>b[pos][len[pos]];i--) op[++tot]=i-b[pos][1]+1;
	for(int i=2;i<=len[pos];i++){
		int sz=(b[pos][i]-b[pos][i-1])/2;
		for(int j=sz+1;j>1;j--) op[++tot]=j;
	}
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		if(a[i]>a[pos]) pos=i;
	}
	if(a[pos]<=0){
		res[0]=a[pos];
		b[0][++len[0]]=pos;
		pos=0;
	}
	else {
		for(int i=1;i<=n;i+=2) if(a[i]>0) b[0][++len[0]]=i,res[0]+=a[i];
		for(int i=2;i<=n;i+=2) if(a[i]>0) b[1][++len[1]]=i,res[1]+=a[i];
		if(res[0]>res[1]) pos=0;
		else pos=1;
	}
	solve();
	printf("%lld\n%d\n",res[pos],tot);
	for(int i=1;i<=tot;i++) printf("%d\n",op[i]);
	return 0;
}

Measured memory_bytes: 6400
#include<iostream>
#include<cctype>
#include<cstdlib>
using namespace std;
int main(){
    char str[100];
    cin>>str;
    int ans=atoi(str);
    while(true){
        cin>>str;
        char ope=str[0];
        if(ope=='=')break;
        cin>>str;
        int i=atoi(str);
        if(ope=='+')ans+=i;
        else if(ope=='-')ans-=i;
        else if(ope=='*')ans*=i;
        else if(ope=='/')ans/=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string s, t;

int N;

int NEXT[300000][30];

string S;

int pos[30];

int main(void) {

	cin >> s >> t;

	N = s.size();

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 26; j++) {
			NEXT[i][j] = -1;
		}
	}

	S = "#" + s + s;

	for (int i = 0; i < 26; i++) { pos[i] = -1; }

	for (int j = 2 * N; j >= 0; j--) {

		if (j <= N) {
			for (int k = 0; k < 26; k++) {
				NEXT[j][k] = pos[k]-j;
			}
		}

		pos[S[j] - 'a'] = j;
		
	}


	/*for (int i = 0; i <= 1; i++) {
		for (int j = 0; j < 26; j++) {
			cout << "NEXT[" << i << "][" << j << "]= " << NEXT[i][j] << endl;
		}
	}*/

	long int ans = 0;

	int M = t.size();
	int loc = 0;
	for (int i = 0; i < M; i++) {
		int val = NEXT[loc][t[i] - 'a'];

		//cout << "val= " << val <<"  loc= " <<loc<< endl;
		if (val <= 0) { ans = -1; break; }
		else {
			ans += val;
			loc += val;
			if (loc > N) { loc -= N; }
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
    char ch[3];
    int i = 0,count = 0,len=0;
    gets(ch);
    len = strlen(ch);
    while(len--) {
        if(ch[i]=='o')count++;
        i++;
    }
    printf("%d\n",(700+(count*100)));

    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B, H, M float64
	fmt.Scanf("%f%f%f%f", &A, &B, &H, &M)

	rad := math.Abs((H+(M/60.0))/12.0 - M/60.0)
	if rad == 0 {
		fmt.Println(math.Abs(A - B))
		return
	}
	if rad == 0.5 {
		fmt.Println(A + B)
		return
	}
	if rad > 0.5 {
		rad = 1.0 - rad
	}

	c := math.Sqrt(math.Pow(A, 2) + math.Pow(B, 2) - 2.0*A*B*math.Cos(2.0*rad*math.Pi))
	fmt.Println(c)
}


Measured memory_bytes: 1824
#!/usr/bin/env ruby

tmp  = STDIN.gets.chomp.split(/\s/).map { |e| e.to_i }
m = tmp[1]
a  = STDIN.gets.chomp.split(/\s/).map { |e| e.to_i }

s = a.inject(:+)
t = 1.0 * s / (4 * m)

cnt = 0

a.each do |i|
	if i >= t
		cnt += 1
	end
end

puts ((cnt >= m) ? "Yes" : "No")



Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

#define mod 1000000007

ll add(ll a, ll b){return (a%mod + b%mod)%mod;}
ll sub(ll a , ll b){return (a%mod - b%mod + mod)%mod;}
ll mul(ll a, ll b){return (a%mod * b%mod)%mod;}
ull poww(ull a,ull b){ull res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll MOD){ll res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define dbg(x) cout<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define dbg4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;

//end of template

int main(int argc, char const *argv[])
{
	crap;
	int n;
	string s;
	cin >> n;
	ll a, b, c, d ;
	a = b = c = d = 0;
	ll ans = 0;
	rep (i, n){
		cin >> s;
		int m = s.length();
		if (s[0] == 'B' && s[m-1] == 'A')
			b++;
		else if (s[m-1] == 'A')
			a++;
		else if (s[0] == 'B')
			c++;
		rep(j, m - 1){
			if (s[j] == 'A' && s[j+1] == 'B')
				ans += 1LL;
		}
	}
	if (a == c && b && a + c < b){
		b -= 1LL;
	}
	ans += b + min(a, c);
 	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//russian flag

#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
	int n,m;//N横列M縦
	int w[50]={},r[50]={},b[50]={};//色の数
	cin >> n >> m;

	for(int i=0; i<n; i++){//n回ループ
		string s;
		cin >> s;
		for(int j=0; j<m; j++){
			char col = s[j];
			if(col=='B')b[i]++;
			if(col=='W')w[i]++;
			if(col=='R')r[i]++;
		}
	}

	int ansl=9999;

	for(int i=1; i<n; i++){
		b[i]+=b[i-1];
		r[i]+=r[i-1];
		w[i]+=w[i-1];
	}

	for(int i=1; i<n-1; i++){//ここからB
		for(int j = n-2; j >= i; j--){//ここまでB
			ansl=min(r[j]+w[n-1]-w[i-1]+b[n-1]-b[j]+b[i-1],ansl);
		}			
	}

	cout << ansl << endl;

	return 0;
}



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

using namespace std;

int main ()
{
	int n;
	cin >> n;
	int l[n];
	int cnt = 0;
	for (int i = 0; i < n; ++i) cin >> l[i];
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j)
			for (int k = j + 1; k < n; ++k)
				if (((l[i] + l[j] > l[k]) && (l[i] + l[k] > l[j]) && (l[j] + l[k] > l[i])) && l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) 
					++ cnt;
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3640
A = []
for i in range(3):
  A += list(map(int, input().split()))
N = int(input())
b = []
for i in range(N):
  b += [int(input())]
S1 = {A[0], A[1], A[2]}
S2 = {A[3], A[4], A[5]}
S3 = {A[6], A[7], A[8]}
S4 = {A[0], A[3], A[6]}
S5 = {A[1], A[4], A[7]}
S6 = {A[2], A[5], A[8]}
S7 = {A[0], A[4], A[8]}
S8 = {A[2], A[4], A[6]}
flg = 0
if S1 < set(b): flg = 1
if S2 < set(b): flg = 1
if S3 < set(b): flg = 1
if S4 < set(b): flg = 1
if S5 < set(b): flg = 1
if S6 < set(b): flg = 1
if S7 < set(b): flg = 1
if S8 < set(b): flg = 1
print('Yes' if flg == 1 else 'No')
  

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,n,mul=0;
    cin>>a>>b>>n;
    mul=a*b;
    if(mul>=n)
    {
        cout<<n;
    }
    else if(n>=mul)
    {
        cout<<mul;
    }
    else
    {
        cout<<n;
    }
    return 0;

}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

H,W,K = I()
maze = [list(s()) for _ in range(H)]
cnty = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            cnty += 1
h = [i for i in range(H)]
w = [i for i in range(W)]
ans = 0
for i in range(H):
    for j in range(W):
        mazey = copy(maze)
        hc = list(itertools.combinations(h,i))
        wc = list(itertools.combinations(w,j))
        for k in range(len(hc)):
            for l in range(len(wc)):
                mazey = copy(maze)
                cnt = 0
                if hc[k]:
                    for m in hc[k]:
                        cnt += mazey[m].count('#')
                        mazey[m] = ['.']*W
                if wc[l]:
                    for m in wc[l]:
                        for n in range(H):
                            if mazey[n][m] == '#':
                                cnt += 1
                if cnty - cnt == K:
                    ans += 1
print(ans)

Measured memory_bytes: 73740
package main

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

func readStringIntArray(rd *bufio.Reader, n int) ([]int, error) {
	nums := make([]int, 0, n)
	s, _, err := rd.ReadLine()
	if err != nil {
		return nums, err
	}

	arr := strings.Split(string(s), " ")
	for _, i := range arr {
		n, err := strconv.Atoi(i)
		if err != nil {
			return nums, err
		}
		nums = append(nums, n)
	}
	return nums, nil
}

func main() {
	n := 3
	rd := bufio.NewReader(os.Stdin)
	for {
		nums, _ := readStringIntArray(rd, n)
		if reflect.DeepEqual(nums, []int{-1, -1, -1}) {
			break
		}
		m, f, r := nums[0], nums[1], nums[2]
		var grade string
		switch {
			case f==-1 || m==-1:
			grade = "F"
		case f+m >= 80:
			grade = "A"
		case f+m >= 65:
			grade = "B"
		case f+m >= 50:
			grade = "C"
		case r >= 50:
			grade = "C"
		case f+m >= 30:
			grade = "D"
		case f+m < 30:
			grade = "F"
		default:
			panic("can't rate")
		}
		fmt.Println(grade)
	}
}



Measured memory_bytes: 1124
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> x(n);
    for(int i=0;i<n;i++) cin>>x[i];
    ll ans=1e10;
    for(int i=0;i+k<=n;i++){
        ll l=abs(x[i])+abs(x[i+k-1]-x[i]);
        ll r=abs(x[i+k-1])+abs(x[i+k-1]-x[i]);
        ans=min(ans,min(l,r));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3796
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    total = m + f
    if m == -1 or f == -1:
        print('F')
        continue
    if total >= 80:
        print('A')
        continue
    if 65 <= total:
        print('B')
        continue
    if 50 <= total or 30 <= total and r >= 50:
        print('C')
        continue
    if 30 <= total:
        print('D')
        continue
    print('F')


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)1e9

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	doublade();
	// w(t) {
		ll n;
		cin >> n;
		ll p = n/500;
		ll rs = 1000*p;
		n -= p*500;
		ll q = n/5;
		rs += 5*q;
		cout<<rs<<"\n";
	// }
	return 0;
}

Measured memory_bytes: 3600
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s;
  cin >> s;
  if(int(s[5] - '0') * 10 + int(s[6] -  '0') > 4){
    cout << "TBD" << endl;
  }else cout << "Heisei" << endl;
}

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


int main() {
	int n, m;

	cin >> n >> m;

	int a[100][100] = { {} };

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	int ve[100] = {};
	for (int j = 0; j < m; j++)cin >> ve[j];

	for (int i = 0; i < n; i++) {
		int x = 0;
		for (int j = 0; j < m; j++) x += a[i][j] * ve[j];
		cout << x << endl;
	}

	return 0;
}



Measured memory_bytes: 3140
r, c = map(int, input().split())

table = []
for x in range(r):
    table.append(list(map(int, input().split())))

for x in range(r):
    print(*table[x],end=" ")
    print(sum(table[x]))

st = 0
for x in range(c):
    s = 0
    for y in range(r):
        s += table[y][x]
    print(s, end = " ")
    st += s
print(st)


 


Measured memory_bytes: 6220
#include <iostream>
#include <array>
#include <vector>
#include <map>
#include <utility>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <string>
#include <limits.h>
#include <algorithm>
#include <assert.h>

using namespace std;

#define MM (1000000000 + 7)

int main(){
    int n,m;
    cin >> n >> m;
    int x[100001],y[100001];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> y[i];
    }
    
    long long sum = 0;
    
    int n2 = n/2;
    int m2 = m/2;
    long long widthx2[10000];
    long long widthy2[10000];
    long long sumx = 0, sumy = 0;
    for (int i = 0; i < n2; i++) {
        widthx2[i] = (x[n-i-1] - x[i]);
        widthx2[i] *= n - 2 * i - 1;
        widthx2[i] %= MM;
        sumx += widthx2[i];
        sumx %= MM;
    }
    for (int k = 0; k < m2; k++) {
        widthy2[k] = (y[m-k-1] - y[k]);
        widthy2[k] *= m - 2 * k - 1;
        widthy2[k] %= MM;
        sumy += widthy2[k];
        sumy %= MM;
    }

    cout << (sumx * sumy) % MM << endl;
    
    return 0;
}


Measured memory_bytes: 1024