akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = input().strip()
r = 0
ccr = [0]*(N+1)
ccg = [0]*(N+1)
ccb = [0]*(N+1)
for i in range(N-1, -1, -1):
    ccr[i] = ccr[i+1]
    ccg[i] = ccg[i+1]
    ccb[i] = ccb[i+1]
    if S[i] == "R":
        ccr[i] += 1
    elif S[i] == "B":
        ccb[i] += 1
    else:
        ccg[i] += 1

for i in range(N-1):
    a = S[i]
    for j in range(i+1, N-1):
        b = S[j]
        df = 2*j-i
        if (a == "R" and b == "G") or (a == "G" and b == "R"):
            if df < N and S[df] == "B":
                r -= 1
            r += ccb[j+1]
        elif (a == "R" and b == "B") or (a == "B" and b == "R"):
            if df < N and S[df] == "G":
                r -= 1
            r += ccg[j+1]
        elif (a == "B" and b == "G") or (a == "G" and b == "B"):
            if df < N and S[df] == "R":
                r -= 1
            r += ccr[j+1]
print(r)




Measured memory_bytes: 69060
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($N,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$used=array();
$next=0;
while(1) {
  if (isset($used[$next])) {
    break;
  }
  $used[$next]=1;
  $next = $A[$next]-1;
}
//最後の$nextからusedの最後までが繰り返し
$amari=0;
foreach($used as $k=>$v) {
  if ($k==$next) break;
  $amari++;
}
$cnt=count($used);
//printf("%d %d loop %d\n",$amari,$cnt,$cnt-$amari);
$p = ($K-$amari)%($cnt-$amari);
//printf("%d used %d\n",$p,$used[$p]);
$c=0;
if ($K-$amari<0) {
$amari=0;
$p=$K;
}
foreach($used as $k=>$v) {
  if ($c>=$amari) {
    if ($c-$amari == $p) {
      printf("%d\n",$k+1);
      exit;
    }
  }
  $c++;
}


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

int main() {
  int number = 1, n, k;
  cin >> n >> k;
  
  for (int i = 0; i < n; i++) {
    if (number * 2 <= number + k) {
      number *= 2;
    } else {
      number += k;
    }
  }
  
  cout << number << endl;
}


Measured memory_bytes: 3580
use proconio::input;
use proconio::marker::{Bytes, Chars};

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        x: usize,
    }
    let mut ans = 0;
    if x >= 400 && x <= 599 {
        ans = 8;
    }
    else if x >= 600 && x <= 799 {
        ans = 7;
    }
    else if x >= 800 && x <= 999 {
        ans = 6;
    }
    else if x >= 1000 && x <= 1199 {
        ans = 5;
    }
    else if x >= 1200 && x <= 1399 {
        ans = 4;
    }
    else if x >= 1400 && x <= 1599 {
        ans = 3;
    }
    else if x >= 1600 && x <= 1799 {
        ans = 2;
    }
    else if x >= 1800 && x <= 1999 {
        ans = 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2164
while True:
    a,op,b = raw_input().split()
    if(op=='+'):
        print(int(a)+int(b))
    elif(op=='-'):
        print(int(a)-int(b))
    elif(op=='*'):
        print(int(a)*int(b))
    elif(op=='/'):
        print(int(a)/int(b))
    elif(op=='?'):
        break


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

enum:char{
	WALL='#',ME='@',PANEL='w',CONTAINER='c',EMPTY='.',ESCAPE='E'
};
constexpr int di[]={-1,1,0,0},dj[]={0,0,-1,1};

string encode(const vs& grid,int i,int j)
{
	int h=grid.size(),w=grid[0].size();
	string res;
	repi(k,1,h-1) res+=grid[k].substr(1,w-2);
	res[(i-1)*(w-2)+j-1]=ME;
	return res;
}

int main()
{
	for(int h,w;cin>>h>>w && h|w;){
		int gi=-1,gj=-1;
		deque<tuple<vs,int,int,int>> dq;
		{
			vs grid(h);
			rep(i,h) cin>>grid[i];
			rep(i,h) rep(j,w) if(grid[i][j]==ESCAPE){
				gi=i,gj=j;
				grid[i][j]=EMPTY;
			}
			rep(i,h) rep(j,w) if(grid[i][j]==ME){
				grid[i][j]=EMPTY;
				dq.emplace_back(grid,i,j,0);
			}
		}
		
		int res=-1;
		set<string> vis;
		while(dq.size()){
			vs cur; int ci,cj,ct; tie(cur,ci,cj,ct)=dq.front(); dq.pop_front();
			if(!vis.insert(encode(cur,ci,cj)).second) continue;
			
			if(ci==gi && cj==gj){
				res=ct;
				break;
			}
			
			rep(k,4){
				int ni=ci+di[k],nj=cj+dj[k];
				if(cur[ni][nj]==WALL || cur[ni][nj]==PANEL) continue;
				if(cur[ni][nj]==CONTAINER){
					int i=ni+di[k],j=nj+dj[k];
					for(;;i+=di[k],j+=dj[k]){
						if(cur[i][j]==EMPTY) continue;
						if(cur[i][j]==PANEL) break;
						if(cur[i][j]==WALL || cur[i][j]==CONTAINER){
							i-=di[k],j-=dj[k];
							break;
						}
					}
					if(i==ni && j==nj) continue;
					vs next=cur;
					next[ni][nj]=EMPTY;
					next[i][j]=next[i][j]==PANEL?EMPTY:CONTAINER;
					dq.emplace_front(next,ci,cj,ct);
				}
				else
					dq.emplace_back(cur,ni,nj,ct+1);
			}
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 9972
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

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

	bool ok = true;
	for (int i = 0; i < s.size(); i++) {
		// cout << i << " " << s[i] << endl;
		if (i == a) {
			if (s[i] != '-') {
				ok = false;
				break;
			}
		} else {
			if (!isdigit(s[i])) {
				ok = false;
				break;
			}
		}
	}

	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


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

const int INF = 1e7;

struct Edge {
  int src, dst, cap, flow, id;
  bool reversed;
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int augment(Graph& graph, vector<vector<Edge*>>& rev,
            vector<int>& level, vector<bool>& finish, int u, int t, int cur) {
  if (u == t || cur == 0) return cur;
  if (finish[u]) return 0;
  finish[u] = true;

  for (Edge& e : graph[u]) {
    if (level[e.dst] > level[u]) {
      int f = augment(graph, rev, level, finish, e.dst, t, min(cur, e.cap - e.flow));
      if (f > 0) {
        e.flow += f;
        finish[u] = false;
        return f;
      }
    }
  }

  for (Edge* e : rev[u]) {
    if (level[e->dst] > level[u]) {
      int f = augment(graph, rev, level, finish, e->dst, t, min(cur, e->flow));
      if (f > 0) {
        e->flow -= f;
        finish[u] = false;
        return f;
      }
    }
  }

  return 0;
}

// Dinic
int maxFlow(Graph& graph, int s, int t) {
  int n = graph.size(), total = 0;

  vector<vector<Edge*>> rev(n);
  for (int u = 0; u < n; ++u)
    for (Edge& e : graph[u])
      rev[e.dst].push_back(&e);

  for (bool cont = true; cont; ) {
    cont = false;

    vector<int> level(n, -1);
    level[s] = 0;

    queue<int> Q;
    Q.push(s);

    for (int d = n; !Q.empty() && level[Q.front()] < d; ) {
      int u = Q.front(); Q.pop();
      if (u == t) d = level[u];
      for (const Edge& e : graph[u]) {
        if (e.cap - e.flow > 0 && level[e.dst] == -1) {
          Q.push(e.dst);
          level[e.dst] = level[u] + 1;
        }
      }
      for (const Edge* e : rev[u]) {
        if (e->flow > 0 && level[e->dst] == -1) {
          Q.push(e->dst);
          level[e->dst] = level[u] + 1;
        }
      }
    }

    vector<bool> finish(n, false);
    for (;;) {
      int f = augment(graph, rev, level, finish, s, t, INF);
      if (f == 0) break;
      total += f;
      cont = true;
    }
  }

  return total;
}

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

  int N, M;
  while (cin >> N >> M) {
    Graph graph(N);
    for (int i = 0; i < M; ++i) {
      int X, Y; cin >> X >> Y; --X; --Y;
      graph[X].push_back({X, Y, 1, 0, i, false});
      graph[Y].push_back({Y, X, 1, 0, i, true});
    }
    int S, T; cin >> S >> T; --S; --T;
    int value = maxFlow(graph, S, T);

    vector<int> answer;
    for (int u = 0; u < N; ++u)
      for (const Edge& e : graph[u])
        if (e.flow > 0 && e.reversed)
          answer.push_back(e.id + 1);
    sort(answer.begin(), answer.end());

    cout << value << endl << answer.size() << endl;
    for (int id : answer)
      cout << id << endl;
  }
}

Measured memory_bytes: 1348
#include "bits/stdc++.h"

using namespace std;

long long minN(long long prev, long long next) {
    long long n = prev / next;
    if (prev % next != 0) {
        ++n;
    }
    return n;
}

void Main() {
    long long N;
    cin >> N;
    pair<long long, long long> ta;
    for (long long i = 0; i < N; ++i) {
        long long T, A;
        cin >> T >> A;
        if (i == 0) {
            ta = make_pair(T, A);
            continue;
        }

        long long n1 = minN(ta.first, T);
        long long n2 = minN(ta.second, A);
        long long n = max(n1, n2);
        ta.first = n * T;
        ta.second = n * A;
    }

    cout << (ta.first + ta.second) << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3548
using System;

class OddOrEven{
  static void Main(string[] args){
    string result = "Odd";
    string[] str_numbers = Console.ReadLine().Split(' ');
    
    int number;
    for(int i = 0; i < str_numbers.Length; i++){
      number = int.Parse(str_numbers[i]);
      if((number % 2) == 0){
        result = "Even";
      }
    }
    
    Console.WriteLine(result);
  }
}

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

using namespace std;

int main(){
    int N; cin >> N;
    vector<int> larr(N,0);
    for(int i=0; i<N; i++){
        int l; cin >> l;
        larr[i] = l;
    }

    int max_idx = 0;
    for(int i=0;i<N;i++){
        if(larr[max_idx] < larr[i]){
            max_idx = i;
        }
    }

    int sum = 0;
    for(int i=0;i<N;i++){
        if(i != max_idx){
            sum += larr[i];
        }
    }

    if(sum > larr[max_idx]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab.sort(key = lambda x:x[0])
ans = 0
for i in range(n):
  while ab[i][1] > 0 and m> 0:
    m -= 1
    ab[i][1] -= 1
    ans += ab[i][0]
    
print(ans)
  

Measured memory_bytes: 64728
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>

 
using namespace std;
 

 
int main()
{
    int n;
    cin >> n;
    int l[n];
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    sort(l,l+n);
    int sum = 0;
    for (int i = 0; i <= n-2; i++)
    {
        sum += l[i];
    }
    if(l[n-1] < sum)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

 
    return 0;
}

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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] line;
      MyList list = new MyList();

      for(int i=0; i<n; i++) {
        line = br.readLine().split(" ");
        switch( line[0] ) {
          case "insert" :
            list.insertFirst( Integer.parseInt(line[1]) );
            break;
          case "deleteFirst" :
            list.deleteFirst();
            break;
          case "deleteLast" :
            list.deleteLast();
            break;
            case "delete" :
              list.delete( Integer.parseInt(line[1]) );
              break;
          default :
            System.out.println("n:" + i + " is failed.");
        }
      }

      System.out.println ( list.getAllElements() );
    }
  }
}

class Node {
  Node next,prev;
  int key;

  public Node(int key) {
    this.key = key;
  }
}

class MyList {
  Node nil;
  Node current;
  int size;

  public MyList() {
    nil = new Node(0);
    nil.next = nil.prev = nil;
    size = 0;
  }

  public String getAllElements() {
    StringBuilder buf = new StringBuilder(size*2);

    if(size > 0){
      current = nil.next;
      for(int i=0; i<size; i++){
        buf.append(current.key).append(" ");
        current = current.next;
      }
    }
    buf.setLength(buf.length()-1);

    return buf.toString();
  }
  public void insertFirst(int x) {
    if(size == 0) {
      current = new Node(x);
      nil.next = current;
      nil.prev = current;
      current.prev = nil;
      current.next = nil;
      size++;
    }
    else {
      Node add = new Node(x);
      
      current.prev.next = add;
      add.prev = current.prev;

      add.next = current;
      current.prev = add;

      current = add;
      size++;
    }
  }
  public void deleteFirst() {
    nil.next = current.next;
    current.next.prev = current.prev;

    current = current.next;
    size--;
  }
  public void deleteLast() {
    current = nil.prev;

    nil.prev = current.prev;
    current.prev.next = current.next;

    current = nil.next;
    size--;
  }
  public void delete(int x) {
    Node target = findFirst(x);

    if(target == nil) current = current.next;
    else {
      current.prev.next = target.next;
      current.next.prev = target.prev;
      current = nil.next;
      size--;
    }
  }
  private Node findFirst(int x) {
    while(current != nil) {
      if(current.key == x) break;
      current = current.next;
    }

    return current;
  }
}


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

int cup[100],stat[100],sum[100],wat[200];
int N,MIN;

int search(int cc,int left,int look,int num){
	int i;

	stat[look]=1;

	if(left==0){
		if(cc<N)stat[cc]=2;
		if(num==0)return 1;
		for(i=N-1;i>=0;i--){
			if(stat[i]==0)break;
			if(stat[i]==1 && search(i,cup[i],99,num))return 1;
		}
		stat[look]=0;
		stat[cc]=1;
		return 0;
	}

	int ccc=(look<N) ? look:cc;

	for(i=ccc-1;i>=0;i--){
		if(left<cup[i])continue;
		if(sum[i]<left)break;
		if(stat[i]==0 && search(cc,left-cup[i],i,num-1))return 1;
		if(i==cc-1 && stat[i]==0)break;
	}

	stat[look]=0;
	return 0;
}

int main(){
    int i,j,k;

    while(scanf("%d",&N)*N){

		for(i=0;i<=100;i++)wat[i]=0;
		for(i=0;i<N;i++){
			scanf("%d",&k);
			wat[k]++;
		}
		for(i=0,j=0,k=0;i<=100,j<N;i++){
			for(;wat[i]>0;wat[i]--){
				k+=i;
				cup[j]=i;
				stat[j]=0;
				sum[j]=k;
				j++;
			}
		}

		if(search(99,0,N-1,N-1))printf("YES\n"); else printf("NO\n");

    }
 
    return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void){
    ull a;
    double b;
    cin >> a >> b;
    ull c = b * 100 + EPS;
    
    cout << (ull)(a * c) /100;
}


Measured memory_bytes: 3732
def energy(ary)
  _ans = 0
  (1..(ary.length - 1)).each do |i|
    _ans += (ary[0] * ary[i])
  end
  return _ans
end

n = gets.chomp.to_i
d = gets.chomp.split(' ').map(&:to_i)

ans = 0

if n > 0
  (0..(d.length - 1)).each do |i|
    ans += energy(d[i..-1])
  end
end

puts ans.to_s


Measured memory_bytes: 1788
using System;

namespace ABC141
{
    class C
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split(' ');

            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);
            int Q = int.Parse(input[2]);


            int[] P = new int[N];

            for (int i = 0; i < Q; i++)
            {
                int a = int.Parse(Console.ReadLine());
                P[a - 1] += 1;
            }

            for (int i = 0; i < N; i++)
            {
                if (K <= (Q - P[i])) { Console.WriteLine("No"); } else { Console.WriteLine("Yes"); }
            }
        }
    }
}


