akhauriyash/Code-Regression huggingface dataset:
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

#define MAXN (1 << 20)

vector<int> e[MAXN];
int a[MAXN];
int col;
int v[MAXN];

void dfs(int k) {
	if (v[k]) {
		return;
	}
	v[k] = col;
	for (auto& cur: e[k]) {
		dfs(cur);
	}
}

int n, m;

int main() {
	cout << fixed << setprecision(12);	
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		int t1, t2;
		cin >> t1 >> t2;
		e[t1].push_back(t2);
		e[t2].push_back(t1);
	}
	col = 0;
	for (int i = 1; i <= n; i++) {
		col++;
		dfs(i);
	}
	int ret = 0;
	for (int i = 1; i <= n; i++) {
		if (v[i] == v[a[i]]) {
			ret++;
		}
	}
	cout << ret << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("d.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    vector<int> A(N);
    vector<int> B(N);

    rep(i, N)
    {
        cin >> A[i];
    }

    rep(i, N)
    {
        B[0] += (A[i]  * (i%2==0 ? 1 : -1));
    }

    for (int i = 1; i < N; i++)
    {
        B[i] = 2*A[i-1] - B[i-1];
    }

    for  (int elem : B)
    {
        cout << elem << " ";
    }



    return 0;
}


Measured memory_bytes: 2048
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, n) cin >> a[i];
  bitset<ohara> dp;
  dp[0] = true;
  rep(i, n) { dp |= dp << a[i]; }
  rrrep(i, ohara, 0) {
    if (i % 10 == 0) continue;
    if (dp[i]) {
      Cout(i);
      return 0;
    }
  }
  Cout(0);
  return 0;
}

Measured memory_bytes: 640
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var b = xArray(0,n)
  var ans = [];
  for(var i = n-1; i >= 0; i--){
    var s = 0;
    for(var j = i; j < n; j += i+1){
      s ^= b[j];
    }
    if(s !== a[i]){
      ans.push(i+1);
      b[i] = 1;
    }
  }
  if(ans.length === 0)return 0;
  console.log(ans.length);
  return ans.join(" ");
}

Measured memory_bytes: 30684
#define _USE_MATH_DEFINES
#include <cmath>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>a(n,0);
	for (int i = 0; i < n-1; i++) {
		int hoge;
		cin >> hoge;
		a[hoge-1]++;
	}
	for (auto x : a) {
		cout << x << endl;
	}
}

Measured memory_bytes: 4048
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
    //cin>>t;
    while(t--)
    {  
      int n;
      cin>>n;
      if(n<1200)
      cout<<"ABC";
      else
      cout<<"ARC";
    }
}
// 🍪 🍪 🍪


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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()
#define mod 1e9+7

using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using P = pair<int,int>;

main()
{
        int x; cin>>x;
        cout<<48-x<<endl;
}

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

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    while( true ){

        int n;
        cin >> n;

        if(!n)
            break;

        int l = 0, r = 0, u = 0;
        int ans = 0;

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

            string t;
            cin >> t;

            if( t == "lu" )
                l = 1;
            else if(t == "ru")
                r = 1;
            else if(t == "ld")
                l = 0;
            else
                r = 0;

            if(!(r^l))
                if( u^l ){
                    ans++;
                    u ^= 1;
                }

        }

        cout << ans << endl;

    }

    return 0;

}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int a,b;
    cin >> a >> b;
    rep(i,2000){
        double tax1 = (double)i * 0.08;
        double tax2 = (double)i * 0.10;
        int t1 = floor(tax1);
        int t2 = floor(tax2);
        if(a == t1 && b == t2){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    
}

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

int main(){
  int h,w,k;
  static int cnt[1000][1000][3] = {};
  char field[1000][1000],joi[] = {'J','O','I'};
  cin >> h >> w >> k;
  getchar();
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      field[i][j] = getchar();
    }
    getchar();
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      for(int l = 0;l < 3;l++){
	if(i == 0 && j != 0){
	  cnt[i][j][l] = cnt[i][j - 1][l];
	}
	else if(j == 0 && i != 0){
	  cnt[i][j][l] = cnt[i - 1][j][l];
	}
	else if(j != 0 && i != 0){
	  cnt[i][j][l] = cnt[i - 1][j][l] + cnt[i][j - 1][l] - cnt[i - 1][j - 1][l];
	}
        if(field[i][j] == joi[l]) cnt[i][j][l]++;
      }
    }
  }
  for(int i = 0;i < k;i++){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;b--;c--;d--;
    int joicnt[3] = {};
    for(int j = 0;j < 3;j++){
      if(a == 0 && b == 0) joicnt[j] = cnt[c][d][j];
      else if(a == 0) joicnt[j] = cnt[c][d][j] - cnt[c][b - 1][j];
      else if(b == 0) joicnt[j] = cnt[c][d][j] - cnt[a - 1][d][j];
      else joicnt[j] = cnt[c][d][j] - cnt[a - 1][d][j] - cnt[c][b - 1][j] + cnt[a - 1][b - 1][j];
    }
    cout << joicnt[0] << " " << joicnt[1] << " " << joicnt[2] << endl;
  }
  return 0;
}

