akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
public class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		long[] fb=new long[45];
		fb[0]=1;
		fb[1]=1;
		for(int i=2; i<=44; i++) {
			fb[i]=fb[i-1]+fb[i-2];
		}
		pl(fb[sc.nextInt()]);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 24452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
    int n,u,d;
    cin>>n;
    u=n/100;
    d=n%100;
    if(u==0||u>12){
        if(0<d&&d<=12){
            cout<<"YYMM"<<endl;
        }
        else{
            cout<<"NA"<<endl;
        }
    }
    else{
        if(0<d&&d<=12){
            cout<<"AMBIGUOUS"<<endl;
        }
        else{
            cout<<"MMYY"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#define m_p make_pair
#define p_b push_back
#define m1 first
#define m2 second
#define N 100010

using namespace std;

typedef pair<int,int> pa;
vector<pa> a;
vector<int> b;
priority_queue<int,vector<int>,greater<int> >pq;
int n,m,pos,tpos,ans;

int main(){
	int i,t1,t2;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d%d",&t1,&t2);
		a.p_b(m_p(t1,t2));
	}
	sort(a.begin(),a.end());
	for(i=0;i<n;i++){
		pq.push(a[i].m2);
		if(a[i].m1<=pos){
			b.p_b(pq.top()); pq.pop();
		} else pos++;
	}
	sort(b.begin(),b.end(),greater<int>());
	tpos=pos; pos=0;
	for(i=0;i<b.size();i++)
	if(pos+tpos==m) ans++; else
	if(m+1-b[i]<=pos) ans++; else pos++;
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int n,r;
  cin>>n>>r;
  if(10 <= n)cout<<r<<endl;
  else cout<<r + (100 * (10 - n))<<endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  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 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;
int N, M;
vector<vector<int>> v( 8 + 1 , vector<int>( 8 + 1, 0 ) );
vector<int> visited( 8 + 1, 0 );
bool flag = true;
int res{};
void dfs( int i )
{
    //始点 -> 1 をset
    visited[ i ] = 1;
    REP2( j, 1, N + 1 )
    {
        if( v[ i ][ j ] == 1 && visited[ j ] == 0 )
        {
            flag = true;
            dfs( j );
            visited[ j ] = 0;
        }
        if( !visited[ j ] )
        {
            flag = false;
        }
    }
    if( flag )
    {
        res++;
    }
}
int main()
{
    cin >> N >> M;
    
    int A, B;
    REP2( i, 1, M + 1 )
    {
        cin >> A >> B;
        v[ A ][ B ] = 1;
        v[ B ][ A ] = 1;
    }
    dfs( 1 );
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int A, B, C;
    cin >> A >> B >> C;
    
    int sound_count = 0;
    while (true) {
        if (B < A || sound_count == C) {
            break;
        }
        B -= A;
        sound_count++;
    }
    
    cout << sound_count << endl;
    return 0;
}


Measured memory_bytes: 256
# 23-Structure_and_Class-Dice_I.py

# ???????????? I
# ?¬?????±??????????????????????????????????????????¢??????????????\??¬????????§????????????????????°????????????????????????????????????

# ????????????????????¢??????????????¨????????? 1 ?????? 6 ????????????????????????????????????????????????
# ??\?????¨??????????????????????????¢?????????????????????????????°?????¨?????¢?????????????????????????????????????????§???
# ????????????????????¢?????°?????????????????????????????????
# ????????\??¬????????§??????????????¶?????????????????¨?????????????????????????????§?????????????????????????????????????????¨????????????

# Input
# ?????????????????¢?????°???????????????????????????????????????????????????????????§?????????????????????

# ???????????????????????¨????????????????????????????????????????????????????????????????????????????????????????????¨????????? E???N???S???W ????????????????????§??????

# Output
# ???????????????????????????????????????????????????????????¢?????°???????????????????????????????????????

# Constraints
# 0???0??? ??\?????????????????????????????¢?????°??? ???100???100
# 0???0??? ???????????¨????????????????????? ???100???100
# Note
# ?¶???????????????? Dice III, Dice IV ??§???????????°????????????????????±????????§???????????????????????????????§?????????§?????????????????????????????????

# Sample Input 1
# 1 2 4 8 16 32
# SE
# Sample Output 1
# 8
# ?????¢??? 1, 2, 4, 8, 16, 32 ??¨??????????????????????????? S ??????????????¢???????????????E ??????????????¢????????¨????????¢?????°?????? 8 ??????????????????



# Sample Input 2
# 1 2 4 8 16 32
# EESWN
# Sample Output 2
# 32

class Dice:
	def __init__(self, dice_num):
		self.side_top=1
		self.side_bot=6
		self.side_Nor=5
		self.side_Eas=3
		self.side_Sau=2
		self.side_Wes=4
		self.dice_num = dice_num

	def op_N(self):
		self.side_top, self.side_bot, self.side_Nor, self.side_Sau =\
		self.side_Sau, self.side_Nor, self.side_top, self.side_bot

	def op_E(self):
		self.side_top, self.side_bot, self.side_Eas, self.side_Wes =\
		self.side_Wes, self.side_Eas, self.side_top, self.side_bot

	def op_S(self):
		self.side_top, self.side_bot, self.side_Nor, self.side_Sau =\
		self.side_Nor, self.side_Sau, self.side_bot, self.side_top

	def op_W(self):
		self.side_top, self.side_bot, self.side_Eas, self.side_Wes =\
		self.side_Eas, self.side_Wes, self.side_bot, self.side_top

	def print_side_top(self):
		print( dice_num[self.side_top-1] )

	def print_side_all(self):
		print( "top:{}, bot:{}, Nor:{}, Eas{}, Sau:{}, Wes,{}.".format(self.side_top, self.side_bot, self.side_Nor, self.side_Eas, self.side_Sau, self.side_Wes ) )

dice_num = list( map(int, input().split()))
op = input()

dice_roll = Dice(dice_num) 
for i in op:
	if i == "N":
		dice_roll.op_N()
	elif i =="E":
		dice_roll.op_E()
	elif i =="S":
		dice_roll.op_S()
	elif i =="W":
		dice_roll.op_W()
	else:
		print("?????°??°")

dice_roll.print_side_top()

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> ans(n,-1);
    bool flag = true;
    rep(i,m) {
        int s,c;
        cin >> s >> c;
        s--;
        if(ans[s] != -1 && ans[s] != c) {
            flag = false;
            break;
        }
        if(s == 0 && n != 1 && c == 0) {
            flag = false;
            break;
        }
        ans[s] = c;
    }
    if(flag) {
        rep(i,n) {
            if(ans[i] == -1) {
                if(i == 0 && n != 1) ans[i] = 1;
                else ans[i] = 0;
            }
        }
        if(n == 1) cout << ans[0] << endl;
        else if(n == 2) cout << ans[0]*10+ans[1] << endl;
        else cout << ans[0]*100+ans[1]*10+ans[2] << endl;
    } else cout << "-1" << endl;
}

Measured memory_bytes: 256
class NullNode():
    def __init__(self):
        self.id = -1

class Node():
    def __init__(self, id):
        self.id = id
        self.parent = NullNode()
        self.left = NullNode()
        self.right = NullNode()
        self.sibling = NullNode()

    def __str__(self):
        return '{} {} {} {} {}'.format(self.id, self.parent.id, self.left.id, self.right.id, self.sibling.id)

    def getHeight(self, right_height=0, left_height=0):
        if self.left.id != -1:
            left_height += 1
            left_height = self.left.getHeight(left_height, left_height)
        if self.right.id != -1:
            right_height += 1
            right_height = self.right.getHeight(right_height, right_height)
        return max(left_height, right_height)

    def getDepth(self, depth=0):
        if self.parent.id != -1:
            depth += 1
            depth = self.parent.getDepth(depth)
        return depth

    def getDegree(self):
        degree = 0
        if self.left.id != -1:
            degree += 1
        if self.right.id != -1:
            degree += 1
        return degree

    def getType(self):
        if self.parent.id == -1:
            return 'root'
        elif self.left.id == -1 and self.right.id == -1:
            return 'leaf'
        else:
            return 'internal node'

n = int(input())
node_list = [Node(id) for id in range(n)]
for i in range(n):
    [id, left, right] = [int(j) for j in input().split()]
    i_node = node_list[id]
    if left != -1:
        i_node.left = node_list[left]
        node_list[left].parent = node_list[id]
        if right != -1:
            node_list[left].sibling = node_list[right]
    if right != -1:
        i_node.right = node_list[right]
        node_list[right].parent = node_list[id]
        if left != -1:
            node_list[right].sibling = node_list[left]

for id in range(n):
    i_node = node_list[id]
    parent = i_node.parent.id
    sibling = i_node.sibling.id
    degree = i_node.getDegree()
    depth = i_node.getDepth()
    height = i_node.getHeight()
    type = i_node.getType()
    print('node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}'.format(id, parent, sibling, degree, depth, height, type))



Measured memory_bytes: 5620
#include <bits/stdc++.h>
#include <stdint.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define int long long
typedef vector<int> vi;
typedef pair<int, int> pii;
const double PI = acos(-1.0);
const int mod = 1e9 + 7;
int pows(int a , int b){int res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
const int N = 1e5+5;
int dp[1006][1005] ;
vector<int> v[N] ;
void init() {
  ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
}

void solve(){
    int n , m ;
    cin >> n >> m ;
    vector<string> v(n) ;
    for(int i = 0 ; i < n ; i++){
        cin >> v[i] ;
    }
    memset(dp,0,sizeof dp) ;
    dp[0][0] = 1 ;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++){
                if(i>=1 && v[i-1][j]=='.')
                    dp[i][j] += dp[i-1][j] ;
                if(j>=1 && v[i][j-1]=='.')
                    dp[i][j] += dp[i][j-1] ;
                dp[i][j] %= mod ;
        }
    }

    cout << dp[n-1][m-1] << endl ;
}
int32_t main()
{
    init();
    int t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 11520
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{

    class Program
    {
        public static (long m, long s)[,] dp;

        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);

                var vals = Console.ReadLine().Split(' ').
                    Select(x => long.Parse(x)).ToList();


                var N = vals[0];
                var X = vals[1];
                var T = vals[2];





                Console.WriteLine(T*((N+X-1)/X));

                Console.Out.Flush();
            }




        }
    }

}




