akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import bisect

def solve(s):
    n = len(s)
    if n % 2 == 1:
        return False
    for i in range(0, n, 2):
        if s[i:i+2] != 'hi':
            return False
    return True

def main():
    if solve(input()):
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


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

int main() {
  
  int n; cin >> n;
  
  int card[4][13] = {
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  };
  
  for (int i = 0; i < n; i++) {
    
    char mark; int num; cin >> mark >> num;
    
    if (mark == 'S') card[0][num - 1] = 1;
    if (mark == 'H') card[1][num - 1] = 1;
    if (mark == 'C') card[2][num - 1] = 1;
    if (mark == 'D') card[3][num - 1] = 1;
    
  }
  
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (card[i][j] == 0) {
        if (i == 0) cout << 'S' << " " << j + 1 << endl;
        if (i == 1) cout << 'H' << " " << j + 1 << endl;
        if (i == 2) cout << 'C' << " " << j + 1 << endl;
        if (i == 3) cout << 'D' << " " << j + 1 << endl;
      }
    }
  }
  
}


Measured memory_bytes: 3092
let sum = List.fold_left (+) 0;;
let read_int_ln _ = read_line () |> int_of_string;;

let () =   
	let (n, m) = Scanf.sscanf(read_line()) "%d %d" (fun x y -> (x, y)) in
	let rec get_a a i = 
		if i = n then List.rev a
		else (
			let row = Str.split (Str.regexp " ") (read_line ()) 
					 |> List.map int_of_string 
			in get_a (row :: a) (i + 1)
		) in
	let rec get_b b j = 
		if j = m then List.rev b 
		else get_b (read_int_ln () :: b) (j + 1) in 
	let a_vec = get_a [] 0 in
	let b_vec = get_b [] 0 in
	let solve a_row = List.map2 ( * ) a_row b_vec |> sum |> Printf.printf "%d\n" in
	List.iter solve a_vec
;;


Measured memory_bytes: 4312
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] l = new int[n];
    int max = 0;
    int pnt = -1;
    for(int i = 0;i<n;i++){
      l[i] = sc.nextInt();
      if(max < l[i]){
        max = l[i];
        pnt = i;
      }
    }
    int total = 0;
    for(int i = 0;i<n;i++){
      if(i == pnt)continue;
      total+=l[i];
    }
    if(max<total){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35784
import collections
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)
N = int(input())
S = list(input())
Q = int(input())
alpha = "abcdefghijklmnopqrstuvwxyz"
d = dict()

for x in alpha:
    d[x] = ord(x) - 97


