akhauriyash/Code-Regression huggingface dataset:
#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())
typedef complex<double> P;
const int MAX_V = 105;
const long INF = 1e18;

int V, E;

void disp(int f, long c[MAX_V][MAX_V]){
  if(!f) cout <<"NEGATIVE CYCLE" <<endl;
  else{
    REP(i, V){
      REP(j, V){
        if(c[i][j] == INF) cout <<"INF";
        else cout <<c[i][j];
        if(j != V - 1) cout <<" ";
      }
      cout <<endl;
    }
  }

}


bool warshall_floyd(long c[MAX_V][MAX_V]){
  REP(k, V)
    REP(i, V)
      REP(j, V)
        if(c[i][k] != INF && c[k][j] != INF) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
  REP(i, V) if(c[i][i] < 0) return false;
  return true;
}

int main() {
  cin >>V >>E;
  long c[MAX_V][MAX_V];
  REP(i, V) REP(j, V) c[i][j] = INF;
  REP(i, V) c[i][i] = 0;
  REP(i, E){
    int f, t, cost; cin >>f >>t >>cost;
    c[f][t] = cost;
  }
  bool f = warshall_floyd(c);
  disp(f, c);
  return 0;
}

Measured memory_bytes: 1244
p=1000000007
n,m=map(int,input().split())

# 0段目
dp=[1] * (n +1)

for i in range(m):
    a= int(input())
    dp[a] = 0

for i in range(n-2,-1,-1):
    if dp[i] == 0:
        continue

    dp[i] = (dp[i+1] + dp[i+2]) %p

print(dp[0])


Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 

int main()
{
	int n;
	ll d;
	cin>>n>>d; 
	d=d*d;
	int s=0;
	for(int i=0;i<n;i++)
	{
		ll x,y;
		scanf("%lld%lld",&x,&y);
		if(x*x+y*y<=d)s++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
void solve()
{
    int d,t,s;
    cin >> d >> t >> s;
    int p=(d/s)+(1 && (d%s));
    if(p<=t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}

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

Measured memory_bytes: 3588
import java.util.Scanner;

class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String code;
		
		Tree tree = new Tree();
		int k;
		
		int n = scan.nextInt();
		
		for (int i = 0; i < n; i++) {
			code = scan.next();
			
			if(code.equals("insert")) {
				k = scan.nextInt();
				tree.insert(new Node(k));
			
			} else if(code.equals("find")) {
				k = scan.nextInt();
				if (tree.find(k) != null) {
					System.out.println("yes");
					
				} else {
					System.out.println("no");
					
				}
			} else if(code.equals("print")) {
				tree.print(Tree.Order.Inorder);
				tree.print(Tree.Order.Preorder);
			}
		}
		
		scan.close();
	}

	public static class Tree {
 
		enum Order {Preorder, Inorder, Postorder}
	
		Node root;
	
		Node insert(Node node) {
			Node parent = null;
			Node child = root;
		
			while (child != null) {
				parent = child;
				if (node.key < child.key) child = child.left;
				else child = child.right;
			}
		
			node.parent = parent;
		
			if (parent == null) {
				this.root = node;
		
			} else if (node.key < parent.key) {
				parent.left = node;
		
			} else {
				parent.right = node;
			}
		
			return node;
		}
	
		Node find(int key) {
			Node node = root;
			while (node != null && key != node.key) {
				if (key < node.key) {
					node = node.left;

				} else {
					node = node.right;
				}
			}
		
			return node;
		}
	
		void print(Order order) {
			switch (order) {
				case Preorder:
					walkPreorder(root);
					break;
				
				case Inorder:
					walkInorder(root);
					break;
				
				case Postorder:
					walkPostorder(root);
					break;
			}
			System.out.println();
		}
	
		void walkPreorder(Node node) {
			if (node == null) return;
		
			System.out.print(" " + node.key);
			walkPreorder(node.left);
			walkPreorder(node.right);
		}
	
		void walkInorder(Node node) {
			if (node == null) return;
		
			walkInorder(node.left);
			System.out.print(" " + node.key);
			walkInorder(node.right);
		}
	
		void walkPostorder(Node node) {
			if (node == null) return;
		
			walkPostorder(node.left);
			walkPostorder(node.right);
			System.out.print(" " + node.key);
		}
	}

	public static class Node {
		int key;
		Node parent, left, right;
	
		Node(int key) {
			this.key = key;
		}
	}
}

Measured memory_bytes: 201292
function Main(input){
  var N = input.split('\n')[0].split(' ')[0];
  var K = input.split('\n')[0].split(' ')[1];
  var h = input.split('\n');

  N = parseInt(N,10);
  K = parseInt(K,10);

  h.shift();

  for(i=0;i<N;i++){
    h[i] = parseInt(h[i],10);
  }

  h.sort((a,b)=>{

    return b - a;
  });

  var min ;

  for(i=0;i+(K-1)<N;i++){

    var a = h[i] - h[i+(K-1)];

    if(min === undefined){
      min = a;
    }else{
      if(min > a){
        min = a;
      }
    }

  }

  console.log(min);

  
}
  
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 53188
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
  
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
  
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
  
using namespace std;
//using namespace __gnu_pbds;
         
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
using pld = pair <ld, ld>;
 
/*
const ll MAX_MEM = 5e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
 
*/
 
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
         
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
         
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
         
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
         
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("circlecover.in", "r", stdin);
    //freopen("circlecover.out", "w", stdout);
}