Measured memory_bytes: 28216
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ARemainingTime {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b;
	    in >> a >> b;
	    out << (a+b)%24 << endl;
	}
};


int main() {
	ARemainingTime solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String str = sc.next();
        int sum=0;
        for (int ct = 0; ct < str.length(); ct++) {
            if(str.charAt(ct)=='+'){
                sum++;
            }else{
                sum--;
            }
        }
        System.out.println(sum);
    }
}


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

int main(void){
        char s[1001],com[20],p[1001],tmp;
        int i,j,q,a,b;
        scanf("%s",s);
        scanf("%d",&q);
        for(i=0;i<q;i++){
                scanf("%s %d %d",com,&a,&b);
                if(strcmp(com,"replace")==0){
                        scanf("%s",p);
                        for(j=0;j<=(b-a);j++)
                                s[a+j]=p[j];
                }else if(strcmp(com,"reverse")==0){
                        for(j=0;j<((b-a+1)/2);j++){
                                tmp=s[a+j];
                                s[a+j]=s[b-j];
                                s[b-j]=tmp;
                        }
                }else if(strcmp(com,"print")==0){
                        for(j=0;j<b-a+1;j++)
                                printf("%c",s[a+j]);
                        putchar('\n');
                }
        }
        return 0;
}

Measured memory_bytes: 580
def main():
  import heapq
  n,m = map(int,input().split())
  a =sorted(list(map(lambda x: int(x)*(-1),input().split())))
  heapq.heapify(a)
  for _ in range(m):
    x=heapq.heappop(a)/2
    heapq.heappush(a,x) 
  print(int(sum((-1)*i//1 for i in a)))
if __name__=='__main__':
  main()

Measured memory_bytes: 14180
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int nb, ans = 0;
	cin >> nb;

	while (nb >= 500)
	{
		nb -= 500;
		ans += 1000;
	}

	while (nb >= 5)
	{
		nb -= 5;
		ans += 5;
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;

using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}

const int MAX = 50;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(void){

    int n;
    cin>>n;

    string s;
    cin>>s;

    char a[27];
    char i;
    int count = 0;
    for(i ='A';i<='Z';++i){
        a[count] = i;
       // cout<<count<<";"<<a[count]<<endl;
        count++;   
    }

    for(int j=0;j<s.size();j++){
        for(int k=0;k<27;k++){
            if(a[k]==s[j]){
                if(k+n > 25){
                    cout<<a[k+n-26];
                }else{
                    cout<<a[k+n];
                }
                break;
            }
        }
    }

    cout<<endl;

   

    return 0;
}

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

using namespace std;

int main(){
	
	int n,T;
	
	int c,t;
	
	cin >> n >> T;
	
	int ans = 1e6;
	
	for(int i=0;i<n;i++){
		cin >> c  >> t;
		
		if(c<ans && t<=T){
			ans = c;
		}
	}
	
	if(ans==1e6){
		cout << "TLE" << endl;
	}else{
		cout << ans << endl;
	}
	
    return 0;
}


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

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

    double a, b, c, d, e, f;
    double ans = -1e9, x, y;
    cin >> a >> b >> c >> d >> e >> f;
    for(int i = 0; i * a * 100 <= f; i++){
        for(int j = 0; j * b * 100 <= f; j++){
            if(i == 0 and j == 0) continue;
            for(int k = 0; i * a * 100 + b * j * 100 + k * c <= f and k * c <= e * (i * a + j * b); k++){
                for(int l = 0; i * a * 100 + b * j * 100 + k * c + l * d <= f and k * c + l * d <= e * (i * a + j * b); l++){
                    if(ans < (k * c + l * d) / (i * a + j * b)){
                        ans = (k * c + l * d) / (i * a + j * b);
                        x = k * c + l * d + i * a* 100 + j * b * 100;
                        y = k * c + l * d;
                    }
                }
            }
        }
    }

    cout << x << ' ' << y << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, m; cin >> n >> m;
  vector<int> h(n); REP(i, n) cin >> h[i];
  vector<vector<int>> graph(n);
  while (m--) {
    int a, b; cin >> a >> b; --a; --b;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }
  int ans = 0;
  REP(i, n) {
    bool ok = true;
    for (int e : graph[i]) ok &= h[e] < h[i];
    ans += ok;
  }
  cout << ans << '\n';
  return 0;
}


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

int N;
#define MAXN 100000
int A[MAXN];
vector<int> adj[MAXN];

long long dfs(int v, int par) {
  vector<long long> ns; long long sum_ns = 0;
  for(auto w : adj[v]) {
    if(w == par) continue;
    ns.push_back(dfs(w, v));
    if(ns.back() < 0) return -1;
    sum_ns += ns.back();
  }
  if(ns.empty()) return A[v];
  long long d = sum_ns - A[v], n = A[v] - d;
  if(d < 0 || n < 0) return -1;
  int nns = ns.size();
  if(par < 0 && nns > 1 && n > 0) return -1;
  sort(ns.begin(), ns.end(), greater<long long>());
  if((ns[0] <= sum_ns - ns[0] ? sum_ns / 2 : sum_ns - ns[0]) < d) return -1;
  return n;
}

int main() {
  scanf("%d", &N);
  for(int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  for(int i = 0; i < N - 1; ++i) {
    int a, b; scanf("%d%d", &a, &b); --a; --b;
    adj[a].push_back(b); adj[b].push_back(a);
  }
  printf("%s\n", dfs(0, -1) >= 0 ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 16768
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n;
	string name[100];
	int score[100];
	int number[100];

	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> name[i] >> score[i];
		number[i] = i + 1;
	}

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (name[i] > name[j]) {
				string temp_s = name[i];
				int temp = score[i];
				int temp_n = number[i];

				name[i] = name[j];
				score[i] = score[j];
				number[i] = number[j];

				name[j] = temp_s;
				score[j] = temp;
				number[j] = temp_n;
			}
			else if (name[i] == name[j] && score[i] < score[j]) {
				string temp_s = name[i];
				int temp = score[i];
				int temp_n = number[i];

				name[i] = name[j];
				score[i] = score[j];
				number[i] = number[j];

				name[j] = temp_s;
				score[j] = temp;
				number[j] = temp_n;
			}
		}
	}

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

Measured memory_bytes: 256
import math
n =int(input())
x = [int (x) for x in input().split()]
y = [int (y) for y in input().split()]

for p in range(1,4):
    s =sum([abs(x[i]-y[i])**p for i in range(n)])
    s = s**(1/p)
    print("%.6f" % s)

s = max([abs(x[i]-y[i]) for i in range(n)])
print("%.6f" % s)

Measured memory_bytes: 7812
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin >> s;
    int l=s.size();
    int sum=0;
    rep(i,l)sum+=s[i]-'0';
    cout << (sum%9==0?"Yes":"No");
}

Measured memory_bytes: 3688
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

bool isInc = false;
vector<int> a;

void check() {
	rep(k, a.size() - 1) {
		if (a[k] != a[k + 1]) {
			if (a[k] < a[k + 1]) {
				isInc = true;
				//cout << "ZOKA\n";

			}
			else {
				isInc = false;
				//cout << "GENSYO\n";
			}
			break;
		}
	}
}

void check2(int i) {
	for (int k = i; k < a.size() - 1; k++) {
		if (a[k] != a[k + 1]) {

			if (a[k] < a[k + 1]) {
				isInc = true;
			/*	cout << "ZOKA\n";
				debug(a[k]);
				debug(a[k + 1]);
				debug(i);*/
			}
			else {
				isInc = false;
			/*	cout << "GENSYO\n";
				debug(a[k]);
				debug(a[k + 1]);
				debug(i);*/
			}
			break;
		}
	}
}
signed main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	rep(i, n) {
		int num;
		cin >> num;
		a.pb(num);
	}
	int ans = 0;
	if (a.size() == 1) {
		cout << 1 << endl;
		return 0;
	}
	check();
	for (int i = 1; i < a.size(); i++) {
		if (isInc) {
			if (a[i - 1] > a[i]) {
				ans++;
				if (a.size() - 1 < i + 1) break;
				check2(i);
			/*	if (a[i] < a[i + 1])
					isInc = true;
				else
					isInc = false;*/
			}
		}
		else {
			if (a[i - 1] < a[i]) {
				ans++;
				if (a.size() - 1 < i + 1) break;
				check2(i);
			/*	if (a[i] < a[i + 1]) {
					isInc = true;
				}
				else {
					isInc = false;
				}*/
			}
		}
	}
	cout << ans + 1 << endl;
	return 0;
}