Measured memory_bytes: 15596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  int N=S.size();
  bool b=0;
  string a=S;
  reverse(S.begin(),S.end());
  if(a!=S){
  b=1;
  }
  string x=a.substr(0,(N-1)/2);
  string y=x;
  reverse(x.begin(),x.end());
  if(x!=y){b=1;}
 
 
  if(b==0){cout<<"Yes"<<endl;}
  if(b==1){cout<<"No"<<endl;}
}

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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 3e5+5;
int xf[N] , yf[N];
int x[N] , y[N];
set<int> st[N];		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n,m,k;
		cin>>n>>m>>k;
		
		int maxx = 0,maxy = 0;
		for(int i=0,xx,yy;i<k;++i)
		{
			cin>>xx>>yy;
			st[yy].insert(xx);
			xf[xx]++;
			yf[yy]++;
			maxx = max(maxx,xf[xx]);
			maxy = max(maxy,yf[yy]);
			x[i] = xx;
			y[i] = yy;
		}
		set<int> tempx,tempy;
		for(int i=1;i<=n;++i)
		{
			if(xf[i]==maxx)
			tempx.insert(i);
		}
		for(int i=1;i<=m;++i)
		{
			if(yf[i]==maxy)
			{
				tempy.insert(i);
			}
		}
		int ans = maxx;
		for(auto it:tempy)
		{
			for(auto it1:tempx)
			{
				if(!st[it].count(it1))
				{
					cout<<ans+maxy;
					return 0;
				}
			}
		}
		cout<<ans+maxy-1;
		
		
    }
    return 0;
}


Measured memory_bytes: 69220
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=1000010;
const int mod=1e9+7;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
	freopen("neutral.in","r",stdin);
	freopen("neutral.out","w",stdout);
}
int n,f[N],s[N],ans;
inline void Add(int &x,int y){x=x+y<mod?x+y:x+y-mod;}
int main()
{
	//file();
	read(n);
	s[0]=f[0]=1;
	For(i,1,n)
	{
		f[i]=(s[i-1]+mod-(i>=2?f[i-2]:0))%mod;
		s[i]=(s[i-1]+f[i])%mod;
	}
	ans=(LL)f[n-1]*(LL)(n-1)%mod;
	Add(ans,f[n]);
	For(i,0,n-2)
	{
		Add(ans,(LL)f[i]*(LL)(n-1)%mod*(LL)(n-1)%mod);
		Add(ans,(LL)f[i]*(LL)(i+1)%mod);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 8064
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int M = sc.nextInt();
        HashMap<Integer, ArrayList<City>> map = new HashMap<Integer, ArrayList<City>>();
        ArrayList<City> idlist = new ArrayList<City>();

        for (int i = 0; i < M; i++) {
            int p = sc.nextInt();
            int y = sc.nextInt();
            City c = new City(p, y);
            map.putIfAbsent(p, new ArrayList<City>());
            map.get(p).add(c);
            idlist.add(c);
        }
        for (int i = 0; i <= N; i++) {
            if (map.containsKey(i)) {
                ArrayList<City> list = map.get(i);
                list.sort(Comparator.comparing(City::getBirth));
                for (int k = 0; k < list.size(); k++) {
                    list.get(k).code = String.format("%06d%06d", i, k + 1);
                }
            }
        }
        for (City c : idlist) {
            System.out.println(c.code);
        }
    }
}

