akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int myabs(int a)
{
  if(a>0) return a;
  else return -a;
}
int main()
{
  int n,mi=2147483647;
  long long sum=0;
  cin>>n;
  bool flag=false;
  for(int i=0;i<n;i++)
  {
    int b;
    cin>>b;
    sum+=myabs(b);
    if(b<0) flag=1-flag;
    if(myabs(b)<mi) mi=myabs(b);
  }
  if(flag) cout<<sum-2*mi<<'\n';
  else cout<<sum<<'\n';
  return 0;
}


Measured memory_bytes: 256
package main

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

// Scan Standard Input
var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	lines := strings.Split(nextLine(), " ")
	r := process(lines)
	fmt.Println(r)
}

func process(lines []string) string {

	queue := make([]string, 0)
	new_stack := &Stack{queue}

	for _, element := range lines {

		switch element {
		case "+":
			a, _ := strconv.Atoi(new_stack.Pop())
			b, _ := strconv.Atoi(new_stack.Pop())
			new_stack = new_stack.Push(strconv.Itoa(b + a))
		case "-":
			a, _ := strconv.Atoi(new_stack.Pop())
			b, _ := strconv.Atoi(new_stack.Pop())
			new_stack = new_stack.Push(strconv.Itoa(b - a))
		case "*":
			a, _ := strconv.Atoi(new_stack.Pop())
			b, _ := strconv.Atoi(new_stack.Pop())
			new_stack = new_stack.Push(strconv.Itoa(b * a))
		case "/":
			a, _ := strconv.Atoi(new_stack.Pop())
			b, _ := strconv.Atoi(new_stack.Pop())
			new_stack = new_stack.Push(strconv.Itoa(b / a))
		default:
			new_stack = new_stack.Push(element)
		}
		// fmt.Printf("%d, %s\n", result, element)
	}
	return new_stack.Pop()
}

type Stack struct {
	stack []string
}

func (s *Stack) Pop() string {
	last_idx := len(s.stack) - 1
	// get last element
	p := s.stack[last_idx]
	// update stack
	n := make([]string, last_idx)
	copy(n, s.stack)
	s.stack = n
	return p
}

func (s *Stack) Push(e string) *Stack {
	s.stack = append(s.stack, e)
	return s
}



