akhauriyash/Code-Regression huggingface dataset:
import math
def fact(n):
  i = 1
  l=[]
  while i <= math.sqrt(n):
    if (n % i == 0) : 
      if (n / i == i) : 
        l.append(i) 
      else : 
        l.append(i)
        l.append(n//i)
    i = i + 1
  return l

n=int(input())
l=fact(n)
xx=0
mini=10000000000000
l.sort()
i,j=0,len(l)-1
while i<j:
  i+=1
  j-=1
# print(l[i],l[j])
print(l[i]+l[j]-2)
# print(xx)


'''
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
'''

Measured memory_bytes: 3276
n, y = [int(i) for i in input().split()]

def cond():
    for i in range(n + 1):
        for j in range(n - i, -1, -1):
            k = n - i - j
            if (10000  * i + 5000 * j + 1000 * k) == y:
                return '{} {} {}'.format(i, j, k)
    return ""

c = cond()
if c:
    print(c)
else:
    print('-1 -1 -1')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <hash_map>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ll long long
using namespace std;

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, k;
int a[200010];
int main()
{
	n = read();
	k = read();
	rep(i, 1, n)
	{
		int x = read();
		a[x] ++;
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	int ans = 0;
	rep(i, k + 1, 200000)
		ans += a[i];
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

for x in A:
	if x%2 == 0 and (x%3 != 0 and x%5 != 0):
		print("DENIED")
		break
else:
	print("APPROVED")


Measured memory_bytes: 5388
n = int(input())
lst1 = [list(map(int,input().split())) for i in range(n)]

lst1.sort()

x,y = 0,0
t = lst1[0][0]
for i in range(n):
    if i > 0:
        t = lst1[i][0] - lst1[i-1][0]
    move = abs(lst1[i][1]-x) + abs(lst1[i][2]-y)
    if move > t:
        print("No")
        exit()
    elif move%2 != t%2:
        print("No")
        exit()

    x,y = lst1[i][1],lst1[i][2]

print("Yes")

Measured memory_bytes: 60248
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <cstring>
#include <queue>
#include <sys/time.h>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rev(i,n) for(int i=(int)n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ( (a)/__gcd((a),(b))*(b) )

template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

int main(){
	int n;
	while(cin >> n && n){
		vector<string> s;
		map<int,vector<string> > ok;
		rep(i,n){
			string a;int t;
			cin >> a >> t;
			rep(j,t){
				int b;
				cin >> b;
				ok[b].push_back(a);
			}
			s.push_back(a);
		}
		map<string,int> score;
		rep(i,s.size())score[s[i]] = 0;
		EACH(it,ok){
			rep(j,it->second.size()){
				score[it->second[j]] += n - it->second.size() + 1;
			}
		}
		string p;
		int ans = 99999999;
		EACH(it,score){
			if(it->second < ans){
				p = it->first;
				ans = it->second;
			}
		}
		cout << ans << " " << p << endl;
	}
}

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

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

  vector<int> data(N, -1);

  for (int i = 0; i < M; i++) {
    int s, c;

    cin >> s >> c;
    s--;  // 0 base

    if (data[s] != -1 && data[s] != c) {
      // 同じ桁数に異なる数値が指定された場合は選べないので処理終了
      cout << -1 << endl;
      return 0;
    }
    data[s] = c;
  }

  string ans = "";
  for (int i = 0; i < N; i++) {
    if (data[i] == -1) {
      // 2桁以上で最初の桁なら1, そうでないなら0にする
      if (N > 1 && i == 0)
        ans += "1";
      else
        ans += "0";
    } else {
      ans += data[i] + '0';
    }
  }

  // 2桁以上で先頭0はNG
  if (N > 1 && ans[0] == '0') {
    cout << -1 << endl;
    return 0;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

struct card{
	char mark;
	int number;
};

void bubbleSort(struct card *a, int N);
void selectionSort(struct card *b, int N);
void check(struct card *a,struct card *b, int N);
int main(void){
	int i,N;
	scanf("%d",&N);
	
	struct card a[N];
	struct card b[N];
	
	for(i=0;i<N;i++){
		scanf(" %c%d",&(a[i].mark),&(a[i].number));
		b[i]=a[i];
		}
	bubbleSort(a, N);
	selectionSort(b, N);
	check(a,b,N);
	return 0;
}


void bubbleSort(struct  card *a,int N){
	int i,j;
	struct card tmp;
	for(i=0;i<N;i++){
		for(j=N-1;j>=i+1;j--){
			if(a[j].number<a[j-1].number){
				tmp=a[j];
				a[j]=a[j-1];
				a[j-1]=tmp;
			}
		}
	}
	
	for(j=0;j<N;j++){
		if(j!=N-1)printf("%c%d ",a[j].mark,a[j].number);
		else{printf("%c%d\n",a[j].mark,a[j].number);}
	}
	printf("Stable\n");
}

void selectionSort(struct card *a,int N){
	int i,j,minj = 0;
	struct card tmp;
	for(i=0;i<=N-1;i++){
		minj = i;
		for(j=i;j<= N-1;j++)
		{
			if(a[j].number<a[minj].number)
			{
				minj = j;
			}
		}
			tmp = a[i];
			a[i] = a[minj];
			a[minj] = tmp;
	}
	
	for(j=0;j<N;j++){
		if(j!=N-1)printf("%c%d ",a[j].mark,a[j].number);
		else{printf("%c%d\n",a[j].mark,a[j].number);}
	}
}

void check(struct card *a,struct card *b,int N){
	int count=0;
	int i;
	for(i=0;i<N;i++){
		if(a[i].mark !=b[i].mark){
			count++;
			}
	}
	
	if(count==0){
			printf("Stable\n");
			}
		else{
			printf("Not stable\n");
			}
}


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

#define ll long long

int main() {
	int n, m;
	int x, y;
	int i, j;
	int q;
	int count = 0;

	cin >> n >> m;
	vector<vector<int>> a(n + 1,vector<int>(0));
	vector<int>b;
	vector<int>c;
	vector<int>h(n + 1);
	for (i = 0; i <= n; i++)h[i] = 0;
	for (i = 1; i <= m; i++) {
		cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for (i = 0; i < a[1].size(); i++) {
		c.push_back(a[1][i]);
		h[a[1][i]] = 1;
		count++;
	}
	h[1] = 1;
	while (count<n-1){
		//cout << count << '\n';
		if (c.size() == 0 )break;
		for (q = 0; q < c.size(); q++) {
			i = c[q];
			for (j = 0; j < a[i].size(); j++) {
				//cout << j << '\n';
				if (h[a[i][j]] != 0)continue;
				b.push_back(a[i][j]);
			    h[a[i][j]] = i;
			    count++;
			}
		}
		c.clear();
		for (j = 0; j < b.size(); j++)c.push_back(b[j]);
		b.clear();
	}

	if (count >= n-1) {
		cout << "Yes"<<'\n';
		for (i = 2; i <= n; i++)cout << h[i] << '\n';
	}
	else {
		cout << "No";
	}
	
	return 0;

}

Measured memory_bytes: 10512
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
#include <atcoder/all>
using namespace atcoder;
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion

const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
const int MAX = 2000005;
using mint = modint998244353;

template<class T>bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}

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

/*-----------------------------------------------------------------------------------------------------*/
struct S{
	mint x, w;
	S(mint x = 0, mint w = 1):x(x), w(w){};
};

S op(S a, S b){
	return S(a.x * b.w + b.x, a.w * b.w);
}

S e(){
	return S();
}

S mapping(int f, S a){
	if(f == 0) return a;
	else return S((a.w - 1) / 9 * f, a.w);
}

int composition(int f, int g){
	if(f == 0) return g;
	else return f;
}
int id(){
	return 0;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	lazy_segtree<S, op, e, int, mapping, composition, id> tree(n);
	rep(i,n) tree.set(i, S(1, 10));
	rep(i,q){
		int l, r, d; cin >> l >> r >> d;
		l--;
		tree.apply(l, r, d);
		S ans = tree.prod(0,n);
		cout << ans.x.val() << endl;
	}
}

Measured memory_bytes: 9832
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	if (n <= k) {
		cout << 0 << endl;
		return 0;
	}

	vector<int>monster(n, 0);
	ll h = 0;
	ll sum = 0;
	rep(i, n) {
		cin >> h;
		monster[i] = h;
		sum += h;
	}

	sort(monster.begin(), monster.end());
	reverse(monster.begin(), monster.end());

	ll decrease = 0;
	rep(i, k) {
		decrease += monster[i];
	}

	ll ans = sum - decrease;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++) cin >> a[i];
    deque<int> q;
    if(n % 2 == 0){
        for(int i = 0;i < n;i++){
            if(i % 2 == 0) q.push_back(a[i]);
            if(i % 2 == 1) q.push_front(a[i]);
        }
    }
    if(n % 2 == 1){
        for(int i = 0;i < n;i++){
            if(i % 2 == 0) q.push_front(a[i]);
            if(i % 2 == 1) q.push_back(a[i]);
        }
    }
    for(int i = 0;i < n;i++){
        cout << q[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  int W, H;
  while (cin >> H >> W) {
    if (H == 0 && W == 0)
      break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if ((j + i) % 2 == 0) {
          cout << '#';
        } else if ((j + i) % 2 == 1)
          cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	string s,ans;
	cin>>s;
	ans="ABC";
	rep(i,0,3){
		ans.push_back(s[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import copy
n=int(input())
t=list(map(int,input().split()))
l=copy.copy(t)
m=int(input())
ans=0
for i in range(m):
    p,x=map(int,input().split())
    t[p-1]=x
    print(sum(t))
    t[p-1]=l[p-1]

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

int main() {
    // 入力
    int n, x, y;
    cin >> n >> x >> y;
    // 数える
    vector<int> v(2001, 0);
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            int d=min(min(abs(j-i), abs(x-i)+1+abs(j-y)), abs(y-i)+1+abs(j-x));
            //cout << "i:" << i+1 << " j:" << j+1 << " d:" << d << endl;
            v[d]++;
        }
    }
    // 出力
    for(int i = 1; i < n; ++i) {
        cout << v[i]/2 << endl;
    }
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();

    let mut ans = 0;
    let mut count_xa = 0;
    let mut count_ba = 0;
    let mut count_bx = 0;
    for _ in 0..n {
        let s = i.read_line().as_bytes();

        for i in 1..s.len() {
            if s[i - 1] == b'A' && s[i] == b'B' {
                ans += 1;
            }
        }
        let is_xa = s[s.len() - 1] == b'A';
        let is_bx = s[0] == b'B';
        match (is_bx, is_xa) {
            (true, true) => count_ba += 1,
            (true, false) => count_bx += 1,
            (false, true) => count_xa += 1,
            _ => {}
        }
    }
    let mut is_xa = false;
    loop {
        if !is_xa {
            if count_xa != 0 {
                count_xa -= 1;
            } else if count_ba != 0 {
                count_ba -= 1;
            } else {
                break;
            }
            is_xa = true;
        }
        if count_ba != 0 {
            count_ba -= 1;

        } else if count_bx != 0 {
            count_bx -= 1;
            is_xa = false;
        } else {
            break;
        }
        ans += 1;
    }

    writeln!(o, "{}", ans).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

int main(void) {
    
    int H,W;
	scanf("%d%d", &H,&W);
	char s[50][50];
	for (int i=0;i<W;i++) {
	    scanf("%s", &s[i]);
	}
	int end=1;
	int check =1;
	for (int i=1;i<=H;i++) {
		for(int j=1;j<=W;j++) {
			if (s[i][j]=='#') {
				if (s[i-1][j] == '#'||s[i+1][j] == '#'||s[i][j-1] == '#'||s[i][j+1] == '#') check=1;
				else { 
				    check=0;
					break;
			    }
			}
		}
		if (check==0) { 
		    int end=0; break;
		}
	}
	if (check ==0) puts("No");
	else puts("Yes");
	return(0);
}

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

int main() {
  string s,t;
  cin>>s>>t;
  sort (s.begin(),s.end());
  sort (t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  int N;
  cin>>N;
  int sum=0;
  int i=1;
  while(sum<N){
    sum+=i;
    i++;
  }
  int c=sum-N;
  for(int k=1;k<i;k++){
    if(k==c){continue;}
    cout<<k<<endl;
  }


  return 0;
}

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


using namespace std;

struct Elem {
	long long prime;
	long long count;
	long long z;
	
    bool operator < (const Elem &a) const {
        return this->z > a.z;	//最小值优先
    }	
};

std::priority_queue<Elem> q;

long long n;
long long d;

std::vector<long long> factors;
std::vector<long long> counts;

void getFactors(long long num)
{
	if (num % 2 == 0)
	{
		int curCount = 0;
		while (num % 2 == 0) {
			num = num / 2;
			curCount++;
		}
		factors.push_back(2);
		counts.push_back(curCount);
	}
	
	long long d = 3;
	while ((d * d) <= num)
	{
		if (num % d == 0)
		{
			factors.push_back(d);
			int curCount = 0;
			while (num % d == 0) {
				num = num / d;
				curCount++;
			}
			counts.push_back(curCount);
		}
		d = d + 2;
	}
	
	if (num > 1) {
		factors.push_back(num);
		counts.push_back(1);
	}
		
}

long long sums[100];

void init() {
	sums[0] = 0;
	for (int i = 1 ; i < 100 ; i++)
		sums[i] = sums[i - 1] + i;
}

int getSum(int num) {
	int p = 1;
	while (num >= sums[p]) {
		p++;
	}
	return p - 1;
}


int main()
{
	init();
	
	scanf("%lld", &n);
	getFactors(n);
	
	long long count;
	count = 0;
	
	for (int i = 0 ; i < counts.size() ; i++) {
		int secCount = getSum(counts[i]);
		count = count + secCount;
	}
	
	printf("%lld\n", count);
	return 0;
}


Measured memory_bytes: 3260
//https://atcoder.jp/contests/abc145/tasks/abc145_b


#include<stdio.h>   //AA06( 23/ 07/ 20) If u see my code, Have a Good Day! (^_^)

int main()
{
    int N, X, i;

    scanf("%d", &N);

    X = (N / 2);

    char S[N + 1];

    scanf("%s", S);

    if(N % 2 == 0) {

        for(i = 0; i < (N / 2); ++i, X++) {

            if(S[i] != S[X]) {

                printf("No\n");

                return 0;
            }

        }

        printf("Yes\n");

    }


    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 1612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

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

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

    ll dp[n + 1][3] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    chmax(dp[i + 1][j], dp[i][k] + a[i][j]);
                }
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < 3; i++) {
        ans = max(dp[n][i], ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7008
#include <iostream>
#include <math.h>

using namespace std;
#define ll long long

int count(int i, string A, string B, string C){
    if(A[i]==B[i] && B[i]==C[i]) return 0;
    else if(A[i]==B[i] || B[i]==C[i] || A[i]==C[i]) return 1;
    else return 2;
}

int main() {
    int N;
    string A,B,C;
    cin>>N >> A >> B>> C;
    int sum = 0;
    for(int i=0;i<N;i++){
        sum += count(i,A,B,C);
    }
    
    cout << sum << endl;
}


Measured memory_bytes: 256
user = str(input())
count = 0
for i in user:
    if i == 'R':
        count += 1
    else:
        count
if count == 3:
        count
elif count == 2:
    if user[0] == user[2]:
        count = 1
    else:
        count = 2
else:
    count = count
print(count)
        
        

Measured memory_bytes: 8964
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
#define wis(x) "[" << #x << " : " << x << "] " << 
typedef long long ll;

const int MAXN = 10, MOD = 1e9 + 7, INF = 1e9 + 5;

char a[MAXN][MAXN];
int row[MAXN], col[MAXN], B;

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m, k, ans = 0;
	cin >> n >> m >> k;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
			if(a[i][j] == '#')
				row[i]++, col[j]++, B++;
		}
	}
	for(int i = 0; i < (1 << n); i++){
		for(int j = 0; j < (1 << m); j++){
			int tmpB = B;
			vector <int> R, C;
			for(int r = 0; r < n; r++)
				if((1 << r) & i)
					R.push_back(r);
			for(int c = 0; c < m; c++)
				if((1 << c) & j)
					C.push_back(c);
			for(int r : R)
				tmpB -= row[r];
			for(int c : C)
				tmpB -= col[c];
			for(int r : R){
				for(int c : C){
					if(a[r][c] == '#')
						tmpB++;
				}
			}
			// if(i == 1 && j == 1)
			// 	cerr << wis(tmpB) endl;
			if(tmpB == k){
				// cerr << wis(i) wis(j) endl;
				ans++;
			}

		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main(){
    int N,K,fillness =0,crack = 0;
    cin >> N >> K;
    
    char S[N+1];
    cin >> S[0];
    for(int i = 1; i < N; i++){
        cin >> S[i];
        if(S[i] == S[i-1]){
            fillness += 1;
        }else{
            crack += 1;
        }
    }
    
    if(K * 2 <= crack){
        cout << fillness + K * 2 << endl;
    }else{
        cout << fillness + crack << endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		
    		String a=scan.next();
    		String b=scan.next();
    		String c=scan.next();
    		
    		if (a.charAt(a.length()-1)==b.charAt(0)&& b.charAt(b.length()-1)==c.charAt(0)) {
    			System.out.print("YES");
    		}else {
    			System.out.print("NO");
    		}

    		
    	
  
    				
    	}
     
    }

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cstring>
#include <cctype>
#include <numeric>
#include <cstdio>
#include <math.h>
#include <functional>
using namespace std;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define na(a, n) rep(i, n) cin >> a[i];
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
vb d(10);
int ans(int x)
{
    while (x)
    {
        if (d[x % 10])
            return 0;
        x /= 10;
    }
    return 1;
}
//ここからメイン
int main()
{
 string a,b;
  cin >>a>>b;
  cout << (a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]?"YES":"NO");
  }
  

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

int f2(int n){
  int cnt=0;
  while(n%2==0){
    n/=2;
    cnt++;
  }
  return cnt;
}

int main(){
  int i,j,k,cnt;
  int n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  int sum=0;
  for(i=0;i<n;i++)sum+=f2(a[i]);
  cout<<sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#define ll long long
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
const int MOD = 1E9+7;
const int N = 1000+5;

int pos(int n)
{
    if(n<0)
        return 0;
    else
        return n;
}
int G[2*N][2*N]={0};
int getNum(int x1,int y1,int x2,int y2){
return G[x2][y2]-G[x1][y2]-G[x2][y1]+G[x1][y1];
}
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        int x,y;
        char c;
        cin>>x>>y>>c;
        if(c=='W')
            x+=k;
        x=x%(k*2);
        y=y%(k*2);
        G[x+1][y+1]++;
    }
    for(int i=1;i<=2*k;i++){
        for(int j=1;j<=2*k;j++){
            G[i][j]+=G[i-1][j]+G[i][j-1]-G[i-1][j-1];
        }
    }
    int res=-INF;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            int temp1=getNum(0,0,i,j);
            int temp2=getNum(0,j+k,i,2*k);
            int temp3=getNum(i+k,0,2*k,j);
            int temp4=getNum(i+k,j+k,2*k,2*k);
            int temp5=getNum(i,j,i+k,j+k);
            int sum=temp1+temp2+temp3+temp4+temp5;
            res=max(res,max(sum,n-sum));
        }
    }
    cout<<res;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define ll long long
#define N 200010
using namespace std;
ll ans;
int n;
int a[N];

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

int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1,cmp);
	int hal=n/2;
	ans+=a[1];
	for(int i=2;i<=hal;i++){
		ans+=(long long)a[i];
		ans+=(long long)a[i];
	}
	if(n%2==1)ans+=(long long)a[hal+1];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4304
from collections import deque

h, w = map(int, input().split())
m = [list(input()) for _ in range(h)]

flag = [[True] * w for _ in range(h)]

q = deque()

for i in range(h):
    for j in range(w):
        if m[i][j] == "#":
            q.appendleft((i, j, 0))
            flag[i][j] = False

ans = 0
while q:
    (i, j, n) = q.pop()
    ans = n
    for dx, dy in zip([1,0, -1, 0], [0, 1, 0, -1]):
        ni = i + dx
        nj = j + dy
        if (0 <= ni < h and 0 <= nj < w and flag[ni][nj]):
            flag[ni][nj] = False
            q.appendleft((ni, nj, n + 1))

print(ans)

Measured memory_bytes: 224764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

int main()
{
    ll n;
    cin>>n;
    vector<ll> a(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    ll gg;
    ll ans=-1;
    /*for(int i=0;i<n-1;i++)
    {
        gg=gcd(a[i],a[i+1]);
        if(a[i+1]%2!=0&&cnt==0)
        {
            cnt++;
            a[i+1]=a[i];
            gg=a[i];
        }
        if((gg<max&&max>0)||(gg>max&&max==-1))
            max=gg;
    }*/
        vector<ll> L(n+2);
        vector<ll> R(n+2);
        vector<ll> M(n+2);
        L[0]=0;
        R[n+1]=0;
        for(ll i=0;i<n;i++)
        {
            L[i+1]=gcd(L[i],a[i]);
        }
        for(ll i=n;i>1;i--)
        {
             R[i]=gcd(R[i+1],a[i]);
        }
        for(ll i=1;i<=n;i++)
        {
            M[i]=gcd(L[i],R[i+1]);
            if(ans<M[i])
                ans=M[i];
        }
    
    
    cout<<ans%1000000007<<endl;
    return 0;
}




Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

int main(void) {
	int i, j, aa, bb;
	string a, b;
	cin >> a >> b;
	if (a.size() == b.size()) {
		for (i = 0; i < a.size(); i++) {
			aa = a[i]; bb = b[i];
			if (a > b) {
				cout << "GREATER" << endl;
				return 0;
			}
			else if (a < b) {
				cout << "LESS" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
	else if (a.size() > b.size()) {
		cout << "GREATER" << endl;
	}
	else {
		cout << "LESS" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
int n,sa,sb,ans;
const int N=405,mod=998244353;
int a[N],b[N],f[N][N][N],jc[N],inv[N];
int ksm(int a,int b,int mod)
{
	int res=1;
	for(;b;b>>=1,a=(LL)a*a%mod)
		if(b&1)res=(LL)res*a%mod;
	return res;
}
void YYCH()
{
	jc[0]=jc[1]=inv[0]=inv[1]=1;
	for(int i=1;i<=400;++i)jc[i]=(LL)jc[i-1]*i%mod;
	inv[400]=ksm(jc[400],mod-2,mod);
	for(int i=399;i>=1;--i)inv[i]=(LL)inv[i+1]*(i+1)%mod;
}
int main()
{
	YYCH();
	cin>>n;
	for(int i=1;i<=n;++i)scanf("%d%d",&a[i],&b[i]),sa+=a[i],sb+=b[i];
	f[0][0][0]=mod-1;
	for(int i=1;i<=n;++i)	
		for(int j=0;j<=sa;++j)
			for(int k=0;k<=sb;++k)
				if(f[i-1][j][k])
				{
					(f[i][j][k]+=f[i-1][j][k])%=mod;
					int x=1;
					for(int l=0;l<b[i];x=(LL)x*a[i]%mod,++l)
						(f[i][j+a[i]][k+l]+=mod-(LL)x*inv[l]%mod*f[i-1][j][k]%mod)%=mod;
				}
	for(int i=0,x,y;i<=sa;++i)
	{
		y=ksm(i,mod-2,mod);x=(LL)sa*y%mod;
		for(int j=0;j<=sb;++j,x=(LL)x*y%mod)(ans+=(LL)x*jc[j]%mod*f[n][i][j]%mod)%=mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String[] info=sc.nextLine().split(" ");
		int N=Integer.parseInt(info[0]),Y=Integer.parseInt(info[1])/1000;
		int[] ijk=new int[] {-1,-1,-1};
		for(int i=0;i<=N;i++) {
			for(int j=0;i+j<=N;j++) {
				if(10*i+5*j+(N-i-j)==Y) {
					ijk=new int[] {i,j,N-i-j};
					break;
				}
			}
		}
		System.out.println(ijk[0]+" "+ijk[1]+" "+ijk[2]);
	}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main( void )
{
	double ans = 1;
	int i;
	int n;
	
	scanf( "%d", &n );
	for( i = 1; i <= n; i++ )
	{
		ans *= i;
	}
	printf( "%0.0lf\n", ans );
	return (0);
}

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

int main() {
  int n; cin >> n;
  vector<vector<ll>> v(n,vector<ll>(3));
  rep(i,n){
    rep(j,3){
      cin >> v[i][j];
    }
  }

  bool flag = true;
  for(int x = 0; x <= 100 ; x++){
    for(int y = 0; y <=100 ; y++){
      vector<ll> judge(0);
        rep(i,n){
          if(v[i][2] > 0){
            // judgeの要素を計算してmemに入れる
            ll mem, diffx, diffy;
            diffx = labs(x - v[i][0]);
            diffy = labs(y - v[i][1]);
            mem = diffx + diffy + v[i][2];
            judge.push_back(mem);
          }
        }

        if(judge.size() == 1){
          rep(k,n){
            if(v[k][2] > 0){
              cout << v[k][0] << " " << v[k][1] << " " << v[k][2];
              exit(0);
            }
          }
        }

        flag = true;
        rep(j , judge.size()-1){
          if(judge[j] == judge[j+1]) continue;
          else{
            flag = false;
            break;
          }
        }

        if(flag){
          cout << x <<" "<< y <<" "<< judge[0] << endl;
          break;
        }
      }
      if (flag) break;
    }

    return 0;
}


Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp
#  Binary Search : python3
#  2018.12.08 yonezawa


#from collections import deque
import sys
input = sys.stdin.readline
#import cProfile

def main():
    n1 = int(input())
    s1 = set(map(int,input().split()))
    n2 = int(input())
    s2 = set(map(int,input().split()))
    print (len(s1 & s2))

if __name__ == '__main__':
   main()
#    pr = cProfile.Profile()
#    pr.runcall(main)
#    pr.print_stats()


Measured memory_bytes: 16848
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;

long double q,h,s,d;
ll n;
                 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>q>>h>>s>>d>>n;
  vector<pair<long double,pair<long double,double> > > v;
  v.push_back(make_pair(q,make_pair(q,0.25)));
  v.push_back(make_pair(h/2,make_pair(h,0.5)));
  v.push_back(make_pair(s/4,make_pair(s,1)));
  v.push_back(make_pair(d/8,make_pair(d,2)));
  sort(v.begin(),v.end());
  //reverse(v.begin(),v.end());
  long double ans=0;
  if(v[0].se.se==2){
    ans+=d*(n/2);
    n%=2;
    if(n)ans+=(1/v[1].se.se)*v[1].se.fi;
    cout<<(ll)ans<<endl;
  }else{
    ans=(ll)(n/v[0].se.se)*v[0].se.fi;
    cout<<(ll)ans<<endl;
  }
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

using namespace std;

int a1, a2, a3;

int main()
{
  cin >> a1 >> a2 >> a3;
  if(a1+a2+a3>=22)
  {
    cout << "bust" << endl;
  }
  else
  {
    cout << "win" << endl;
  }
}

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

int main()
{

	int H, W;

	while( cin >> H >> W, H || W ) {

		for( int i = 0; i < H; i++ ) {
			for( int j = 0; j < W; j++ ) cout << "#";
			cout << endl;
		}

		cout << endl;

	}

	return 0;

}

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

int main(){

	bool flag=0;

	int n;
	cin >> n;
	int time=0;

	int a,b;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		if(a==b){
			time++;
			if(time>=3)flag=1;
		}else{
			time=0;
		}
	}

	if(flag==1) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main() {
    
    
    int N,H,W;
    cin>>N>>H>>W;
    vector<int> A(N),B(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i)>>B.at(i);
    }
    int count=0;
    for(int i=0;i<N;i++){
        if(A.at(i)>=H&&B.at(i)>=W) count++;
    }
    cout<<count<<endl;
}


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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = LI()
    wakeme = N
    Aleftsum = [0 for _ in range(3*N+1)]
    Arightsum = [0 for _ in range(3*N+1)]

    leftA = [x for x in A[:N]]
    rightA = [-x for x in A[-N:]]

    heapq.heapify(leftA)
    heapq.heapify(rightA)

    lsum = sum(leftA)
    rsum = sum(rightA)

    Aleftsum[wakeme] = lsum
    Arightsum[2*N] = -rsum

    # [0, N)から[0, 2N)までの和が欲しい
    # Aleftsum(i): [0, i)までの上位N個の和

    # [2N, 3N)から[N, 3N)までの和が欲しい
    # Arightsum(i): [i, 3N)までの上位N個の和

    for i in range(N):
        # [0, N+1)から[0, 2N)までやる。
        # [0, wakeme + i + 1)の和を計算する。
        # wakeme=Nなので、wakeme + i + 1 = 2N -> i = N - 1
        newl = A[wakeme + i]
        lsum += newl
        lsum -= heapq.heappushpop(leftA, newl)
        Aleftsum[wakeme+i+1] = lsum

        # [2N-1, 3N)から[N, 3N)までやる。
        # r_wakeme = 2N-1として、
        # r_wakeme - i = 2N - 1 -> i=0
        # r_wakeme - i = N -> i=N-1
        newr = A[2*N-1 - i]
        rsum -= newr
        rsum -= heapq.heappushpop(rightA, -newr)
        Arightsum[2*N-1 - i] = -rsum

    ans = -inf
    for i in range(N, 2*N+1):
        ans = max(ans, Aleftsum[i] - Arightsum[i])

    print(ans)
main()



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

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            String ans = "";
            switch (s) {
                case "Sunny":
                    ans = "Cloudy";
                    break;
                case "Cloudy":
                    ans = "Rainy";
                    break;
                case "Rainy":
                    ans = "Sunny";
                    break;
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 21716
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int m = scan.nextInt();
		int x = scan.nextInt();
		int skill[][] = new int[n][m+1];
		for(int i=0;i<n;i++) {
			for(int j=0;j<m+1;j++) {
				skill[i][j] = scan.nextInt();
			}
		}
		
		boolean check = false;
		int min_cost = 1500000;
		
		for(int i=0;i<(1<<n);i++) {
			boolean judge = true;
			int cost = 0;
			int now_skill[] = new int[m];
			
			for(int j=0;j<n;j++) {
				if((1 & i>>j)==1) {
					cost += skill[j][0];
					for(int k=0;k<m;k++) {
						now_skill[k] += skill[j][k+1];
					}
				}
			}
			
			for(int j=0;j<m;j++) {
				if(now_skill[j] < x) {
					judge = false;
					break;
				}
			}
			
			if(judge) {
				if(min_cost > cost) {
					check = true;
					min_cost = cost;
				}
			}
			
		}
		
		if(check) {
			System.out.println(min_cost);
		}else {
			System.out.println(-1);
		}
		
		
		
	}	
}
 

Measured memory_bytes: 37360
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        int s;
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            s = Integer.parseInt(br.readLine());
        }
        int h = s / 3600;
        s -= h * 3600;

        int m = s / 60;
        s -= m * 60;

        System.out.printf("%d:%d:%d%n", h, m, s);
    }

}



Measured memory_bytes: 24760
program arc081_d
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,j,ans
    integer(int64),parameter:: md=1000000007
    character(:),allocatable:: s(:)

    read*, n
    allocate(character(n):: s(2))
    read*, s(1)
    read*, s(2)

    i=1
    if (s(1)(1:1) == s(2)(1:1)) then
        ans = 3
    else
        ans = 6
    end if

    do while (i <= n)
        if (s(1)(i:i) == s(2)(i:i)) then
            if (i+1 <= n) ans=mod(ans*2,md)
            i=i+1
        else
            if (i+2 <= n) then 
                j = i+2
                if (s(1)(j:j) /= s(2)(j:j)) ans=mod(ans*3,md)
            end if
            i=i+2
        end if
    end do

    print'(i0)', ans
end program arc081_d

Measured memory_bytes: 2928
/*
３つの整数a, b, cを読み込み、それらが a < b < cの条件を満たすならば"Yes"を、満たさないならば"No"を出力するプログラムを作成して下さい。
 */

#include <stdio.h>

int main(void)
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);
    if (a < b && b < c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return (0);
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef pii point;
using namespace std;

vi f(ll i){
  vi ret;
  REP(j,20){
    ret.PB(i%2);
    i/=2;
  }
  return ret;
}

ll g(vi a,vi b){
  ll m=0;
  REP(i,20){
    m=max(m,b[i]-a[i]);
  }
  return m<=1;
}

int main(){
  ll N; cin>>N;
  vi A(N); REP(i,N) cin>>A[i];
  vvi B(N);
  REP(i,N){
    B[i]=f(A[i]);
  }
  vvi C(N+1); C[0]=vi(20);
  REP(i,N){
    C[i+1]=C[i];
    REP(j,20) C[i+1][j]+=B[i][j];
  }
  ll l=0,ans=0;
  FOR(r,1,N+1){
    while(l<r&&!g(C[l],C[r])) l++;
    ans+=r-l;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 98688
#include<bits/stdc++.h>
using namespace std ;
#define  ll long long int 
#define pb push_back 

vector<ll> sss , dd;
ll arr[401][401] , visi[401][401] ;
ll sum(ll i , ll j)
{
    if(i!=0)
    return sss[j] -sss[i-1] ;
    
    return sss[j] ;
}


ll solve(ll i , ll j )
{
    if(i==j){
        
//     cout<< i<<"  "<< j<<"  " << 0  <<endl ;
    
    return 0 ;
    }
    if(j-i==1)
    {
        
//    cout<< i<<"  "<< j<<"  " << sum(i,j)  <<endl ;
    
        return sum(i,j) ;
    }
    if(visi[i][j] ==1 )
    {
        
        return arr[i][j] ;
    }
    
    
    
    ll m =10000000000000 ;
    for(ll h = i; h < j ;h++)
    {
        m = min(m , solve(i, h) +solve(h+1 , j) ) ;
        
  //      cout<<  i <<"  "<<h  << "  "<< h+1 <<"  " << j << "  sum" << "  "<<solve(i , h)  << "  " << solve(h+1 , j ) << endl ;
        
        
        
    }
    m+=sum(i , j)  ;
    
    visi[i][j] =1 ;
    arr[i][j] = m ;
    
    // cout<< i<<"  "<< j<<"  " << m  <<endl ;
    return m ;
    
    
    
}

int main()
{
     ll n ;
     cin >> n ;
     for(ll i= 0;i < n ;i++)
     {
         ll l ;
         cin >> l ;
         dd.pb(l) ;
     }
     
     sss.pb(dd[0] ) ;
     for(ll i= 1 ; i<n ;i++ )
     {
         sss.pb(sss[i-1] + dd[i]) ;
     }
     
     
     cout<<solve(0,n-1) ;
     return 0 ;
}

Measured memory_bytes: 2816
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const double EPS = 1e-10;

class C{
  public:
    double p, l, r;
    int k;
    C(){}
    C(double ll, double rr, int kk, double pp) { l = ll; r = rr; k = kk; p = pp; }
};

int K, R, L; 
double P, E, T;

int check(double l, double r){
  double a = T - E, b = T + E;
  if(a <= r && b >= l) return 1;
  if(l < a || r > b) return -1;
  return 0;
}

int main() {
  cin >>K >>R >>L;
  double ans = 0.0; cin >>P >>E >>T;
  queue<C> open;
  open.push(C(L, R, K, 1.0));
  while(!open.empty()){
    C tmp = open.front(); open.pop();
    double &l = tmp.l, &r = tmp.r, &p = tmp.p;
    int &k = tmp.k;
    double m = (l + r) / 2.0;
    if(k <= 0){
      if(abs(m - T) + EPS <= E) ans += p;
      continue;
    }
    int f = check(l, r);
    if(f == -1) continue;
    if(f == 1){ ans += p; continue; }
    if(m + EPS >= T){
      open.push(C(m, r, k - 1, p * (1.0 - P)));
      open.push(C(l, m, k - 1, p * P));
    } else{
      open.push(C(l, m, k - 1, p * (1.0 - P)));
      open.push(C(m, r, k - 1, p * P));
    }
  }
  printf("%.6lf\n", ans);
  return 0;
}

Measured memory_bytes: 1268
// Created by sz
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;

const int N = 5e6 + 5;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin>>s;
    int len = s.length();
    int date = 0;
    for(int i = 5; i<len;i++){
        if(s[i]!='/')date = 10*date + s[i] - '0';
    }
    if(date<=430)cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
    
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

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

#define ll long long
#define ull unsigned long long
using _loop_int = int;
#define rep(i,n) for(_loop_int i=0;i<(_loop_int)(n);i++)
using namespace std;

int n, m;
int p[100005];
string s[100005];
bool ans[100005];
int sei = 0, pe[100005] = { 0 };
int pena = 0;
int main() {
	cin >> n >> m;
	for(int i=0;i<m;i++) {
		cin >> p[i] >> s[i];
		ans[p[i]] = true;
	}

	for (int i = 0; i < m; i++) {
		if (ans[p[i]]) {
			if (s[i] == "WA") pe[p[i]]++;
			if (s[i] == "AC") {
				sei++;
				ans[p[i]] = false;
				//cout << sei << endl;
			}
		}
	}
	for (int i = 0; i < m; i++) {
		if (ans[p[i]]) pe[p[i]] = 0;
		pena += pe[p[i]];
		pe[p[i]] = 0;
	}
	
	cout << sei << " " << pena << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int a=0,b=0,c=0;

    for(int i=0;i<s.size();i++){
        if(s[i]=='a') a++;
        else if(s[i]=='b') b++;
        else c++;
    }

    int u=s.size()/3+(s.size()%3?1:0),d=s.size()/3;
    if(a<=u && b<=u && c<=u && a>=d && b>=d && c>=d) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 512
n, m = [int(i) for i in input().split()]
A = [[] for i in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    A[a].append(b)
    A[b].append(a)

flag = [False] * (n+1)
flag[0] = True
cnt = 0

def dfs(i, flag):
    flag[i] = True
    for b in A[i]:
        if not flag[b]:
            dfs(b, flag[:])
    if all(flag) == True:
        global cnt
        cnt += 1

dfs(1, flag[:])
print(cnt)


Measured memory_bytes: 3064
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <numeric>

using namespace std;
int n;
string res;
void recur(string s)
{
	int num1, num2;

	num1 = 0;
	num2 = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == ')')
		{
			num2++;
			if (num1 < num2)
			{
				recur("(" + s);
				return;
			}
		}
		else
		{
			num1++;
		}
	}

	for (int i = s.length()-1; i >=0 ; i--)
	{
		if (s[i] == '(')
		{
			num1++;
			if (num2 < num1)
			{
				recur(s+")");
				return;
			}
		}
		else
		{
			num2++;
		}
	}

	if (num1 == num2)
	{
		res = s;
	}
}
int main(void)
{
	string s;

	cin >> n;
	cin >> s;

	recur(s);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256