class City {
    int birth;
    int prefecture;
    String code;

    City(int p, int b) {
        birth = b;
        prefecture = p;
    }

    /**
     * @return the birth
     */
    public int getBirth() {
        return birth;
    }
}

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

namespace ABC082A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            c = a + b;

            if (c % 2 == 0)
                Console.WriteLine(c / 2);
            
            else
                Console.WriteLine(c / 2 + 1);

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11220
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	char c1, c2, c3;
	c1 = toupper(s1[0]);
	c2 = toupper(s2[0]);
	c3 = toupper(s3[0]);
	cout <<  c1<< c2 <<  c3<< endl;
   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.next());
        int m = Integer.parseInt(s.next());
        boolean[] goodTen = new boolean[n];
        int[] h = new int[n];
        for (int i = 0;i<n;i++) {
            goodTen[i] = true;
        }
        for(int i=0; i<n;i++){
            h[i] = Integer.parseInt(s.next());
        }

        int[] a = new int[m];
        int[] b = new int[m];
        for(int i=0; i<m ;i++){
            a[i] = Integer.parseInt(s.next());
            b[i] = Integer.parseInt(s.next());

            if(h[a[i]-1] > h[b[i]-1]) {
                goodTen[b[i]-1] = false;
            } else if(h[a[i]-1] < h[b[i]-1]){
                goodTen[a[i]-1] = false;
            } else {
                goodTen[a[i]-1] = false;
                goodTen[b[i]-1] = false;
            }
        }

        int res = 0;
        for (boolean bol:goodTen) {
            if (bol) {
                res++;
            }
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 60304
INF=10**30
n,m=map(int,input().split())
c=list(map(int,input().split()))
dp=[INF]*(n+10)
dp[0]=0
for i in range(1,n+1):
    for j in range(len(c)):
        if(i-c[j]<0):
            continue
        dp[i]=min(dp[i],dp[i-c[j]]+1)
print(dp[n])


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

int coins(int a, int b, int c, int x);
int main(void);

int coins(int a, int b, int c, int x){
    int ii1, ii2, ii3, p, count = 0;
    for(ii1=0; ii1<a+1; ii1++){
        for(ii2=0; ii2<b+1; ii2++){
           for(ii3=0; ii3<c+1; ii3++){
              p = 500*ii1+100*ii2+50*ii3;
              if(p == x)
                 count++;
           }
        }
    }

    return count;
}

int main(void){
    int a, b, c, x, score;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &x);
    score = coins(a, b, c, x);
    printf("%d\n", score);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM,X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM,X,Y) cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
const ll INF = 1e+9+7;
ll n,m,l;
// string s,t;
ll d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];

