akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,m;
  cin>>n>>m;
  vll a(n);
  REP(i,n)cin>>a[i];

  sort(ALL(a), greater<ll>());
  ll sum=0;
  REP(i,n)sum+=a[i];
  ll lim=sum/(4*m);
  if(sum%(4*m)!=0)
    lim++;

  if(a[m-1]>=lim)
    yes;
  else
    no;

}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int a, b, c; cin >> a >> b >> c;
    if (b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    int x = sc.nextInt();
    for(int i = 0; i < n; i++){
      int a = sc.nextInt();
      for(int j = 1; j <= d; j += a){
        x++;
      }
    }
    System.out.println(x);
  }
}

Measured memory_bytes: 23636
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i64>();
    let b = read::<i64>();
    println!("{}", if b % a == 0 { a + b } else { b - a });
}


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

int n,f=0;

int main()
{
	cin >> n;
	for(int i=1;i<=9;i++)
		if(n%i==0&&n/i>=1&&n/i<=9) f=1;
	if(f==1) cout << "Yes" << endl;
	else cout  << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
l=len(a)
ans=0
for i in range(l-2):
    e=l-1
    for j in range(i+1,l-1):
        if e<=j:
            break
        while a[i]-a[j]>=a[e] and e>j:
            ans+=(e-j)
            e-=1
ans=(n*(n-1)*(n-2))//6-ans
print(ans)
            

Measured memory_bytes: 42716
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		
		int[] ans = new int[394];
		Arrays.fill(ans, -1);
		ans[0] = 0;
		
		for(int i=0;i<=393;i++){
			for(int j=0;j<n;j++){
				if(ans[i]>=0){
					for(int k=a[j];k<=b[j];k++){
						if(i+k<=393) ans[i+k] = Math.max(ans[i+k], ans[i]+c[j]);
					}
				}
			}
		}
		
		int m = sc.nextInt();
		int[] d = new int[m];
		boolean flag = false;
		for(int i=0;i<m;i++){
			d[i] = sc.nextInt();
			if(ans[d[i]]==-1) flag = true;
		}
		
		if(flag==true){
			System.out.println("-1");
		}else{
			for(int i=0;i<m;i++) System.out.println(ans[d[i]]);
		}
	}	
}

Measured memory_bytes: 23736
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = nk[0];
        int k = nk[1];

        int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int count = 0;
        for (int i = 0; i < n; i++)
        {
            if (h[i] >= k)
            {
                count++;
            }
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 18656
import math
a = [[] for i in range(5)]
min_inp = 0
for i in range(5):
    inp = int(input())
    inp_ceil = math.ceil(inp/10)*10
    first = inp - int(inp/10) * 10
    if first == 0:
        first = 10
    a[i].append(inp)
    a[i].append(inp_ceil)
    a[i].append(first)
a = sorted(a, key=lambda x: x[2])
ans = a[0][0]

for i in range(4):
    ans += a[i+1][1]

print(ans)


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

int main(){
    string a,b,c,ans;
    cin>>a>>b>>c;
    cout<<(char)(a[0]-32)<<(char)(b[0]-32)<<(char)(c[0]-32)<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());
    long answer = 0;
    for(long i = 1; i <= n; i++)
    {
      if(whatDigit(i) % 2 == 1) answer++;
    }

		Console.WriteLine(answer);
	}

  static long whatDigit (long n)//nは何桁か
    {
      for(long i = 1; i < 20; i++)
      {
        n /= 10;
        if(n == 0)
        {
          return i;
          break;
        }
      }
      return 0;
    }
  
}

Measured memory_bytes: 13140
from typing import List
import sys


def read_data(file_name: str, std_in=True):
    satisfactions_list = list()
    file = sys.stdin if std_in else open(file_name, 'r')
    days = int(file.readline().rstrip())
    satisfaction_decreases = [int(c) for c in file.readline().rstrip().split(" ")]
    for i in range(days):
        satisfactions_list.append([int(c) for c in file.readline().rstrip().split(" ")])
    if not std_in:
        file.close()
    return days, satisfaction_decreases, satisfactions_list


class Contest:
    def __init__(self, _type: int, satisfactions: List[int], satisfaction_decrease: int):
        self.dissatisfaction = 0
        self.type = _type
        self.satisfactions = satisfactions
        self.satisfaction_decrease = satisfaction_decrease

    def __getitem__(self, key: int):
        return self.satisfactions[key - 1]

    def __str__(self):
        return str(self.type)

    def __repr__(self):
        return f"Contest(_type={self.type}, satisfactions={self.satisfactions}, satisfaction_decrease={self.satisfaction_decrease})"

    def heuristic(self, day):
        return self[day] - 2*(self.dissatisfaction - self.satisfaction_decrease)
        # return self[day] - self.dissatisfaction

    def winner(self):
        self.dissatisfaction = 0

    def loser(self):
        self.dissatisfaction -= self.satisfaction_decrease