Measured memory_bytes: 15708
#include <iostream>
using namespace std;
int main(int, char**)
{
	signed char a, b, c, d;
	cin >> a >> b >> c >> d;
	cin.ignore();
	a -= '0';
	b -= '0';
	c -= '0';
	d -= '0';
	if (a + b + c + d == 7)
	{
		printf("%d+%d+%d+%d=7\n", a, b, c, d);
	}
	else if (a + b + c - d == 7)
	{
		printf("%d+%d+%d-%d=7\n", a, b, c, d);
	}
	else if (a + b - c + d == 7)
	{
		printf("%d+%d-%d+%d=7\n", a, b, c, d);
	}
	else if (a - b + c + d == 7)
	{
		printf("%d-%d+%d+%d=7\n", a, b, c, d);
	}
	else if (a + b - c - d == 7)
	{
		printf("%d+%d-%d-%d=7\n", a, b, c, d);
	}
	else if (a - b - c + d == 7)
	{
		printf("%d-%d-%d+%d=7\n", a, b, c, d);
	}
	else if (a - b + c - d == 7)
	{
		printf("%d-%d+%d-%d=7\n", a, b, c, d);
	}
	else if (a - b - c - d == 7)
	{
		printf("%d-%d-%d-%d=7\n", a, b, c, d);
	}
	else if (a + b + c - d == 7)
	{
		printf("%d+%d+%d-%d=7\n", a, b, c, d);
	}
	return 0;
}


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

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

    int count = 0;
    int max = 0;
    int maxt = 1;
    for(int i = 1; i <= N; i++){
        int count = 0;
        int res = i;
        while(res % 2 == 0){
            res /= 2;
            count++;
        }

        if(max < count) {
            max = count;
            maxt = i;
        }
    }

    cout << maxt << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