Measured memory_bytes: 1400
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	void run() throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] A = new long[n];
		for (int i = 0; i < n; ++i) {
			A[i] = sc.nextLong();
		}

		ArrayDeque<Long> que = new ArrayDeque<>();

		for (int i = 0; i < n; ++i) {
			if (i - 1 >= 0 && A[i - 1] == A[i])
				continue;
			que.add(A[i]);
		}

		int cnt = 0;
		ArrayList<Long> cur = new ArrayList<>();
		while (!que.isEmpty()) {
			long v = que.pollFirst();
			if (cur.size() < 2) {
				if (cur.size() == 0)
					++cnt;
				cur.add(v);
				continue;
			}

			if ((cur.get(cur.size() - 1) - cur.get(cur.size() - 2)) * (v - cur.get(cur.size() - 1)) >= 0) {
				cur.add(v);
			} else {
				cur.clear();
				cur.add(v);
				++cnt;
			}
		}
		System.out.println(cnt);

	}
}

Measured memory_bytes: 61252
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(M),b(M);
  rep(i,M){
      cin >> a[i] >> b[i];
      a[i]--;b[i]--;
  }
  vector<int> num(N);
  rep(i,M){
      num[a[i]]++;
      num[b[i]]++;
  }
  rep(i,N){
      cout << num[i] << endl;
  }
} 

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
    int P = 0;
    char tmp[100000];
    if (scanf("%s", tmp) < 1) return 0;

    for (int i = 0; i < strlen(tmp); i++)
        if (tmp[i] == 'p') P++;

    printf("%ld\n", strlen(tmp) / 2 - P);
    return 0;
}


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



