akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var S1 = ReadLine();
            var S2 = ReadLine();
            var ans = 1L;
            var pre = -1;//0:縦、1:横
            for (var i = 0; i < N; ++i)
            {
                if (S1[i] == S2[i])//縦に並ぶ
                {
                    if (pre == -1)//初期値
                        ans = 3;
                    else if (pre == 0)//縦→縦なら2通り
                        ans = ans * 2 % Mod;
                    else//横→縦なら固定
                        ans = ans;
                    pre = 0;
                }
                else//横に並ぶ
                {
                    if (pre == -1)//初期値は3*2
                        ans = 3 * 2;
                    else if (pre == 0)//縦→横なら2通り
                        ans = ans * 2 % Mod;
                    else//横→横なら3通り
                        ans = ans * 3 % Mod;
                    pre = 1;
                    ++i;
                }
            }
            WriteLine(ans);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28196
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
const int MOD = 1000000007;
#define MAX_N (100010)

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);

	if (N == 1) {
		printf("%d\n", M);
		return 0;
	}

	int res = 1;
	for (int i = 2; i <= M / N; i++) {
		int rest = M - (i * (N - 1));
		if (rest <= 0)
			break;
		if (rest % i == 0) {
			res = i;
		}
	}

	printf("%d\n", res);

	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
ww = []
tmp = 0
for i in range(n):
    if s[i] == 'W':
        tmp += 1
    ww.append(tmp)
ee = []
tmp = 0
for i in range(n)[::-1]:
    if s[i] == 'E':
        tmp += 1
    ee.append(tmp)
ee = ee[::-1]
a = [ee[0]] +  [ee[i+1] + ww[i-1] for i in range(1,n-1)] + [ww[-1]]
print(min(a))


Measured memory_bytes: 33160
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
	ll n;
	cin>>n;
	vector<ll> v;
	rep(i,0,n*3){
		ll a;
		cin>>a;
		v.pb(a);
	}
	sort(all(v));
	reverse(all(v));
	ll ans = 0;
	rep(i,0,2*n){
		if(i%2==1)ans += v[i];
	}
	printf("%lld\n",ans);	
	return 0;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
typedef long long int ll;
#define in insert 
#define rep(i,n) for (ll i = 0; i < n; i++)
#define  pb push_back
#define N 200001


 int main(){
  ll t;
  cin>>t;
   map<string,ll> m;
   m["WA"]++;
   m["TLE"]++;
   m["AC"]++;
   m["RE"]++;
  while(t--){
  string a;
  cin>>a;
  m[a]++;
  }
  cout<<"AC"<<" "<<"x"<<" "<<m["AC"]-1<<endl;
   cout<<"WA"<<" "<<"x"<<" "<<m["WA"]-1<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<m["TLE"]-1<<endl;
     cout<<"RE"<<" "<<"x"<<" "<<m["RE"]-1<<endl;
 }

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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  
  int a[n];
  int b[n];

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

  int diff[n];
  for (int i = 0; i < n; i++) {
    diff[i] = a[i] - b[i];
  }
  sort(diff, diff + n);

  long less = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (diff[i] < 0) {
      less += diff[i];
      cnt++;
    }
    else break;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (less >= 0) break;
    if (less < 0 && diff[i] <= 0) {
      cnt = -1;
      break;
    }
    less += diff[i];
    cnt++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1408
// https://atcoder.jp/contests/abc159/tasks/abc159_b

use proconio::input;

fn main() {
    input! { s: String, }
    println!("{}", if is_strong(&s) { "Yes" } else { "No" });
}