#互いに素なa,bについて、a*x+b*y=1の一つの解
N,K=map(int,input().split())
mod=10**9+7

mx=0
mi=0
ans=0
for k in range(N+1):
    mx+=N-k
    mi+=k
    if k>=K-1:
        ans+=mx-mi+1

print(ans%mod)



Measured memory_bytes: 9172
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(void){
    double a, b;
    int ans=0, max;
    cin >> a >> b;

    for(int i=0; i < 1010; i++){
      if(floor(i*0.08) == a && floor(i*0.1) ==b) {
        ans = i;
        cout << ans << endl;
        break;
      }
    }

    if (ans == 0){
      cout << -1 << endl;
    }

return 0;
}


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

  vector<char> c(1, 'a');

void dog(ll n) {
  char x;
  if(n/26 == 0 | n == 26){
    x = 'a' + (n - 1);
    c.push_back(x);
    reverse(c.begin(), c.end());
    c.pop_back();
    for(int i = 0; i < c.size(); ++i) cout << c[i];
  }

  else{
    if(n%26 == 0){
      x = 'z';
      c.push_back(x);
      dog(n/26 - 1);
    }
    else{
      x = 'a' + (n%26 - 1);
      c.push_back(x);
      dog(n/26);
    }
  }


}

int main() {
  ll n;
  cin >> n;
  dog(n);

  cout << endl;
}


