akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long int l;
typedef long long int ll;

bool comp(pair<ll,ll> a,pair<ll,ll> b)
{
    return a.second>b.second;
}

int main() {
    l n,m;
    cin>>n>>m;
    ll a,sum=0;
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    for(l i=0;i<n;i++) {
        cin>>a;     
        sum+=a;
        pq.push(a);
    }
   // cout<<sum<<endl;
    std::vector<pair<ll,ll>> v ;
    for(long int i=0;i<m;i++)
    {
        ll a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end(),comp);
    bool flag=false;
    
    for(ll i=0;i<m;i++)
    {
        ll a,b;
        a=v[i].first;
        b=v[i].second;
        if(b>pq.top())
        {
            while(a--)
            {
                sum-=pq.top();
                sum+=b;
                pq.pop();
                pq.push(b);
                if(pq.top()>=b)
                {
                    flag=true;
                    break;
                }
            }
            
        }
        else
        {
            flag = true;
        }
        
        if(flag)
        {
            break;
        }
    }
    cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	LL a,b,c,d;
	cin>>a>>b>>c>>d;
	LL a1=a*c;
	LL a2=a*d;
	LL a3=b*c;
	LL a4=b*d;
	a1=max(a1,a2);
	a1=max(a1,a3);
	a1=max(a1,a4);
	cout<<a1<<endl;
	return 0;
}

Measured memory_bytes: 3604
from itertools import permutations

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, m, r = read_line(int, int, int)

rs = [int(r) for r in input().split()]

costs = {}
for i in range(n + 1):
    costs[i] = {}
    for j in range(n + 1):
        costs[i][j] = float('inf')

for _ in range(m):
    a, b, c = read_line(int, int, int)

    costs[a][b] = costs[b][a] = c

for k in range(n + 1):
    for i in range(n + 1):
        for j in range(n + 1):
            c = costs[i][k] + costs[k][j]
            if costs[i][j] > c:
                costs[i][j] = c

def cost(selected):
    c = 0
    for i in range(len(selected) - 1):
        a = selected[i]
        b = selected[i + 1]
        c += costs[a][b]
    return c

smallest = float('inf')

for p in permutations(rs):
    c = cost(p)
    if smallest > c:
        smallest = c

print(smallest)


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

import static java.lang.Integer.parseInt;

/**
 * Decimal Sequences - Time Limit Exceeded
 */
public class Main {

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

		int n = parseInt(br.readLine());
		char[] seq = new char[n];

		int _i = 0;
		while ((line = br.readLine()) != null && !line.isEmpty()) {
			for (int i = 0; i < line.length(); i += 2, _i++) {
				seq[_i] = line.charAt(i);
			}
		}

		//solve
		boolean[] nums = new boolean[1_000_000];
		outer:
		for (int i = 0; i < n; i++) {
			for (int j = i; j < n; j++) {
				int len = j - i + 1;
				if ((seq[i] == '0' && len > 1) || len > 6) continue outer;
				//
				char[] _seq = Arrays.copyOfRange(seq, i, j + 1);
				nums[parseInt(String.valueOf(_seq))] = true;
			}
		}

		for (int i = 0; i < nums.length; i++) {
			if (!nums[i]) {
				System.out.println(i);
				break;
			}
		}

	} //end main
}

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

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 600000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000 大きいとワ―シャルフロイドでオーバーフローを起こす
#define PI 3.14159265358979

//.size()はunsignedなので0-1でオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

long long int dy[5] = { 0,0,1,-1,0 };
long long int dx[5] = { 1,-1,0,0,0 };


int main(void) {

	int right = 0;
	int left = 0;
	bool check = false;
	string s;

	cin >> s;

	FOR(i, 0, s.size() - 1) {
		if (s[i] == '*') {
			check = true;
			continue;
		}
		if (check == false) {
			if (s[i] == '(') {
				left++;
			}
			else {
				if (left > 0) {
					left--;
				}
			}
		}
		if (check == true) {
			if (s[i] == ')') {
				right++;
			}
			else {
				right--;
			}
		}
	}



	cout << max(0,min(left,right)) << endl;

}


Measured memory_bytes: 3192
n = input()

if n[0] == n[1] and n[0] == n[2]:
    print("Yes")

elif n[1] == n[2] and n[1] == n[3]:
    print("Yes")

elif n[0] == n[1] and n[0] == n[2] and n[0] == n[3]:
    print("Yes")

else:
    print("No")

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