signed main()
{
    Start();
    int a, b;
    cin >> a >> b;
    if (a <= 0 && 0 <= b)
        return cout << "Zero", 0;
    if (b < 0)
        return cout << ((b - a) % 2 == 0 ? "Negative" : "Positive"), 0;
    cout << "Positive";
    return 0;
}



Measured memory_bytes: 256
from sys import stderr, setrecursionlimit
from functools import reduce
from operator import add
setrecursionlimit(2147483647)
def f(): return [int(i) for i in input().split()]
def yes(n): print("Yes" if n else "No")
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

x, y = f()
print(x+y//2)

Measured memory_bytes: 3572
#include<stdio.h>
#include<string.h>
int main(){
 int i,slen;
 char str[21];

 fgets(str,21,stdin);
 slen=strlen(str);  
 for(i=slen-1;i>-1;i--){
  printf("%c",str[i]);
 }
 printf("\n");
 return 0;
} 

Measured memory_bytes: 0
n, m = gets.split.map(&:to_i)
mat = []
vec = []
n.times do
  mat << gets.split.map(&:to_i)
end
m.times do
  vec << gets.to_i
end
mat.each do | line |
  puts line.zip( vec ).map{ | i, j | i * j }.inject(:+)
end

Measured memory_bytes: 6140
// E - Handshake
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using ll = long long;
using vl = vector<ll>;
#define all(x) (x).begin(),(x).end()

ll N,M;
vl A;

bool check(ll x){ // (x<=ai+aj となる aj の個数) < M?
	ll total = 0; // cnt_aj を集計
	for(auto ai:A){
		ll pos_aj = lower_bound(all(A), x-ai) - A.begin(); // x<=ai+aj -> x-ai<=aj
		ll cnt_aj = N - pos_aj; // "ai のときの" aj の個数
		total += cnt_aj;
	}
	return total < M;
}

ll solve(){
	sort(all(A));

	// binary search
	ll lower = 2*A[0], next_lower = 2*A[N-1];
	while(lower+1 < next_lower){ // l+1 < r
		ll x = (lower + next_lower)/2;
		if(check(x)) next_lower = x; else lower = x;
	}

	ll ans = 0;
	vl csum(N+1); rp(i,0,N) csum[i+1] = csum[i] + A[i]; // 累積和
	for(auto ai:A){
		ll pos_aj = upper_bound(all(A), lower-ai) - A.begin(); // lower<ai+aj -> lower-ai<aj
		ll cnt_aj = N - pos_aj;
		ans += ai * cnt_aj + (csum[N] - csum[pos_aj]);
		M -= cnt_aj;
	}
	ans += lower * M;

	return ans;
}

int main(){
	cin>>N>>M;
	A.resize(N);
	rp(i,0,N) cin>>A[i];
	cout<< solve() <<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , A , B ;
  cin >> N >> A >> B ;
 
  if (N*A>B) {
    cout << B << endl;
  }
  else if (N*A<=B){
    cout << N*A << endl;
  }
}

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

#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    while(h--) {
        if(b-- > 0)cout << string(a,'0') + string(w-a,'1') << endl;
        else cout << string(a,'1') + string(w-a, '0') << endl;
    }
    return 0;
}



Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main() {
	int N, Y,i,j,k;
	cin >> N >> Y;
	for (i = 0;i <= N;i++) {
		for (j = 0;j <= N-i ;j++) {
			for (k = 0;k <= N-i-j ;k++) {
				if (10000 * i + 5000 * j + 1000 * k == Y&&i + j + k == N) {
					cout << i << " " << j << " " << k << endl;
					return 0;
				}
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

class Node {
public:
	int location;
	int p, l, r;
	Node(){}
};

class Point {
public:
	int id, x, y;
	Point(){}
	Point(int id, int x, int y):id(id),x(x),y(y){}
	bool operator<(const Point&p) const {
		return id < p.id;
	}

	void print() {
		printf("%d\n", id);
	}
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) {
	return p1.x < p2.x;
}

bool lessY(const Point &p1, const Point &p2) {
	return p1.y < p2.y;
}

int makeKDTree(int l, int r, int depth) {
	if (!(l < r)) return NIL;
	int mid = (l + r) / 2;
	int t = np++;
	if (depth % 2 == 0) {
		sort(P + l, P + r, lessX);
	}
	else {
		sort(P + l, P + r, lessY);
	}
	T[t].location = mid;
	T[t].l = makeKDTree(l, mid, depth + 1);
	T[t].r = makeKDTree(mid + 1, r, depth + 1);

	return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;

	if (sx <= x && x <= tx && sy <= y && y <= ty) {
		ans.push_back(P[T[v].location]);
	}

	if (depth % 2 == 0) {
		if (T[v].l != NIL) {
			if (sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		}
		if (T[v].r != NIL) {
			if (x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
		}
	}
	else {
		if (T[v].l != NIL) {
			if (sy <= y) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		}
		if (T[v].r != NIL) {
			if (y <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
		}
	}
}

int main() {
	int x, y;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &x, &y);
		P[i] = Point(i, x, y);
		T[i].l = T[i].r = T[i].p = NIL;
	}

	np = 0;

	int root = makeKDTree(0, N, 0);

	int q;
	scanf("%d", &q);
	int sx, tx, sy, ty;
	vector<Point> ans;
	for (int i = 0; i < q; i++) {
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		ans.clear();
		find(root, sx, tx, sy, ty, 0, ans);
		sort(ans.begin(), ans.end());
		for (unsigned int j = 0; j < ans.size(); j++) {
			ans[j].print();
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 17416
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
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() {
    ll a, b, k;
    cin >> a >> b >> k;

    if (a >= k) a -= k;
    else {
        k -= a;
        if (b >= k) b -= k;
        else b = 0;
        a = 0;
    }
    cout << a << " " << b << endl;
}


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

int main()
{

    ll r, d , x;
    cin>>r>>d>>x;
    for(int i=1;i<=10;i++)
    {
        x=r*x-d;
        cout<<x<<endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;
const long INF = 2000000000;

int main() {
  long n;
  cin >> n;
  long a[n];
  for(int i = 0; i < n; i++)
    cin >> a[i];
  
  long sum[n];
  sum[n-1] = a[n-1];
  for(int i = n-2; i >= 0; i--)
    sum[i] = sum[i+1] + a[i];
  
  long ans = 0;
  for(int i = 0; i < n-1; i++)
    ans += (sum[i+1] % mod * a[i]) % mod;
  
  cout << ans % mod << endl;
}

Measured memory_bytes: 6744
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i]--;
    }
    int s   = 0;
    int ret = 0;
    set<int> used;
    used.insert(0);
    while (s != 1) {
        ret++;
        s = a[s];
        if (used.count(s) == 1) {
            cout << -1 << "\n";
            return 0;
        }
        used.insert(s);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define For(i, l, r) for (register int i = l, _r = r; i <= _r; ++i)
#define Ford(i, l, r) for (register int i = r, _l = l; i >= _l; --i)
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 20;
int a[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 

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 << 3) + (x << 1) + ch - '0';ch = getchar();}
	return x * f;
}

int main()
{
	int p=read();
	printf("%d",a[p]);
	return 0;
}

Measured memory_bytes: 256
lines = []
colums = []
   
while True:
  H,W = map(int,input().split())
  if H == 0 and W == 0:
    break
  lines.append(H)
  colums.append(W)
   
for H,W in zip(lines,colums):
  for i in range(H):
    if i == 0 or i == H-1:
      for j in range(W):
        print("#",end="")
    else:
      for j in range(W):
        if 0 < j and j < W-1:
          print(".",end="")
        else:
          print("#",end="")
    print("\n",end="")
  print("\n",end="")


Measured memory_bytes: 7016
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let ss: Vec<u8> = read_line().bytes().collect();
    let mut c_count = 0;
    let mut res = true;
    for (i,&c) in ss.iter().enumerate() {
        if i == 0 {
            res = ss[i] == b'A';
        }
        else {
            if 2 <= i && i != ss.len()-1 {
                res = res && (b'C' == c || (b'a' <= c && c <= b'z'));
                if c == b'C'  {
                    c_count += 1;
                }
            }
            else {
                res = res && (b'a' <= c && c <= b'z');
            }
        }
    }
    res = res && c_count == 1;
    println!("{}", tf(res, "AC", "WA"));
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}

#[allow(dead_code)]
fn tf<T>(cond: bool, t: T, f: T) -> T {
    if cond { t } else { f }
}


Measured memory_bytes: 4352
from collections import deque

def msf(s,queries):
    queue = deque(s)
    addl = queue.appendleft
    addr = queue.append
    is_reversed = 0

    for query in queries:
        if query[0] == '1':
            is_reversed ^= 1
            addl,addr = addr,addl
        elif query[0] == '2':
            f = query[1]
            c = query[2]
            if f == '1':
                addl(c)
            elif f == '2':
                addr(c)
    return ''.join(queue) if not is_reversed else ''.join(reversed(queue))

if __name__ == '__main__':
    s = list(input())
    q = int(input())
    ql = [input().split() for i in range(q)]
    print(msf(s,ql))


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

int main() {

  int n;
  int check[5] = {5, 7, 5, 7, 7};
  int count;
  int tmp;
  int ans;

  bool found;
  
  while (1) {
  
    cin >> n;
    if (n == 0) break;

    vector<string> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];

    for (int i = 0; i < n; i++) {
      
      ans = -1;
      count = 0;
      tmp   = 0;
      found = false;
      
      for (int j = i; j < n; j++) {

        //cout << "i: " << i << "  j:" << j << "  tmp: " << tmp << "  size: " << v[j].size() << "  count: " << count << endl;

        if (tmp + v[j].size() > check[count])
          break;

        else if (tmp + v[j].size() == check[count]) {
          count ++;
          tmp = 0;
        }
        else
          tmp += v[j].size();

        if (count == 5) {
          found = true;
          break;
        }
        if (found == true)
          break;
      }
      if (found == true) {
        ans = i + 1;
        break;
      }
    }
    cout << ans << endl;
  }
}




Measured memory_bytes: 3036
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<pll> v(n);
    for(auto &x:v)
    {
        cin>>x.fi>>x.se;
    }
    sort(v.begin(),v.end());
    vector<ll> maxL_left(n);
    vector<ll> minR_left(n);
    vector<ll> maxL_right(n);
    vector<ll> minR_right(n);
    maxL_left[0] = v[0].fi;
    minR_left[0] = v[0].se;
    for(ll i=1;i<n;i++)
    {
        maxL_left[i] = max(maxL_left[i-1],v[i].fi);
        minR_left[i] = min(minR_left[i-1],v[i].se);
    }
    maxL_right[n-1] = v[n-1].fi;
    minR_right[n-1] = v[n-1].se;
    for(ll i=n-2;i>=0;i--)
    {
        maxL_right[i] = max(maxL_right[i+1],v[i].fi);
        minR_right[i] = min(minR_right[i+1],v[i].se);
    }
    ll mv = 0;
    for(ll i=0;i<(n-1);i++)
    {
        ll val1 = minR_left[i]-maxL_left[i]+1ll;
        ll val2 = minR_right[i+1]-maxL_right[i+1]+1ll;
        if(val1<0)
        {
            val1=0;
        }
        if(val2<0)
        {
            val2=0;
        }
        ll temp = val1+val2;
        mv = max(mv,temp);
    }
//    error(mv);
    for(ll i=1;i<n-1;i++)
    {
        ll cc = v[i].se-v[i].fi+1;
        pll p1;
        p1.fi = maxL_left[i-1];
        p1.se = minR_left[i-1];
        if(p1.se<p1.fi)
        {
            mv = max(mv,cc);
            continue;
        }
        pll p2;
        p2.fi = maxL_right[i+1];
        p2.se = minR_right[i+1];
        if(p2.se < p2.fi)
        {
            mv = max(mv,cc);
            continue;
        }
        ll L = max(p1.fi,p2.fi);
        ll R = min(p1.se,p2.se);
        ll val = R-L+1;
        if(val<0){val=0;}
        cc += val;
        mv = max(cc,mv);
    }
    cout<<mv;
    return 0;
}































Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int L,R,D; cin >> L>>R>>D;
    cout << R/D - (L-1)/D << endl;

}

Measured memory_bytes: 3608
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long

long long int gcd(ll int a,ll int b){
    if(a==0||b==0)return max(a,b);
    ll int mi=min(a,b);ll int ma=max(a,b);
    ll int c=ma%mi;
    return gcd(mi,c);
}
int N;
ll int A[100004];
ll int bef[100004];
ll int aft[100004];
int main(void){
    scanf("%d",&N);
    rep(i,N)scanf("%lld",&A[i]);
    rep(i,N){
        if(i==0)continue;
        i==1 ? bef[i]=A[i-1] : bef[i]=gcd(bef[i-1],A[i-1]);
    }
    rep(i,N){
        int j=N-1-i;if(j==N-1)continue;
        j==N-2 ? aft[j]=A[j+1] : aft[j]=gcd(aft[j+1],A[j+1]);
    }
    ll int ans=0;
    rep(i,N){
        if(i==0)ans=max(ans,aft[i]);
        else if(i==N-1)ans=max(ans,bef[i]);
        else ans=max(ans,gcd(bef[i],aft[i]));
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;



int main(void) {

	int D, N, ans, cal, count = 0;
	cin>>D>>N;


	if (D == 0) {
		ans = N;
		if (N == 100) {
			ans = 101;
		}

		cout<<ans;
	}

	else {
		if (D == 1) {
			cal = 100;
		}

		if (D == 2) {
			cal = 10000;
		}

		for (int i = 1;count < N;i++) {
			if (i % cal == 0) {
				if (i % ((cal *100)) != 0) {

					ans = i;
					count++;



				}
			}
		}

		cout<< ans;

	}



}



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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  bool flag = true;
  for(int i=0; i<N; i++){
    if(A[i]%2==1)continue;
    if(A[i]%3!=0 && A[i]%5!=0){flag=false; break;}
  }
  if(flag)cout << "APPROVED" <<endl;
  else cout << "DENIED" <<endl;
  return 0;
}

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

bool isPalindromic(int n) {
  if ( n/10000==n%10 && n/1000-n/10000*10==n%100/10 ) return true;
  else return false;
}

int main() {
  int A, B, x=0; cin >> A >> B;
  for (int i=A; i<=B; i++) {
    if ( isPalindromic(i) ) x++;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647


int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);
ll power(ll x, unsigned long long y)
{
    int res = 1;     // Initialize result

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x);

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x);  // Change x to x^2
    }
    return res;
}


map<ll, ll> mp;
vector<ll>v;
void solve()
{
    ll n, m, k, pos, pos1;

    cin >> n >> k;
    ll a[n+10], p[n+10];
    int f = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        cin >> a[i];
        p[a[i]] = i;

    }

    ll i = 1;
    m = k;
    while(m--)
    {
        if(a[i] == i)
        {
         //cout << a[i] << endl;
          f = 1;
          break;
        }
        //cout << a[i] << endl;
        if(mp.find(a[i]) != mp.end())
        {
            pos = a[i];
            break;
        }
        v.pb(a[i]);
        mp[a[i]] = 1;
        i = a[i];
    }
    //cout << m << endl;
    if(f) cout << a[i] << endl;
    else if(m == -1) cout << i << endl;
    else
    {
        for(int i = 0 ; i < v.size() ; i++)
        {
            if(v[i] != pos) k--;
            else
            {
                pos1 = i;
                break;
            }

        }
        if(v.size() == 1) cout << v[0] << endl;
        else
        {
            ll diff = v.size() - pos1;
            k %= diff;
            if(k == 0) k = diff;
            cout << v[pos1 + k - 1] << endl;
        }

    }


}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 17460
#include<stdio.h>
int main(void)
{
	int h,m,s,x,S;
	scanf("%d",&S);
	h=S/3600;
	x=S%3600;
	m=x/60;
	s=x%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

	


Measured memory_bytes: 2072
#include <stdio.h>

int main() {
	int a,b;
	for(int i=0;;i++) {
		scanf("%d %d", &a, &b);
		if (a==0&&b==0) break;
		if(a<b) {
			printf("%d %d\n",a,b);
		} else {
			printf("%d %d\n",b,a);
		}
	}
	return 0;
}


Measured memory_bytes: 2104
//35分
import java.util.Arrays;
import java.util.Scanner;

public class Main {
//java11
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] n = new int[N];
		int[] a = new int[M];
		int[] b = new int[M];

		for(int i=0; i<N; i++) {
			n[i] = i+1;
		}

		for(int i=0; i<M; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}

		int ans = 0;
		//順列全探索
		for(int i=0; i<factorial(N-1); i++) {
			boolean flag = true;
			for(int j=0; j<N-1; j++) {
				boolean check = false;
				for(int k=0; k<M; k++) {
					if((n[j] == a[k] && n[j+1] == b[k]) || (n[j] == b[k] && n[j+1] == a[k])) {
						check = true;
						break;
					}
				}
				if(!check) {
					flag = false;
					break;
				}
			}

			if(flag)
				ans++;
			next_permutation(n, 1, n.length);
		}

		System.out.println(ans);
	}

	//階乗
	static int factorial(int n) {
		if(n == 1)
			return 1;

		return n * factorial(n-1);
	}

	//次の順列を生成する
	static boolean next_permutation(int[] array, int start, int end) {

		if(array == null || start > end || start < 0 || end > array.length) {
			System.out.println("Error: 引数が正しくありません。");
			return false;
		}

		for(int i=end-2; i>=start; i--) {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		}

		return false;
	}

}


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

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

  int N1, N2, N3, N4;
  N1 = N / 1000;
  N -= N1 * 1000;
  N2 = N / 100;
  N -= N2 * 100;
  N3 = N / 10;
  N -= N3 * 10;
  N4 = N;

  if (N2 != N3) {
    cout << "No" << endl;
  } else {
    if (N1 == N2 || N4 == N2) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


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

int main () {
  string today;

  cin >> today;

  if (today == "Sunny") cout << "Cloudy";
  if (today == "Cloudy") cout << "Rainy";
  if (today == "Rainy") cout << "Sunny";

  return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{

	static void Main(string[] args)
	{
		var N = long.Parse(Console.ReadLine());
		var tekiArray = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
		var mikataArray = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
		long count = 0;

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

		Console.WriteLine(count);
	}
}


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

int main(){
    int n,t,a,h;
    cin >> n >> t >> a;
    int pos = -1;
    double sub = 1000.0;

    for(int i=0; i<n; i++){
        cin >> h;
        double tmp = abs((double)a-((double)t-0.006*h));
        if(tmp < sub){
            sub = tmp;
            pos = i+1;
        }
    }
    cout << pos <<endl;
}

Measured memory_bytes: 256
#pypyで通らないと思ったけど普通に通るやん
'''
Created on 2020/09/19

@author: harurun
'''

def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  ans=0
  for i in range(1,N):
    for j in range(1,N+1):
      if N-i*j>0:ans+=1
      else:break
  print(ans)
  return
main()

Measured memory_bytes: 67700
#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>


using std::string;
using std::vector;

void printList(const vector<int>& list) {
    for (int i = 0; i < list.size(); i++) {
        if (i == list.size() - 1){
            printf("%d\n", list[i]);
        }else{
           printf("%d ", list[i]);
        }
    }
}
int main() {
    // input
    int n = 0;
    scanf("%d", &n);
    vector<int> list = {};
    for (int i = 0; i < n; i++) {
        int v = 0;
        scanf("%d", &v);
        list.push_back(v);
    }

    // sort
    for (int i = 1; i < list.size(); i++) {
        int key = list[i];
        printList(list);
        int j = i - 1;
        for (;0 <= j && key < list[j]; j--) {
            list[j+1] = list[j];
        }
        list[j+1] = key;
    }
    printList(list);

    return 0;
}


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

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

    if (a == 'H')
        if (b == 'H')
            cout << "H" << endl;
        else
            cout << "D" << endl;
    else
        if (b == 'H')
             cout << "D" << endl;
        else
             cout << "H" << endl;

    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    int A, B;
    std::cin >> A >> B;

    if(A + B == 15){
        std::cout << "+" << std::endl;
    }else if(A * B == 15){
        std::cout << "*" << std::endl;
    }else{
        std::cout << "x" << std::endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  ll N, K;
  cin >> N >> K;
  ll ans;
  if(N - K > 0){
    if(N%K == 0){
      ans = 0;
    }
    else{
      ll div = N/K;
      ll dif = N - K*div;
      ans = min(dif,abs(dif - K));
    }
  }
  else{
    if(N >= (K+1)/2) ans = abs(N - K);
    else ans = N;
  }
  cout << ans << endl;
}


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

using namespace std;

int main(){
    int N;
    int d[100000];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> d[i];
    sort(d, d+N);
    int ans = d[N/2]-d[N/2-1];
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],max1,max2,mmax;
int main() {
	scanf("%d",&n);
	max1=max2=0;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		if(max1<a[i]) max1=a[i],mmax=i;
	}
	for(int i=1;i<=n;i++) if(mmax!=i) max2=max(max2,a[i]);
//	printf("max1:%d max2:%d\n",max1,max2);
	for(int i=1;i<=n;i++)
		if(max1==a[i]) printf("%d\n",max2);
		else printf("%d\n",max1);
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n,m;
	cin>>n>>m;
	n--;
	m--;
	cout<<n*m<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
       public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	Dice dice1 = new Dice();
    	Dice dice2 = new Dice();
    	int count = 0;
    	
    	for(int i = 0; i < 6; i++){
    		dice1.S[i] = scan.nextInt();
    	}
    	for(int i = 0; i < 6; i++){
    		dice2.S[i] = scan.nextInt();
    	}
    	
    	for(int i = 0; i < 4; i++){
    		for(int j = 0; j < 4; j++){
        		for(int k = 0; k < 4; k++){
        			int temp3 = dice1.S[0];
            		dice1.S[0] = dice1.S[1];
            		dice1.S[1] = dice1.S[5];
            		dice1.S[5] = dice1.S[4];
            		dice1.S[4] = temp3;
            		if(dice1.S[0] == dice2.S[0] && dice1.S[1] == dice2.S[1] && dice1.S[2] == dice2.S[2] && dice1.S[3] == dice2.S[3] && dice1.S[4] == dice2.S[4] && dice1.S[5] == dice2.S[5]) {
            			System.out.println("Yes");
            		    return;
            		}
        		}
        		int temp2 = dice1.S[0];
        		dice1.S[0] = dice1.S[3];
        		dice1.S[3] = dice1.S[5];
        		dice1.S[5] = dice1.S[2];
        		dice1.S[2] = temp2;
    		}
    		int temp = dice1.S[0];
    		dice1.S[0] = dice1.S[1];
    		dice1.S[1] = dice1.S[5];
    		dice1.S[5] = dice1.S[4];
    		dice1.S[4] = temp;
    	}
    	System.out.println("No");
     }
}