Measured memory_bytes: 3608
#include <iostream>
//#include <string>
//#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  
  //  cout << setprecision(8) << 1.0 * a / b << endl;
  printf("%d %d %.8lf\n", a/b, a%b, 1.0 * a/b);
  
  return 0;
}



Measured memory_bytes: 3200
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

int L[105];
int n,ans;

int main()
{
	cin >> n;
	for(int i = 0 ; i < 2 * n ; i++){
		cin >> L[i];
	}
	sort(L,L + 2 * n);
	for(int i = 0 ; i < 2 * n ; i+=2){
		ans += L[i];
	}
	cout << ans << endl;
}
		


Measured memory_bytes: 256
A,B,C = map(int, input().split())
ans_list = []
count = 1
while True:
  div_num = A*count
  ans = div_num % B
  if ans in ans_list:
    break
  else:
    ans_list.append(ans)
  count += 1
if C in ans_list:
  print("YES")
else:
  print("NO")

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,p; cin >> n >> p;
    vl a(n);
    rep(i,n)cin>>a[i];
    vvl dp(n+1,vl(2));
    dp[0][0] = 1;
    rep(i,n){
        //偶数なら
        if(a[i] % 2 == 0){
            chmax(dp[i+1][0],dp[i][0]*2);
            chmax(dp[i+1][1],dp[i][1]*2);
        }
        else{
            chmax(dp[i+1][1],dp[i][0]+dp[i][1]);
            chmax(dp[i+1][0],dp[i][1]+dp[i][0]);
        }
    }
    out(dp[n][p]);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