int main() {
  long long N;
  long long A, B;
  long long ans;

  cin >> N >> A >> B;

  long long ab = A+B;
  long long quo = N/ab;
  long long rem = N%ab;

  if(rem < A) {
    ans = A*quo + rem;
  } else {
    ans = A*quo + A;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
def f():
 for i in range(n-1):
  d=a[i][:];d[3],d[4]=d[4],d[3]
  for j in range(i+1,n):
   e=a[j][:];e[3],e[4]=e[4],e[3]
   for p in('012345','152043','215304','302541','410352','514320'):
    f=[d[int(k)]for k in p]
    if f[0]==e[0]and f[5]==e[5]:
     f=f[1:5]*2
     for k in range(4):
      if f[k:k+4]==e[1:5]:return 'No'
 return 'Yes'
print(f())


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

    int N,R;
    cin >> N >> R;

    if(N>=10){
        cout << R << endl;
    }else{
        cout << R + 100 * (10 - N) << endl;
    }

}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let s = read!(String);
    let t = read!(String);

    let mut sc: Vec<_> = s.chars().collect();
    let mut tc: Vec<_> = t.chars().collect();

    sc.sort();
    tc.sort();
    tc.reverse();

    println!("{}", if sc < tc { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstdio>
using namespace std;

int main(){
  char ch;
  string num = "";
  int ans = 0;
  while(scanf("%c",&ch) != EOF){
      
    if('0' <= ch && ch <= '9'){
      num += ch;
    } else {
      if(num.size() > 0)ans+=atoi(num.c_str());
      num = "";
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcopy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;


int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	if(n>m)swap(n,m);
	if(n==1){
		if(m==1)puts("1");
		else printf("%d\n",m-2);
	}
	else printf("%lld\n",1LL*(n-2)*(m-2));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define loop(i,k,n) for (ll i = k; i <= n; i++) 
#define rloop(i,k,n) for (ll i = k; i >= n; i--)
#define INF 1000000000 
#define umap unordered_map
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vl>
#define vpll vector<pll>
#define f first 
#define s second 
#define pb push_back 
#define pob pop_back 
#define mp make_pair 
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define gcd(a,b) __gcd((a),(b))
#define bitcnt(a) __builtin_popcount(a)
#define fill(a, b) memset(a, b, sizeof(a))
#define tc() int t; cin>>t;while(t--)
#define PI 3.1415926535897932384626
#define srtv(A) sort((A).begin(), (A).end())
#define srta(a,n) sort(a,a+n)
#define mod 1000000007
using namespace std;
int dp[100000+1];
vi h(100001,0);
int solve(int i,int n){
   if(i==n-2){
      return dp[i]=abs(h[i]-h[i+1]);
   }
   else if(i==n-3){
      return dp[i]=min(abs(h[i]-h[i+2]),abs(h[i]-h[i+1])+solve(i+1,n));
   }
   else if(dp[i]!=-1)return dp[i];
   else{
      return dp[i]=min(abs(h[i]-h[i+1])+solve(i+1,n),abs(h[i]-h[i+2])+solve(i+2,n));
   }
}
int main(){   	
   ios_base::sync_with_stdio(false);
   cin.tie(NULL); 
   cout.tie(NULL);
   fill(dp,-1);
   int n,x;cin>>n;
   loop(i,0,n-1){
      cin>>x;
      h[i]=x;
   }
   cout<<solve(0,n);
   return 0;
}

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

int main() {
    int N, K, count;
    cin >> N >> K;
    
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        if (tmp >= K) {
            count ++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if ( c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ) {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'T'){
            if(tmp)tmp--;
            else ans++;
        }
        else tmp++;
    }
    cout << ans + tmp << endl;
    
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

class Dice {
	private int _t, _s, _e, _w, _n, _b;
	int getTop() {
		return _t;
	}
	void setTop(int t) {
		_t = t;
	}
	int getSouth() {
		return _s;
	}
	void setSouth(int s) {
		_s = s;
	}
	int getEast() {
		return _e;
	}
	void setEast(int e) {
		_e = e;
	}
	int getWest() {
		return _w;
	}
	void setWest(int w) {
		_w = w;
	}
	int getNorth() {
		return _n;
	}
	void setNorth(int n) {
		_n = n;
	}
	int getBottom() {
		return _b;
	}
	void setBottom(int b) {
		_b = b;
	}
	void rollX(boolean d) {
		if (d) {
			int temp = _t;
			_t = _n;
			_n = _b;
			_b = _s;
			_s = temp;
		} else {
			int temp = _t;
			_t = _s;
			_s = _b;
			_b = _n;
			_n = temp;
		}
	}
	void rollY(boolean d) {
		if (d) {
			int temp = _s;
			_s = _w;
			_w = _n;
			_n = _e;
			_e = temp;
		} else {
			int temp = _s;
			_s = _e;
			_e = _n;
			_n = _w;
			_w = temp;
		}
	}
	void rollZ(boolean d) {
		if (d) {
			int temp = _e;
			_e = _b;
			_b = _w;
			_w = _t;
			_t = temp;
		} else {
			int temp = _e;
			_e = _t;
			_t = _w;
			_w = _b;
			_b = temp;
		}
	}
	void anchor_t_s(int t, int s) {
		if (t == _e) {
			rollZ(true);
		} else if (t == _w) {
			rollZ(false);
		} else {
			while (t != _t) {
				rollX(true);
			}
		}
		while (s != _s) {
			rollY(true);
		}
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Dice d = new Dice();
		d.setTop(sc.nextInt());
		d.setSouth(sc.nextInt());
		d.setEast(sc.nextInt());
		d.setWest(sc.nextInt());
		d.setNorth(sc.nextInt());
		d.setBottom(sc.nextInt());
		sc.nextLine();
		int q = sc.nextInt();
		sc.nextLine();
		for (int i = 0; i < q; ++i) {
			int t = sc.nextInt(), s = sc.nextInt();
			sc.nextLine();
			d.anchor_t_s(t, s);
			System.out.println(d.getEast());
		}
		sc.close();
	}
}


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

int main(){
  string str;
  while(cin>>str,str!="#"){
    bool dir[20]={false};
    int angle=0;
    int shift=1;
    int i=0;
    int cnt=0;
    while(i<(int)str.size()){
      if(str[i]=='n'){
	dir[cnt++]=0;
	i+=5;
      }else if(str[i]=='w'){
	dir[cnt++]=1;
	i+=4;
      }else{
	i=(int)str.size();
      }
    }
    cnt--;
    shift = (shift<<cnt);
    int max = shift*90;
    angle = dir[cnt]*90*shift;
    shift = (shift>>1);
    for(i=cnt-1;i>=0;i--){
      int temp;
      if(dir[i]){
	temp=angle+90*shift;
      }else{
	temp=angle-90*shift;
      }
      shift=(shift>>1);
      if(temp < 0 ) temp = 0;
      if(temp > max) temp = max;
      angle = temp;
    }
    max = (1<<cnt);
    while(max%2 == 0 && angle%2 == 0){
      max=(max>>1);
      angle=(angle>>1);
    }
    cout<<angle;
    if(max!=1)
      cout<<"/"<<max;
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <string.h>


int main(void){
	int class,blood[4]={0},i;
	char str[3];
	while(scanf("%d,%s",&class,str)!=EOF){
		if(strcmp(str,"AB")==0) blood[2]++;
		if(strcmp(str,"A")==0) blood[0]++;
		if(strcmp(str,"B")==0) blood[1]++;
		if(strcmp(str,"O")==0) blood[3]++;
	}
	for(i=0;i<4;i++){
		printf("%d\n",blood[i]);
	}
	return 0;
}

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

typedef struct{
  double x;
  double y;
}point;

void kock(int n,point p1,point p2){
  point s,t,u;
  if(n==0)return ;

  s.x = (2*p1.x+p2.x)/3;
  s.y = (2*p1.y+p2.y)/3;

  t.x = (p1.x+2*p2.x)/3;
  t.y = (p1.y+2*p2.y)/3;

  u.x=(t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3)+s.x;
  u.y=(t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3)+s.y;

  kock(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  
  kock(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);

  kock(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);

  kock(n-1,t,p2);
 
}

int main(){
  int n;
  point sta,fin;

  sta.x=0;
  sta.y=0;
  fin.x=100;
  fin.y=0;

  scanf("%d",&n);
  printf("%.8f %.8f\n",sta.x,sta.y);

  kock(n,sta,fin);

  printf("%.8f %.8f\n",fin.x,fin.y);
  return 0;

}



Measured memory_bytes: 2052
# import sys; input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def inverse(N, mod):
	return (pow(N, mod - 2, mod))

def main():
	N = int(input())
	L = []
	for i in range(N):
		D1, D2 = getlist()
		if D1 == D2:
			L.append(1)
		else:
			L.append(0)

	for i in range(N - 2):
		if L[i] + L[i + 1] + L[i + 2] == 3:
			print("Yes")
			return

	print("No")




if __name__ == '__main__':
	main()

Measured memory_bytes: 66988
#include <bits/stdc++.h>
using namespace std;
const int P=1e9+7;
int dp[100010][14];
char s[100010];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		if(s[i]!='?'){
			for (int j=0;j<=12;j++) {
				dp[i][j]=dp[i-1][((13+j-s[i]+'0')*4)%13];
			}
		}else{
			for(int j=0;j<=12;j++){
				for(int k=0;k<=9;k++){
					dp[i][j]=(dp[i][j]+dp[i-1][((13+j-k)*4)%13])%P;
				}
			}
		}
	}
	cout<<dp[n][5];
	return 0;
}

Measured memory_bytes: 5760
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;



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

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

const MOD: i64 = 998244353;

fn main() {
    input! {
        n:usize,
        k:usize,
        lr: [(usize, usize); k],
    }

    let mut dp = vec![0; n + 1];
    let mut a = vec![1];
    dp[0] = 1;
    let mut sum = 1;

    for i in 1..n {
        let mut next = 0;
        for j in 0..lr.len() {
            let l = lr[j].0;
            let r = lr[j].1;
            if l > a.len() {
                continue;
            }
            next += a[a.len() - l];
            if r + 1 > a.len() {
                continue;
            }
            next -= a[a.len() - r - 1];
        }
        next %= MOD;
        dp[i] = next;
        sum += next;
        a.push(sum);
        // println!("dp:{:?}", dp);
        // println!("a:{:?}", a);
    }
    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 5336
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    static Map<Integer, Integer> source = new HashMap<Integer, Integer>();
    static Map<Integer, Integer> destination = new HashMap<Integer, Integer>();

    public static void buildMap(Map<Integer, Integer> map, int[] array) {
        for (int i : array) {
            if (map.get(i) == null)
                map.put(i, 1);
            else
                map.put(i, map.get(i) + 1);
        }
    }

    public static boolean solution(){
        for (Integer integer : destination.keySet()) {
            if (source.get(integer) == null)
                return false;
            if (source.get(integer) < destination.get(integer))
                return false;
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] array1 = new int[n];
        for (int i = 0; i < n; i++) {
            array1[i] = in.nextInt();
        }
        int m = in.nextInt();
        int[] array2 = new int[m];
        for (int i = 0; i < m; i++) {
            array2[i] = in.nextInt();
        }
        buildMap(source, array1);
        buildMap(destination, array2);
        System.out.println(solution()? "YES": "NO");
    }
}


Measured memory_bytes: 106444
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	int N;
	cin >> N;
	vi T(N + 1, 0);
	int sum = 0;
	FOR(i, 1, N + 1) {
		cin >> T[i];
		sum += T[i];
	}
	int M;
	cin >> M;
	vi P(M + 1, 0), X(M + 1, 0);
	FOR(i, 1, M + 1) cin >> P[i] >> X[i];

	FOR(i, 1, M + 1) {
		cout << sum - T[P[i]] + X[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int S(int n){
    int res = 0;
    while(n){
        res += n % 10;
        n /= 10;
    }
    return res;
}
int main(){
    int N; cin>>N;
    int res = 1 << 30;
    for(int i=1; i<=N/2; ++i){
       res = min(res, S(i)+S(N-i));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
// *_*
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define  sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const long long inf2 = (long long)1e18;
const long long mod = (long long)(1e9+7);
const long long inf1 =(long long)(1e6+1);
 
 
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n, m, ans = 0;
    cin >> n >> m;

    char a[n+1][m+1];
 
    fori(i, 1, n) fori(j, 1, m) cin >> a[i][j];
    
    fori(i, 1, n)
    {
        fori(j, 1, m)
        {
            if(a[i][j] == '.')
            {
                int vis[n+1][m+1] = {}, d[n+1][m+1] = {};
                vis[i][j] = 1;
                queue < pair <int, int>> q;
                q.push({i, j});
             
                while(!q.empty())
                {
                    int ii = q.front().fi;
                    int jj = q.front().se;
                    
                    q.pop();
             
                    if(ii < n)
                    {
                        if(a[ii+1][jj] == '.' && vis[ii+1][jj] == 0) {q.push({ii+1, jj}); vis[ii+1][jj] = 1; d[ii+1][jj] = d[ii][jj]+1;}
                    }
                    
                    if(ii > 1)
                    {
                        if(a[ii-1][jj] == '.' && vis[ii-1][jj] == 0) {q.push({ii-1, jj}); vis[ii-1][jj] = 1; d[ii-1][jj] = d[ii][jj] + 1;}
                    }
             
                    if(jj < m)
                    {
                        if(a[ii][jj+1] == '.' && vis[ii][jj+1] == 0) {q.push({ii, jj+1}); vis[ii][jj+1] = 1; d[ii][jj+1] = d[ii][jj] + 1; }
                    }
                    
                    if(jj > 1)
                    {
                        if(a[ii][jj-1] == '.' && vis[ii][jj-1] == 0) {q.push({ii, jj-1}); vis[ii][jj-1] = 1; d[ii][jj-1] = d[ii][jj] + 1;}
                    }
                }

                fori(k, 1, n) fori(l, 1, m) ans = max(ans, d[k][l]);
            }
        }
    }
 
    cout << ans;
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

//しっかり制約確認したか?
int main()
{
    int n, d; cin >> n >> d;
    int ans = 0;
    rep(i, n){
        ll a, b; cin >> a >> b;
        if((ll)d*d >= (a*a)+(b*b)){
            ans++;
        }
    }
    cout << ans << endl;
    

    system("pause");
}


Measured memory_bytes: 3692
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if((a < b) && (b < c)){
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	int sol = 0;
	for(int i=1;i<=n;i++) {
		int cnt = 0;
		int num = i;
		while(num%2==0) {
			cnt++;
			num/=2;
		}
		sol=max(sol,cnt);;
	}
	cout<<(1<<sol);
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3620
import math
a,b,c,d = map(int, input().split())
ans = b - a + 1
cntc = b//c - (a-1)//c
cntd = b//d - (a-1)//d
cd = (c * d) // math.gcd(c, d)
cntcd = b//cd - (a-1)//cd
ans = ans - cntc - cntd + cntcd
print(ans)

Measured memory_bytes: 62176
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Console;

namespace CPLib
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(s);
            if ((s[0]==s[1]&&s[0]!=s[2])||(s[2]==s[1]&&s[0]!=s[1]))
            {
                WriteLine("Yes");
            }
            else WriteLine("No");
        }
    }
}


Measured memory_bytes: 13396
#include <cstdio>
#include <deque>

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

  std::deque<int> a;
  for (int i=0; i<q; ++i) {
    int t;
    scanf("%d", &t);
    if (t == 0) {
      int d, x;
      scanf("%d %d", &d, &x);
      if (d == 0) {
        a.push_front(x);
      } else {
        a.push_back(x);
      }
    } else if (t == 1) {
      int p;
      scanf("%d", &p);
      printf("%d\n", a[p]);
    } else {
      int d;
      scanf("%d", &d);
      if (d == 0) {
        a.pop_front();
      } else {
        a.pop_back();
      }
    }
  }
}



Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n, A, B, C;
vector<int> l;
int rec(int phase,int a,int b, int c) {
    if(phase == n){
        if (!a || !b || !c) return 1e9;
        else return abs(a-A) + abs(b-B) + abs(c-C) -30;
    }
    int ret0 = rec(phase+1,a,b,c);
    int ret1 = rec(phase+1,a+l[phase],b,c) + 10;
    int ret2 = rec(phase+1,a,b+l[phase],c) + 10;
    int ret3 = rec(phase+1,a,b,c+l[phase]) + 10;
    
    return min(ret0,min(ret1,min(ret2,ret3)));
}
int main(){
    cin >> n >> A >> B >> C;
    l.resize(n);
    rep(i, n) cin >> l[i];
    cout << rec(0,0,0,0);
}


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

using namespace std;

int u[400],v[400];
string w[400];

int main(){
    ios::sync_with_stdio(0);
    
    int n,m,s,e;
    char str[7];
    string dist[40];
    bool visited[40],change,inf;
    
    while(true){
        cin >> n >> m >> s >> e;
        
        if(n == 0) break;
        
        for(int i = 0;i < m;++i)
            cin >> u[i] >> v[i] >> w[i];
        
        memset(visited,0,sizeof visited);
        
        dist[e] = "";
        visited[e] = true;
        change = true;
        inf = false;
        
        for(int it = 0;it <= 6*n && change && !inf;++it){
            change = false;
            
            for(int i = 0;i < m;++i){
                if(visited[ v[i] ]){
                    string aux = w[i] + dist[ v[i] ];
                    
                    if(!visited[ u[i] ] || aux < dist[ u[i] ]){
                        dist[ u[i] ] = aux;
                        change = true;
                        if(it >= n - 1 && u[i] == s) inf = true;
                    }
                    
                    visited[ u[i] ] = true;
                }
            }
        }
        
        if(inf || !visited[s]) cout << "NO\n";
        else cout << dist[s].c_str() << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 1332
#include <bits/stdc++.h>
double a, b, x;
int main() {
	scanf("%lf%lf%lf", &a, &b, &x);
	double k = acos(-1);
	if(2 * x <= a * a * b) {
		printf("%.10lf", 180 * atan(a * b * b / (2 * x)) / k);
	} else {
		printf("%.10lf", 180 * atan((2 * a * a * b - 2 * x) / (a * a * a)) / k);
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
int main()
{
    int N;
    cin >> N;
    vector<int> H;

    int max = 0;
    int tempmax = 0;
    for (int i=0; i<N; i++) {
        int tempH;
        cin >> tempH;
        H.push_back(tempH);
        if (1 <= i && H[i-1] >= H[i]) {
            tempmax++;
            if (max < tempmax) {max = tempmax;}
        } else {
            tempmax = 0;
        }
    }
    cout << max;

    return 0;
}


Measured memory_bytes: 892
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int Y = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		long ans = 0;
		int[] p = new int[A];
		int[] q = new int[B];
		int[] r = new int[C];
		for (int i = 0; i < A; i++ ) {
			p[i] = scan.nextInt();
		}
		for (int i = 0; i < B; i++ ) {
			q[i] = scan.nextInt();
		}
		for (int i = 0; i < C; i++ ) {
			r[i] = scan.nextInt();
		}

		Arrays.sort(p);
		Arrays.sort(q);
		Arrays.sort(r);

		for(int i = A-1; i >= A-X; i--) {
			ans += p[i];
		}
		for(int i = B-1; i >= B-Y; i--) {
			ans += q[i];
		}

		int i = A-X;
		int j = B-Y;
		int k = C-1;
		while (true) {
			if (i == A) {
				while (q[j] < r[k]) {
					ans += r[k] - q[j];
					j++;
					k--;
				}
				break;
			} else if (j == B) {
				while (p[i] < r[k]) {
					ans += r[k] - p[i];
					i++;
					k--;
				}
				break;
			}else if (p[i] < q[j]) {
				if (p[i] < r[k]) {
					ans += r[k] - p[i];
					i++;
				} else {
					break;
				}
			} else {
				if (q[j] < r[k]) {
					ans += r[k] - q[j];
					j++;
				} else {
					break;
				}
			}

			k--;
			if (k < 0) break;

		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 62364
#include <bits/stdc++.h>
using namespace std;
#define ll long long
double S(ll n){
    double s=0;
    while(n){
        s+=n%10;
        n/=10;
    }
    return s;
}
ll F(ll n){
    ll f=n;
    double mn=n/S(n),s;
    for(ll d=1;d<=n;d*=10){
        ll t=n/(d*10)*(d*10)+d*10-1;
        s=t/S(t);
        if(s<mn){
            mn=s;
            f=t;
        }
    }
    return f;
}

ll k,n;
int main(){
    scanf("%lld",&k);
    for(n=1;k--;n=F(n+1))
		printf("%lld\n",n);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

vector<int> G[2010];

int N, K;

int height[2010];

void dfs(int parent, int a, int depth) {
	height[depth]++;
	rep(i, G[a].size()) {
		if (G[a][i] != parent) {
			dfs(a, G[a][i], depth + 1);
		}
	}
}

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

	cin >> N >> K;
	int A[N - 1];
	int B[N - 1];
	rep(i, N - 1) {
		cin >> A[i] >> B[i];
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	}
	int ans = N;
	rep(i, N) {
		rep(i, 2010) height[i] = 0;
		if (K % 2 == 0)
			dfs(-1, i + 1, 0);
		else {
			if (i == N - 1) break;
			dfs(A[i], B[i], 0);
			dfs(B[i], A[i], 0);
		}
		int tmp = 0;

		for (int j = N; j > (K - K % 2)/2; j--) tmp += height[j];
		//cout << i + 1 << " " << tmp << endl;
		ans = min(ans, tmp);
	}
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
    char S[5],T[5];
    int i,match=0;
    scanf("%s",S);
    scanf("%s",T);
    for(i = 0 ; i < 3 ; i++){
        if(S[i] == T[i]){
            match++;
        }
    }
    printf("%d",match);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
int distance(int yo,int xo,int yi,int xi){
    return (yo-yi)*(yo-yi)+(xo-xi)*(xo-xi);
}
signed main(){
    string S;
    cin >> S ;
    int N = S.length();
    int count = 0;
    rep(i,N/2){
        if(S[i]!=S[N-i-1]){
            count ++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e2+100;
#define fr(i,low,up,st) for(register int i = low;i <= up;i += st)
#define nfr(i,low,up,st) for(register int i = low;i >= up;i -= st)
#define fill(a,b) memset(a,b,sizeof a)
#define cpy(a,b) memcpy(a,b,sizeof a)
int n,m;
int cnt[N][N],sum;
int a[N][N],b[N][N];

int cost(int i,int x,int y){
   int w1 = (a[i][x]-1)/m,w2 = (a[i][y]-1)/m;
   if(w1 == w2)return 0;
   int diff = 0;
   diff -= cnt[x][w1]; diff -= cnt[y][w2];
   diff += cnt[x][w2]; diff += cnt[y][w1];
   return diff+2;
}

int main(){
   srand(time(0));
   scanf("%d%d",&n,&m);
   fr(i,1,n,1)
      fr(j,1,m,1){
         scanf("%d",&a[i][j]);
         cnt[j][i-1] = -1;
      }

   fr(i,1,n,1)
      fr(j,1,m,1){
         cnt[j][(a[i][j]-1)/m] ++;
      }
   int tot = 0;
   fr(i,1,m,1){
      fr(j,0,n-1,1){
         tot += cnt[i][j]*cnt[i][j];
      }
   }
   tot /= 2;

   while(tot){
      int i = rand()%n+1,x = rand()%m+1,y = rand()%m+1;
      if(x == y)continue ;
      int w = cost(i,x,y);
      if(w <= 0){
         int cx = (a[i][x]-1)/m,cy = (a[i][y]-1)/m;
         cnt[x][cx] --; cnt[x][cy] ++; cnt[y][cy] --; cnt[y][cx]++;
         swap(a[i][x],a[i][y]);
         tot += w;
      }
   }
   fr(i,1,n,1){
      fr(j,1,m,1){
         printf("%d ",a[i][j]);
      }
      puts("");
   }
   fr(i,1,n,1){
      fr(j,1,m,1){
         b[(a[i][j]-1)/m+1][j] = a[i][j];
      }
   }
   cpy(a,b);
   fr(i,1,n,1){
      fr(j,1,m,1){
         printf("%d ",a[i][j]);
      }
      puts("");
   }
   return 0;
}


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const int maxn=1e5+5;
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    cin>>n;
    vector<ll> values(maxn,0);
    ll sum=0;
    rep(i,n)
    {
      ll val;
      cin>>val;
      values[val]++;
      sum+=val;
    }
    ll q;
    cin>>q;
    while(q--)
    {
      ll b,c;
      cin>>b>>c;
      ll numb=values[b];
      sum-=(b*values[b]);
      values[b]=0;
      sum+=c*numb;
      values[c]+=numb;
      cout<<sum<<'\n';
    }
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


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

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


int main(void){
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  
  sort(h.rbegin(), h.rend());
  ll ans = 0;
  rep(i, n) {
    if (i < k) continue;
    ans += h[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
s = input()
l = len(s)

c = set([])
for x in s:
    c.add(x)

def solve(arg):
    res = 0
    id = -1
    for i in range(l):
        if s[i] == arg:
            if res < i - id - 1:
                res = i - id - 1
            id = i
    if l - id - 1 > res:
        res = l - id - 1
    return res

ans = 1001001
for x in c:
    tmp = solve(x)
    if tmp < ans:
        ans = tmp

print(ans)


Measured memory_bytes: 8964
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin>>n;
    if ((1<<(int)log2(n))==n) return puts("No"),0;
    puts("Yes"),printf("1 2\n2 3\n3 %d\n%d %d\n%d %d\n",n+1,n+1,n+2,n+2,n+3);
    for (int i=4;i<n;i+=2) printf("%d %d\n%d %d\n%d %d\n%d %d\n",i,1,i+1,1,i,i+n+1,i+1,i+n);
    if (!(n&1)) for (int i=2;i<=n;i++) {
        int w=i^1^n; if (i==3 || w==3 || w>n) continue;
        printf("%d %d\n%d %d\n",n,i,n+n,w); break;
    }
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main(void) {
    int h,w;
    for (;;){
        cin >> h >> w;
        if (!h && !w) break;
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                cout << (!((i+j)%2)?'#':'.');
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	ll ans = 1;
	for (int i = 1; i <= n; ++i) (ans *= i) %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define set set<int>
#define u_set unordered_set<int>
#define pb push_back
#define endl "\n"
#define ll long long int
#define vll vector<long long int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define umap unordered_map 
#define mod 1000000007
#define fori(a,n) for(int i=a;i<n;i++)
#define forj(a,n) for(int j=a;j<n;j++)
#define MAX 300303
#define V vector
using namespace std;

V<bool> dp(100005,0);

signed main()
{
    io
    int n;
    int k;
    cin >> n >> k;
    vi p(n);
    fori(0,n)cin >> p[i];
    sort(p.begin(),p.end());
    fori(0,p[0]){
        dp[i] = 0;
    }
    dp[p[0]] = 1;
    int cnt = 1;
    fori(p[0]+1,k+1){
        if(cnt < n && i==p[cnt]){cnt++; dp[i] = 1;continue;}
        forj(0,cnt){
            // if(i>p[j])
            dp[i] = dp[i] | 1^(dp[i-p[j]]);
            // else cout <<  "why??\n";
            if(dp[i]==1)break;
        }
    }
    if(dp[k]==1)
    cout << "First" << endl;
    else cout << "Second" << endl;

} 

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N,0);
    for(int i=1; i<N; ++i){
        int num;
        cin >> num;
        --num;
        a[num] += 1;
    } 

    for(int i=0; i<N; ++i){
        cout << a[i] << endl;
    }    
}

Measured memory_bytes: 4000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
s=input()
r="keyence"
res=False

for i in range(0,len(r)):
  r1=r[:i+1]
  r2=r[-(len(r)-i-1):]
  r1i=s.find(r1)
  r2i=s.rfind(r2)
  
  if r1i<0 or r2i<0:
    continue
  elif r1i==0:
    if r2i==len(s)-len(r2):
      res=True
if s.find(r)>=0 and s.find(r)==len(s)-len(r):
  res=True
if s.find(r)==0:
  res=True
    
  
if res:
  print('YES')
else:
  print('NO')



Measured memory_bytes: 3188
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        boolean[][] meiro = new boolean[n][n];

        for (int i = 0; i < m; i++) {
            int left = sc.nextInt() - 1;
            int right = sc.nextInt() - 1;
            meiro[left][right] = true;
            meiro[right][left] = true;
        }

        StringBuilder builder = new StringBuilder();

        for (int i = 1; i < n; i++) {
            builder.append(i);
        }

        String base = builder.toString();
        permutation(base, "");

        int count = 0;

        top : for (String target: list
             ) {
            String[] values = target.split("");
            int lastValue = 0;
            for (String value : values) {
                int start = lastValue;
                int end = Integer.parseInt(value);
                if (!meiro[start][end]) {
                    continue top;
                }
                lastValue = end;
            }
            count++;
        }

        System.out.println(count);
    }

    private static ArrayList<String> list = new ArrayList<>();

    private static void permutation(String q, String ans){
        // Base Case
        if(q.length() <= 1) {
            list.add(ans + q);
        }
        // General Case
        else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1),
                        ans + q.charAt(i));
            }
        }
    }
}

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

Measured memory_bytes: 23252
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  n <- getInt

  let solve i res
        | i*i > n        = res
        | n `mod` i /= 0 = solve (i+1) res
        | otherwise      = solve (i+1) (min res (g i))

      g x = let y = n `div` x
                nx = length $ show x
                ny = length $ show y
            in max nx ny

  print $ solve 1 inf

Measured memory_bytes: 892
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for l in range(n)]
ans = 0
for i in range(n):
    sum = c
    for j in range(m):
        sum += b[j]*a[i][j]
    if(sum > 0):
        ans = ans + 1
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define LL long long
using namespace std;
typedef pair<LL,LL>pii;
LL a[1<<18+5];
vector<pii>v[1<<18+5];
int main(void)
{
	int i,j,n,S;
	LL ans=0;
	scanf("%d",&n);
	for(i=0;i<(1<<n);++i)scanf("%lld",&a[i]);
	for(i=0;i<(1<<n);++i)v[i].push_back(make_pair(a[i],i));
	for(S=0;S<(1<<n);++S)
	{
		for(i=0;i<n;++i)
		{
			if(!((S>>i)&1))continue;
			for(j=0;j<v[S^(1<<i)].size();++j)v[S].push_back(v[S^(1<<i)][j]);
		}
		sort(v[S].begin(),v[S].end(),greater<pii>());
		v[S].erase(unique(v[S].begin(),v[S].end()),v[S].end());
		if(v[S].size()>2)v[S].resize(2);
	}
	for(S=1;S<(1<<n);++S)
	{
		ans=max(ans,v[S][0].first+v[S][1].first);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 323200
n,y = map(int,input().split())
a = 10000
b = 5000
c = 1000
for i in range(n+1):
         for j in range(n-i+1):
                  if a*i+b*j+(n-i-j)*c == y:
                           print(i,j,n-i-j)
                           exit()
print(-1,-1,-1)


Measured memory_bytes: 2940