int main() {
  int N, X, T;
  cin >> N >> X >> T;
  int cnt = 0;
  cnt = N/X;
  if (N%X != 0) cnt++;
  cout << cnt*T << endl;


	return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate など
#include <stdexcept>
#include <cassert> // assert
using namespace std;

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

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

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

// constexpr inline ll MOD = 1'000'000'007;

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int k;
    string s;
    cin >> k >> s;
    if (k >= s.size())
    {
        cout << s << endl;
    }
    else
    {
        s = s.substr(0,k);
        s = s + "...";
        cout << s << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACh(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int a[550][550];
int odd[550][550];
vector<pair<int,int>> memo;
int N;

int main() {
  int H,W;
  int num = 0;
  memo.PB(MP(0,0));
  scanf("%d%d", &H,&W);
  FOR(i,0,H-1){
    FOR(j,0,W-1){
      scanf("%d", &a[i][j]);
      if(a[i][j]%2!=0) {
        odd[i][j] = 1;
      }
    }
  }

  int count = 0;
  FOR(i,0,H-2){
    FOR(j,0,W-1){
      if(odd[i][j]%2!=0){
        // cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
        ++odd[i+1][j];
        ++count;
      } 
    }
  }
  FOR(i,0,W-2){
    if(odd[H-1][i]%2!=0){
      // cout << H-1 << " " << i+1 << " " <<  H-1 << " " << i+2 << endl;
      ++odd[H-1][i+1];
      ++count;
    }
  }
  cout << count << endl;


  FOR(i,0,H-2){
    FOR(j,0,W-1){
      if(a[i][j]%2!=0){
        cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
        ++a[i+1][j];
      } 
    }
  }
  FOR(i,0,W-2){
    if(a[H-1][i]%2!=0){
      cout << H << " " << i+1 << " " <<  H << " " << i+2 << endl;
      ++a[H-1][i+1];
    }
  }

}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int c[1005][1005];
int a[1005][1005];
int px[]={1,1,1,0,0,-1,-1,-1},py[]={1,0,-1,1,-1,1,-1,0};
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			char f=getchar();
			if(f=='\n')f=getchar();
			if(f=='#')
			c[i][j]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			for(int k=0;k<8;k++)
			{
				if(c[i+px[k]][j+py[k]]==1)
				a[i][j]++;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{for(int j=1;j<=m;j++)
	{
		if(c[i][j]==1)cout<<'#';
		else cout<<a[i][j];
	}
	cout<<endl;
	}
}

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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

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

bool possible(llong groups, llong s, llong c) {

	// Use up all the S
	llong s_left = max(0LL, groups - s);

	// use Cs to make the S's that are left
	llong c_left = c - s_left * 2;

	// Check if we have enough Cs
	return c_left >= groups * 2;

}

void solve() {

	llong s, c;
	cin >> s >> c;

	llong ans = 0;

	llong lo = 0, hi = 1e12;

	while (lo < hi) {

		llong m = lo + (hi - lo + 1) / 2;

		if (possible(m, s, c)) {
			lo = m;
		} else {
			hi = m - 1;
		}

	}

	cout << lo << endl;

}

int main() {

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

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}

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

int main() 
{ 
	
int n,k,ans=0;
cin>>n>>k;

int p[n];

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

sort(p,p+n);

for(int i=0;i<k;i++)
{
    ans+=p[i];
}

cout<<ans;
	return 0; 
} 


Measured memory_bytes: 3616
import math
import string
import collections
from collections import Counter


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

x, y, z = map(int, input().split())
n = 0
while(y*n+z*(n+1) <= x):
    n += 1
print(n-1)


Measured memory_bytes: 3832
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef double db;
typedef long long li;
typedef long double ld;
typedef pr<int, int> ii;
typedef pr<ld,ld> dd;
typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;
typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;
typedef set<int> s_i;
typedef set<char> s_c;
const int MOD = 998244353;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
int dp[305][305][305];
int sum1[305][305][305];
int sum2[305][305][305];
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	vi v(1);string s;int K;
	cin>>s>>K;s='0'+s;
	int cnt=0;
	for(int i=s.length()-1; i>=0; i--)
	{
		if(s[i]=='1') cnt++;
		else 
		{
			v.eb(cnt);
			cnt=0;
		}
	}
	reverse(begin(v)+1, end(v));
	int n=v.size()-1;
	for(int i=1; i<=n; i++)
	{
		for(int j=0; j<=min((int)s.length(), K); j++) 
		{
			for(int k=0; k<=j; k++) 
			{
//				cout<<v[i]<<" \n";
//				cout<<sum1[i-1][j][k]<<" "<<sum2[i-1][j][k]<<" "<<sum2[i-1][j][min(j+1, k+v[i]+1)]<<" "<<dp[i-1][j][k]<<endl;
				if(i==1 and j==k) dp[i][j][k]=1;
				else if(i>1) 
					dp[i][j][k]=(sum1[i-1][j][k]+sum2[i-1][j][k]-sum2[i-1][j][min(j+1, k+v[i]+1)]-dp[i-1][j][k]+3*MOD)%MOD;
				dp[i][j][k]%=MOD;
//				cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
				if(k) sum1[i][j][k]=(sum1[i][j-1][k-1]+dp[i][j][k])%MOD;
				else sum1[i][j][k]=dp[i][j][k];
			}
			for(int k=j; k>=0; k--)
				sum2[i][j][k]=(sum2[i][j][k+1]+dp[i][j][k])%MOD;
		}
	}
	int ans=0;
	for(int j=0; j<=min((int)s.length(), K); j++)
	{
		ans+=dp[n][j][0];
		ans%=MOD;
	}
	while(ans<0) ans+=MOD;
	cout<<ans;
}

Measured memory_bytes: 330324
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
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 mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};



int main(){
    int n,k,s;cin >> n >> k >> s;
    vector<int> ans(n,0);
    for (int i = 0; i < k; i++) {
        ans[i] = s;
    }
    for (int i = k; i < n; i++) {
        ans[i] = (s==(int)1e9?1e9-1:1e9);
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << (i==n-1?"\n":" ");
    }
    return 0;
}


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

struct dice{
	int top;
	int front;
	int left;
	int right;
	int back;
	int bottom;
};

void ClockwiseTop(dice *X){
	int c = X->front;
	X->front  = X->right;
	X->right  = X->back;
	X->back   = X->left;
	X->left   = c;
}

void ClockwiseFront(dice *X){
	int c = X->top;
	X->top    = X->left;
	X->left   = X->bottom;
	X->bottom = X->right;
	X->right  = c;
}

void ClockwiseRight(dice *X){
	int c = X->top;
	X->top    = X->front;
	X->front  = X->bottom;
	X->bottom = X->back;
	X->back   = c;
}

void ClockwiseBottom(dice *X){
	ClockwiseTop(X);
	ClockwiseTop(X);
	ClockwiseTop(X);
}

void ClockwiseBack(dice *X){
	ClockwiseFront(X);
	ClockwiseFront(X);
	ClockwiseFront(X);
}

void ClockwiseLeft(dice *X){
	ClockwiseRight(X);
	ClockwiseRight(X);
	ClockwiseRight(X);
}

void TwiceClockwiseTop(dice *X){
	ClockwiseTop(X);
	ClockwiseTop(X);
}

void TwiceClockwiseRight(dice *X){
	ClockwiseRight(X);
	ClockwiseRight(X);
}

dice ArrengeTop(dice A, dice B){
	if(B.front  == A.top) ClockwiseRight(&B);
	if(B.right  == A.top) ClockwiseBack(&B);
	if(B.left   == A.top) ClockwiseFront(&B);
	if(B.back   == A.top) ClockwiseLeft(&B);
	if(B.bottom == A.top) TwiceClockwiseRight(&B);
	return B;
}

dice ArrengeFront(dice A, dice B){
	if(B.right  == A.front) ClockwiseTop(&B);
	if(B.left   == A.front) ClockwiseBottom(&B);
	if(B.back   == A.front) TwiceClockwiseTop(&B);
	return B;
}

char Judge(dice A, dice B){
	B = ArrengeTop(A, B);
	B = ArrengeFront(A, B);	
	if(B.top    != A.top   ) return 'F';
	if(B.front  != A.front ) return 'F';
	if(B.right  != A.right ) return 'F';
	if(B.left   != A.left  ) return 'F';
	if(B.back   != A.back  ) return 'F';
	if(B.bottom != A.bottom) return 'F';
	return 'T';
}

dice Enter(dice X){
	cin >> X.top;
	cin >> X.front;
	cin >> X.right;
	cin >> X.left;
	cin >> X.back;
	cin >> X.bottom;
	return X;
}

int main(){
	//?????????????????????????????¢?????°????????\?????????
	dice A = Enter(A);
	dice B = Enter(B);
	//???????????????????????¨?????????
	if(Judge(A, B) == 'F') cout << "No"  << endl;
	if(Judge(A, B) == 'T') cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1160
import util.control.Breaks._

object Main extends App {
  val Array(n, m) = io.StdIn.readLine().split(' ').map(_.toInt)
  val edges = Array.fill(n+1)(Array.fill(n+1)(false))
  var count = 0
  for (_ <- 0 until m; Array(a, b) = io.StdIn.readLine().split(' ').map(_.toInt))
    edges(a)(b) = true
  for (p <- (2 to n).permutations) {
    var current = 1
    breakable {
      for (next <- p) {
        if (!edges(current)(next) && !edges(next)(current)) break
        current = next
      }
      count += 1
    }
  }
  println(count)
}

Measured memory_bytes: 33564
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let vs: Vec<i32> = line.split(' ').map(|x| x.parse().unwrap()).collect();
  let n = vs[0];
  let m = vs[1];
  let ans_n = if n == 0 { 0 } else { n * (n - 1) / 2 };
  let ans_m = if m == 0 { 0 } else { m * (m - 1) / 2 };
  println!("{}", ans_n + ans_m);
}

Measured memory_bytes: 4352
#include <stdio.h>

#define MAXCMD 2000000

struct tagLinkList
{
	int forward;
	int data;
	int back;
}LinkList[MAXCMD];
int head = -1;
int tail = 0;
int deletePos[20] = { -1 };

void InsertData(int data)
{
	int now, next;
	now = head;
	next = ++head;

	LinkList[next].data = data;
	LinkList[next].forward = tail;

	if (next == tail)
	{
		LinkList[next].back = tail;
	}
	else
	{
		LinkList[next].back = now;

		LinkList[now].forward = next;
		LinkList[tail].back = next;
	}
}

void del(int i)
{
	int f = LinkList[i].forward;
	int b = LinkList[i].back;

	LinkList[f].back = b;
	LinkList[b].forward = f;

	LinkList[i].forward = -1;
	LinkList[i].data = -1;
	LinkList[i].back = -1;

	if (i == head)
	{
		head = b;
		if (head == 0)
		{
			head = -1;
		}
	}
	if (i == tail)
	{
		tail = f;
	}
}

void DeleteData(int d)
{
	for (int i = head;;)
	{
		int b = LinkList[i].back;

		if (LinkList[i].data == d)
		{
			del(i);
			break;
		}
		i = b;
		if (i == head)
		{
			break;
		}
	}
}

void DeleteFirst()
{
	del(head);
}

void DeleteLast()
{
	del(tail);
}

int main()
{
	int N;
	char Command[15];
	int Data;
	
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		LinkList[i].forward = -1;
		LinkList[i].data = -1;
		LinkList[i].back = -1;
	}
	
	for (int i = 0; i < N; i++)
	{
		scanf("%s", Command);
		if (Command[0] == 'i')
		{
			scanf("%d",&Data);
			InsertData(Data);
		}
		else if (Command[6] == 'F')
		{
			DeleteFirst();
		}
		else if (Command[6] == 'L')
		{
			DeleteLast();
		}
		else
		{
			scanf("%d", &Data);
			DeleteData(Data);
		}
	}

	for (int i = head;;)
	{
		printf("%d", LinkList[i].data);
		i = LinkList[i].back;
		if (i == head)
		{
			break;
		}
		printf(" ");
	}
	printf("\n");
	return 0;
}

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