def get_best(contests: List[Contest], day: int):
    # improve this by optimistically making everyone a loser and then going back to undo that for the winner
    best = contests[0]
    for contest in contests:
        if contest.heuristic(day) > best.heuristic(day):
            best = contest
    return best


def main(file_name="input.txt"):
    contests = list()
    days, satisfaction_decreases, satisfactions_list = read_data(file_name)
    picks = list()

    for (_type, (satisfactions, satisfaction_decrease)) in enumerate(zip(zip(*satisfactions_list), satisfaction_decreases), start=1):
        contests.append(Contest(_type, satisfactions, satisfaction_decrease))

    for day in range(days):
        best = get_best(contests, day + 1)
        for contest in contests:
            if contest.type == best.type:
                contest.winner()
                picks.append(contest)
            else:
                contest.loser()

    return "\n".join([str(pick) for pick in picks])


if __name__ == "__main__":
    print(main("input.txt"))


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

//素因数分解
vector<pair<ll, ll>> prime_factor(ll n) {
    vector<pair<ll, ll>> res;

    for (ll i = 2; i * i <= n; ++i) {
        if (n % i != 0) continue;

        ll num = 0;

        while (n % i == 0) {
            ++num;
            n /= i;
        }

        res.push_back(make_pair(i, num));
    }

    if (n != 1) res.push_back(make_pair(n, 1));

    return res;
}

int main() {

    ll a, b; cin >> a >> b;

    ll gcd = __gcd(a, b);

    auto pf = prime_factor(gcd);

    cout << pf.size() + 1 << endl;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){

  if(u==NIL||k==u->key) return u;
  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL) return treeMinimum(x->right);

  y = x->parent;
  while(y!=NIL && x==y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

/*void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL) y=z;
  else y=TreeSuccessor(z);
  
  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;

  if(y->parent==NIL) 

  }*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y = x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent = y;

  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){

  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    /*if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      } */
    if (com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }

  return 0;
}

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