enum = enumerate

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in [0,]*rep)

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	N = int(input())
	vS = vinput(N,str)
	
	res = 0

	vT = "AC WA TLE RE".split()
	for t in vT:
		print(t,"x",vS.count(t))
	
	#sT = "No Yes".split()
	#print(sT[res])
	#print(res)

if __name__ == "__main__":
	main()


Measured memory_bytes: 16968
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint D;
llint c[30], csum;
llint s[400][30];
llint ans[405];

llint score(llint ans[], llint n)
{
	llint last[26];
	for(int i = 0; i < 26; i++) last[i] = 0;
	
	llint ret = 0, sub = 0;
	for(int i = 1; i <= n; i++){
		llint x = ans[i];
		ret += s[i][x];
		sub -= (i-last[x]) * c[x];
		sub += csum;
		ret -= sub;
		last[x] = i;
	}
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	srand(time(NULL));
	
	cin >> D;
	for(int i = 0; i < 26; i++) cin >> c[i];
	for(int i = 1; i <= D; i++){
		for(int j = 0; j < 26; j++){
			cin >> s[i][j];
		}
	}
	for(int i = 0; i < 26; i++) csum += c[i];
	
	for(int i = 1; i <= D; i++){
		llint max_val = -inf, max_j;
		for(int j = 0; j < 26; j++){
			ans[i] = j;
			llint res = score(ans, i);
			if(res > max_val){
				max_j = j;
				max_val = res;
			}
		}
		ans[i] = max_j;
	}
	
	llint cur = score(ans, D);
	for(int t = 0; t < 1000000; t++){
		llint x = rand() % D + 1, y = rand() % D + 1;
		swap(ans[x], ans[y]);
		llint nxt = score(ans, D);
		if(nxt < cur) swap(ans[x], ans[y]);
	}
	
	for(int i = 1; i <= D; i++) cout << ans[i]+1 << endl;
	
	
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

long power(long a, long b) {
    return b ? power(a*a%MOD, b/2) * (b%2?a:1)%MOD:1;
}

long perm(int N, int K) {
    long x = 1;
    for(int i = 1; i <= K; i++) x = x * (N-i+1) % MOD;
    return x % MOD;
}

long comb(int N,int K) {
    long x = 1, y = 1;
    for(int i = 1; i <= K; i++) {
        x = x * (N-i+1) % MOD;
        y = y * i % MOD;
    }
    return x * power(y, MOD-2) % MOD;
}

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

void dfs(const vector<vector<int> > &G, int v, vector<int> &seen) {
    seen[v] = true;

    for(int next_v : G[v]) {
        if(seen[next_v]) continue;
        dfs(G, next_v, seen);
    }
}

void yes() { cout << "Yes" << endl;}
void no() { cout << "No" << endl;}

int main() {
  int n, m, a, b;
  cin >> n >> m;
  vector<int> way(n);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a -= 1;
    b -= 1;
    way[a]++;
    way[b]++;
  }
  for (int value : way) {
    cout << value << endl;
  }
}

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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

int dp[101][101];

void solve() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> f(H, vector<char>(W));
  vector<vector<int>> dp(H, vector<int>(W, INF));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> f[i][j];
    }
  }
  dp[0][0] = f[0][0] == '#';
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i > 0) {
        if (f[i - 1][j] == '.' && f[i][j] == '#') {
          dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
        } else {
          dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
      }
      if (j > 0) {
        if (f[i][j - 1] == '.' && f[i][j] == '#') {
          dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
        } else {
          dp[i][j] = min(dp[i][j], dp[i][j - 1]);
        }
      }
    }
  }
  cout << dp[H - 1][W - 1] << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<29)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    int d;
    cin >> d;
    if (d == 25)cout << "Christmas" << endl;
    else if (d == 24)cout << "Christmas Eve" << endl;
    else if (d == 23)cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