class segment_tree:
    n = 0
    segtree = []

    def __init__(self, A):
        N = len(A)
        self.n = (N-1).bit_length()
        self.n = 1 << self.n
        self.segtree = [0 for i in range(2*self.n)]
        for i in range(N):
            self.segtree[self.n+i-1] = 1 << d[A[i]]
        for i in range(self.n - 2, -1, -1):
            self.segtree[i] = self.segtree[i*2 + 1] | self.segtree[i*2 + 2]

    def update(self, i, x):
        id = self.n+i - 1
        self.segtree[id] = 1 << d[x]
        while(id > 0):
            id = (id - 1) // 2
            self.segtree[id] = self.segtree[id *
                                            2 + 1] | self.segtree[id*2 + 2]

    def query(self, a, b, k, l, r):
        if r <= a or l >= b:
            return(0)
        if a <= l and r <= b:
            return(self.segtree[k])
        else:
            vl = self.query(a, b, k*2+1, l, (l+r)//2)
            vr = self.query(a, b, k*2+2, (l+r)//2, r)
            return(vl | vr)


def popcount(x):
    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f  # 8bitごと
    x = x + (x >> 8)  # 16bitごと
    x = x + (x >> 16)  # 32bitごと
    x = x + (x >> 32)  # 64bitごと = 全部の合計
    return x & 0x0000007f


ST = segment_tree(S[:-1])
N = (N-1).bit_length()
N = 1 << N

for _ in range(Q):
    t, a, b = input().split()

    if t == "1":
        a = int(a)
        ST.update(a-1, b)
    elif t == "2":
        a = int(a)
        b = int(b)
        ret = ST.query(a-1, b, 0, 0, N)
        print(popcount(ret))

    # print(ST.segtree)


Measured memory_bytes: 51616
#define NDEBUG
#include<deque>
#include<functional>
#include<utility>
#include<cstddef>
#include<cassert>

template<typename T, class Compare = std::less<T>>
class SlidingMinimum{
public:
	using value_compare = Compare;
	using value_type = T;
private:
	using size_type = std::size_t;
	using container_type = std::deque<std::pair<const value_type, size_type>>;
	container_type c;
	value_compare comp;
public:
	SlidingMinimum(const value_compare &x = value_compare()) :comp(x){}
	const value_type &top()const{
		return c.front().first;
	}
	const size_type top_index()const{
		return c.front().second - 1;
	}
	void push(const value_type &x){
		size_type s = 1;
		while (!c.empty() && comp(x, c.back().first)){
			s += c.back().second;
			c.pop_back();
		}
		c.push_back(std::pair<const value_type, size_type>(x, s));
	}
	void push(value_type &&x){
		size_type s = 1;
		while (!c.empty() && comp(x, c.back().first)){
			s += c.back().second;
			c.pop_back();
		}
		c.push_back(std::pair<const value_type, size_type>(std::move(x), s));
	}
	void pop(){
		assert(!c.empty());
		if (!(--c.front().second))
			c.pop_front();
	}
};


#include<cstdio>
#include<utility>

int main(){
	int n, l;
	scanf("%d%d", &n, &l);
	SlidingMinimum<int> S;
	int a;
	n -= l;
	while (l--){
		scanf("%d", &a);
		S.push(a);
	}
	printf("%d", S.top());
	while (n--){
		S.pop();
		scanf("%d", &a);
		S.push(a);
		printf(" %d", S.top());
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    ll a, b ,c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if (a >= k) ans = k;
    else if (a+b >= k) ans = a;
    else ans = 2*a + b - k;
    cout << ans << endl;
}

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

#define N 100


int main(){
  int i, j, k, n, a[N], v;

  scanf("%d", &n);


  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);

  for(i = 0; i < n; i++){
    if(i < n - 1)
      printf("%d ", a[i]);

    else
      printf("%d", a[i]);
  }

  printf("\n");
   

  for(i = 1; i < n; i++){
    v = a[i];
    j = i - 1;

    while(j >= 0 && a[j] > v){
      a[j + 1] = a[j];
      j--;
    }

    a[j + 1] = v;

    for(k = 0; k < n; k++){
      if(k < n - 1)
	printf("%d ", a[k]);

      else
	printf("%d", a[k]);
    }

      

    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2072
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap());
    let a = it.next().unwrap();
    let b = it.next().unwrap();
    let c = it.next().unwrap();
    if a == b {
        println!("{}", c);
    } else if b == c {
        println!("{}", a);
    } else {
        println!("{}", b);
    }
}


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

inline long long read(){
	long long s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

int main(){
	int n = read(), m = read();
	if (n >= 10){
		cout << m;
		return 0;
	}
	cout << m + 100 * (10-n);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
l = len(str(n))

if l == 6:
    ans = 90909
elif l == 5:
    ans = 909 + n - 10000 + 1
elif l == 4:
    ans = 909
elif l == 3:
    ans = 9 + n - 100 + 1
elif l == 2:
    ans = 9
else:
    ans = n 
print(ans)

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

int main(){
  int n,x;
  cin >> n >> x;
  int l[n];
  rep(i,n){cin >> l[i];}
  
  int bound=1,num=0l;
  for(int i=0; i<n; i++){
    int sum = 0;
    for(int j=0; j<=num; j++){
      sum += l[j];
    }
    if(sum<=x) bound++;
    num++;
  }
  cout << bound << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(10)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll a;
  cin>>a;
  string s;
  cin>>s;ll p=0;
  for(ll i=0;i<s.length();i++)
  {
  	if(s[i]=='.')
  	{
  		p=i;
  		break;
  	}
  }
  ll r=0;
  fo(i,p)
  	r=(r*10)+(ll)(s[i]-'0');
  ll q=0;
  for(ll i=p+1;i<s.length();i++)
  	q=(q*10)+(ll)(s[i]-'0');
  ll ans=r*a;
  ans=ans+(q*a)/100;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
struct node{
	int zhi;
	int xu;
}a[100001];
bool comp(node x,node y)
{
	return x.zhi<y.zhi;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].zhi;
		a[i].xu=i;
	}
	sort(a+1,a+n+1,comp);
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		
		if(i%2!=a[i].xu%2)sum++;
	}
	cout<<sum/2;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var H = r[0].ToInt();
            var N = r[1].ToInt();
            var r2 = ReadSplit();
            var ar = new int[N];
            for (int i = 0; i < N; i++)
            {
                ar[i] = r2[i].ToInt();
            }
            if (H <= ar.Sum())
            {
                Write("Yes");
                return;
            }
            Write("No");
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
            Read();
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 18528
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.string;
import std.conv;
import std.typecons;
import std.math;

void main(){
    string s = readln().chomp();
    string t = readln().chomp();
    solve(s,t).writeln();
}

string solve(string s,string t){
   string result;
   string doubleS = s ~ s;
   result = !find(doubleS, t).empty ? "Yes" : "No";

   return result; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ld=long double;
 
 
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    for(int i=0;i<n;i++)
    cin>>b[i];
    int sum=0;
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            sum+=(a[i]-b[i]);
            //cout<<a[i]<<" "<<b[i]<<endl;
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include <complex>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;

const double EPS = 1e-14;
typedef complex<long double> P;
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

long long pow_binary_mod(long long x,long long y,long long M){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=z*x%M;
		x=x*x%M;
	}
	return z;
}

int main(){
	int M=998244353;
	int N,x,y;
	scanf("%d",&N);
	vector<P>v(N);
	int r=pow_binary_mod(2,N,M);
	set<L>se;
	for(int i=0;i<N;i++)scanf("%d%d",&x,&y),v[i]={(double)x,(double)y};
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
		//if(se.find({i,j})!=se.end())continue;
		L l(v[i],v[j]);
		vector<int>x={i,j};
		for(int k=0;k<N;k++)if(k!=i&&k!=j&&intersectSP(l,v[k]))x.push_back(k);
		r=(r-pow_binary_mod(2,x.size()-2,M))%M;
		for(int a=0;a<x.size();a++)for(int b=a+1;b<x.size();b++){
			//se.emplace(x[a],x[b]);
		}
	}
	printf("%d\n",((r-N-1)%M+M)%M);
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];

    sort(d.begin(), d.end());
    cout << d[N / 2] - d[N / 2 - 1] << endl;
}

Measured memory_bytes: 640
// Problem : D - String Formation
// Contest : AtCoder - AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
    string s;
    cin>>s;
    ll q;
    cin>>q;
    ll rev=0;
    vector<char> start,endi;
    while(q--)
    {
    	ll a;
    	cin>>a;
    	if(a==1)
    		rev=(rev+1)%2;
    	else
    	{
    		ll b;
    		char c;
    		cin>>b>>c;
    		if(rev!=0)
    		{
    			b=(b==2)?1:2;
    		}
    		if(b==1)
    			start.pb(c);
    		else
    			endi.pb(c);
    	}
    }
    string str="";
    reverse(all(start));
    for(auto i:start)
    	str=str+i;
    str+=s;
    for(auto i:endi)
    	str+=i;
    if(rev)
    	reverse(all(str));
    cout<<str;
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 1572
#include <stdio.h>
#include <math.h>

int is_prime1(int);
int is_prime2(int);

int prime[168];

int main()
{
	int input_count;
	int prime_count;
	int input;
	int cnt;
	int output[30];
	int prime_cnt;
	
	/*Make prime table*/
	prime[0] = 2;
	prime_cnt = 1;
	for(cnt = 3; cnt < 1000; cnt += 2)
	{
		if(is_prime1(cnt))
		{
			prime[prime_cnt] = cnt;
			prime_cnt++;
		}
	}
	
	
	/*Get, calculate input then save in output[]*/
	input_count = 0;
	while(scanf("%d", &input) != EOF)
	{
		prime_count = 0;
		if(input >= 2)
		{
			prime_count++;
		}
		for(cnt = 3; cnt <= input; cnt += 2)
		{
			if(is_prime2(cnt))
			{
				prime_count++;
			}
		}
		output[input_count] = prime_count;
		input_count++;
	}
	
	/*print output[]*/
	for(cnt = 0; cnt < input_count; cnt++)
	{
		printf("%d\n", output[cnt]);
	}
	
    return 0;
}

int is_prime1(int prime1_input)
{
	int prime1_cnt;
	
	if(prime1_input == 1)
	{
		return 0;
	}
	else if(prime1_input == 2 || prime1_input == 3 || prime1_input == 5 || prime1_input == 7)
	{
		return 1;
	}

	for(prime1_cnt = 3 ; prime1_cnt <= (sqrt(prime1_input)); prime1_cnt += 2)
	{
		if(prime1_input % prime1_cnt == 0)
		{
			return 0;
		}
	}
	
	return 1;
}

int is_prime2(int prime2_input)
{
	
	int prime2_cnt = 0;
	for( ;prime2_cnt <168; prime2_cnt++)
	{
		if(prime[prime2_cnt] > sqrt(prime2_input))
		{
			break;
		}
		if(prime2_input % prime[prime2_cnt] == 0)
		{
			return 0;
		}
	}
	return 1;
}

Measured memory_bytes: 596
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;

//#include "atcoder.hpp"

long long gcd(long long a, long long b) {
    if (a>b) swap(a,b);
    
    auto r = b % a;
    
    return (r ? gcd(r, a) : a);
}

int main() {
    int H,W;
    
    cin>>H>>W;
    
    vector<string> A(H);
    
    for (auto& i : A)
    cin >> i;
    
    vector<vector<int>> dis(H, vector<int>(W, 999999999));
    
    
    //    for (int i = 0; i < W; i++)
    //        dis[0][i] = dis[H-1][i] = 99999999;
    for (int i = 0; i < W; i++)
        for (int j = 0; j < H; j++)
            if (A[j][i] == '#')
            dis[j][i] = 0;
  
   for (int i = 0; i < W; i++) {
    for (int j = 1; j < H; j++) {
        if (A[j][i] == '.')
        dis[j][i] = min(dis[j][i], min({dis[j-1][i]}) + 1);
    }
    }
   for (int i = 0; i < W; i++) {
    for (int j = H-2; j >= 0; j--) {
        if (A[j][i] == '.')
        dis[j][i] = min(dis[j][i], min({dis[j+1][i]}) + 1);
    }
    }

   for (int i = 1; i < W; i++) {
        for (int j = H-1; j >= 0; j--) {
            if (A[j][i] == '.')
            dis[j][i] = min(dis[j][i], min({dis[j][i-1]}) + 1);
        }
    }

    for (int i = W-2; i >= 0; i--) {
        for (int j = H-1; j >= 0; j--) {
            if (A[j][i] == '.')
            dis[j][i] = min(dis[j][i], min({dis[j][i+1]}) + 1);
        }
    }

    int res = 0;
    for (auto& i : dis)
    res = max(res, *max_element(i.begin(), i.end()));
    
    
    cout << res << endl;
    
    return 0;
}






Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
const int MAX = 1000000;


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

    int N; cin >> N;
    int T, A; cin >> T >> A;
    int H[2000];
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }

    double temperature, gap, min = 100000, place;
    for(int i = 0; i < N; i++){
        temperature = T - H[i] * 0.006;
        gap = abs(temperature - A);
        if(gap < min){
            min = gap;
            place = i;
        }       
    }
    cout << place + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>  