static const int MAX = 100000;
static const int INFTY = (1 << 29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void dfs(int s){
  queue<int> que;
  que.push(s);
  V[s] = true;
  while(!que.empty()){
    int u = que.front();que.pop();
    out.push_back(u);
    for(int i = 0;i < G[u].size();i++){
      int v = G[u][i];
      indeg[v]--;
      if(indeg[v] == 0 && !V[v]){
        V[v] = true;
        que.push(v);
      }
    }
  }
}

void tsort(){
  for(int i = 0;i < N;i++){
    indeg[i] = 0;
  }
  for(int u = 0;u < N;u++){
    for(int i = 0;i < G[u].size();i++){
      int v = G[u][i];
      indeg[v]++;
    }
  }
  for(int u = 0;u < N;u++)
    if(indeg[u] == 0 && !V[u])dfs(u);

  for(list<int>::iterator it = out.begin(); it != out.end();it++){
    cout << *it << endl;
  }
}

int main(){
  int p,q,M;
  cin >> N >> M;
  for(int i = 0;i < N;i++)V[i] = false;
  for(int i = 0;i < M;i++){
    cin >> p >> q;
    G[p].push_back(q);
  }

  tsort();
  return 0;
}


Measured memory_bytes: 6252
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討

#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5 * 1e5 + 1000;
const int SIZE2 = 3010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const ld INF = 1e18;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
ut N, M, K, X, L, Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps[SIZE2][SIZE2], answer = zero;
LL A[SIZE];
LL B[SIZE];
LL solve() {
	cin >> N;
	LL sum = 0;
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	ld ave = sum*1.0 / N;
//	cout << ave << endl;
	LL minium = 0;
	REP(i, N) {
		if (abs(A[minium]-ave)>abs(A[i]-ave)) {
			minium=i;
		}

	}
	cout << minium << endl;
	return 0;
}
signed main() {
	solve();
	cin >> N;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 14592
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=1LL<<60;
ll dp[110][4][4][4][4];

int main(){
    ll n;
    cin>>n;
    vector<ll> a(3*n);
    for(ll i=0;i<3*n;i++)cin>>a[i];

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll sum=0;
    for(ll i=0;i<2*n;i++){
        if(i%2==1)sum+=a[i];
    }
    cout<<sum<<endl;
}
 
   

Measured memory_bytes: 2560
calc :: Int -> Int
calc n  
  | n `mod` 2 == 0 = n `div` 2
  | otherwise = 3 * n + 1

loop :: Int -> Int -> Int
loop c n
  | n == 4 || n == 2 || n == 1 = c + 3
  | otherwise = loop (c + 1) (calc n)

main = do
  s <- readLn
  let ans = loop 1 s
  print ans

Measured memory_bytes: 508
#include <stdio.h>
 
int main(void) {
	int money;
	int uresi = 0;
	
    scanf("%d", &money);
 
	for(; money >= 500; money -= 500) {
		uresi += 1000;
	}
	
	for(; money >= 5; money -= 5) {
		uresi += 5;
	}
	
	printf("%d", uresi);
 
	return 0;
}


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

int n, s, b;
vector<int> a, c;

int main(){
	cin >> n;
	a.resize(n);
	c.resize(n-1);
	s = 0;
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i){
		cin >> b;
		s += b;
	}
	for (int i = 0; i < n-1; ++i) cin >> c[i];
	for (int i = 0; i < n-1; ++i){
		if (a[i+1] == a[i] + 1) s += c[a[i]-1];
	}
	printf("%d\n", s);
}

Measured memory_bytes: 256
#include<stdio.h>

int isleap(int year){
  if(year%4) return 0;
  if(year%100) return 1;
  if(year%400) return 0;
  return 1;
}
int main(){
  int i,y1,m1,d1,y2,m2,d2,day1,day2;
  int mon[]={31,28,31,30,31,30,31,31,30,31,30,31};
  do{
    scanf("%d %d %d %d %d %d",&y1,&m1,&d1,&y2,&m2,&d2);
    if(y1==-1&&m1==-1&&d1==-1&&y2==-1&&m2==-1&&d2==-1) break;

    if(isleap(y1)) mon[1]=29;
    y1--; m1--; d1--;
    day1=y1*365+y1/4-y1/100+y1/400+d1;
    for(i=0;i<m1;i++) day1+=mon[i];
    mon[1]=28;

    if(isleap(y2)) mon[1]=29;
    y2--; m2--; d2--;
    day2=y2*365+y2/4-y2/100+y2/400+d2;
    for(i=0;i<m2;i++) day2+=mon[i];
    mon[1]=28;
    printf("%d\n",day2-day1);
  }while(1);
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
int MOD=1000000000+7;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n;
    cin>>n;
    int ans=0;
    if(n%10){
        while(n){
            ans+=(n%10);
            n/=10;
        }
    }
    else{
        ans=9;
        while(n){
            ans+=(n%10);
            n/=10;
        }
    }
    cout<<ans;
    return 0;

}   


Measured memory_bytes: 256
main = do
  (h:w:_) <- return . (map read) . words =<< getLine
  pic <- return . lines =<< getContents

  mapM_ putStrLn $ concat [[take (w+2) (repeat '#')], map f pic, [take (w+2) (repeat '#')]]

  where
    f xs = '#' : (xs ++ ['#'])


Measured memory_bytes: 1020
#include<iostream>
#include<cmath>

using namespace std;

int other[ 3 ][ 2 ] = { { 1, 2 },
                        { 0, 2 },
                        { 1, 0 } };

int getDp( int data[][ 3 ], int i, int choice, int dp[] [ 3 ] ) {
  if( dp[ i ][ choice ] != -1 ) {
     return dp[ i ][ choice ];
  }

  for( int j = 0; j < 2; j++ ) {
     dp[ i ][ choice ] = max( data[ i ][ choice ]
                              + getDp( data, i-1, other[ choice ][ j ], dp ),
                              dp[ i ][ choice ] );
  }
  return dp[ i ][ choice ];
}

int main() {
   int N;
   cin >> N;
   int data[ N ][ 3 ];
   for( int i = 0; i < N; i++ ) {
      for( int j = 0; j < 3; j++ ) {
         cin >> data[ i ][ j ];
      }
   }
   int dp[ N ][ 3 ];
   for( int i = 0; i < 3; i++ ) {
      dp[ 0 ][ i ] = data[ 0 ][ i ];
   }

   for( int i = 1; i < N; i++ ) {
      for( int j = 0; j < 3; j++ ) {
         dp[ i ][ j ] = -1;
      }
   }
   for( int i = 0; i < 3; i++ ) {
      getDp( data, N-1, i, dp );
   }
   cout << max( dp[ N-1 ][ 0 ], max( dp[ N-1 ][ 1 ], dp[ N-1 ][ 2 ] ) );
   return 0;
}


Measured memory_bytes: 11904
import java.util.Scanner;

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

        if(str.equals("ABC")){
            str = "ARC";
        } else{
            str = "ABC";
        }

        System.out.println(str);
        sc.close();
        
    }
}