Measured memory_bytes: 1464
#include <bits/stdc++.h>
using namespace std;
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long ans = 0, n, k;
	cin >> n >> k;
	long a[n];
	for (long i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (long i = 0; i < k; i++)
		ans += a[i];
	cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n; std::cin >> n;
	std::string str; std::cin >> str;
	int count = 0;
	for (auto i = 0; i < str.size(); ++i) {
		if (str.substr(i, 3) == "ABC") ++count;
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S;
	int w;
	cin >> S >> w;
	for (int i = 0; i < S.size(); i += w) {
		cout << S[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Maximum Sum of Minimum
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 10000;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

vi nbrs[MAX_N];
int cs[MAX_N], ps[MAX_N], qs[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
  }

  for (int i = 0; i < n; i++) scanf("%d", cs + i);
  sort(cs, cs + n);

  int m = n, sum = 0;
  ps[0] = -1;
  qs[0] = cs[--m];
  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &up = ps[u];
    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = *vit;
      if (v != up) {
	ps[v] = u;
	qs[v] = cs[--m];
	sum += qs[v];
	q.push(v);
      }
    }
  }

  printf("%d\n", sum);
  for (int i = 0; i < n; i++) {
    if (i) putchar(' ');
    printf("%d", qs[i]);
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
  int num1, num2;
  for(;;){
    cin >> num1; cin >> num2;
    if(!num1 && !num2) { break; }
    if(num1 > num2){
      cout << num2 << " " << num1 << endl;
    } else{
      cout << num1 << " " << num2 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
n,m = map(int, raw_input().split())

def g(u,parent):
    if parent[u]!= u:
        parent[u] = g(parent[u], parent)
    return parent[u]
parent = {u:u for u in range(1, n+1)}
for _ in range(m):
    u,v = map(int, raw_input().split())
    pu,pv = g(u,parent), g(v,parent)
    if pu!= pv:
        parent[pu] = pv

ans = 0
for u in parent:
    if g(u,parent) == u:
        ans+=1
print ans -1

Measured memory_bytes: 94668
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,x,y = inpl()
x -= 1; y -= 1
g = [[] for _ in range(n)]
for i in range(n-1):
    g[i] += [i+1]; g[i+1] += [i]
g[x] += [y]; g[y] += [x]
res = [0] * (n-1)
def bfs(i):
    q = deque()
    q.append(i)
    while q:
        v = q.popleft()
        for nv in g[v]:
            if dist[nv] >= 0:
                continue
            dist[nv] = dist[v] + 1
            q.append(nv)

for i in range(n-1):
    dist = [-1] * n
    dist[i] = 0
    bfs(i)
    for j,cost in enumerate(dist):
        if j > i and cost > 0:
            res[cost-1] += 1
    # print(dist)
print(*res)

Measured memory_bytes: 73304
import java.util.Scanner;

public class Main {
        public static void main(String [] args){
            Scanner sc =new Scanner(System.in);
            double ans = 0;
            double n = sc.nextLong();
            double m = sc.nextLong();
            double d = sc.nextLong();

            if(d==0) {
                System.out.println((1.0/n)*(m-1));
            }else {
                ans =2.0*(n-d)/n/n;
                System.out.println(ans *(m-1.0));
            }

        }
}


Measured memory_bytes: 21844
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<int> a(n);
		REP(i,n) cin >> a[i];
		vector<P> ans;
		int ma = *max_element(ALL(a));
		int mi = *min_element(ALL(a));
		// if(mi > 0) {

		// } else if(ma < 0) {

		// } else {
		int ind = -1;
		if(abs(ma) > abs(mi)) {
			ind = max_element(ALL(a))-a.begin();
		} else {
			ind = min_element(ALL(a))-a.begin();
		}
		REP(i,n) {
			ans.emplace_back(ind, i);
			a[i] += a[ind];
		}
		dpite(ALL(a));
		bool f = true;
		REP(i,n) {
			if(a[i] < 0) f = false;
		}
		if(f) {
			REP(i,n-1) {
				ans.emplace_back(i, i+1);
			}
		} else {
			RREP(i,n-1) {
				ans.emplace_back(i+1, i);
			}
		}
		// }
		cout << SZ(ans) << endl;
		REP(i, SZ(ans)) {
			cout << ans[i].F+1 << ' ' << ans[i].S+1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
//#include <math.h>
using namespace std;
typedef long long LL;

int main()
{
	int A, B, K;
	cin >> A >> B >> K;

	int miEn = A + K - 1;
	int maSt = B - K + 1;

	if (maSt <= miEn) {
		for (int i = A; i <= B; i++)
			cout << i << endl;
	}
	else {
		for (int i = A; i <= miEn; i++)
			cout << i << endl;
		for (int i = maSt; i <= B; i++)
			cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
    	int M = sc.nextInt();
      	if(N%M ==0){
        	System.out.println(0);
        }else{
        	System.out.println(1);
        }
      	
    }
}


Measured memory_bytes: 21844
n, k = map(int, input().split())


tab = [0]*(10**5//2)



for i in range(1, n+1):
    
    t = i
    count = 0
    while t < k:
        t *= 2
        count += 1

    tab[count] += 1
    
#    print(x)

acc = 0
for i in range(len(tab)):
    e = tab[i]
    if e == 0:
        continue

#    print((e,i))
    acc += e * (.5**i)

print( acc/n )


Measured memory_bytes: 3444
fn main() {
    let s = read::<String>();
    if s == "Sunny" {
        println!("Cloudy");
    } else if s == "Cloudy" {
        println!("Rainy");
    } else {
        println!("Sunny");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e4 + 10;
const int M = 100;
char s[N];
int a[N];
int dp[N][2][M];

void add(int& x, int y) {
  x = (x + y) % MOD;
}

int main() {
  scanf("%s", s);
  int n = strlen(s), m;
  scanf("%d", &m);
  for (int i = 0; i < n; ++i) {
    a[i] = s[i] - '0';
  }
  dp[0][1][0] = 1;
  for (int i = 0; i < n; ++i) {
    // touch = 0
    for (int j = 0; j < 10; ++j) {
      for (int k = 0; k < m; ++k) {
        int nk = (k + j) % m;
        add(dp[i + 1][0][nk], dp[i][0][k]);
      }
    }
    // touch = 1
    for (int j = 0; j < a[i]; ++j) {
      for (int k = 0; k < m; ++k) {
        int nk = (k + j) % m;
        add(dp[i + 1][0][nk], dp[i][1][k]);
      }
    }
    for (int k = 0; k < m; ++k) {
      int nk = (k + a[i]) % m;
      add(dp[i + 1][1][nk], dp[i][1][k]);
    }
    // for (int k = 0; k < m; ++k) {
    //   cout << k << " " << dp[i + 1][0][k] << " " << dp[i + 1][1][k] << endl;
    // }
  }
  int ret = ((dp[n][1][0] + dp[n][0][0]) % MOD + MOD - 1) % MOD;
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int m1, m2, d1, d2; cin >> m1 >> d1 >> m2 >> d2;
	if (m1 == m2) cout << 0 << endl;
	else cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio> /*C++ÌÅC¾êðp*/
using namespace std;
int Fib[1001],Fi[1001][1001],count=0;

void visit(int i,int V)
{/*visit*/
 
      for(int x=1;x<=V;x++)
	{
	  if(Fi[i][x]==1 && Fib[x]==0)
	    {
	      Fib[x]=1;
	      visit(x,V);
	    }
	  
	}
    
  
}/*E_visit*/


int main(){
  int V,d,i,j,k,F[1001],h,min=0,sum;



  while(cin >> V >> d){ /*EOF*/
    count=0;
    for(i=0;i<1001;i++)
      {
	Fib[i]=0;
      }

    for(i=0;i<=V;i++){/*Fibonacci + ALPHA*/
      if(i==0)
    {
      F[0]=1;
      F[-1]=1;
    }
      else
    {
      if(F[i-1]>=1001)
        {
          F[i-1]=F[i-1]%1001;
        }
      if(F[i-2]>=1001)
        {
          F[i-2]=F[i-1]%1001;
        }
      F[i]=F[i-1]+F[i-2];
      if(F[i]>=1001)
        {
          F[i]=F[i]%1001;
        }     
      //   printf("%d\n",F[i]);

    }

     
    }/*E-Fibonacci + ALPHA*/

    /*------------------sort------------------*/ /*ÊÉÀÑÖ¦éKvÍÈ©Á½*/

     for(k=0;k<V;k++){
       min=k;
      for(i=k;i<V;i++){
    if(F[k]<F[min])
      {
        min=i;
      }
      }
      if(F[i]<F[min])
    {
      h=F[min];
      F[min]=F[i];
      F[i]=h;
    }
    }
  
     /*--------------sort----------------------*/

     //############# TEST ###############
     //                               
     //   for(i=1;i<=V;i++){          
     // printf("TES_%d\n",F[i]);      
     // }                             
     //##################################

     /*--------------------\ðÂ­é---------------*/

     for(i=0;i<=V;i++)
       {
     for(j=0;j<=V;j++)
       {
         Fi[i][j]=1;
         if(i==0 && j!=0)
           {
	     
	     Fi[i][j]=F[j];
	     
           }
         else if(j==0 && i!=0)
           {
	     Fi[i][j]=F[i];
           }
         else
           {
	     sum=F[j]-F[i];
	     if(sum<0)
	       {
		 sum=-sum;
	       }
	     if(sum<d)
	       {
		 Fi[i][j]=1;
	       }
	     else if(sum>=d)
	       {
		 Fi[i][j]=0;
	       }
           }
       }         
       }        
     /*--------------\Â­Á½è------------------------*/ 
     
    
     //     for(i=0;i<=V;i++){ /*TEST*/
    //for(j=0;j<=V;j++){
      
         
	 // printf("%d\t",Fi[i][j]);
   
    // }
       // cout << endl;
       //  } 

     /*------------------GO VISIT--------------------------*/

     for(i=1;i<=V;i++)
       {
	 for(j=1;j<=V;j++)
	   {
	     if(Fi[i][j]==1 && Fib[i]==0)
	       {
		 Fib[i]=1;
		 count++;
		 visit(i,V);
		 
	       }
	   }
       }
     
     
 
         printf("%d\n",count);/*JEgñð\¦*/

  }/*E-EOF*/

}/*E-main*/

Measured memory_bytes: 4812
#include<bits/stdc++.h>
#define debug(x) cerr<<#x<<" = "<<x<<endl
using namespace std;
const long long mod=1e9+7;
long long dp[105][70005];
int X[70005],Y[70005],cnt;
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int x=1,y,t;
	while(x<=n){
		t=n/x; y=n/t;
//		printf("%d ~ %d\n",x,y);
		X[++cnt]=x, Y[cnt]=y;
		x=y+1;
	}
	for(int i=1; i<=cnt; i++) dp[1][i]=Y[i];
	for(int i=2; i<=m; i++)
		for(int j=1; j<=cnt; j++){
			dp[i][j]=((dp[i-1][cnt-j+1]*(Y[j]-X[j]+1))%mod+dp[i][j-1])%mod;
		}
	printf("%lld\n",dp[m][cnt]);
	return 0;
}

Measured memory_bytes: 56960
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;

    ll r = 0;

    ll t = n / k;
    r += t * t * t;

    if (k % 2 == 0) {
        int l = k / 2;
        ll t = (n + l) / k;
        r += t * t * t;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int a,b,c,d; cin >> a >> b >> c >> d;
    if(a!=c) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	int w, h, n, i, x, y, a;

	cin >> w >> h >> n;

	int hi = 0, m = w, u = h, s = 0;

	for(i = 0; i < n; i++){
		cin >> x >> y >> a;
		if(a == 1 && hi < x){
			hi = x;
		}
		if(a == 2 && m > x){
			m = x;
		}
		if(a == 3 && s < y){
			s = y;
		}
		if(a == 4 && u > y){
			u = y;
		}
	}

	int xx, yy;
	xx = m - hi;
	yy = u - s;
	if(xx < 0 || yy < 0){
		cout << "0" << endl;
	}
	else{
		cout << xx * yy << endl;
	}
}

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

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

    vector<int> b(n);
    for (auto i = 0; i < n; i++) cin >> b[i];

    vector<int> ans(n, 0);
    for (auto i = 0; i < n; i++) {
        auto tmp = 0;
        for (auto j = (int)b.size() - 1; j >= 0; j--) {
            if(b[j] == j + 1) {
                tmp = j + 1; break;
            }
        }
        if(tmp == 0) {
            cout << "-1" << endl;
            return 0;
        }
        b.erase(b.begin() + (tmp - 1));
        ans[n - i - 1] = tmp;
    }

    for (auto i = 0; i < n; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

vector<int> G[100010];
bool f[100010];
int ord[100010], low[100010];
vector<P> bridge;

//in main() k = 0; dfs(0, -1, k)
void dfs(int v, int p, int &k){
    ord[v] = k++;
    low[v] = ord[v];
    f[v] = true;
    rep(i, 0, G[v].size()){
        int u = G[v][i];
        if(f[u]){
            if(u != p) low[v] = min(low[v], ord[u]);
        }else{
            dfs(u, v, k);
            if(ord[v] < low[u]) bridge. push_back(P(min(v, u), max(v, u)));
            low[v] = min(low[v], low[u]);
        }
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    rep(i, 0, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int k = 0;
    dfs(0, -1, k);
    cout << bridge.size() << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int p[n];

    int sum = 0;
    int maxp = 0;
    rep(i, n) {
        cin >> p[i];
        sum += p[i];
        maxp = max(maxp, p[i]);
    }

    cout << sum - maxp / 2 << endl;


    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import math


def main():
    N, K = map(int, input().split())

    if K == 0:
        return N * N

    ans = 0
    for n in range(1, N + 1):
        if n <= K:
            pass
        else:
            ans += (N // n) * (n - K)
            ans += (N % n) - K + 1 if (N % n) - K + 1 > 0 else 0

    return ans


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ProjectContest
{
    class Test
    {
        static void Main()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            var p = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
            int kq = 0;
            for (int i=0;i<=n-3;i++)
            {
                if ((p[i] - p[i + 1]) * (p[i + 1] - p[i + 2]) >= 0) kq++;
            }
            Console.WriteLine(kq);
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        a[i] *= 2;
    }
    long nans = a[0];
    for (int i = 0; i < (n-1)/2; i++) {
        nans -= a[2*(i+1)-1];
        nans += a[2*(i+1)];
    }
    nans /= 2;
    cout << nans;
    vector<long> ans(n);
    ans[0] = nans;
    for (int i = 1; i < n; i++) {
        ans[i] = a[i-1] - ans[i-1];
    }
    for (int i = 1; i < n; i++) {
        cout << " " << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 2944
function Main(input) {
  input = input.trim().split("\n").map(function(x) { return x.split(" ")});
  var a = parseInt(input[0]);
  var ans = a + a*a + a*a*a;
  console.log(ans);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29680
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);

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

	int N;
	cin >> N;
	vector<int> W(N);

	rep(i, N)
		cin >> W[i];

	int s = sum(W);

	int tmp = 0;
	vector<int> num(N);
	rep(i, N) {
		tmp += W[i];
		num[i] = abs(s - 2 * tmp);
	}

	cout << min(num) << endl;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

int sum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int min(vector<int> v) {
	int min = INT32_MAX;
	for(auto it = v.begin();it != v.end();it++) 
		min = std::min(min,*it);
	return min;
}
int max(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}


Measured memory_bytes: 504
import sys

input = sys.stdin.readline

def main():
    V, E = map(int, input().split())
    grid = [[float('inf')]*V for _ in range(V)]
    for _ in range(E):
        s, t, d = map(int, input().split())
        grid[s][t] = d
    
    for i in range(V):
        grid[i][i] = 0

    for k in range(V):
        for i in range(V):
            for j in range(V):
                grid[i][j] = min(grid[i][j], grid[i][k] + grid[k][j])
    
    for i in range(V):
        for j in range(V):
            if grid[i][j] < 0 and grid[j][i] < 0:
                print('NEGATIVE CYCLE')
                return
    
    for tmp in grid:
        ans = ['INF' if x == float('inf') else x for x in tmp ]
        print(*ans)

if __name__ == "__main__":
    main()



Measured memory_bytes: 6288
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 
#define ALL(a)  (a).begin(),(a).end()



using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  int N;
  cin>>N;
  int A[N];
  int zero=0;
  int ichi=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    A[i]%=2;
    if(A[i]%2==0){
      zero++;
    }else{
      ichi++;
    }
  }
  if(ichi%2==1){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }



}





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


int main() {
  
  int N;
  cin >> N;
  
  int cake = N / 4;
  int donut = N / 7;
  
  string ans = "No";
  for(int a = 0; a <= cake; ++a){
    for(int b = 0; b <= donut; ++b){
      if( N == (a*4+b*7)){
        ans = "Yes";
      }
     }
  	}
    
 
  cout << ans << endl;
  
 

 
}


           

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX 100005

typedef struct PP {
int t;
char name[100];
}P;

P Q[MAX];
int head, tail, n;

void enqueue(P u) {
Q[tail] = u;
tail = (tail + 1) % MAX;
}

P dequeue() {
P x = Q[head];
head = (head + 1) % MAX;
return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main() {
int q, sum = 0 , w;
scanf("%d %d", &n,&q);

int i;
for ( i = 1; i <= n; i++){
scanf("%s %d", Q[i].name,&Q[i].t);
}

head = 1; tail = n + 1;
P u;
while (head != tail) {
u = dequeue();
w = min(q, u.t);
sum += w;
u.t -= w;
if (u.t > 0)enqueue(u);
else { printf("%s %d\n", u.name, sum); }
}
return 0;

}

Measured memory_bytes: 10756
import numpy as np

n,k=map(int,input().split())
l=list(map(int,input().split()))
l=np.array(l)
dp=np.zeros(n,dtype=int)
for i in range(1,n):
    x=max(0,i-k)
    dp[i]=np.min(dp[x:i]+np.abs(l[x:i]-l[i]))
print(dp[-1])

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

int main() {
    int a;
    cin >> a;
    cout << (a + a * a + a * a * a) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807

short find(short target, short p[], short n) {
  short ret_val = 0;
  //  printf("target: %hd\n", target);
  rep(i, n) {
    //    printf("i: %d\n", i);
    //    printf("p[i]: %hd\n\n", p[i]);
    if (p[i] == target) {
      ret_val = 1;
      break;
    }
  }
  //  printf("ret_val: %hd\n", ret_val);
  return ret_val;
}

// Xとの差が一番小さい not p な値を求める
int main() {
  short X, N;

  scanf("%hd%hd", &X, &N);

  short p[N]; // p[N] >= 1
  char null;
  if (N == 0) {
    scanf("%c", &null);
  } else {
    rep(i, N) {
      scanf("%hd", p + i);
    }
  }

  short output = 0;
  // X + i || X - i
  // i += 1
  // N = 100 の時最悪
  // 並び替えが必要??
  rep(i, 100) {
    if (find(X - i, p, N) == 0) {
      output = X - i;
      break;
    } else {
      if (find(X + i, p, N) == 0) {
        output = X + i;
        break;
      }
    }
  }

  printf("%hd\n", output);

  return 0;
}


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

int main(){
  while(1){
    int n;
    cin >> n;

    if(n==0)
      break;

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

    int min=1000000;

    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        int dif = abs(a[i]-a[j]);
        if(dif<min)
          min = dif;
      }
    }

    cout << min << endl;
  }
}



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

signed main ( ) {

    priority_queue<double, vector<double>, greater<double> > p;
    int n;
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        int a;
        cin >> a;
        p.push(a);
    }

    for ( int i = 1; i < n; i++ ) {
        double a = p.top();
        p.pop();
        double b = p.top();
        p.pop();
        p.push((a+b)/2);
    }

    cout << p.top() << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	m := nextInt()
	s := nextString()
	t := nextString()

	gcdnm := gcd(n, m)
	x := n / gcdnm * m
	used := map[int]byte{}
	for i := 0; i < n; i++ {
		used[x/n*i] = s[i]
	}
	for i := 0; i < m; i++ {
		if used[x/m*i] != 0 {
			if used[x/m*i] != t[i] {
				fmt.Println("-1")
				return
			}
		}
	}
	fmt.Println(x)

	// x := ""
	// l := len(x)
	// l%n==0 && l%m==0
	// if s[0] != t[0] {
	// 	fmt.Println("-1")
	// }
	// g := lcm(n, m)
	// ans := 0
	// for i := 1; i < 100000; i++ {
	// 	lenx := i * g
	// 	ln := lenx / n
	// 	lm := lenx / m
	// 	gg := lcm(ln, lm)
	// 	flag := true
	// 	// log.Println(ln, lm, gg)
	// 	for j := 1; j < 100000; j++ {
	// 		xidx := gg * j
	// 		sidx := xidx / ln
	// 		tidx := xidx / lm
	// 		if sidx >= len(s) || tidx >= len(t) {
	// 			break
	// 		}
	// 		if s[sidx] != t[tidx] {
	// 			flag = false
	// 			break
	// 		}
	// 	}
	// 	if flag {
	// 		ans = lenx
	// 		break
	// 	}
	// }
	// if ans == 0 {
	// 	fmt.Println("-1")
	// 	return
	// }
	// fmt.Println(ans)
}
func lcm(a, b int) int {
	return a * b / gcd(a, b)
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func Max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func Min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func Sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int k=n%10;
	if(k==2||k==4||k==5||k==7||k==9)
		cout << "hon" << endl;
	else if(k==0||k==1||k==6||k==8)
		cout << "pon" << endl;
	else
		cout << "bon" << endl;
	return 0;
}

Measured memory_bytes: 3652
def larger(x, y):
	if x > y: return x
	else: return y

N, A = map(int, raw_input().split())
x = map(int, raw_input().split())
x = map(lambda a: a-A, x)
max = larger(x[-1], A)
dp = []

for i in range(0, N+1):
	tmp = []
	for j in range(0, 2*N*max+1):
		tmp.append(0)
	dp.append(tmp)

for i in range(0, N+1):
	for j in range(0, 2*N*max+1):
		if i == 0:
			if j == N*max: dp[i][j] = 1
		else:
			if j-x[i-1] < 0 or j-x[i-1] > 2*N*max:
				dp[i][j] = dp[i-1][j]
			else:
				dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i-1]]

print dp[N][N*max]-1

Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int cnt(int a) {
  int count = 0;
  while (a % 2== 0) {
    ++count;
    a /= 2;
  }
  return count;
}



int foo(vector<int> A) {
  int count = 0;
  for (auto a : A) {
    count += cnt(a);
  }
  return count;
}


int main() {
  int N;
  vector<int> A;
  cin>>N;
  for (int i = 0; i < N; ++i) {
    int a;
    cin>>a;
    A.push_back(a);
  }
  cout<<foo(A)<<endl;
  return 0;
    
}

Measured memory_bytes: 384
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = []
for i in range(n):
    a.append(INT())
print("second" if all(a[i]%2 == 0 for i in range(n)) else "first")

Measured memory_bytes: 13892
#include <bits/stdc++.h>
 
#define ll long long
#define loop(a) for(long long i=0; i<a; i++)
 
using namespace std;

int main(){
	int n;
	ll ans;
	cin >> n;
	int a[n];
	loop(n) cin >> a[i];
	ans=0;
	loop(n) ans=ans+a[i];
	ans=ans*ans;
	loop(n) ans=ans-a[i]*a[i];
	cout << ans/2 << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

bool f(int a, int b) {
    return (!a && !b) || (a && b);
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s; cin >> s;
    vector<int> cnt(26, 0);
    REP(i, s.size()) {
        cnt[s[i]]++;
    }
    if ( f(cnt['N'], cnt['S']) && f(cnt['E'], cnt['W']) ) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  for (auto &c : s) {
    if (c == '?') {
      c = 'D';
    }
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 3776
s = input()
t = input()

def main(S, T):
    seen = {}

    for i in range(len(S)):
        if S[i] not in seen:
            seen[S[i]] = T[i]
        else:
            if seen[S[i]] != T[i]:
                return 0
    return 1

ans = main(s, t)*main(t, s)
if ans == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 500005, MAXT = 1 << 21;
namespace ST {
	int mn[MAXT], tn;
	void build(int n) {
		memset(mn, 0x3f, sizeof(mn));
		for (tn = 1; tn <= n + 1; tn <<= 1);
	}
	
	void modify(int p, int x) {
		p += tn;
		for (; p; p >>= 1) chkmin(mn[p], x);
	}
	
	int query(int l, int r) {
		if (l > r) return 1e9;
		l += tn - 1, r += tn + 1;
		int ans = 1e9;
		for (; l ^ r ^ 1; l >>= 1, r >>= 1) {
			if (~l & 1) chkmin(ans, mn[l ^ 1]);
			if ( r & 1) chkmin(ans, mn[r ^ 1]);
		}
		return ans;
	}
}
struct Edge { int to, next; } edge[MAXN << 1];
int pp[MAXN], qq[MAXN], head[MAXN], deg[MAXN], ans[MAXN], n, K, tot;
void add_edge(int u, int v) {
	edge[++tot] = Edge { v, head[u] };
	head[u] = tot;
	++deg[v];
}
priority_queue<int> pq;

int main() {
	scanf("%d%d", &n, &K);
	for (int i = 1; i <= n; i++) {
		scanf("%d", pp + i);
		qq[pp[i]] = i;
	}
	ST::build(n);
	for (int i = n; i > 0; i--) {
		int l = max(1, qq[i] - K + 1), r = min(qq[i] + K - 1, n);
		int p = ST::query(l, qq[i] - 1);
		if (p <= n) add_edge(qq[p], qq[i]);
		p = ST::query(qq[i] + 1, r);
		if (p <= n) add_edge(qq[p], qq[i]);
		ST::modify(qq[i], i);
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) if (!deg[i]) pq.push(i);
	while (!pq.empty()) {
		int u = pq.top(); pq.pop();
		pp[++cnt] = u;
		for (int i = head[u]; i; i = edge[i].next) {
			int v = edge[i].to;
			if (!--deg[v]) pq.push(v);
		}
	}
	reverse(pp + 1, pp + cnt + 1);
	assert(cnt == n);
	for (int i = 1; i <= n; i++) ans[pp[i]] = i;
	for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 29816
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m;
vector<vector<lli>> e;
vector<lli> ne;

void dfs(lli v) {
  for (lli to : e[v]) {
    if (ne[to] == -1) {
      ne[v] = to;
      dfs(to);
      return;
    }
  }
  ne[v] = -2;
}

int main() {
  cin >> n >> m;
  init_n(e, n+1);
  for (lli i=0; i<m; ++i) {
    lli a, b; cin >> a >> b;
    e[a].emplace_back(b);
    e[b].emplace_back(a);
  }
  
  init_n(ne, n+1, -1);

  dfs(1);
  vector<lli> p1;
  for (lli v=1; v>=0; v=ne[v]) p1.push_back(v);

  ne[1] = -1;
  dfs(1);
  vector<lli> p2;
  for (lli v=1; v>=0; v=ne[v]) p2.push_back(v);
  
  for (lli v : p1) cerr << v << ' '; cerr << '\n';
  for (lli v : p2) cerr << v << ' '; cerr << '\n';

  vector<lli> p;
  for (lli i=p1.size()-1; i>=0; --i) p.push_back(p1[i]);
  for (lli i=1; i<p2.size(); ++i) p.push_back(p2[i]);

  cout << p.size() << '\n';
  bool first = true;
  for (lli v : p) {
    if (first) first = false; else cout << ' ';
    cout << v;
  }
  cout << '\n';
  
  return 0;
}


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

namespace ABC164_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var param = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var T_HP = param[0];
            var T_AT = param[1];
            var A_HP = param[2];
            var A_AT = param[3];

            while (true)
            {
                A_HP -= T_AT;
                if (A_HP <= 0)
                {
                    Console.WriteLine("Yes");
                    return;
                }
                T_HP -= A_AT;
                if (T_HP <= 0)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 28144
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int ans = a - (b * 2);
        if (ans > 0) {
            System.out.println(ans);
        } else {
            System.out.println(0);
        }
    }
}

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

int main() {
    int N,s=0,t;
    cin >> N;
    vector<int> A(N+2);

    A.at(0)=0, A.at(N+1)=0;
    rep(i,N) {
        cin >> A.at(i+1);
        s += abs(A.at(i+1)-A.at(i));
    }
    s += abs(A.at(N+1)-A.at(N));

    rep(i,N) {
        t = abs(A.at(i+1)-A.at(i))+abs(A.at(i+2)-A.at(i+1))-abs(A.at(i+2)-A.at(i));
        cout << s-t << endl;
    }
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector <int> h(n);
  
  for (int i; i < n; i++) {
    cin >> h[i];
  }
  
  int count = 0;
  
  for (int i; i < n; i++) {
    if (h[i] >= k) {
      count++;
    }
  }
  
  cout << count;
  
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

char v[1000];
int fr1[26],fr2[26];

int main()
{
    int n;
    cin>>n;
    if(n==25)
        cout<<"Christmas";
    else if(n==24)
        cout<<"Christmas Eve";
    else if(n==23)
        cout<<"Christmas Eve Eve";
    else if(n==22)
        cout<<"Christmas Eve Eve Eve";
    return 0;
}


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

using namespace std;

typedef long long ll;

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

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

// {position, hp}
vector<pair<int, int>> enemies;

ll solve(const int N, const int D, const int A) {
    // {postion, effect}
    queue<pair<int, int>> q;
    ll count = 0;
    ll effect = 0;

    for (int i = 0; i < N; i++) {
        auto enemy = enemies[i];
        ll hp = enemy.second;
        while (!q.empty()) {
            auto p = q.front();
            if (enemy.first > p.first) {
                effect -= p.second;
                q.pop();
            } else {
                break;
            }
        }

        hp -= effect;
        if (hp > 0) {
            ll k = (hp + A - 1LL) / A;
            count += k;
            effect += A * k;
            q.push({enemy.first + 2 * D, A * k});
        }
    }

    return count;
}

int main(void) {
    int N, D, A;
    cin >> N >> D >> A;

    enemies.resize(N);
    for (int i = 0; i < N; i++) {
        int x, h;
        cin >> x >> h;
        enemies[i] = {x, h};
    }
    sort(enemies.begin(), enemies.end());

    cout << solve(N, D, A) << endl;

    return 0;
}


Measured memory_bytes: 2560
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [x, n]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    if (n == 0) {
      return `${x}`;
    }
    const p: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const pSet = new Set();
    for (let i = 0, len = p.length; i < len; i++) {
      pSet.add(p[i]);
    }
    let i = 0;
    while (true) {
      if (!pSet.has(x - i)) {
        return `${x - i}`;
      }
      if (!pSet.has(x + i)) {
        return `${x + i}`;
      }
      i++;
    }
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

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

int main() {
	int N, M, P;
	
	while (cin >> N >> M >> P, N) {
		int win = 0, sum = 0;
		
		for_(i,0,N) {
			int X; cin >> X;
			if (i == M - 1) win = X;
			sum += X;
		}
		
		if (win == 0) cout << 0 << endl;
		else {
			double ans = (100.0 * sum) / (double)win;
			ans *= (double)(100 - P);
			ans /= 100.;
			cout << (int)ans << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
X, N = map(int, input().split())
plist = [int(i) for i in input().split()]

x = 0
hx = -1
while True:
    px = x
    nx = -x
    if X + nx not in plist: 
        hx = nx
        break
    if X + px not in plist:
        hx = px
        break
    x += 1
print(X+hx)


Measured memory_bytes: 9184
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val n = nextInt()
    val r = n / 3
    println(r)
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
            .filter { value % it == 0L }
            .map { listOf(it, value / it) }
            .flatten()
            .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 29468