int main()
{
    int h{}, n{};
    std::cin >> h >> n;
    std::vector<int> attack(n);
    int total = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> attack[i];
        total += attack[i];
    }
    if (total >= h) {
        std::cout << "Yes" << std::endl; 
    } else {
        std::cout << "No" << std::endl; 
    }

    return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

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



int main(){
  ll n; cin >> n;
  vl an(n); vl bn(n);
  
  rep(i,n){
    cin >> an[i] >> bn[i];
  }
  
  sort(all(an)); sort(all(bn));
  
  if(n % 2 == 1) cout << bn[n/2] - an[n/2] + 1 << endl;
  else{
    cout << bn[n/2 - 1] +bn[n/2] - an[n/2 - 1] - an[n/2] + 1 << endl;
  }
}

Measured memory_bytes: 6484
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int n;
char s[2001];
vector <int> v[2000];

pair<int, pair<int, int>> dfs(int x, int y) {
    int c1 = 0, c2 = 0, c3 = 0, m1 = 0, m2 = 0, m3 = 0, i;
    
    for (i = 0; i < v[x].size(); i++) {
        if (v[x][i] == y) continue;
        
        pair<int, pair<int, int>> p = dfs(v[x][i], x);
        p.second.first += p.first;
        
        c1 += p.first;
        c2 += p.second.first;
        
        if (p.second.first - p.second.second * 2 > m1) {
            m1 = p.second.first - p.second.second * 2;
            m2 = p.second.first;
            m3 = p.second.second;
        }
    }
    
    if (m1 > c2 - m2) {
        c3 = m3 + c2 - m2;
    } else {
        c3 = c2 / 2;
    }
    
    if (s[x] == '1') c1++;
    
    return make_pair(c1, make_pair(c2, c3));
}

int main() {
    int ans = 1e9, i;
    
    scanf("%d", &n);
    scanf("%s", s);
    
    for (i = 0; i < n - 1; i++) {
        int a, b;
        
        scanf("%d %d", &a, &b);
        a--;
        b--;
        
        v[a].push_back(b);
        v[b].push_back(a);
    }
    
    for (i = 0; i < n; i++) {
        pair<int, pair<int, int>> p = dfs(i, -1);
        if (p.second.first % 2 == 0 && p.second.second == p.second.first / 2) ans = min(ans, p.second.second);
    }
    
    if (ans == 1e9) ans = -1;
    printf("%d\n", ans);
    
    return 0;
}


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

//各桁の和を計算する関数
int carry (int n){

  int sum=0;

  while(n>0){
    sum+=n%10;
    n/=10;
  }

  return sum;

}
 
int main() {
  int N,A,B,ans=0;

  cin>>N>>A>>B;
  
  for(int i=1;i<N+1;i++){
    int c=carry(i);
    if(A<=c && c<=B){
      ans+=i;

    }
  }
   

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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 argc, char const *argv[]) {
  int n;
  cin >> n;
  pii stu[n];
  rep(i,n){
    int s;
    cin >> s;
    stu[i].fi=s;
    stu[i].se=i;
  }

  sort(stu,stu+n);

  rep(i,n) cout << stu[i].se+1 << " ";
  cout  << endl;


  return 0;
}


Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main()
{
    int x, n;
    cin >> n >> x;
    int s, cnt = 1, coord = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        coord += s;
        if (coord <= x)
        {
            cnt++;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
    t = str(i)
    b = True
    for j in range(len(t)):
        if t[j] != t[-j-1]:
            b = False
            break
    if b:
        cnt += 1
print(cnt)


Measured memory_bytes: 2940
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {s: Chars};

    let s: Vec<char> = s;

    let mut v: Vec<usize> = vec![0; s.len()];
    let acgt = vec!['A', 'C', 'G', 'T'];

    for (i, si) in s.iter().enumerate() {
        if acgt.contains(si) {
            if i == 0 {
                v[i] = 1;
            } else {
                v[i] = v[i - 1] + 1;
            }
        }
    }

    println!("{}", v.iter().max().unwrap());
}


Measured memory_bytes: 2152
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bf.readLine());
        StringBuilder sb = new StringBuilder();
        HashSet<Integer> hashSet = new HashSet<>();
        final char[] key = new char[128];
        key['A'] = 0;
        key['C'] = 1;
        key['G'] = 2;
        key['T'] = 3;
        for (int i = 0; i < n; i++) {
            String sp = bf.readLine();
            if (sp.charAt(0) == 'i') {
                int hash = 1;
                for (int j = 7; j < sp.length(); j++) {
                    hash <<= 2;
                    hash+=key[sp.charAt(j)];
                }
                hashSet.add(hash);
            } else {
                int hash = 1;
                for (int j = 5; j < sp.length(); j++) {
                    hash <<= 2;
                    hash+=key[sp.charAt(j)];
                }
                sb.append(hashSet.contains(hash) ? "yes\n" : "no\n");
            }
        }
        bf.close();
        System.out.print(sb.toString());
    }
}



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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define repl(n) for (int l = 0; l < (n); l++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v[2];
  repi(2) v[i].resize(100001);
  repi(100001) v[0][i].second = v[1][i].second = i;
  repi(n) {
    int x;
    cin >> x;
    v[i % 2][x].first++;
  }
  repi(2) sort(v[i].begin(), v[i].end(), greater<pair<int, int>>());
  if (v[0][0].second == v[1][0].second) {
    cout << min(n - v[0][1].first - v[1][0].first,
                n - v[0][0].first - v[1][1].first)
         << endl;
  } else {
    cout << n - v[0][0].first - v[1][0].first << endl;
  }
}