Measured memory_bytes: 35644
#include<stdio.h>
#include<string.h>
#define MAX 100

int n,c,k=0;
int pre[MAX],in[MAX],post[MAX];


int find(int x);
void rec(int l,int r);

int main(){
	int i;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&pre[i]);
	}
	
	for(i=0;i<n;i++){
		scanf("%d",&in[i]);
	}
	
	rec(0,n);
	
	for(i=0;i<n;i++){
		if(i != n-1)printf("%d ",post[i]);
		else printf("%d\n",post[i]);
	}
	
	return 0;
}

int find(int x){
	int i;
	for(i=0;i<n;i++){
		if(x==in[i]) return i;
	}
	return 0;
}

void rec(int l,int r){
	int x,y;
	if(l >= r) return;
	
	x=pre[k++];
	y=find(x);
	rec(l,y);
	rec(y+1,r);
	post[c++]=x;
}


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

namespace ConsoleApp15
{
    class Class117
    {
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = NM[0], M = NM[1];
            long ans = 0;
            if (N * 2 <= M)
            {
                M -= N * 2;
                ans += N;
                N = 0;
                ans += M / 4;
            }
            else
            {
                N -= M / 2;
                ans += M / 2;
                M = 0;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
int main(){
int a,c,d,e,f=0,g;
int b[10000],A[100][100];
scanf("%d %d",&a,&c);
for(d=0;d<a;d++){
for(e=0;e<c;e++){
scanf("%d",&A[d][e]);
}
}
for(d=0;d<c;d++)
scanf("%d",&b[d]);

for(d=0;d<a;d++){
for(e=0;e<c;e++){
f+=A[d][e]*b[e];
}
printf("%d\n",f);
f=0;
}
return 0;
}

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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);

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

    long long g = GCD(A[0], A[1]);
    bool one_flag = true;
    bool other_flag = false;
    set<long long> s;