#include<cstdio>  
#include<cstring> 
#include <cmath> 
#include<stack>
#include<vector>
#include<map> 
#include<set>
#include<queue> 
#include<algorithm>  
using namespace std;

typedef long long LL;
const int INF = (1<<30)-1;
const int mod=1000000007;
const int maxn=105;

int a[maxn];
int b[maxn],c[maxn];
int cnt1,cnt2;

bool ok(int b[],int c[]){
	for(int i=0;i<cnt1;i++){
		if(b[i] < b[i-1]) return false;
	}
	
	for(int i=0;i<cnt2;i++){
		if(c[i] < c[i-1]) return false;
	}
	return true;
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		for(int i=0;i<10;i++) scanf("%d",&a[i]);
		
		int flag=0;
		for(int i=0;i< 1<<10;i++){
			 cnt1=0;cnt2=0;
			memset(b,0,sizeof(b));
			memset(c,0,sizeof(c));
			for(int j=0;j<10;j++){
				if(i>>j & 1) b[cnt1++]=a[j];
				else c[cnt2++]=a[j];				
			}
			
			if(ok(b,c)){
					flag=1;
					break;			
				}	
		//	printf("cnt1=%d  cnt2=%d\n",cnt1,cnt2);
		}
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

long long N,D,X,Y,cnt;

int main(){
	cin>>N>>D;
	for(int i=0;i<N;i++){
		cin>>X>>Y;
		if(X*X+Y*Y<=D*D)cnt++;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

vector<ll> dijkstra(vector<vector<pair<int,int>>>& graph,int s){
    int n=(int)graph.size();
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
    vector<ll> dist(n,LINF);
    dist[s]=0;
    pq.push({0,s});
    while(pq.size()){
        auto p=pq.top();
        pq.pop();
        int v=p.second;
        if(dist[v]<p.first)continue;
        for(auto edge:graph[v]){
            int u=edge.first;
            int w=edge.second;
            if(dist[v]+w<dist[u]){
                dist[u]=dist[v]+w;
                pq.push({dist[u],u});
            }
        }
    }
    return dist;
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<pair<int,int>>> g(n);
    for(int i=0;i<n-1;i++){
        g[i+1].push_back({i,0});
    }
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        --a,--b;
        g[a].push_back({b,c});
    }
    vector<ll> d=dijkstra(g,0);
    cout<<(d[n-1]==LINF?-1:d[n-1])<<endl;
}

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

typedef pair<int,int> P;
const int INF = 1 << 28;

int main() {
    int N, K;
    while (cin >> N >> K, N || K) {
        vector<vector<P> > V(N+1);
        while (K--) {
            int f;
            cin >> f;
            if (f) {
                int c, d, e;
                cin >> c >> d >> e;
                V[c].push_back(P(e, d));
                V[d].push_back(P(e, c));
            } else {
                int a, b;
                cin >> a >> b;

                priority_queue<P, vector<P>, greater<P> > que;
                vector<int> dp(N+1, INF);
                dp[a] = 0;
                que.push(P(0, a));

                while (que.size()) {
                    P p = que.top(); que.pop();
                    int now = p.second;
                    int cost = p.first;

                    if (dp[now] < cost) continue;

                    for (int i = 0; i < V[now].size(); i++) {
                        int next = V[now][i].second;
                        int ncost = V[now][i].first + cost;

                        if (dp[next] > ncost) {
                            dp[next] = ncost;
                            que.push(P(ncost, next));
                        }
                    }
                }

                if (dp[b] == INF) cout << -1 << endl;
                else cout << dp[b] << endl;
            }
        }
    }

    return 0;
}

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

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

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

using namespace std;

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

    int res = 0;
    for (int i = 0, j = 1; i < static_cast<int>(s.size()); i++, j++) {
        if (s[i] == 'R') {
            res = max(res, j);
        } else {
            j = 0;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<vector>


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


int min_u(ll&m, ll v)
{
	if(m>v)
	{
		m=v;
		return 1;
	}
	return 0;
}


int main(void)
{
	int n, c;

	while(scanf("%d%d", &n, &c)==2)
	{
		vvi d(c);
		vvi a(n);
		vvll s(c);
		for(auto&md:d) md.resize(c);
		for(auto&ma:a) ma.resize(n);
		for(auto&ms:s) ms.resize(3);

		for(int i=0;i<c;i++)
		{
			for(int j=0;j<c;j++) scanf("%d", &d[i][j]);
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				scanf("%d", &a[i][j]);
				for(int k=0;k<c;k++)
				{
					s[k][(i+j)%3]+=d[a[i][j]-1][k];
				}
			}
		}

		if(0)
		{
			for(auto&ms:s)
			{
//				printf("%lld %lld %lld\n", ms[0], ms[1], ms[2]);
			}
		}

		ll ans=s[0][0]+s[1][1]+s[2][2];
		for(int i=0;i<c;i++)
		{
			for(int j=i+1;j<c;j++)
			{
				for(int k=j+1;k<c;k++)
				{
					min_u(ans, s[i][0]+s[j][1]+s[k][2]);
					min_u(ans, s[i][0]+s[k][1]+s[j][2]);
					min_u(ans, s[j][0]+s[i][1]+s[k][2]);
					min_u(ans, s[j][0]+s[k][1]+s[i][2]);
					min_u(ans, s[k][0]+s[i][1]+s[j][2]);
					min_u(ans, s[k][0]+s[j][1]+s[i][2]);
				}
			}
		}
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }

    public static void main(String[] args) throws Exception {
        int result = 0;
        int[] ball = inputval();
        int N = ball[0];
        int K = ball[1];
        int[] A = inputval();
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int i=0; i<A.length; i++){
            if(!map.containsKey(A[i])) map.put(A[i],1);
            else map.put(A[i], map.get(A[i])+1);
        }
        //int minkey;
        //int mincount = Integer.MAX_VALUE;
        /*while(map.size() > K){
            for(Map.Entry<Integer, Integer> entry : map.entrySet()){
                if(entry.getValue() < mincount){
                    minkey = entry.getValue();
                }
            }

            result++;

        }*/
        int c = 0;
        int i = 0;
        List<Map.Entry<Integer, Integer>> list_entries = new ArrayList<Map.Entry<Integer, Integer>>(map.entrySet());

        // 3.比較関数Comparatorを使用してMap.Entryの値を比較する(昇順)
        Collections.sort(list_entries, new Comparator<Map.Entry<Integer, Integer>>() {
            public int compare(Map.Entry<Integer, Integer> obj1, Map.Entry<Integer, Integer> obj2) {
                // 4. 昇順
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });
        
        
        //map.entrySet().stream().sorted(java.util.Collections.reverseOrder(java.util.Map.Entry.comparingByValue()));
        for(Map.Entry<Integer, Integer> entry : list_entries){
            //System.out.println(entry.getKey()+" "+entry.getValue());
            i++;
            if(i > K) break;
            c += entry.getValue();
        }
        System.out.println(N-c);
    }
}

Measured memory_bytes: 49820
n = int(input())
A = list(map(int, input().split()))
ans = 1
p = m = 0
c = A[0]
for i in A[1:]:
    if i > c:
        p = 1
    elif i < c:
        m = 1
    if p == 1 and m == 1:
        p = m = 0
        ans += 1
    c = i
print(ans)
# maybe pills will work??

Measured memory_bytes: 20056
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

double entropy(int N, const vector<int> &x) {
    double H = 0;
    for (int i=0; i<256; ++i) {
        if (x[i] != 0) {
            H -= (double)x[i] / N * log((double)x[i] / N);
        }
    }
    return H;
}

int main() {
    int N;
    while (cin >> N && N) {
        vector<int> I(N+1);
        for (int i=1; i<=N; ++i) cin >> I[i];
        int M = 256;
        double Hmin = 999999;
        vector<int> ans(3);
        for (int S=0; S<=15; ++S) {
            for (int A=0; A<=15; ++A) {
                for (int C=0; C<=15; ++C) {
                    vector<int> x(256, 0);
                    int R = S;
                    int O;
                    for (int i=1; i<=N; ++i) {
                        R = (A * R + C) % M;
                        O = (I[i] + R) % M;
                        x[O] ++;
                    }
                    double H = entropy(N, x);
                    if (H + 1e-8 < Hmin) {
                        Hmin = H;
                        ans[0] = S;
                        ans[1] = A;
                        ans[2] = C;
                    }
                }
            }
        }
        cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
    }
    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  if(!(n&1)) {
    cout<<n<<endl;
    return 0;
  }
  else      cout<<n*2<<endl;



 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    string s1 = s.substr(0,n);
    string s2 = s.substr(n,n);
    map<pair<string,string>,ll>m1;
    for(ll bit=0;bit<(1<<n);bit++){
        string now = "";
        string b = "";
        rep(i,n){
            if((bit>>i)&1){
                now += s1[i];
            }
            else{
                b += s1[i];
            }
        }
        m1[{now,b}]++;
    }
    map<pair<string,string>,ll>m2;
    for(ll bit=0;bit<(1<<n);bit++){
        string now = "";
        string b = "";
        rep(i,n){
            if((bit>>i)&1){
                now += s2[i];
            }
            else{
                b += s2[i];
            }
        }
        reverse(now.begin(),now.end());
        reverse(b.begin(),b.end());
        m2[{now,b}]++;
    }
    ll ans = 0;
    for(auto itr=m1.begin();itr!=m1.end();itr++){
        auto p = itr->first;
        ans += (itr->second)*m2[p];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 103424
n,m=map(int,input().split())
li = [0]*(10**5+5)
for _ in range(m):
	l,r=map(int,input().split())
	li[l-1]+=1
	li[r]-=1
cnt=0
ans=0
for i in range(n):
	cnt+=li[i]
	if cnt==m:
		ans+=1
print(ans)

Measured memory_bytes: 44888
A, B = map(int, input().split())

for i in range(int(min(A/0.08, B/0.1)), int(max((A+1)/0.08,(B+1)/0.1))):
    if int(i*0.08) == A and int(i*0.1) == B:
        print(i)
        exit()

print(-1)

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

int main(){
    vector<vector<int>> v;
    vector<int> x(10);
    for(int i = 0; i < 10; i++) x[i] = i+1;
    do{
        int z = (x[0]+x[1]+x[2])%x[9];
        bool judge = true;
        for(int i = 0; i < 3; i++){
            judge &= (x[3*i]+x[3*i+1]+x[3*i+2])%x[9] == z;
            judge &= (x[i]+x[3+i]+x[6+i])%x[9] == z;
        }
        judge &= (x[0]+x[4]+x[8])%x[9] == z;
        judge &= (x[2]+x[4]+x[6])%x[9] == z;
        if(judge)   v.push_back(x);
    }while(next_permutation(x.begin(),x.end()));
    
    while(1){
        for(int i = 0; i < 10; i++) cin >> x[i];
        if(x[0] == -1)  break;
        int ans = 0;
        for(vector<int> y : v){
            bool judge = true;
            for(int i = 0; i < 10; i++){
                judge &= x[i]==0 || x[i]==y[i];
            }
            if(judge)   ans++;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 28348
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	LL gcd = 0;
	rep(i, 0, n) {
		sll(num);
		gcd = __gcd(gcd, num);
	}
	pll(gcd); nl;
}


Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val a = cin.nextInt()
    val b = cin.nextInt()

    if ((a+b) % 2 == 0) {
        println((a+b)/2)
    } else {
        println("IMPOSSIBLE")
    }
}

Measured memory_bytes: 31516
import Data.Char
import Data.List

select :: Int -> [Int] -> [[Int]]
select 0 _ = [[]]
select _ [] = [[]]
select n list =
    [ (x:xs) | x <- list, xs <- (select (n-1) $ filter (>= x) list) ]

------------------------------------------------
f :: Int -> Int
f n = if n >= 5
      then 1 + ( (n-5) * 2 )
      else n * 2

-- (*??\???????¨???????????\???°?????????*?????°?????¶??°?????????*?????°)
ev :: [Char] -> (Int,Int,Int)
ev [] = (0,0,0)
ev ('*':ns) =
  let (a,b,c) = od ns
  in
    (a,b,c+1)

ev (n:ns) =
  let v = f $ digitToInt n
      (a,b,c) = od ns
  in
    (a+v,b,c)

od :: [Char] -> (Int,Int,Int)
od [] = (0,0,0)
od ('*':ns) =
  let (a,b,c) = ev ns
  in
    (a,b+1,c)

od (n:ns) =
  let n' = digitToInt n
      (a,b,c) = ev ns
  in 
     (a+n',b,c)   
------------------------------------------------

fact 1 = 1
fact n = n * fact(n-1)

cnv :: [Int] -> [(Int,Int)]
cnv [] = []
cnv x@(x0:xs) =
  let l = length $ takeWhile (==x0) x
  in
    (x0,l):(cnv $ dropWhile (==x0) x)

comb :: [Int] -> Int
comb x =
  let l = fact $ length x
      m = product $ map (\(a,b) -> fact b) $ cnv x
  in
    l `div` m

chk :: Int -> [Int] -> Int
chk p yc =
  let y = sum $ map f yc
      v = p + y
  in
    if v `mod` 10 == 0
    then comb yc
    else 0

solve'' :: Int -> Int -> [Int] -> Int
solve'' p y set =
  let ycs = select y set
      res = map (\yc -> chk p yc) ycs
  in
    sum res

solve' :: Int -> Int -> [Int] -> [Int] -> Int
solve' p y set xc =
  let c  = comb xc
      p' = p + sum xc
  in
    c * solve'' p' y set

solve id set = 
  let (p,x,y) = od id -- (*??\???????¨???????????\???°?????????*?????°?????¶??°?????????*?????°)
      xcs = select x set
      res = map (solve' p y set ) xcs
  in
    sum res

main = do
  c <- getContents
  let l = lines c
      n  = read (l!!0) :: Int
      id = reverse $ l!!1
      m  = read (l!!2) :: Int
      s  = map read $ words (l!!3) :: [Int]
      o  = solve id s
  print o

Measured memory_bytes: 27500
h,w=map(int,input().split())
dp=[ [-1]*(w+1) for _ in range(h+1) ]
for i in range(h):
  i+=1
  tmp=input()
  for j in range(w):
    j+=1
    if tmp[j-1]=='.':
      dp[i][j]=0
    else:
      dp[i][j]=-1
dp[1][1]=1

for i in range(1,h+1):
  for j in range(1,w+1):
    if i==1 and j==1:continue
    if dp[i][j]==-1:continue
    dp[i][j]=0
    if dp[i-1][j]!=-1:
      dp[i][j]+=dp[i-1][j]
    if dp[i][j-1]!=-1:
      dp[i][j]+=dp[i][j-1]
    dp[i][j]=dp[i][j]%(10**9+7)
#print(dp)
print(dp[-1][-1])

Measured memory_bytes: 42516
#include<iostream>
using namespace std;
int main () {
    int r,c,sum;
    
    cin >> r >> c;
    
    int mat[100][100] = {{}};
    
    int row[100] = {};
    
    int column[100] = {};
    
    for (int i = 0; i < r; i ++) {
        
        for (int j = 0; j < c; j ++) {
            
            cin >> mat[i][j];
            
            row[i] += mat[i][j];
            
        }
    }
    
    for (int i = 0; i < c; i ++) {
        
        for (int j = 0; j < r; j ++) {
            
            column[i] += mat[j][i];
            
        }
        
        sum += column[i];
        
    }
    
    for (int i = 0; i < r; i ++) {
        
        for (int j = 0; j < c; j ++) {
            
            cout << mat[i][j] << ' ';
            
        }
        
        cout << row[i] << endl;
        
    }
    
    for (int i = 0; i < c; i ++) {
        
        cout << column[i] << ' ';
        
    }
    
    cout << sum << endl;
    
    return 0;
    
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int N;
	cin >> N;
    vector<int> P(N);
    rep(i,N) cin >> P[i];
    vector<int> Q(N);
    rep(i,N) cin >> Q[i];

    vector<int> a(N);
    rep(i,N) a[i] = i+1;
    
    map<vector<int>, int> mp;
    do {
        mp[a] = mp.size();
    } while (next_permutation(a.begin(), a.end()));

    int ans = abs(mp[P] - mp[Q]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
一番上の桁を見る
総当りでも行ける
*/

int n,k,d[10]={};

int main(void){
	cin>>n>>k;
	rep(i,k){
		int a;
		cin>>a;
		d[a]=1;
	}
	reg(i,n,100000){
		int a = i;
		bool ok=true;
		while(a>0){
			if(d[a%10]==1)ok=false;
			a/=10;
		}
		if(ok){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int n,m;
	cin >> n >> m;

	int x = 1;
	while (m > 0)
	{
		if (m & 1)
		{
			x = (x*n) % MOD;
		}
		n = (n*n)%MOD;
		m >>= 1;
	}

	cout << x << endl;

	return 0;
}


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

vector<int> sieve_of_eratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i)
    primes[i] = i;
  for (int i = 2; i*i < n; ++i)
    if (primes[i])
      for (int j = i*i; j < n; j+=i)
        primes[j] = 0;
  return primes;
}

int main() {
  int a;
  while (cin >> a, a) {
    vector<int> p = sieve_of_eratosthenes(a + 1);
    for (int i = a; i > 2; --i) {
      if (p[i - 2] && p[i]) {
        cout << i - 2 << ' ' << i << endl;
        break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include<climits>

using namespace std;
#define ll long long int
#define Max 110000

int main() {
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0 ;i<n ; i++)
	{
		cin>>arr[i];
	}
	ll dp[Max+1];
	for(int i=0 ; i<=Max ; i++)
	{
		dp[i]=INT_MAX;
	}
	dp[0]=0;
	//cout<<dp[1];
	for(int i=0 ; i<n ; i++)
	{
		for(int j=1 ; j<=k ; j++)
		{
			if(i+j<n)
				dp[i+j]=min(dp[i+j],dp[i]+abs(arr[i+j]-arr[i]));
		}
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1536
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        String s_join = s + s;
        if(s_join.contains(t)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	string s;
	cin >> s;
	bool isformm = false;
	if (s[0] == '0') {
		if (s[1] != '0') {
			isformm = true;
		}
	}
	else if (s[0] == '1') {
		if (s[1] == '1' || s[1] == '2') {
			isformm = true;
		}
	}

	bool islatmm = false;
	if (s[2] == '0') {
		if (s[3] != '0') {
			islatmm = true;
		}
	}
	else if (s[2] == '1') {
		if (s[3] == '1' || s[3] == '2') {
			islatmm = true;
		}
	}
	
	if (isformm && islatmm) {
		ps(AMBIGUOUS)
	}
	else if (isformm) {
		ps(MMYY);
	}
	else if (islatmm) {
		ps(YYMM);
	}
	else {
		ps(NA);
	}
	return(0);
}

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

using namespace std;
using ll = long long;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }
  vector<int> dp(N);
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < N; ++i) {
    int candi = dp[i - 1] + abs(h[i] - h[i - 1]);
    for (int j = 2; j <= K; ++j) {
      if (i - j < 0) break;
      candi = min(candi, dp[i - j] + abs(h[i] - h[i - j]));
    }
    dp[i] = candi;
  }
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> S( H );
	for( auto &x : S )
  {
    cin >> x;
  }
	for( int i = 0; i < H; ++i )
	{
		for( int j = 0; j < W; ++j )
		{
			if( S[ i ][ j ] == '#' )
			{
				continue;
			}
			int cnt{};
			for( int k = i - 1; k <= i + 1; ++k )
			{
				for( int l = j - 1; l <= j + 1; ++l )
				{
					if( k >= 0 && l >= 0 && k != H && l != W && S[ k ][ l ] =='#' )
					{
						cnt++;
					}
				}
				S[ i ][ j ] = '0' + cnt;
			}
		}
	}
	for( auto &x : S )
	{
		cout << x << endl;
	}
	return 0;
}

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

using namespace std;

bool check(vector<string> S)
{
    for (string &s: S)
        sort(s.begin(), s.end());
    set<string> X;
    for (string s: S)
        if (X.count(s)>0)
            X.erase(s);
        else
            X.insert(s);
    return X.size()<=1;
}

int main()
{
    int H, W;
    cin>>H>>W;
    vector<string> S(H);
    for (string &s: S)
        cin>>s;
    vector<string> S2(W, string(H, '.'));
    for (int y=0; y<H; y++)
        for (int x=0; x<W; x++)
            S2[x][y] = S[y][x];
    if (check(S) && check(S2))
    {
        unsigned long long hash = 0;
        for (int y=0; y<H; y++)
        for (int x=0; x<W; x++)
            hash = hash*97 + S[y][x];
        //if (hash < 0x8000000000000000LL)  //  RE
        //if (hash >= 0x4000000000000000LL &&   // RE
        //    hash <  0x8000000000000000LL)
        //if (hash >= 0x6000000000000000LL &&   //  WA
        //    hash <  0x8000000000000000LL)
        //if (hash >= 0x5000000000000000LL &&   //  WA
        //    hash <  0x6000000000000000LL)
        //if (hash >= 0x4800000000000000LL &&   //  WA
        //    hash <  0x5000000000000000LL)
        //if (hash >= 0x4400000000000000LL &&   //  WA
        //    hash <  0x4800000000000000LL)
        //if (hash >= 0x4200000000000000LL &&   //  RE
        //    hash <  0x4400000000000000LL)
        //    *(int *)1234 = 1234;
        //cout<<"YES"<<endl;

        if (hash >= 0x4200000000000000LL &&
            hash <  0x4400000000000000LL)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
}



Measured memory_bytes: 256
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
from collections import Counter

def main():
    n = II()
    aa = [0] + MII()
    c = Counter(aa)
    for i in range(n):
        print(c[i+1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 35340
a,b,c,x,y = map(int, input().split())

if a+b <= 2*c:
    print(a*x+b*y)
else:
    min_xy = min(x,y)
    max_xy = max(x,y)
    # ハーフハーフで少ない方を穴埋め
    n_c = min_xy*2
    v = n_c*c + max(0,x-min_xy)*a+max(0,y-min_xy)*b
    # print(min_xy,n_c,max(0,x-min_xy))
    # ハーフハーフで余らせた方が安い場合
    N_c = max_xy*2
    V = N_c * c
    print(min(v,V))



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
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);
	string str;
	cin>>str;
	ll ptr1=(str.size()+1)/2;
	ll ptr2;
	ll n=str.size();
	if(n%2==0){
		ptr2=ptr1-1;
	}
	else{
		ptr2=ptr1-2;
	}
	ll cnt=0;
	while(ptr2>=0&&ptr1<str.size()){
		if(str[ptr1]!=str[ptr2]){
			cnt++;
		}
		ptr1++;
		ptr2--;
	}
	cout<<cnt<<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 r=sc.nextInt();
    int ans=0;
    if(n>=10) ans=r;
    else ans=r+(100*(10-n));
    System.out.println(ans);
  }
}

Measured memory_bytes: 25172