Measured memory_bytes: 1792
// AOJ 2709 Dark Room
// 2018.3.31 bal4u

#include <stdio.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define INF 0x10101010
#define QMAX 100000
int q[QMAX]; int top, end;
int d[18], r[102];
int v[102][102];
int dist[1<<16];

int main()
{
	int N, M, K, i, j, k, s, e, t;

	N = in(), M = in(), K = in();
	memset(r, -1, sizeof(r));
	for (i = 0; i < M; i++) d[i] = in()-1, r[d[i]] = 1<<i;
	for (i = 0; i < N; i++) for (j = 0; j < K; j++) v[i][j] = in()-1;

	memset(dist, INF, sizeof(dist));
	q[0] = s =(1<<M)-1, dist[s] = 0;
	top = 0, end = 1;
	while (top != end) {
		s = q[top++];

		if ((t=dist[s]) == INF) continue;
		for (i = 0; i < K; i++) {
			e = 0;
			for (j = 0; j < M; j++) if ((s>>j)&1) {
				k = v[d[j]][i];
				if (r[k] >= 0) e |= r[k];
			}
			if (dist[e] > t+1) dist[e] = t+1, q[end++] = e;
		}
	}
	printf("%d\n", dist[0]);
	return 0;
}


Measured memory_bytes: 2408
#include<iostream>
#include<vector>
#include<cmath>
#include<complex>
#define MAX 21
#define INF 10000
#define EPS 1.0e-10
using namespace std;
typedef double elem;
typedef complex<elem> point;
double dist(const point &a, const point &b){return std::abs(b-a);}
bool vis[MAX];
bool bt(const vector<point> &v, double walk, const point &h, const point &d){
	bool bCont = false;

	for(unsigned int i = 0; i < v.size(); ++i){
		if( !vis[i] )bCont=true;
	}
	if( !bCont )return true;

	for(unsigned int i = 0; i < v.size(); ++i){
		if( !vis[i] ){
			double t = walk + dist(h,v[i]);
			if( t < dist(d, v[i]) ){
				vis[i] = true;
				if( bt( v, t, v[i], d ) )
					return true;
				vis[i] = false;
			}else{
				return false;
			}
		}
	}
	return false;
}
int main(){
	while(true){
		bool bImpossible = false;
		int n,hx,hy,dx,dy;
		point hero, daemon;
		vector< point > vp;

		scanf("%d%d%d%d%d", &n, &hx, &hy, &dx, &dy);
		if(!(n||hx||hy||dx||dy))break;
		
		hero = complex<elem>(hx,hy);
		daemon = complex<elem>(dx,dy);
		
		for(int i=0;i<n;++i){
			bool bInserted = false;
			int cx,cy;scanf("%d%d", &cx, &cy);point p(cx,cy);
			if(cx==hx&&cy==hy)continue;
			for(unsigned int j = 0; j < vp.size() && !bInserted; ++j){
				if( dist( daemon, vp[j] ) > dist( daemon, p ) ){
					vp.insert( vp.begin()+j, p );
					bInserted = true;
				}
			}
			if( !bInserted ){
				vp.push_back( p );
			}
			if( dist(daemon,p) <= dist(hero,p) )bImpossible=true;
			vis[i]=false;
		}
		/*for(unsigned int i = 0; i < vp.size(); ++i){
			cout<<vp[i]<< ' ';
		}
		cout << endl;*/
		
		if( !bImpossible && bt( vp, 0.0, hero, daemon ) )
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 904
#include <stdio.h>

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

 scanf("%d%d%d", &a, &b, &c);

 int ispoor = 0;
 if (a == b && b != c) ispoor = 1;
 if (b == c && c != a) ispoor = 1;
 if (c == a && a != b) ispoor = 1;

 if (ispoor) {
 puts("Yes");
 } else {
 puts("No");
 }

 return 0;
 }

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int p = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int[] cnt = new int[2];
		for (int i = 0; i < n; i++) {
			cnt[a[i] % 2]++;
		}

		long val0 = 1L << cnt[0];
		long val1 = 0;
		for (int i = p; i <= cnt[1]; i+=2) {
			val1 += nCr(cnt[1], i);
		}
		System.out.println(val0 * val1);
	}

	static long nCr(int n, int r) {
		long val = 1;
		for (int i = 1; i <= r; i++) {
			val = val * (n - i + 1) / i;
		}
		return val;
	}
}


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