    if(g == 1){
        other_flag = false;
        auto res = prime_factorize(A[0]);
        for(auto pe: res){
            s.insert(pe.first);
        }
        res = prime_factorize(A[1]);
        for(auto pe: res){
            s.insert(pe.first);
        }
    }else{
        other_flag = true;
    }


    for(int i=1; i<N-1; ++i){
        auto res = prime_factorize(A[i+1]);
        for(auto pe: res){
            if(s.count(pe.first) > 0){
                other_flag = true;
            }else{
                s.insert(pe.first);
            }
        }

        g = GCD(g, A[i+1]);
    }


    if(g == 1){
        one_flag = true;
    }else{
        one_flag = false;
    }

    if(one_flag){
        if(other_flag){
            cout << "setwise coprime" << endl;
        }else{
            cout << "pairwise coprime" << endl;
        }
    }else{
        cout << "not coprime" << endl;
    }

}

Measured memory_bytes: 14748
n = int(input())
h = list(map(int, input().split()))
move = []
i = 0
count = 0
while i < (n-1):
    if h[i] >= h[i+1]:
        count += 1
        i += 1
    else:
        move.append(count)
        count = 0
        i += 1
move.append(count)
print(max(move))

Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 7;
int lst[Max];

int main()
{
	int n, k;
	cin >> n >> k;
	int res = 0;
	for (int i = 1; i <= n; i++)
	{
		int t;
		cin >> t;
		res += min(abs(k - t), t);
	}
	cout << 2 * res;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll inf=1e16; 
const ll mod=1e9+7;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

ll n,k;
vll a;

const long nmax=100005;


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

void comint(){
 fac[0]=fac[1]=1;
 finv[0]=finv[1]=1;
 inv[1]=1;
 for(long i=2;i<nmax;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;
}
}

auto com(auto n, auto k){
 if(n<k||n<0||k<0) return 0;
 return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}



int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
  cin >> n >> k;
  a.resize(n);
  rep(i,0,n) cin >> a[i];
  sort(a.begin(),a.end());
  
  comint();
  ll res=0;
  rep(i,0,n-1) {
    ll f=com(n,k)-com(i+1,k)-com(n-i-1,k);
    f+=mod;
    f%=mod;
    res+=f*(a[i+1]-a[i]);
    res%=mod; 
  }
  cout << res << endl;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        vector<int> P(N); cin >> P;
        rep(i, N) P[i]--;
        vector<vector<int>> E(N);
        rep(i, M) {
            int x, y; cin >> x >> y;
            x--; y--;
            E[x].push_back(y);
            E[y].push_back(x);
        }
        vector<int> group_id(N);
        vector<set<int>> group(N + 1);
        function<void(int, int)> dfs = [&] (int now, int id) {
            assert(group_id[now] == 0);
            group_id[now] = id;
            group[id].insert(P[now]);
            for(int nxt : E[now]) {
                if(group_id[nxt] == 0) dfs(nxt, id);
                else assert(group_id[nxt] == id);
            }
        };
        rep(i, N) {
            if(group_id[i] == 0) {
                dfs(i, i + 1);
            }
        }
        int ans = 0;
        rep(i, N) if(group[group_id[i]].count(i)) ans++;
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 19968
#include<iostream>
using namespace std;
int main(void) {
	int n, m;
	cin >> n >> m;
	int answer(0);
	if (n >= 2)answer += n * (n - 1) / 2;
	if (m >= 2)answer += m * (m - 1) / 2;
	cout << answer << endl;
	return 0;
}

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

const bool DEBUG = false;

template <typename T, typename Pred>
typename std::vector<T>::iterator insert_sorted(std::vector<T>& vec,
                                                T const& item, Pred pred) {
  return vec.insert(std::upper_bound(vec.begin(), vec.end(), item, pred), item);
}

long long X, Y, A, B, C;
vector<long long> p, q, r;

void input() {
  cin >> X >> Y >> A >> B >> C;
  p = vector<long long>(A);
  q = vector<long long>(B);
  r = vector<long long>(C);
  for (size_t i = 0; i < A; i++) cin >> p[i];
  for (size_t i = 0; i < B; i++) cin >> q[i];
  for (size_t i = 0; i < C; i++) cin >> r[i];
}

int main(int argc, char const* argv[]) {
  input();

  sort(p.begin(), p.end(), greater<long long>());
  sort(q.begin(), q.end(), greater<long long>());
  sort(r.begin(), r.end());

  p.resize(X);
  q.resize(Y);

  long long total = 0;

  // 着色した際に効用が上がるかどうかでgreedy search
  long long p_swap_idx = X - 1;
  long long q_swap_idx = Y - 1;
  while (r.size() > 0) {
    if (p[p_swap_idx] < q[q_swap_idx]) {
      // pを交換したほうがよい
      if (p[p_swap_idx] < r[r.size() - 1]) {  // 食べたい
        insert_sorted(p, r[r.size() - 1], greater<long long>());
        p.pop_back();
        // p[p_swap_idx] = r[r.size() - 1];
        r.pop_back();
        // p_swap_idx--;
        // sort(p.begin(), p.end(), greater<long long>());
      } else {  // もう食べたくない
        break;
      }
    } else {
      // qを交換したほうがよい
      if (q[q_swap_idx] < r[r.size() - 1]) {  // 食べたい
        insert_sorted(q, r[r.size() - 1], greater<long long>());
        q.pop_back();
        // q[q_swap_idx] = r[r.size() - 1];
        r.pop_back();
        // q_swap_idx--;
        // sort(q.begin(), q.end(), greater<long long>());
      } else {  // もう食べたくない
        break;
      }
    }
  }

  // 食べる
  for (size_t i = 0; i < X; i++) total += p[i];
  for (size_t i = 0; i < Y; i++) total += q[i];

  // 出力
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

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

    int h=S/(60*60);
    S%=(60*60);
    int m=S/60;
    S%=60;
    int s=S%60;
    
    cout<<h<<':'<<m<<':'<<s<<"\n";
    
    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> P(N);
  for(int i=0; i<N; i++){
    P[i]=i+1;
  }
  bool E[9][9]={};
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    E[a][b]=E[b][a]=true;
  }
  int count=0;
  do{
    bool f =true;
    for(int i=0; i<N-1; i++){
      if(E[P[i]][P[i+1]]) continue;
      f=false; break;
    }
    if(f) count++;
  }while(next_permutation(P.begin()+1, P.end()));
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

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

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 1e5 + 5;

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	int n=2e5; cin>>n;
	int cnt[50][50] = {};
	ll ans = 0;
	for(int i = 0; i < n; i++){
		double x=1; cin>>x;
		ll tmp = llround(x * 1e9);
		int k1 = 0, k2 = 0;
		for(; tmp%2 == 0; k1++, tmp /= 2){}
		for(; tmp%5 == 0; k2++, tmp /= 5){}
		for(int j = max(0, 18 - k1); j < 50; j++){
			for(int k = max(0, 18 - k2); k < 50; k++){
				ans += cnt[j][k];
			}
		}
		cnt[k1][k2]++;
	}
	cout<<ans;
}

Measured memory_bytes: 3700
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 100000

int h,t,A1[N];
char A2[N][10];

void enqueue(char *s, int x)
{
  int i = 0;

  if(isFull()){
    fprintf(stderr,"overflow!\n");
    exit(2);
  }

  A1[t] = x;
  strcpy(A2[t],s);
  if(t + 1 == N) t = 0;
  else t++;
}

int dequeue()
{
  int x;

  if(isEmpty()){
    fprintf(stderr,"underflow!\n");
    exit(1);
  }

  x = h;
  if(h + 1 == N) h = 0;
  else h++;
 
  return x;
}

int isEmpty()
{
  return h == t;

}

int isFull()
{
  return h == (t + 1) % N;
}

void roundschedule(int n, int m)
{
  int i,num,a;
  int total = 0;
  char B[10];

  for(i=0;i<n;i++){
    scanf("%s%d",B,&num);
    enqueue(B,num);
  }

  while(!isEmpty()){
    num = dequeue();
    if(m>=A1[num]){
      total += A1[num];
      printf("%s %d\n",A2[num],total);
    }
    else{
      a = A1[num] - m;
      total += m;
      enqueue(A2[num],a);
    }
  }
}

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