int main() {
  int n, c, p, sum = 0;
  cin >> n >> c;
  for (int i = 0; i < c; i++) {
    cin >> p;
    sum += p;
  }
  int ans = sum / (n + 1);
  if (sum % (n + 1)) ans++;
  cout << ans << "\n";
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int A,B; cin >> A >> B;
	cout << A * B << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	ans := 0
	for i:=1; i<n+1; i++ {
		if len(strconv.Itoa(i)) % 2 == 1{
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1024
M,D = [int(s) for s in input().split(" ")]

if M < 2:
    print(0)
elif D < 12:
    print(0)
else:
    mulday = 0
    for m in range(2,M+1):
        for d in range(12,D+1):
            d10 = int(str(d)[0])
            d1 = int(str(d)[1])
            if d10 == 1 or d1 == 1:
                continue
            if d10*d1 == m:
                #print(m,d)
                mulday+=1
                
    print(mulday)

Measured memory_bytes: 3064
/*

RFL <3
The Feeling of Happiness

"In dreams begin responsibility"

*/


#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)


/*
#define nMX 5000000
#define pMX 500000
int pr[pMX+1],prnum[nMX+1];

int sieve()
{
    int i,j;
    for(i=1;i<=nMX;i++)
        prnum[i]=i+1;
    for(i=1;i<=nMX;i++)
        if(prnum[i]!=-1)
            for(j=2*prnum[i]-1;j<=nMX;j+=prnum[i])
                    prnum[j]=-1;
    j=0;
    for(i=1;i<=nMX;i++)
        if(prnum[i]!=-1)
            pr[++j]=prnum[i];
    re j;
}*/

/*ll m_ncr[10001][10001];
ll ncr(ll i,ll j)
{
    if(j==1) re i;
    if(i==j) re 1;
    if(m_ncr[i][j]!=-1) re m_ncr[i][j];
    re m_ncr[i][j]=ncr(i-1,j) + ncr(i-1,j-1);
}*/

/*ll m_fact[21];
ll fact(ll i)
{
    if(i==1 || i==0) re 1;
    if(m_fact[i]!=-1) re m_fact[i];
    re m_fact[i]=i*fact(i-1);
}*/


/*#define MX 200005
ll int arr[MX];
ll int tree[MX * 3];
void init(ll int node, ll int b, ll int e)
{
    if (b == e) {
        tree[node] = arr[b];
        return;
    }
    ll int Left = node * 2;
    ll int Right = node * 2 + 1;
    ll int mid = (b + e) / 2;
    init(Left, b, mid);
    init(Right, mid + 1, e);
    tree[node] = max(tree[Left], tree[Right]);
}
ll int query(ll int node, ll int b, ll int e, ll int i, ll int j)
{
    if (i > e || j < b)
        return -1e6;
    if (b >= i && e <= j)
        return tree[node];
    ll int Left = node * 2;
    ll int Right = node * 2 + 1;
    ll int mid = (b + e) / 2;
    ll int p1 = query(Left, b, mid, i, j);
    ll int p2 = query(Right, mid + 1, e, i, j);
    return max(p1, p2);
}
void updateRange(ll int node, ll int start, ll int endd, ll int l, ll int r, ll int val)
{
    // out of range
    if (start > endd or start > r or endd < l)
        return;

    // Current node is a leaf node
    if (start == endd)
    {
        // Add the difference to current node
        tree[node] += val;
        return;
    }

    // If not a leaf node, recur for children.
    ll int mid = (start + endd) / 2;
    updateRange(node*2, start, mid, l, r, val);
    updateRange(node*2 + 1, mid + 1, endd, l, r, val);

    // Use the result of children calls to update this node
    tree[node] = tree[node*2] + tree[node*2+1];
}*/


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll int i,j,x,y,n,m,cnt=0,k,g,flg,t;
    string s;
    cin>>n;
    cin>>s;
    if(n%2)
    {
        cout<<"No";
        re 0;
    }
    string tt=s.substr(0, n/2);
    string ss=s.substr(n/2, n/2);
    if(ss==tt)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stdint.h>
#define int long long
using namespace std;

const int maxn = 1e5 + 10;
struct node {
    int a, b;
} s[maxn];
bool cmp(const node& m, const node& n) { return m.a < n.a; } 

int32_t main() {
    int n, m;
    scanf("%lld%lld", &n, &m);
    for (int i = 0; i < n; i++) scanf("%lld%lld", &s[i].a, &s[i].b);
    sort(s, s + n, cmp);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (m > s[i].b) {
            m -= s[i].b;
            ans += s[i].b * s[i].a;
        } else {
            ans += s[i].a * m;
            m = 0;
            break;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

string cal(string inp, ll a , ll b){
    if(a == b ) return inp;

    string ret = "";
    rep(i, inp.size()){
        if(a <= i  &&  i < b) continue;
        ret += inp[i];
    }
    return ret;
}

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

    string s;
    cin >> s;
    
    string cpr = "keyence";
    
    rep(i,s.size()+1){
        rep(j, s.size()+1){
            if( j < i) continue;
            if(cpr == cal(s, i, j)){
                cout <<"YES" << endl;
                return 0;
            }
        }
    }
    
    cout << "NO" << endl;
    
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int A,B;
    cin>>A>>B;
    if(A==B)cout<<2*A<<endl;
    else cout<<2*max(A,B)-1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
bool visited[8];
std::vector<int> G[8];
int N, M;

int search(int new_index) {
    bool finish = true;

    for (size_t i = 0; i < N; i++) {
        if (!visited[i]) {
            finish = false;
            break;
        }
    }
    if (finish) {
        return 1;
    }
    int sum = 0;
    for (size_t i = 0; i < G[new_index].size(); i++) {
        if (visited[G[new_index][i]]) {
            continue;
        }
        visited[G[new_index][i]] = true;
        sum += search(G[new_index][i]);
        visited[G[new_index][i]] = false;
    }
    return sum;
}

int main(int argc, char const *argv[]) {
    std::cin >> N >> M;
    int a, b;
    for (size_t i = 0; i < M; i++) {
        std::cin >> a >> b;
        G[a - 1].push_back(b - 1);
        G[b - 1].push_back(a - 1);
    }

    for (size_t i = 0; i < N; i++) {
        visited[i] = false;
    }
    visited[0] = true;
    std::cout << search(0) << '\n';

    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int X, Y;
char maps[10][10];
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
int ans;

struct Data {
	int cnt;
	char m[10][10];
	
	Data(int _cnt, char _m[10][10]) {
		cnt = _cnt;
		REP(i, 10) REP(j, 10) m[i][j] = _m[i][j];
	}
};

int main() {
	while (cin >> X >> Y, X || Y) {
		REP(i, Y) REP(j, X) {
			string s; cin >> s;
			int num;
			switch (s[0]) {
				case 'R': num = 0; break;
				case 'G': num = 1; break;
				case 'B': num = 2; break;
			}
			maps[i][j] = num;
		}
		
		queue<Data> que;
		que.push(Data(0, maps));
		int ans = INF;
		
		while (!que.empty()) {
			Data now = que.front(); que.pop();
			if (ans <= now.cnt) continue;
			
			bool en = true;
			FOR(i, 1, Y) REP(j, X) if (now.m[i][j] != now.m[i - 1][j]) en = false;
			FOR(j, 1, X) REP(i, Y) if (now.m[i][j] != now.m[i][j - 1]) en = false;
			if (en) { ans = now.cnt; continue; }
			
			queue<pii> que2;
			bool done[10][10] = {};
			vector<pii> v[3];
			
			que2.push(pii(0, 0));
			done[0][0] = true;
			v[now.m[0][0]].push_back(pii(0, 0));
			
			char base = now.m[0][0];
			
			while (!que2.empty()) {
				int x = que2.front().se, y = que2.front().fi;
				que2.pop();
				
				REP(i, 4) {
					int nx = x + dx[i], ny = y + dy[i];
					if (!(nx >= 0 && nx < X && ny >= 0 && ny < Y)) continue;
					if (done[ny][nx]) continue;
					if (now.m[ny][nx] == base) que2.push(pii(ny, nx));
					
					done[ny][nx] = true;
					
					if (now.m[ny][nx] == base || (base != now.m[ny][nx] && v[now.m[ny][nx]].empty()))
						v[now.m[ny][nx]].push_back(pii(ny, nx));
				}
			}
			
			REP(i, 3) if (i != base) {
				if (v[i].empty()) continue;
				
				REP(j, v[base].size()) now.m[v[base][j].fi][v[base][j].se] = i;
				que.push(Data(now.cnt + 1, now.m));
			}
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 10020
s = list(input())

N = len(s)

for i in range(N - 1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        exit()

if N >= 3:
    for i in range(N - 2):
        if s[i] == s[i+2]:
            print(i+1, i+3)
            exit()

print("-1 -1")

Measured memory_bytes: 3956
#include <iostream>

using namespace std;

int main()
{
    long long a, b, c, d;
    long long ans = -1000000000000000000LL;

    cin >> a >> b >> c >> d;

    if (ans < a*c)
        ans = a*c;
    if (ans < a*d)
        ans = a*d;
    if (ans < b*c)
        ans = b*c;
    if (ans < b*d)
        ans = b*d;

    cout << ans;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(int i=k;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> iv;
typedef pair<int,int> iip;
typedef map<int,int> mii;
template <typename T>
void dbg(T t){cerr<<t<<endl ;}
template<typename T, typename... Args>
void dbg(T t, Args... args) {cerr << t <<" ";dbg(args...) ;}

int main(){
	//ios::sync_with_stdio(0);cin.tie(0);
	int test,n,a,b,c,dd,bb,d;
	cin>>a>>b>>c>>d;
	cout<<max(0,min(b,d)-max(a,c));
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var sa = Console.ReadLine();
            var sb = Console.ReadLine();
            var sc = Console.ReadLine();

            var cur = 'a';
            while (true)
            {
                switch (cur)
                {
                    case 'a':
                        if (Check(sa, 'A')) return;
                        cur = Solve(ref sa);
                        break;
                    case 'b':
                        if (Check(sb, 'B')) return;
                        cur = Solve(ref sb);
                        break;
                    case 'c':
                        if (Check(sc, 'C')) return;
                        cur = Solve(ref sc);
                        break;
                    default:
                        break;
                }
            }
        }

        static char Solve(ref string s)
        {
            var cur = s[0];
            s = s.Substring(1);
            return cur;
        }

        static bool Check(string s, char target)
        {
            if (string.IsNullOrEmpty(s))
            {
                Console.WriteLine(target);
                return true;
            }
            else return false;
        }
    }
}


Measured memory_bytes: 13140
MOD = 10**9+7
n = int(input())
A = ['{:060b}'.format(a)[::-1] for a in map(int, input().split())]
A_d = []
for col in zip(*A):
    zero_cnt = col.count('0')
    A_d.append(zero_cnt*(n-zero_cnt))

ans = 0
for d in range(60):
    ans = ans + A_d[d]*pow(2, d, MOD) % MOD
print(ans % MOD)


Measured memory_bytes: 67884
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  cout << (N-H+1)*(N-W+1) << endl;
}

Measured memory_bytes: 256
while 1:
    n,m = map(int,input().split())
    if n == 0 and m == 0:
        break
    taro = [int(input()) for i in range(n)]
    hanako = [int(input()) for i in range(m)]
    ans = []
    for i in range(n):
        for j in range(m):
            taro[i],hanako[j] = hanako[j],taro[i]
            if sum(taro) == sum(hanako):
                ans.append([hanako[j],taro[i]])
            taro[i],hanako[j] = hanako[j],taro[i]
    Min = 9999999999
    for i,j in ans:
        if Min > (i+j):
            Min = (i+j)
            ans_taro = i
            ans_hanako = j
    if len(ans) != 0:
        print(ans_taro,ans_hanako)
    else:
        print(-1)



Measured memory_bytes: 6244
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N; cin >> N;
    vector<pair<int, int>> p(N);
    rep(i, N){
        int a, b;
        cin >> a >> b;
        p[i] = make_pair(b, a);
    }
    sort(all(p));
    ll time = 0;
    rep(i, N){
        time += p[i].second;
        if(time > p[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

bool kai(int x){
  bool res=0;
  int  num[5];
  for(int i=0;res==0;i++){
    num[i]=x%10;
    x/=10;
    if(x==0){
      res=1;
      for(int j=0;j<(i+1)/2;j++){
	if(num[i-j]!=num[j])
	  res = 0;
      }
      break;
      
    }
  }
  return res;
}

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

  for(int i=0;i<=1000;i++){
    int b=a+i;
    int c=a-i;
    bool f1,f2;
    f1=kai(b);
    f2=kai(c);
    if(f1&&f2) cout <<c<<endl;
    else if(f1) cout <<b<<endl;
    else if(f2) cout <<c<<endl;
    if(f1||f2) break;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <cstring>

char S[10000];

using namespace std;

int main() {
    scanf("%s", S);
    if (strlen(S) < 4) {
        printf("No\n");
    } else {
        if (S[0] == 'Y' && S[1] == 'A' && S[2] == 'K' && S[3] == 'I') {
            printf("Yes\n");
        } else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){	
	int a,b,n;
	while(scanf("%d%d", &a, &b) && a && b){
		int x,y;
		int road[32][32]={0};
		int stop[32][32]={0};
		
		scanf("%d", &n);
		for(int i = 0; i < n; i++){
			scanf("%d%d",&x, &y);
			stop[y][x] = 1;
		}
		road[0][1] = 1;
		
		for(int i = 1 ; i <=b; i++){
			for(int j = 1 ;j <= a; j++){
				if(stop[i][j] == 0){
					road[i][j] = road[i-1][j]+road[i][j-1];
				}
			}
		}
		
		printf("%d\n",road[b][a]);
	}
	return 0;
}

/*
					road[i+1][j] += road[i][j];
					road[i][j+1] += road[i][j];
					*/

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

const int MOD = 1000000007;

using namespace std;



int main(){

    long long i,j,n,count=0,sum=0;
    cin >> n;
    string s[n],t;
    int c[n];
    for(i=0;i<n;i++){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
        c[i]=0;
    }
    sort(s,s+n);
    for(i=0;i<n-1;i++){
        t=s[i];
        if(t==s[i+1]){
            count++;
            sum+=count;
        }else count=0;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 7680
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
int w, a, b;

int main(){
	scanf("%d%d%d", &w, &a, &b);
	int n = max(a, b);
	int m = min(a, b);
	m += w;
	if(m >= n) printf("0\n");
	else printf("%d\n", n - m);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define F first
#define S second
using namespace std;

typedef pair< int,int > point;
vector< point > graph[101];
vector< int > v(101);
int n;
const int INF=1<<30;

void dijkstra(int s){
    priority_queue< point,vector< point >,greater< point > >pq;
    pq.push({0,s});
    fill(v.begin(),v.end(),INF);
    v[s]=0;
    while(!pq.empty()){
        point p=pq.top();
        pq.pop();
        REP(i,graph[p.S].size()){
            int nex=graph[p.S][i].S;
            int cost=p.F+graph[p.S][i].F;
            if(v[nex]>cost){
                v[nex]=cost;
                pq.push({cost,nex});
            }
        }
    }
}

int main(){
    scanf("%d",&n);
    int u,k,to,c;
    REP(i,n){
        scanf("%d%d",&u,&k);
        REP(j,k){
            scanf("%d%d",&to,&c);
            graph[u].push_back({c,to});
        }
    }
    dijkstra(0);
    REP(i,n){
        printf("%d ",i);
        printf("%d\n",v[i]);
    }
    return 0;
}




Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	ll x;
	cin >> x;
	for (ll a = 0; a <= 120; a++) {
		for (ll b = -120; b <= 120; b++) {
			if (a*a*a*a*a - b*b*b*b*b == x) {
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3636
n,l=map(int,input().split())
A=list(map(int,input().split()))
add=0
for i in range(1,n):
    if A[i]+A[i-1]>=l:
        add=i+1
        break
if add==0:print("Impossible");exit()
print("Possible")
for i in range(1,add-1):print(i)
for i in [j for j in range(add,n)][::-1]:print(i)
print(add-1)

Measured memory_bytes: 14052
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto n = readNum!int;
  auto w = readNums!int;

  int ans = 10001;
  foreach(i; 1 .. n){
    ans = min(ans, abs(w[0 .. i].sum - w[i .. $].sum));
  }

  writeln(ans);
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b,c = LI()
    if min(a,b) < c < max(a,b):
        print("Yes")
    else:
        print("No")
    return

#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#G
def G():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38512
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <sstream>

using namespace std;

typedef long long lint;

using namespace std;

void test_case() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); ++i) {
        ans += s[i]!=t[i];
    }
    cout << ans << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int tests=1;
    //cin >> tests;
    for(int test = 0; test < tests; ++test) {
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3808
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int A[5010];
int n;
int main()
{
  while(scanf("%d",&n)){
    if(n ==0)
      break;
  for(int i = 0;i < n;i++){
    cin>>A[i];
  }
  int ans = -(1<<25);
  for(int i = 0;i < n;i++){
    int sum = 0;
    for(int j = i;j <n;j++){
      sum +=A[j];
      ans =max(sum,ans);
    }
  }
  cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1260
//  cd Desktop/Atcoder
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define rep(i,n) for(i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

int main(){
    ll n,i,sq=0;
    scanf("%lld",&n);
    sq=(ll)sqrt(n);
    for ( i = sq; i > 0; i--) if (n%i==0)break;
    printf("%lld",i+(n/i)-2);
    return 0;
}

Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <climits>
#include <iterator>
#include <stack>
#include <deque>
#include <list>
#include <array>
#include <unordered_set>
#include <unordered_map>
using namespace std;
const long long MOD = 1e9 + 7;
int main()
{
	long long n, k;
	cin >> n >> k;
	long long w[n], sc[n];
	for (long long i = 0; i < n; i++)
	{
		cin >> w[i] >> sc[i];
	}

	long long dp[n + 1][k + 1];
	for (long long i = 0; i <= n; i++)
	{
		for (long long j = 0; j <= k; j++)
		{
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else if (w[i - 1] > j)
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = max(sc[i - 1] + dp[i - 1][j - w[i - 1]], dp[i - 1][j]);
		}
	}
	// for (long long i = 0; i < n + 1; i++)
	// {
	// 	for (long long j = 0; j < k + 1; j++)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }

	cout << dp[n][k];
}

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

const int maks = 1e6+5;
int arr[maks];
int a,d,n;
int sum ;
int main()
{
    cin >> n >> d >> a;
    for(int i=0;i<n;i++)cin >> arr[i];

    for(int i=0;i<n;i++)
    {
        if(d % arr[i] != 0)sum += d/arr[i] + 1;
        else sum += d/arr[i];
    }
    cout << sum + a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cstring>

#define HIT(a,b) ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)<(a.r+b.r)*(a.r+b.r))

using namespace std;

struct DISK {
	int x,y,r,c;
	int o;
} D[30];
int n;
set<int> dp;

int main(){
	int i,j,ans;
	set <int>::iterator it;
	while(cin>>n,n){
		memset(D, 0, sizeof(D));
		dp.clear();
		ans=0;
		
		for(i=0;i<n;i++) cin>>D[i].x>>D[i].y>>D[i].r>>D[i].c;

		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++)
				if(HIT(D[i],D[j])) D[j].o |= 1<<i;
		}

		dp.insert(0);
		for(it=dp.begin();it!=dp.end();it++){
			for(i=0;i<n-1;i++){
				if((*it >> i) & 1) continue;
				for(j=i+1;j<n;j++){
					if(D[i].c != D[j].c) continue;
					if((*it >> j) & 1) continue;

					if(~*it & D[i].o || ~*it & D[j].o) continue;
					dp.insert(*it | 1 << i | 1 << j);
					ans = max(ans, __builtin_popcount(*it | 1 << i | 1 << j ));
				}
			}
		}

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

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

int main()
{
    int n; cin >> n; int a[10000];
    for(int i=0; i<n; ++i) cin >> a[i];
    
    int mn=a[0], mx=a[0];
    long long sum=0;
    for(int i=0; i<n; ++i)
    {
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
        sum += a[i];
    }
    cout <<mn<<" "<<mx<<" "<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3136
/* E */
#include <bits/stdc++.h>
#define Fail puts("NO"), exit(0);
#define eps 1e-10
#define maxn 100010
#define maxm 4010
#define inf 1000000007
#define mod 1000000007
#define G 3
#define pi acos(-1)
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef bitset<maxn> bit;
int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch - '0' < 0 || ch - '0' > 9) {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch - '0' >= 0 && ch - '0' <= 9) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
int primesize, prime[maxn], miu[maxn];
bool notprime[maxn];
void init() {
    notprime[1] = 1;
    miu[1] = 1;
    for (int i = 2; i <= 100000; i++) {
        if (!notprime[i]) {
            prime[++primesize] = i;
            miu[i] = mod - 1;
        }
        for (int j = 1; j <= primesize && i * prime[j] <= 100000; j++) {
            notprime[i * prime[j]] = 1;
            if (i % prime[j] == 0) {
                miu[i * prime[j]] = 0;
                break;
            }
            miu[i * prime[j]] = mod - miu[i];
        }
    }
}
int n, K, ans;
int quick_pow(int x, int p) {
    int an = 1, po = x;
    while (p) {
        if (p & 1)
            an = 1ll * an * po % mod;
        po = 1ll * po * po % mod;
        p >>= 1;
    }
    return an;
}
int main() {
    init();
    n = read();
    K = read();
    for (int i = 1; i <= K; i++) {
        int sum = 0;
        for (int j = 1; j * i <= K; j++) {
            sum = (sum + 1ll * miu[j] * quick_pow(K / (i * j), n)) % mod;
        }
        ans = (ans + 1ll * sum * i) % mod;
    }
    cout << ans << endl;
    return 0;
}


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

#define lson(id) (id<<1)
#define rson(id) ((id<<1)|1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn=100003;
const ll inf=0x3f3f3f3f3f3f3f3f;

vector<pii> v[maxn];
ll f[maxn],lz[maxn<<2],mn[maxn<<2];
int n,m,a,b,c;

void pushup(int id){
	mn[id]=min(mn[lson(id)],mn[rson(id)]);
}

void change(int id,ll w){
	lz[id]=min(lz[id],w);
	mn[id]=min(mn[id],w);
}

void pushdown(int id){
	if(lz[id]!=inf){
		change(lson(id),lz[id]);
		change(rson(id),lz[id]);
		lz[id]=inf;
	}
}

void update(int id,int l,int r,int pos,ll w){
	if(l==r){
		change(id,w);
		return ;
	}
	int mid=(l+r)/2;
	pushdown(id);
	if(mid>=pos) update(lson(id),l,mid,pos,w);
	else update(rson(id),mid+1,r,pos,w);
	pushup(id);
}

ll query(int id,int l,int r,int L,int R){
	if(l>=L&&r<=R)return mn[id];
	if(l>R||L>r) return inf;
	int mid=(l+r)/2;
	pushdown(id);
	return min(query(lson(id),l,mid,L,R),query(rson(id),mid+1,r,L,R));
}

int main(){
	memset(f,0x3f,sizeof(f));
	memset(mn,0x3f,sizeof(mn));
	memset(lz,0x3f,sizeof(lz));
	f[1]=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		scanf("%d%d%d",&a,&b,&c);
		v[b].push_back(pii(a,c));
	}
	for(int i=1;i<=n;++i){
		for(int j=0;j<v[i].size();++j)
			f[i]=min(f[i],query(1,1,n,v[i][j].first,i-1)+v[i][j].second);
		update(1,1,n,i,f[i]);
	}
	printf("%lld\n",f[n]==inf?-1:f[n]);
	return 0;
}



Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	vector<ll> arr(n);
	ll count=0;
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	sort(arr.begin(),arr.end());
	for(ll i=0;i<n;i++)
		for(ll j=i+1;j<n;j++)
			for(ll k=j+1;k<n;k++)
			{
				if(arr[i]!=arr[j] && arr[j]!=arr[k])
				{
					if(arr[i]+arr[j]>arr[k])
						count++;
				}
			}
	cout<<count;
	return 0;
	
}

Measured memory_bytes: 3620
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include <string.h>
using namespace std;
int a[100005];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int sum = 0;
	int pre = 0;
	int mx = 0;
	for (int i = 1; i <= n; i++) {
		sum += abs(pre - a[i]);
		pre = a[i];
	}
	for (int i = 1; i <= n; i++) {

			cout << sum - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]) +abs(a[n])<< endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);

  if(a==b&&c==d||(a==c&&b==d)||(a==d&&b==c))printf("yes\n");
  else printf("no\n");
  return 0;
}


Measured memory_bytes: 2680
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        int len = int.Parse(ReadLine());

        List<Menu> menus = new List<Menu>(len);

        for (int i = 0; i < len; i++)
        {
            int[] input = MyUtil.ReadIntArray();
            menus.Add(new Menu(input[0], input[1]));
        }

        menus.Sort();
        menus.Reverse();

        long point_a = 0;
        long point_b = 0;

        for (int i = 0; i < len; i++)
        {
            if (i % 2 == 0)
            {
                point_a += menus[i].Point_a;
            }
            else
            {
                point_b += menus[i].Point_b;
            }
        }

        Console.WriteLine(point_a - point_b);
        Console.ReadKey();
    }
}

class Menu : IComparable
{
    public int Point_a { get; set; }
    public int Point_b { get; set; }
    public int Value { get; set; }

    public Menu(int a, int b)
    {
        Point_a = a;
        Point_b = b;
        Value = a + b;
    }

    public int CompareTo(object obj)
    {
        if (obj is Menu)
        {
            Menu x = (Menu)obj;
            return Value.CompareTo(x.Value);
        }
        else
        {
            throw new Exception();
        }
    }
}

static class MyUtil
{
    public static int[] ReadIntArray()
    {
        return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }
}


Measured memory_bytes: 23096
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	string S;
	cin >> S;
	if (S[0] == S[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3592
import numpy as np
N = int(input())
A = list(map(int, input().split()))
A = np.array(A)
count = 0
while 1:
    x = 0
    for i in range(N):
        if A[i] % 2 == 1:
            x = 1
    if x == 1:
        break
    else:
        A = A / 2
        count+=1
print(count)

Measured memory_bytes: 12392
N = int(input())
Position = [list(map(int,input().split())) for i in range(N)]
Position.insert(0,[0,0,0])
counter = 0
for i in range(N):
    td = Position[i+1][0] - Position[i][0]
    xd = abs(Position[i][1] - Position[i+1][1])
    yd = abs(Position[i][2] - Position[i+1][2])
    if td > xd+yd:
        if (td-(xd+yd))%2 != 0:
            break
    elif td < xd+yd:
        break
    counter += 1

if counter == N:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 27380
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define ppb pop_back
#define orta ((bas+son)>>1)
#define st first
#define nd second
#define ll long long
#define N 505
#define inf 1000000000
#define MOD 1000000007
#define LOG 29
#define EPS 0.000000001
#define M 305
using namespace std;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);	

	int a,b,m;
	cin>>a>>b>>m;
	vector<int> A(a+1),B(b+1);
	for(int i=1;i<=a;i++)
		cin>>A[i];
	for(int i=1;i<=b;i++)
		cin>>B[i];
	int ans=inf;
	for(int i=1;i<=m;i++) {
		int x,y,c;
		cin>>x>>y>>c;
		ans=min(ans,A[x]+B[y]-c);
	}
	sort(A.begin()+1,A.begin()+1+a);
	sort(B.begin()+1,B.begin()+1+b);
	ans=min(ans,A[1]+B[1]);
	cout<<ans;

}

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

#define lld long long
#define pp pair<int,int>
#define pb push_back
#define MOD 10007
#define left lleft
#define right rright
#define INF 2000000000
#define LINF 1000000000000000000LL
#define next nnext

using namespace std;

int N;
int a[100002];
char s[100002];

void process(){
	for(int i=2; i<N; i++){
		if(a[i] == 1){
			if(s[i-1] == 'o') a[i+1] = a[i-1];
			else a[i+1] = 3-a[i-1];
		}else{
			if(s[i-1] == 'o') a[i+1] = 3-a[i-1];
			else a[i+1] = a[i-1];
		}
	}
}

int main(){
	scanf("%d",&N);
	scanf("%s",s);
	for(a[1]=1; a[1]<=2; a[1]++){
		for(a[2]=1; a[2]<=2; a[2]++){
			process();
			bool flag = true;
			if(a[1] == 1){
				if(s[0] == 'o' && a[N] != a[2]) flag = false;
				else if(s[0] == 'x' && a[N] == a[2]) flag = false;
			}else{
				if(s[0] == 'o' && a[N] == a[2]) flag = false;
				else if(s[0] == 'x' && a[N] != a[2]) flag = false;
			}
			if(a[N] == 1){
				if(s[N-1] == 'o' && a[N-1] != a[1]) flag = false;
				else if(s[N-1] == 'x' && a[N-1] == a[1]) flag = false;
			}else{
				if(s[N-1] == 'o' && a[N-1] == a[1]) flag = false;
				else if(s[N-1] == 'x' && a[N-1] != a[1]) flag = false;
			}
			if(flag){
				for(int k=1; k<=N; k++) printf("%c",a[k]==1?'S':'W');
				puts("");
				return 0;
			}
		}
	}
	puts("-1");

	return 0;
}


Measured memory_bytes: 768
n = int(input())
a = [int(input()) - 1 for _ in range(n)]

count = 0
index = 0

while count < n:
  count += 1
  if a[index] == 1:
    break
  else:
    index = a[index]

if count != n:
  print(count)
else:
  print(-1)

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

int main() {
    int n;
    long long k;
    cin >> n >> k;
    vector<pair<long long, long long>> a(n);
    for (auto& e : a) cin >> e.first >> e.second;
    sort(a.begin(), a.end());
    
    long long seen = 0, ans;
    for (auto e : a) {
        long long c, v; tie(v, c) = e;
        if (seen + c < k) {
            seen += c;
        } else {
            ans = v;
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792