fn is_strong(s: &String) -> bool {
    let len = s.len();
    let a = &s[..len / 2];
    let b = &s[(len + 2) / 2..];
    let rev_a = a.chars().rev().collect::<String>();
    a.to_string() == rev_a && b.to_string() == rev_a
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000000 + 7;
#define endl '\n'
#define scan(s) scanf("\n%[^\n]", s);
#define rep(a) cout<<#a<<"-> ";for(int i=0;i<a.size();i++) cout<<i<<":"<<a[i]<<" ";cout<<endl;
#define val(a) cout<<#a<<"-> "<<a<<endl;
#define ok cout<<"ok"<<endl;
#define clock cout<<(double)clock()/CLOCKS_PER_SEC<<endl;
void solve()
{
	int x,y;
	cin>>x>>y;
	int left=2*x;
	int right=4*x;
	if((y%2==0 || y%4==0) && left<=y && y<=right) cout<<"Yes\n";
	else cout<<"No\n";
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N, A, B;
  while (cin >> N >> A >> B) {
    if (A + B - 1 > N || N > 1ll * A * B) {
      cout << -1 << endl;
      continue;
    }
    vector<vector<ll>> res(B);
    for (int i = 0; i < B; i++) {
      int j = B - i - 1;
      res[j].push_back(1ll * A * i);
    }
    int rem = N - B;
    for (int i = 0; i < B; i++) {
      int j = B - i - 1;
      for (int k = 1; k < A && rem > 0; k++, rem--) {
        res[j].push_back(1ll * A * i + k);
      }
    }
    vector<ll> xs;
    for (auto &vs : res) {
      for (auto x : vs) {
        xs.push_back(x);
      }
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    for (auto &vs : res) {
      for (auto x : vs) {
        int y = lower_bound(xs.begin(), xs.end(), x) - xs.begin() + 1;
        cout << y << " ";
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 15748
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 2100000000
#define MOD 1000000007

int main(){
  int N;
  cin>>N;
  vector<ll> a(3*N);
  for(int i=0;i<3*N;i++){
    cin>>a.at(i);
  }

  priority_queue<ll,vector<ll>,greater<ll>> A;
  priority_queue<ll> B;
  vector<ll> sum_A(N+1,0);
  for(int i=0;i<N;i++){
    sum_A.at(0)+=a.at(i);
    A.push(a.at(i));
  }
  for(int i=N;i<2*N;i++){
    ll x=A.top();
    if(a.at(i)>x){
      sum_A.at(i-N+1)=sum_A.at(i-N)+a.at(i)-x;
      A.pop();
      A.push(a.at(i));
    }else{
      sum_A.at(i-N+1)=sum_A.at(i-N);
    }
  }
  vector<ll> sum_B(N+1,0);
  for(int i=2*N;i<3*N;i++){
    sum_B.at(N)+=a.at(i);
    B.push(a.at(i));
  }
  for(int i=2*N-1;i>=N;i--){
    ll x=B.top();
    if(a.at(i)<x){
      sum_B.at(i-N)=sum_B.at(i-N+1)+a.at(i)-x;
      B.pop();
      B.push(a.at(i));
    }else{
      sum_B.at(i-N)=sum_B.at(i-N+1);
    }
  }

  ll ans=sum_A.at(0)-sum_B.at(0);
  for(int i=0;i<N+1;i++){
    ans=max<ll>(ans,sum_A.at(i)-sum_B.at(i));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6516
# -*- coding: utf-8 -*-

def f(k,a,b):
    if b-a<=0:
        return k+1
    elif k+1<a:
        return k+1
    else:
        res1 = k+1
        res2 = b
        k -= 1+a
        # print(k,res2)
        if k>0:
            res2 += (b-a)*(k//2)
            res2 += k%2
        elif k<0:
            res2 = -1
        return max(res1, res2)

def f2(k,a,b):
    k_ = k
    res = 1
    while k>0 and res<a:
        res += 1
        k -= 1
    res += (b-a)*(k//2)
    res += k%2
    return max(res, k_+1)

if __name__ == '__main__':
    k,a,b = map(int, input().split())
    print(f(k,a,b))

    # print(f(3,3,5))
    # from random import randint
    # for _ in range(1000):
    #     k = randint(1,100)
    #     a = randint(1,100)
    #     b = randint(1,100)
    #     res1 = f(k,a,b)
    #     res2 = f2(k,a,b)
    #     if res1!=res2:
    #         print(k,a,b)
    #         print(res1,res2)
    #         break


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    int a = 0, b = 0;
    char x,y,z;
    cin >>s;
    x=s.at(0);
    y=s.at(1);
    z=s.at(2);
    if(x == 'A')a+=1;
       else if(x == 'B')b+=1;
    if(y == 'A')a+=1;
       else if(y == 'B')b+=1;
    if(z == 'A')a+=1;
       else if(z == 'B')b+=1;
    
    if(a==3 || b==3) cout <<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		int i = 1;
		int a = x.nextInt();
		while(a != 0){
			System.out.println("Case " + i + ": " + a);
			a = x.nextInt();
			i++;
			
		}
	}

}

Measured memory_bytes: 33044
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
double EPS=1e-10;
int INF=1e9;
string sum(string a,string b){
      string res="";
      reverse(ALL(a));
      reverse(ALL(b));
      if(a.size()>b.size())swap(a,b);
      int k=0;
      REP(i,a.size()){
            int t=a[i]-'0'+b[i]-'0'+k;
            res+=(char)(t%10+'0');
            k=t/10;
      }
      for(int i=a.size();i<b.size();i++){
            int t=b[i]-'0'+k;
            res+=(char)(t%10+'0');
            k=t/10;
      }
      while(k>0){
            res+=(char)(k%10+'0');
            k/=10;
      }
      reverse(ALL(res));
      return res;
}
int main(){
      int n;
      cin>>n;
      while(n--){
            string a,b;
            cin>>a>>b;
            string ans=sum(a,b);
            if(ans.size()>80){
                  cout<<"overflow"<<endl;
            }else{
                  cout<<ans<<endl;
            }
      }
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<vector<ll>> v(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        v[i] = {a, b};
    }

    ll ret = 0;
    for (int i = 0; i <= 30; i++) {
        ll now = 0;
        for (auto x:v) {
            if ((k | x[0]) == k)now += x[1];
        }
        ret = max(ret, now);

        if (k & (1 << i)) {
            k ^= 1 << i;
            for (int j = i - 1; j >= 0; j--)k |= 1 << j;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 5760
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	vote := make([]int, n)
	sum := 0
	for i := range vote {
		vote[i] = nextInt()
		sum += vote[i]
	}
	//人気順にm個の得票数をチェック
	sort.Sort(sort.Reverse(sort.IntSlice(vote)))
	for i := 0; i < m; i++ {
		//条件を満たさない商品があった時点でNoを表示して終了
		if vote[i]*4*m < sum {
			fmt.Println("No")
			return
		}
	}
	//m個全て条件を満たした時のみYesを表示
	fmt.Println("Yes")
}


Measured memory_bytes: 640
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
 
using namespace std;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    long long mod = pow(10, 9) + 7;

    long long X, Y;

    cin >> X >> Y;

    if((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    long long r = (2 * X - Y) / 3;
    long long l = (2 * Y - X) / 3;

    if(r < 0 || l < 0) {
        cout << 0 << endl;
        return 0;
    }

    long long ans = 1;

    for(int i = l + 1; i <= l + r; i++) {
        ans *= i % mod;
        ans %= mod;
    }

    for(int i = 2; i <= r; i++) {
        ans *= modpow(i, mod - 2, mod);
        ans %= mod;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
const int INF = 1e9;
string s;

int main(void){
    cin >> s;
    int n = s.size()+1;
    vector<int> a(n, -1);
    if(s[0] == '>') a[0] = INF;
    else a[0] = 0;
    if(s[s.size()-1] == '>') a[n-1] = 0;
    else a[n-1] = INF;
    for(int i = 1; i < n-1; i++){
        if(s[i-1] == '<' && s[i] == '>') a[i] = INF;
        else if(s[i-1] == '>' && s[i] == '<') a[i] = 0;
    }
    for(int i = 0; i < n; i++){
        if(a[i] == 0){
            int j;
            j = 1;
            while(i-j > 0 && a[i-j] == -1){
                a[i-j] = j;
                j++;
            }
            j = 1;
            while(i+j < n && a[i+j] == -1){
                a[i+j] = j;
                j++;
            }
        }
    }
    lli res = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == INF){
            if(i == 0){
                a[i] = a[i+1]+1;
            }else if(i == n-1){
                a[i] = a[i-1]+1;
            }else{
                a[i] = max(a[i-1]+1, a[i+1]+1);
            }
        }
        res+=a[i];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5836
#include <stdio.h>
int main(){

  int a,b,n,r,i;

  scanf("%d",&n);

  for(i = 0; i < n; i++){

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

    r=a%b;
    if(r == 0) r=b;

    printf("%d\n",r);

  }

  return 0;

}

Measured memory_bytes: 596
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect

a,b,q=map(int,input().split())
s=[int(input()) for _ in range(a)]
t=[int(input()) for _ in range(b)]
x=[int(input()) for _ in range(q)] 

for start in x:
    res=[]
    start_s=bisect.bisect_left(s,start)
    start_t=bisect.bisect_left(t,start)
    if start_s<a and start_t<b:
        res.append(max(s[start_s]-start,t[start_t]-start))
    if start_s-1>-1 and start_t-1>-1:
        res.append(max(start-s[start_s-1],start-t[start_t-1]))
    if start_s<a and start_t-1>-1:
        res.append(2*(s[start_s]-start)+start-t[start_t-1])
        res.append(2*(start-t[start_t-1])+s[start_s]-start)
    if start_t<b and start_s-1>-1:
        res.append(2*(t[start_t]-start)+start-s[start_s-1])
        res.append(2*(start-s[start_s-1])+t[start_t]-start)
    print(min(res))

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

int main() {
    int s;
    cin >> s;
    cout << s/3600 << ":" << (s%3600)/60 << ":" << s%60 << endl;
    return 0;
}




Measured memory_bytes: 3092
#include<iostream>

int main(){
  int a;
  int b;
  int c;
  std::cin >> a >> b >> c;
  
  int tmp = b;
  b=a;
  a=tmp;
  
  tmp = c;
  c=a;
  a=tmp;
  
  std::cout << a << " " << b << " " <<c<< std::endl;
  
  return 0;
}

Measured memory_bytes: 256
from fractions import gcd
n=int(input())
A=list(map(int,input().split()))
L=[0]
R=[0]
for i in range(1,n):
	l=gcd(L[i-1],A[i-1])
	L.append(l)
	r=gcd(R[i-1],A[n-i])
	R.append(r)
G=[]
for i in range(n):
	g=gcd(L[i],R[n-1-i])
	G.append(g)
print(max(G))

Measured memory_bytes: 16132
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()

p = -Max
po = 0

pp = Max
ppo = 0


for i in range(n):
    if a[i] >= p:
        p = a[i]
        po = i+1
    if a[i] <= pp:
        pp = a[i]
        ppo = i+1

if abs(p) >= abs(pp):

    print(2*n-1)
    for i in range(1,n+1):
        print(po,i)
    for i in range(1,n):
        print(i,i+1)

else:

    print(2*n-1)
    for i in range(1,n+1):
        print(ppo,i)
    for i in range(n,1,-1):
        print(i,i-1)












Measured memory_bytes: 38516
#include<stdio.h>
#define MAX_N 10000

int linear_search(int n, int key, int *S)
{
  S[n] =  key;
  int i = 0;
  while (S[i] != key)
    i++;
  if (i < n)
    return i;
  return -1;
}
int main(void)
{
  int n, q;
  int S[MAX_N+1];

  // 入力処理
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d ", &S[i]);
  }
  scanf("%d", &q);
  
  int cnt = 0, key;
  for (int i = 0; i < q; i++) {
    scanf("%d ", &key);
    if (linear_search(n, key, S) != -1)
      cnt++;
  }

  printf("%d\n", cnt);
  return 0;

}
  



Measured memory_bytes: 2092
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();
            int e = sc.nextInt();
            int k = sc.nextInt();
            if(k >= b-a && k >= c-a && k >= d-a && k >= e-a&& k >= c-b && k >= d-b && k >= e-b && k >= d-c && k >= e-c && k >= e-d){
              System.out.println("Yay!");
            } else {
              System.out.println(":(");
            }
        }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}

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

#define INF 1e9
#define ll long long int
#define ff first
#define ss second


int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin>>s;
	int n=s.size();
	char x=s[n-1];
	
	if(x=='s')
	{
		cout<<s<<"es"<<'\n';
	}
	else
	{
		cout<<s<<"s"<<'\n';
	}
	
	return 0;
}

Measured memory_bytes: 3648
A, B, K = map(int, input().split())
list=[]
for i in range(A, A+K):
    if i < A+K and i <= B:
        list.append(i)
for i in range(B-K, B+1):
    if i > (B-K) and i >= A:
        list.append(i)
for i in sorted(set(list)):
    print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,m,k,t,cnt[3],c[maxn],edge;
bool vis[maxn],flag;
vector<pair<int,int>>e[maxn];
void dfs(int x,int y)
{
    cnt[y]++;
    c[x]=y;
    for(int i=0;i<e[x].size();i++)
    {
        int to=e[x][i].first,w=e[x][i].second;
        if(w==1)edge++;
        if(!vis[to])
        {
            vis[to]=true;
            dfs(to,(y+w)%3);
        }
        else if(c[to]!=(y+w)%3)flag=false;
    }
}
int main()
{
    int i,j;
    scanf("%d%d",&n,&m);
    while(m--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        e[x].push_back({y,1}),e[y].push_back({x,2});
    }
    long long ret=0;
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            vis[i]=true;
            cnt[0]=cnt[1]=cnt[2]=0;
            flag=true;
            edge=0;
            dfs(i,0);
            if(!flag)
            {
                ret+=1LL*(cnt[0]+cnt[1]+cnt[2])*(cnt[0]+cnt[1]+cnt[2]);
            }
            else if(!cnt[2]||!cnt[1]||!cnt[0])
            {
                ret+=edge;
            }
            else ret+=1LL*cnt[0]*cnt[1]+1LL*cnt[1]*cnt[2]+1LL*cnt[2]*cnt[0];
        }
    }
    printf("%lld\n",ret);
    return 0;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(x,n) for(int i=x;i<n;i++)
#define REP(y,n) for(int j=y;j<n;j++)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
signed main(){
  double x1,x2,y1,y2;
  double distance;
  cin>>x1>>y1>>x2>>y2;
  double x,y;
  x=abs(x1-x2);
  y=abs(y1-y2);
  distance=sqrt(x*x+y*y);
  printf("%.7f",distance);
}



Measured memory_bytes: 3276
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

ll N;

signed main(){
    cin >> N;
    for(ll i=1; i<=3500; i++){
        for(ll j=1; j<=3500; j++){
            ll tmp = 4*i*j-N*i-N*j;
            if(tmp <= 0) continue;
            if(tmp > 0 && N*i*j%tmp == 0){
                cout << i << " " << j << " " << N*i*j/tmp << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

int main()
{
    int H, W, K;
    io >> H >> W >> K;
    vvi grid(H, vi(W));
    for (int h = 0; h < H; h++)
    {
        string line;
        io >> line;
        for (int w = 0; w < W; w++)
        {
            grid[h][w] = (line[w] == '#') ? 1 : 0;
        }
    }

    int ans = 0;
    for (int bit_h = 0; bit_h < (1 << H); bit_h++)
    {
        for (int bit_w = 0; bit_w < (1 << W); bit_w++)
        {
            int black = 0;
            for (int h = 0; h < H; h++)
            {
                for (int w = 0; w < W; w++)
                {
                    if (!((bit_h & (1 << h)) || (bit_w & (1 << w))) && grid[h][w])
                    {
                        ++black;
                    }
                }
            }
            if (black == K)
            {
                ++ans;
            }
        }    
    }
    
    io << ans << BR;
}

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

using namespace std;

//#define FILE_IO

const int INF = 1 << 30;

int N, M;
int v[100005];
int lft[100005], rgt[100005], par[100005];
vector <int> edg[100005];

void DFS(int nod, int fth)
{
    lft[nod] = -INF;
    rgt[nod] = INF;
    par[nod] = -1;
    if(v[nod] != -1)
    {
        lft[nod] = rgt[nod] = v[nod];
        par[nod] = v[nod] & 1;
    }

    for(auto nxt: edg[nod])
    {
        if(nxt == fth)  continue;

        DFS(nxt, nod);
        lft[nod] = max(lft[nod], lft[nxt] - 1);
        rgt[nod] = min(rgt[nod], rgt[nxt] + 1);
        if(par[nxt] != -1)
        {
            if(par[nod] == -1)
                par[nod] = 1 ^ par[nxt];
            if(par[nod] == par[nxt])
            {
                printf("No\n");
                exit(0);
            }
        }
    }

    if(lft[nod] > rgt[nod])
    {
        printf("No\n");
        exit(0);
    }
}

void solve(int nod, int fth)
{
    if(v[nod] == -1)
    {
        if( lft[nod] <= v[fth] - 1 && v[fth] - 1 <= rgt[nod] )
            v[nod] = v[fth] - 1;
        else if( lft[nod] <= v[fth] + 1 && v[fth] + 1 <= rgt[nod] )
            v[nod] = v[fth] + 1;
        else
        {
            printf("No\n");
            exit(0);
        }
    }

    for(auto nxt: edg[nod])
    {
        if(nxt == fth)  continue;
        solve(nxt, nod);
    }
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i < N; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        edg[x].push_back(y);
        edg[y].push_back(x);
    }

    for(int i = 1; i <= N; i++)
        v[i] = -1;

    scanf("%d", &M);
    for(int i = 1; i <= M; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        v[x] = y;
    }

    DFS(1, 0);

    if(v[1] == -1)
    {
        v[1] = lft[1];
        if(par[1] != -1 && v[1] % 2 != par[1])
            v[1]++;
        if(v[1] > rgt[1])
        {
            printf("No\n");
            return 0;
        }
    }
    solve(1, 0);

    printf("Yes\n");
    for(int i = 1; i <= N; i++)
        printf("%d\n", v[i]);

    return 0;
}


Measured memory_bytes: 14208
// Problem : A - Lucky 7
// Contest : AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	
	while(n != 0){
		if (n % 10 == 7){
			cout << "Yes" << endl;
			return 0;
		}
		n = n / 10;
	}
	cout << "No" << endl;
	return 0;	
}


Measured memory_bytes: 3588
N = int(input())
A = [int(input()) for _ in range(N)]

i = 1
cnt = 0
while i != 2 and cnt <= N:
  cnt += 1
  i = A[i-1]
  if i == 2:
    break

if i == 2:
  print(cnt)
else:
  print(-1)

Measured memory_bytes: 7084
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
ll Gcd(ll a, ll b) {
	if (a % b == 0) return b;
	else return Gcd(b, a%b);
}
 
int main() {
	int k;
	cin >> k;
	ll sum = 0;
	for(int a = 1; a <= k; a++){
		for(int b = 1; b <= k; b++){
			for(int c = 1; c <= k; c++){
				sum += Gcd(Gcd(a,b),c);
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>

int dp[20001];

int main(void) {
	int H, N, arr[1001][2], i, j, m = 987654321;
	scanf("%d %d", &H, &N);
	for(i=0; i<N; i++)
		scanf("%d %d", &arr[i][0], &arr[i][1]);

	for (i = 1; i < 20001; i++)
		dp[i] = 987654321;
	
	for (i = 0; i <= H; i++)
	{
		for (j = 0; j < N; j++)
		{
			if (dp[i + arr[j][0]] > dp[i] + arr[j][1])
				dp[i + arr[j][0]] = dp[i] + arr[j][1];
		}
	}
	
	for (i = H; i < 20001; i++)
	{
		if (m > dp[i])
			m = dp[i];
	}
	
	printf("%d", m);
	return 0;
}

Measured memory_bytes: 256
/*
~Like a small boat
~On the ocean
~Sending big waves
~Into motion
!Like how a single word
!Can make a heart open
!I might only have one match
!But I can make an explosion
#And all those things I didn't say
#Wrecking balls inside my brain
#I will scream them loud tonight
#Can you hear my voice this time?
@This is my fight song
@Take back my life song
@Prove I'm alright song
@My power's turned on
$Starting right now I'll be strong
$I'll play my fight song
$And I don't really care if nobody else believes
$'Cause I've still got a lot of fight left in me!!!
*/

#include "bits/stdc++.h"
using namespace std;

#define  F  first
#define  S  second
#define  pb push_back
#define  mp make_pair
#define  sz(s) (int)s.size()
typedef long long int ll;
const int N = 1e5+5;

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

    ll a,b;cin>>a>>b;
    if( a<=0&&b>=0 )cout<< "Zero\n";
    else if( (a>0&&b>0)||(b-a)%2==1 )cout<< "Positive\n";
    else cout<< "Negative\n";



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int wr;
int dp[1000001];
int a[1000001];
int it;

int fr(int p){
	if (p==it-1){
        return 0;
	}
	if(dp[p]!=-1){
        return dp[p];
	}
	int re=abs(a[p]-a[p+1])+fr(p+1);
	for(int i=2;i<=wr;i++){
		if(p+i<it){
      re=min(re,abs(a[p]-a[p+i])+fr(p+i));
    }
	}
	return dp[p]=re;
}
int main(){
	cin>>it>>wr;
	for(int i=0;i<it;i++){
      cin>>a[i];
    }
	memset(dp, -1, sizeof dp);
	cout<<fr(0)<<endl; //arreglar
	return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>num(1e5+10);
  for(int i=0;i<n;i++){
    int a;cin>>a;
    num[a]++;
  }
  int cnt=0;
  sort(num.begin(),num.end(),greater<int>());
  for(int i=0;i<n;i++){
    if(num[i]>0)cnt++;
  }
  if(cnt%2)
    cout<<cnt<<endl;
  else
    cout<<cnt-1<<endl;
  return 0;
}


Measured memory_bytes: 768
#include<stdio.h>

int main(void){

	int turn,i,j,mysco,yoursco,even=0;
	int win[2]={0};
	char myca[100],yourca[100];

	scanf("%d",&turn);

	for(i=0;i<turn;i++){
		scanf("%s %s",myca,yourca);
		for(j=0;j<100;j++){
			if(myca[j]=='\0'&& yourca[j]=='\0'){
				even+=1;
				break;
			}
			if(myca[j]>yourca[j]){
				win[0]+=1;
				break;
			}
			else if(myca[j]<yourca[j]){
				win[1]+=1;
				break;
			}
		}
	}
	mysco=(win[0]*3)+even;
	yoursco=(win[1]*3)+even;
	printf("%d %d\n",mysco,yoursco);
	return 0;
}

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

int main() {
  int n;
  int x[100] ={};
  cin >> n;
  rep(i,n) cin >> x[i];

  int sum_x = 0 ,p;
  rep(i,n) sum_x += x[i];
  p = sum_x / n;

  int power[2]={};
  rep(i,2){
    rep(j,n) power[i] += (x[j] - (p+i))*(x[j] - (p+i));
  }
  if(power[0]>power[1]) power[0]=power[1];

  cout << power[0] << endl;
}

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

int D, N;
int T[256];
int A[256], B[256], C[256];
int memo[256][256];

int dfs(int day, int b) {
  if (day == D) return 0;
  if (memo[day][b] != -1) return memo[day][b];

  int &res = memo[day][b];
  for (int i = 0; i < N; ++i) {
    if (A[i] <= T[day] && T[day] <= B[i]) {
      res = max(res, dfs(day + 1, C[i]) + abs(b - C[i]));
    }
  }

  return res;
}

int main() {
  cin >> D >> N;
  for (int i = 0; i < D; ++i) cin >> T[i];
  for (int i = 0; i < N; ++i) cin >> A[i] >> B[i] >> C[i];
  memset(memo, -1, sizeof(memo));

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (A[i] <= T[0] && T[0] <= B[i]) {
      ans = max(ans, dfs(1, C[i]));
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3352
using System;
using System.Collections;
using System.Collections.Generic;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().run();
        return 0;
    }


    int[] vy = new int[] { -1, 0, 1, 0 };
    int[] vx = new int[] { 0, 1, 0, -1 };

    void run()
    {
        int T = int.Parse(Console.ReadLine());
        for (int test = 0; test < T; test++)
        {
            int N = int.Parse(Console.ReadLine());
            int[, ] board = new int[N, N];
            for (int i = 0; i < N; i++)
            {
                board[i, 0] = 1;
            }
            int y = 0;
            int x = 0;
            int k = 1;
            for (int i = N - 1; i > 1; i-=2)
            {
                for (int j = 0; j < 2; j++)
                {
                    for (int l = 0; l < i; l++)
                    {
                        y = y + vy[k];
                        x = x + vx[k];
                        board[y, x] = 1;
                    }
                    k = (k + 1) % 4;
                }
            }
            if (N % 2 == 0)
            {
                y = y + vy[k];
                x = x + vx[k];
                board[y, x] = 1;
            }
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    if (board[i, j] == 0) Console.Write(" ");
                    else Console.Write("#");
                }
                Console.WriteLine();
            }
            if(test != T-1) Console.WriteLine();
        }
    }
}

Measured memory_bytes: 5440
T = int(input())
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
def check(a, b, c, d):
    if b > a or d < b:
        return 0
    g = gcd(b, d)
    k = (a - c - 1) // g
    p = a - k*g
    if p - b < 0:
        return 0
    return 1

for _ in range(T):
    a, b, c, d = map(int, input().split())
    print("Yes" if check(a, b, c, d) else "No")


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

#define ll long long
#define scl(n) scanf("%lld",&n)
#define scd(n) scanf("%d",&n)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

ll ara[1005][2],dp[100005],inf=1e18;

int main()
{

    ll n,m,i,j,k,a,b,c,x,y,z,ans=1e18;
    cin>>m>>n;
    for(i=1;i<=n;i++)
    {
        scl(ara[i][0]);
        scl(ara[i][1]);
    }
    z=m+10002;
    for(i=0;i<=z;i++)
        i==0?dp[i]=0:dp[i]=inf;
    for(i=1;i<=n;i++)
    {
        a=ara[i][0];
        b=ara[i][1];
        for(j=1;j<=z;j++){
            if(j<a)
                continue;
            if(dp[j-a]==inf)
                continue;
            dp[j]=min(dp[j],dp[j-a]+b);
            //cout<<i<< "   "<<j<<" "<<dp[j]<<endl;
            if(j>=m)
                ans=min(ans,dp[j]);
        }
    }
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 384
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    A, B = map(str, input().split())

    #output
    A = int(A)
    C = int(B[0])
    D = int(B[2])
    E = int(B[3])

    print(A * (100*C + 10*D + E) // 100)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 61992
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i){ return i/2;}
int left(int i){ return 2*i;}
int right(int i){ return 2*i + 1;}

int main(){
  int H, i, A[MAX+1];

  cin >> H;
  for(i=1;i<=H;i++) cin >> A[i];

  for(i=1;i<=H;i++){
    cout << "node " << i << ": key = " << A[i] << ", ";
    if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
    if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
    if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
    cout << endl;
  }
  
  return 0;
}



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

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

	int n,m;

	cin >> n >> m;

	int x = 1900*m + 100*(n-m);
	x*=pow(2,m);

	cout << x << '\n';

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){

  int a,b,c,i,count=0;
  
  scanf("%d %d %d",&a,&b,&c);

  for(i=a;i<=b;i++){
    if((c%i)==0){
      count++;
    }
  }

  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e6+3;

ll d1[1001000],d2[1001000];

ll mult(ll n,ll m){//n^m%modを求める
    if(m==1){
        return n%mod;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%mod;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%mod;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin>>q;
    d1[0]=1;
    d2[0]=1;
    FOR(i,1,1000011){
      d1[i]=d1[i-1]*i;
      d1[i]%=mod;
      d2[i]=mult(d1[i],mod-2);
    }
    rep(i,q){
      ll x,d,n;
      cin>>x>>d>>n;
      if(d==0){
        cout<<mult(x,n)<<endl;
        continue;
      }
      ll ans=mult(d,n);
      ll a=x*mult(d,mod-2);
      a%=mod;
      ll b=a-1;
      a+=n-1;
      if(a/mod-b/mod>=1) ans=0;
      else{
        a%=mod;
        (ans*=d1[a])%=mod;
        if(b!=0) (ans*=d2[b])%=mod;
      }
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 16512
/* A Heap */
#include <stdio.h>
int main(){
  int heap_size;
  int pk,lk,rk;
  int i;

  scanf("%d",&heap_size);
  int A[heap_size+1];

  /* scan A[1...heap_size] */
  for(i=1;i<=heap_size;i++){
    scanf("%d",&A[i]);
  }

  /* print */
  for(i=1;i<=heap_size;i++){
    if(i>1)printf("\n");
    printf("node %d: ",i);

    printf("key = %d, ",A[i]);

    pk=i/2;
    if(pk>0)printf("parent key = %d, ",A[pk]);

    lk=2*i;
    if(lk<=heap_size)printf("left key = %d, ",A[lk]);
    else continue;    /* If left key doesn't exist, right key doesn't exist too. */

    rk=2*i+1;
    if(rk<=heap_size)printf("right key = %d, ",A[rk]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 0
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

def bisearch(l,key):
    left = 0
    right = len(l)
    while left < right:
        mid = (left + right) // 2
        if l[mid] == key:
            return 1
        elif key < l[mid]:
            right = mid
        else:
            left = mid + 1
    return 0

ans = 0
for i in t:
    ans += bisearch(s,i)

print(ans)


Measured memory_bytes: 16708
# coding: utf-8
import sys
import collections

def main():
	n, quantum = map(int, raw_input().split())
	processes = [x.split() for x in sys.stdin.readlines()]
	for p in processes:
		p[1] = int(p[1])
	queue = collections.deque(processes)
	elapsed = 0
	while queue:
		# print elapsed, queue
		head = queue.popleft()
		if head[1] > quantum:
			head[1] -= quantum
			queue.append(head)
			elapsed += quantum
		else:
			elapsed += head[1]
			print head[0], elapsed

if __name__ == '__main__':
	main()

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

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

    int l0 = 0;
    int l1 = 1;
    int ans0 = 0;
    int ans1 = 0;
    rep(i, s.size()) {
        if (l0 != int(s.at(i) - '0'))
            ans0++;
        if (l1 != int(s.at(i) - '0'))
            ans1++;

        l0 ^= 1;
        l1 ^= 1;
    }
    cout << min(ans0, ans1) << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int[] alist = new int[N];
    
    for(int i=0; i<N;i++){
      
      alist[i]=sc.nextInt();
    }
    
    Arrays.sort(alist);
    
    int diff = alist[N-1]-alist[0];
    
    System.out.println(diff);
  }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin>>N>>M;

  int G[101][101] = {};
  for(int i=0;i<M;i++){
    int s, t;
    cin>>s>>t;
    G[s][t] = 1;
  }

  int used[101] = {};
  int ans = 0;
  function <void(int)> dfs = [&](int pos){
    if(used[pos] == 2) return;
    if(used[pos] == 1) ans = 1;
    if(ans == 1) return;
    used[pos] = 1;
    
    for(int to=0;to<N;to++){
      if(G[pos][to] == 0) continue;
      dfs(to);
    }
    used[pos] = 2;
  };

  for(int i=0;i<N;i++) dfs(i);
  cout<<ans<<endl;     

  return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include<bits/stdc++.h>
const int P=2e5;
const int Q=2e5+2;
#define FOR(i,a,b) for (i = (a); i < (b); i++)
#define ROF(i,a,b) for (i = (a); i > (b); i--)
int k=0,x,i,n;
char s[55];
using namespace std;
int main()
{
    cin>>n;
    for(i=0;i<n;i++)
        cin>>s[i];
    FOR(i,0,n-2)
    {
        if(s[i]=='A'&&s[i+1]-s[i]==1&&s[i+2]-s[i]==2) k++;
    }
    cout<<k;
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 256
# A_1からスタートして、同じA_iに戻ってくるまでの[移動回数][到着場所]をリスト化

import sys
readline = sys.stdin.readline

N,K = map(int,readline().split())
A = list(map(int,readline().split()))

route = [0]
visited = {0}
while True:
  nex = A[route[-1]] - 1
#  print(route[-1]," -> ",nex)
  if nex in visited:
#    print(nex,"is already visited")
    loopstart = route.index(nex)
#    print("loopstart =",loopstart)
    break
  else:
    visited.add(nex)
    route += [nex]
    
#print("route",route)

before_loop,one_loop = route[:loopstart],route[loopstart:]
#print("before_loop",before_loop)
#print("one_loop",one_loop)

if K <= len(before_loop) - 1:
  print(before_loop[K] + 1)
else:
  K -= len(before_loop)
  K %= len(one_loop)
  print(one_loop[K] + 1)


Measured memory_bytes: 36588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const ll MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  V<int> a(n);
  rep(i, n) cin >> a[i];

  map<int, int> m;
  rep(i, n) m[a[i]]++;

  ll ans = 1;
  if (n % 2 != 0 && m[0] != 1) ans = 0;
  if (n % 2 == 0 && m[0] != 0) ans = 0;
  m.erase(0);
  for (auto e : m) {
    if (e.second != 2) ans = 0;
    ans = ans * 2 % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6692
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1e5 + 10;
#define singleCase
// #define multipleCase
int n;
bool rmark[N],mark[N],vis[N];

void dfs(int x , int elm , vector <int> &v) {
   if (x < 0 || x >= n) return;
   if (vis[x]) return;
   if (v[x] != elm) return;
   vis[x] = 1;
   dfs(x + 1 , elm , v);
   dfs(x - 1 , elm , v);
   return;
}

void work() {
   in(n);
   vector <int> inp(n);
   for (int i = 0 ; i < n ; i++) {
      in(inp[i]);
   }
   vector <int> v;
   for (int i = 0 ; i < n ; i++) {
      if (!vis[i]) {
         dfs(i , inp[i] , inp);
         v.pb(inp[i]);
      }
   }
   vector <int> r;
   for (int i = 1 ; i < v.size() ; i++) {
      if (v[i] > v[i - 1]) {
         r.pb(1);
      } else if (v[i] < v[i - 1]) {
         r.pb(2);
      } else {
         r.pb(3);
      }
   }
   if (n > 1 && r[0] == 3) r[0] = r[1];
   for (int i = 1 ; i < r.size() ; i++) {
      if (r[i] == 3) r[i] = r[i - 1];
      if (rmark[i]) continue;
      if (r[i] == 3 || r[i - 1] == 3) continue;
      if (r[i] != r[i - 1]) {
         rmark[i + 1] = 1;
         mark[i] = 1;
      }
   }
   mark[v.size()] = 1;
   int sol = 0;
   for (int i = 0 ; i <= v.size() ; i++) {
      sol += mark[i];
   }
   printf("%d\n" , sol);
   return;
}

int main() {
   #ifdef multipleCase
      int nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(int &x) {
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 4896