  return 0;
}



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

int main(){
  string S;
  int K;
  cin >> S >> K;
  int one_len = 0;
  char sub_one = '0';

  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '1'){
      one_len++;
    } else {
      sub_one = S.at(i);
      break;
    }
  }
  
  if (one_len >= K || sub_one == '0') {
    cout << '1' << endl;
  } else {
    cout << sub_one << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int A[][] = new int[n][m];
        int b[] = new int[m];
        int i,j,c;
        
        for(i=0; i<n; i++){
            for(j=0; j<m; j++){
                A[i][j] = sc.nextInt();
            }
        }
        
        for(j=0; j<m; j++){
            b[j] = sc.nextInt();
        }
        
        for(i=0; i<n; i++){
            c = 0;
            for(j=0; j<m; j++){
                c += ( A[i][j] * b[j] );
            }
            System.out.println(c);
        }
    }
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;




int main(){
  ll a, p;
  cin >> a >> p;

  cout << (3*a + p)/2 << endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) sort(v.begin(), v.end())
typedef long long ll;
using Graph = vector<vector<int>>;

int main()
{
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i < n; i++)
  {
    for (int j = 1; j <= (n / i); j++)
    {
      if (i * j < n)
      {
        cnt++;
      }
      else
      {
        break;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if(d == 25) dunk("Christmas");
    if(d == 24) dunk("Christmas Eve");
    if(d == 23) dunk("Christmas Eve Eve");
    if(d == 22) dunk("Christmas Eve Eve Eve");
}

   

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

int main()
{
  int city_1 = 2;
  int city_2 = 2;
  int city_3 = 2;
  int city_4 = 2;
  
  int a, b;

  for(int i = 0; i < 3; i++){

    cin>>a>>b;

    if(a == 1)
      city_1--;
    else if(a == 2)
      city_2--;
    else if(a == 3)
      city_3--;
    else
      city_4--;

    if(b == 1)
      city_1--;
    else if(b == 2)
      city_2--;
    else if(b == 3)
      city_3--;
    else
      city_4--;

  }

  if(city_1 < 0 || city_2 < 0 || city_3 < 0 || city_4 < 0)
    cout<<"NO"<<endl;
  else
    cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n, x, count = 0;
    while(1){
        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0) break;
        for(int i=1; i<n-1; i++){
            for(int j=i+1; j<n; j++){
                for(int k=j+1; k<=n; k++){
                    if(i + j + k == x){
                        count += 1;
                    }
                }
            }
        }
        printf("%d\n", count);
        count = 0;
    }
    return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int W,H,N;cin>>W>>H>>N;
  vector<vector<int>> G(H,vector<int>(W,1));
  int x,y,a;
  REP(i,0,N){
    cin>>x>>y>>a;
    if(a==1){
      REP(i,0,H){
        REP(j,0,x){
          G[i][j]=0;
        }
      }
    }
    if(a==2){
      REP(i,0,H){
        REP(j,x,W){
          G[i][j]=0;
        }
      }
    }
    if(a==3){
      REP(i,H-y,H){
        REP(j,0,W){
          G[i][j]=0;
        }
      }
    }
    if(a==4){
      REP(i,0,H-y){
        REP(j,0,W){
          G[i][j]=0;
        }
      }
    }
    // debug(G);
  }
  int ans=0;
  REP(h,0,H)REP(w,0,W)ans+=G[h][w];
  print(ans);


}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<Integer> inList = new ArrayList<Integer>();
		ArrayList<Integer> outList = new ArrayList<Integer>();

		while (scanner.hasNext()) {

			int num = input();

			if (num == 0) {

				outList.add(inList.remove(inList.size() - 1));

			} else {

				inList.add(num);

			}
		}

		for (int j = 0; j < outList.size(); j++) {

			System.out.println(outList.get(j));

		}

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26312