using namespace std;
int main() {
  int n;
  cin >> n;
  long num[n];
  for (int i = 0; i < n; i++) {
    cin >> num[i];
  }
  int cnt = 0;
  while (true) {
    for (int i = 0; i < n; i++) {
      if (num[i] % 2 != 0) {
        cout << cnt << endl;
        return 0;
      }
      num[i] /= 2;
    }
    cnt++;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		String[] temp = scanner.nextLine().split(" ");
		long a = Long.parseLong(temp[0]);
		long b = Long.parseLong(temp[1]);
		long k = Long.parseLong(temp[2]);

		if(k <= a) {

			System.out.println(a - k + " " + b);


		}else if(k > a && k - a < b) {

			System.out.println(0 + " " + (b - (k - a)));

		}else {

			System.out.println(0 + " " + 0);

		}



	}
}

Measured memory_bytes: 38908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    int n; cin >> n;

    map<string, int> mp;
    rep(i, n) {
        string s, t; cin >> s >> t;
        if(s == "insert") mp[t]++;
        else {
            if(mp[t] >= 1) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 47448
use proconio::{input, fastout};
use num::integer::gcd;

#[fastout]
fn main() {
    input! {
        n: u64,
    }
    let mut ans: u64 = 0;

    for i in 1..=n {
        for j in 1..=n {
            let ij = gcd(i, j);
            if ij == 1 {
                ans += n;
                continue;
            }
            for k in 1..=n {
                ans += gcd(ij, k);
            }
        }
    }
    println!("{}", ans);
}


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

fn main() {
    input!{
        mut s: Chars,
        t: Chars,
    }

    let mut ok = false;

    'next: for i in (t.len()-1..s.len()).rev() {
        for (j, &c) in t.iter().rev().enumerate() {
            if s[i-j] != c && s[i-j] != '?' {
                continue 'next;
            }
        }
        ok = true;
        for (j, &c) in t.iter().rev().enumerate() {
            s[i-j] = c;
        }
        break;
    }
    
    if !ok {
        println!("UNRESTORABLE");
        return;
    }

    for c in s.iter_mut() {
        if *c == '?' {
            *c = 'a';
        }
    }

    let s = s.iter().collect::<String>();

    println!("{}", s);
}


Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
#include <map>
#include <unordered_map>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <limits.h>
#include <tgmath.h>

using namespace std;

typedef uint16_t ui16;
typedef uint32_t ui32;
typedef uint64_t ui64;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef long double ld;
typedef pair<int, int> pr;

//template<typename T> inline T abs(T a) { return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a) { return a * a; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) {for (int i = 0; i < v.size(); ++i) cout << v[i] << " "; cout << endl; return cout; }
void print() { cout << endl; }
template<typename T, typename... Ts> void print(T x, Ts... xs) { cout << x << " "; print(xs...); };
template<typename T> void read(vector<T>& v) { for (int i = 0; i < v.size(); ++i) cin >> v[i]; };

long long dp[101][100001] = { 0 };

// dp[i][j] = min weight to reach value j using i items

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N + 1, 0);
    vector<int> w(N + 1, 0);

    int sum = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= sum; ++j) {
            if (j == 0) {
                dp[i][j] = 0;
            } else if (i == 0) {
                dp[i][j] = 1000*1000*1000 + 7;
            } else {
                dp[i][j] = dp[i - 1][j];
                if (v[i] <= j) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
                }
            }
//            cout << dp[i][j] << " ";
        }
//        cout << endl;
    }

    int ret = 0;
    for (int i = 1; i <= sum; ++i) {
        if (dp[N][i] <= W) {
            ret = i;
        }
    }
    cout << ret;

    return 0;
}


Measured memory_bytes: 79104