int cnt;

void insertionSort(int A[], int n, int g)
{
	for (int i = g; i < n; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n)
{
	cnt = 0;
	int G[100];		
	int k, m = 1;
	G[0] = 1;

	while ((k = G[m - 1] * 3 + 1) < n) {
		G[m] = k;
		m++;
	}
	for (int i = 1; i < m; i++)
		G[i] = 3 * G[i - 1] + 1;

	cout << m << "\n";
	for (int i = m - 1; i >= 0; i--) {
		cout << G[i];
		if (i != 0) cout << " ";
	}
	cout << "\n";

	for (int i = m - 1; i >= 0; i--)
		insertionSort(A, n, G[i]);
}

int main()
{
	int n;
	cin >> n;
	int *p = new int[n];

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

	shellSort(p, n);
	cout << cnt << "\n";
	for (int i = 0; i < n; i++)
		cout << p[i] << "\n";
	return 0;
}

Measured memory_bytes: 5088
#include<bits/stdc++.h>
using namespace std;
const int N=1E5+7;
int arr[N];
int main(){
	int n,m,q;
	cin>>n>>m>>q;
	int x;
	for(int i=1;i<=n;i++) arr[i]=m;
	for(int i=1;i<=q;i++){
		scanf("%d",&x);
		arr[x]++;
	}
	for(int i=1;i<=n;i++){
		if(arr[i]<=q) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import sys
from functools import lru_cache

sys.setrecursionlimit(10 ** 9)

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p = p[0:X]
q = q[0:Y]

s = p + q + r
s.sort(reverse=True)

print(sum(s[0:(X + Y)]))


Measured memory_bytes: 23856
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<pair<ll, ll> > lr;
  set<pair<ll, ll> > se;
  ll mx=-inf, mn=inf;
  rep(i, N) {
    ll l, r;
    cin >> l >> r;
    l--;
    lr.push_back(make_pair(l, r));
    mx = max(mx, l);
    mn = min(mn, r);
  }
  ll ans = 0;
  for(auto s: lr) {
    ll l = s.first, r = s.second;
    ans = max(ans, max(0LL, mn-mx)+r-l);
  }
  for(auto s: lr) {
    ll l = s.first, r = s.second;
    ll a = max(0LL, r - mx);
    ll b = max(0LL, mn - l);
    se.insert(make_pair(a, -b));
  }
  ll w = inf;
  for(auto s: se) {
    ll a = s.first, b = - s.second;
    if(w != inf) ans = max(ans, w + a);
    w = min(w, b);
  }
  cout << ans << endl;
  return 0;
}



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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll x,idx,ans;

int main(){
  cin >> n;
  x = vll(n);
  for(lli i = 0;i < n;i++) cin >> x[i];
  idx = vll(n);
  ans = vll(n);
  iota(idx.begin(),idx.end(),0ll);
  sort(idx.begin(),idx.end(),[](lli a,lli b){
    return x[a] < x[b];
  });
  sort(x.begin(),x.end());
  for(lli i = 0;i < n/2;i++){
    ans[idx[i]] = x[n/2];
  }
  for(lli i = n/2;i < n;i++){
    ans[idx[i]] = x[n/2-1];
  }
  for(lli i = 0;i < n;i++){
    cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 6912
#include <iostream>
using namespace std;
int main(void){
    string S;
    cin >> S;
    char o = 'o';
    int v = 700;
    for (int i = 0; i < 3; i++){
        if (S[i] == o){
            v += 100;
        }
    }
    cout << v << endl;
}


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

long long lcd(long long a, long long b) {
	if (b == 0) {
		return a;
	}
	else {
		return lcd(b, a%b);
	}
}


int main() {
	int t;
	cin >> t;
	for (int i = 1; i <= t; i++) {
		long long a, b, c, d;
		cin >> a >> b >> c >> d;
		if (b > d || a<b) {
			cout << "No" << endl;
		}
		else {
			long long q;
			if (a > c) {
				q = a - ((a - c) / b + 1 - (0==(a - c) % b))*b;
			}
			else {
				q = a - b;
			}
			if (q < 0) {
				cout << "No" << endl;
				continue;
			}
			if (d%b == 0) {
				cout << "Yes" << endl;
				continue;
			}
			else {
				long long x = lcd(b, d);
				q = q + ((c - q) / x + 1)*x;
				if (q < b) {
					cout << "No" << endl;
				}
				else {
					cout << "Yes" << endl;
				}
			}
		}
	}
}

Measured memory_bytes: 256