class Dice{
	int[] S = new int[6];
}

Measured memory_bytes: 26388
def main():
    N = int(input())
    
    counter = 0
    l = []
    for i in range(1, N+1):

        if i % 3 == 0 and i % 5 == 0:
            pass
        elif i % 3 == 0:
            pass
        elif i % 5 == 0:
            pass
        else:
            # print(i)
            counter += i
            
    print(counter)            
        
    
main()



Measured memory_bytes: 9168
import numpy as np

N, L = map(int, input().split())

# リンゴの味は L, L+1, L+2, ... となる
nums = np.arange(L, L + N)
# 絶対値が最も小さい値のリンゴを選べば良い
# 0を含むなら0を食べる
# それ以外の場合、マイナススタートならラスト、プラススタートなら先頭を食べる
if 0 in nums:
    pass
elif L < 0:
    nums = nums[:-1]
elif L > 0:
    nums = nums[1:]

# 食べた後の合計値を出す
print(np.sum(nums))

Measured memory_bytes: 12488
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,m,x,c[12],a[12][12];
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    }
    int ans=mod;
    for(int S=0;S<1<<n;S++){
        int arr[12]={},sum=0;
        for(int i=0;i<n;i++){
            if(S>>i&1){
                sum+=c[i];
                for(int j=0;j<m;j++)
                    arr[j]+=a[i][j];
            }
        }
        bool ok=1;
        for(int i=0;i<m;i++)
            if(arr[i]<x)
                ok=0;
        if(ok)
            ans=min(ans,sum);
    }
    cout<<(ans==mod?-1:ans)<<endl;
}

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

int main(){
    int S;
    cin >> S;
    
    int h=S/(60*60);
    int m=(S-h*60*60)/60;
    int s=S-h*60*60-m*60;
    
    cout << h <<":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdint>
#include <limits>
#include <bits/stdc++.h>
#include<string>
using namespace std;
int main(void)
{
    
    uint64_t n;
    int k,ans;
    char s[334];
    cin >> s;
    if((s[0]=='A' &&  s[1]=='A' && s[2]=='A') || (s[0]=='B' &&  s[2]=='B' && s[1]=='B'))
    {
    cout << "No" << endl;
    }
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <map>
#include <queue>
#include <vector>
using namespace std;

int main() {
	long long int w, h, i, j, x, y;
	long long int sum = 0;
	cin >> w >> h;
	vector<long int> p(w);
	vector<long int> q(h);
	for (i = 0; i < w; i++) {
		cin >> p[i];
		sum += p[i];
	}
	for (i = 0; i < h; i++) {
		cin >> q[i];
		sum += q[i];
	}
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	i = j = 0;
	x = w;
	y = h;
	while (i < p.size() && j < q.size()) {
		if (j == q.size() || p[i] <= q[j]) {
			sum += p[i] * y;
			x--;
			i++;
		}
		else if (i == p.size() || p[i] >= q[j]) {
			sum += q[j] * x;
			y--;
			j++;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1920
a = list(input())
b = list(input())
c = list(input())
s = a.pop(0)
ans = "a"
while 1:
    if s == "a":
        if a: s = a.pop(0)
        else: break
    elif s=="b":
        if b: s = b.pop(0)
        else: break
    else:
        if c: s = c.pop(0)
        else: break
print(s.upper())

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll a,b; cin>>a>>b;
    cout<<a*b<<endl;
}








Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn=500005;
const int INF=0x3f3f3f3f;
int n;
int a[maxn];
int cnt=0;
void Sort (int left,int mid,int right)
{
    int L[(maxn>>1)+10],R[(maxn>>1)+10];
    int numl=mid-left;
    int numr=right-mid;
    for (int i=0;i<numl;i++)
        L[i]=a[i+left];
    for (int i=0;i<numr;i++)
        R[i]=a[i+mid];
    L[numl]=R[numr]=INF;
    for (int i=left,j=0,k=0;i<right;i++)
    {
        cnt++;
        L[j]<R[k]?a[i]=L[j++]:a[i]=R[k++];
    }
}
void Merge (int left,int right)
{
    if(left+1<right)
    {
        int mid=(left+right)>>1;
        Merge (left,mid);
        Merge (mid,right);
        Sort (left,mid,right);
    }
}
int main()
{
    scanf("%d",&n);
    for (int i=0;i<n;i++)
        scanf("%d",&a[i]);
    Merge (0,n);
    for (int i=0;i<n;i++)
        printf("%d%c",a[i],i==n-1?'\n':' ');
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 6996
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b,c,t;cin>>a>>b>>c;
    int ans = 0;
    REP(i,a){
        cin >> t;
        ans += (b-1) / t + 1;
    }
    cout << ans + c << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A_1 = list(map(int, input().split( )))
A_2 = list(map(int, input().split( )))

ans_list = []
for i in range(N):
	ans_v = sum(A_1[0:i+1]) + sum(A_2[i:N+1])
	ans_list.append(ans_v)


ans = max(ans_list)
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


    class Progrm
{
   public static void Main(string[] args)
    {
        while(true){
            int t=int.Parse(Console.ReadLine());
            if(t==0)break;
            int n=int.Parse(Console.ReadLine());
            int sum=0;
            for(int i=0;i<n;++i){
               	
                string[] input = Console.ReadLine().Split(' ');
                int s=int.Parse(input[0]);
                int f=int.Parse(input[1]);
                sum+=f-s;
            }
            if(sum>=t){
                Console.WriteLine("OK");
            }else{
                Console.WriteLine(t-sum);
            }
        }
    }

}

Measured memory_bytes: 9208
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {
	final static String SHORT = "0.25";
	final static String TALL = "0.5";
	final static String GRANDE = "1";
	final static String VENTI = "2";

	public static void main(String[] args)throws Exception {
		BufferedReader br = new BufferedReader ( new InputStreamReader(System.in));
		String [] input = br.readLine().split(" ");
		String  input2 = br.readLine();
		HashMap<String,Integer> iceTeaMap = new HashMap<String,Integer>();
		iceTeaMap.put(SHORT,Integer.parseInt(input[0]));
		iceTeaMap.put(TALL,Integer.parseInt(input[1]));
		iceTeaMap.put(GRANDE,Integer.parseInt(input[2]));
		iceTeaMap.put(VENTI,Integer.parseInt(input[3]));
		int max = Integer.parseInt(input2);
		long first =(long)( max / Double.parseDouble(SHORT));
		long second = 0;
		long third = 0;
		long forth = 0;
		//long sf = iceTeaMap.get(TALL)/iceTeaMap.get(SHORT);
		if(iceTeaMap.get(SHORT)*2 > iceTeaMap.get(TALL) ) {
			second = first/2;
			first = first%2;
		}
		if(second > 0) {
			if(iceTeaMap.get(TALL)*2 > iceTeaMap.get(GRANDE)) {
				third = second/2;
				second = second%2;
			}
		}else {
			if(iceTeaMap.get(SHORT)*4 > iceTeaMap.get(GRANDE)) {
				third = first/4;
				first = first%4;
			}
		}
		if(third > 0) {
			if(iceTeaMap.get(GRANDE)*2 > iceTeaMap.get(VENTI)) {
				forth = third/2;
				third = third%2;
			}
		}else if(second > 0) {
			if(iceTeaMap.get(TALL)*4 > iceTeaMap.get(VENTI)) {
				forth = second/4;
				second = second%4;
			}
		}else {
			if(iceTeaMap.get(SHORT)*8 > iceTeaMap.get(VENTI)) {
				forth = first/8;
				first = first%8;
			}
		}
		System.out.println(first * iceTeaMap.get(SHORT) + second * iceTeaMap.get(TALL) + third * iceTeaMap.get(GRANDE) + forth * iceTeaMap.get(VENTI));
	}
}


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

const int MOD = 1e9+7;

int inverse(int n){ // MODは素数
  int r = 1;
  for(int m = MOD - 2; m > 0; m >>= 1){
    if(m & 1) r = (r * n) % MOD;
    n = (n * n) % MOD;
  }
  return r;
}

int mod_comb(int n,int r){ // nCr
  if(n < r) return 0;
  int child = 1,mother = 1;
  for(int i = 0; i < r; i++){
    child = (child * (n - i)) % MOD;
    mother = (mother *  (r - i)) % MOD;
  }
  return child * inverse(mother) % MOD;
}

int a[100000];

signed main(){

  int n; cin >> n;
  for(int i = 2; i <= n; i++){
    int t = i;
    for(int j = 2; j*j <= t; j++){
      int cnt = 0;
      while(t%j == 0){
        t /= j;
        cnt++;
      }
      a[j] += cnt;
    }
    if(t != 1) a[t]++;
  }

  vector<int> v;
  for(int i = 0; i < 100000; i++){
    if(a[i] > 0){
      v.push_back(a[i]);
    }
  }
  int ans = 0;

  int c1 = 0,c2 = 0;
  for(int i = 0; i < v.size(); i++){
    if(v[i] >= 2) c1++;
    if(v[i] >= 24) c2++;
  }
  ans += c1*c2 - c2;

  c1 = 0,c2 = 0;
  for(int i = 0; i < v.size(); i++){
    if(v[i] >= 4) c1++;
    if(v[i] >= 14) c2++;
  }
  ans += c1*c2 - c2;

  c1 = 0,c2 = 0;
  for(int i = 0; i < v.size(); i++){
    if(v[i] >= 74) c1++;
  }
  ans += c1;

  c1 = 0,c2 = 0;
  for(int i = 0; i < v.size(); i++){
    if(v[i] >= 2) c1++;
    if(v[i] >= 4) c2++;
  }
  ans += c2*(c2-1)/2 * (c1-2);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int f[11]={0};
int main()
{
    int n;
    scanf("%d",&n);
    int i,s=0;
    for(i=0;i<n;i++){
        scanf("%d",&f[i]);
        s=s+f[i];
    }
    int max=f[0];
    for(i=1;i<n;i++){
        if(f[i]>max)
            max=f[i];
    }
    printf("%d",s-max/2);

	return 0;
}

Measured memory_bytes: 256