akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;

class Main
{
    public static String getId(int p, int x) {
        return String.format("%06d", p) + String.format("%06d", x);
    }
    
    public static void main(String args[])
    {
        class Io {
            public BufferedReader br;

            public Io() {
                InputStreamReader ir = new InputStreamReader(System.in);
                this.br = new BufferedReader(ir);
            }
            
            public ArrayList<Integer> inputInts() {
                String[] inputParts = {""};
        
                try { 
                    inputParts = br.readLine().split(" ");
                }
                catch (IOException e) {
                    System.out.println("Error " + e.getMessage());
                    e.printStackTrace();
                }

                int n = inputParts.length;
                ArrayList<Integer> ints = new ArrayList<>();
                for (int i = 0; i < n; i++) {
                    ints.add(Integer.valueOf(inputParts[i]));
                }
                return ints;
            }
        }

        Io io = new Io();
        ArrayList<Integer> ints = io.inputInts();
        int N = ints.get(0), M = ints.get(1);
        HashMap<Integer, ArrayList<Integer>> prefs = new HashMap<>();
        HashMap<Integer, ArrayList<Integer>> cities = new HashMap<>();

        for (int i = 1; i <= N; i++) {
            prefs.put(i, new ArrayList<Integer>());
        }

        for (int i = 1; i <= M; i++) {
            ints = io.inputInts();
            int p = ints.get(0), y = ints.get(1);
            prefs.get(p).add(i);
            ArrayList<Integer> attrs = new ArrayList<>(3);
            attrs.add(p);
            attrs.add(y);
            cities.put(i, attrs);
        }

        for (int i = 1; i <= N; i++) {
            if (prefs.get(i).size() > 1) {
                prefs.get(i).sort((Integer city_a, Integer city_b) -> cities.get(city_a).get(1) - cities.get(city_b).get(1));
            }
        }

        for (int i = 1; i <= N; i++) {
            int size = prefs.get(i).size();
            for (int j = 0; j < size; j++) {
                cities.get(prefs.get(i).get(j)).add(j + 1);
            }
        }

        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 1; i <= M; i++) {
            ArrayList<Integer> city = cities.get(i);
            pw.println(getId(city.get(0), city.get(2)));
        }
        pw.flush();
    }
}


Measured memory_bytes: 175224
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main()
{
    ll l;
    cin >> l;
    ll v=1;
    ll n=0; //頂点数
    vector<ll> p(20);
    while(2*v<=l){
        p[n]=v;
        n++;
        v*=2;
    }
    p[n]=v;
    vector<pll> ans;
    vector<ll> w;
    ll val=1;
    rep(i,n){
        ans.push_back(make_pair(i,i+1));
        w.push_back(0);
        ans.push_back(make_pair(i,i+1));
        w.push_back(val);
        val*=2;
    }
    ll cnt=n;
    while(l>v){
        if(l-p[cnt]>=v){
            ans.push_back(make_pair(cnt,n));
            ll diff=l-p[cnt];
            w.push_back(diff);
            l-=p[cnt];
        }
        cnt--;
    }
    cout << n+1 << " " << w.size() << endl;
    rep(i,w.size()){
        cout << ans[i].fi+1 << " " << ans[i].se+1 << " " << w[i] << endl;
    }
    return 0;
} 

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

using namespace std;

int main() {
  int N, Q;
  long long cusum = 0;
  
  map<int, int> count;
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int _in;
    
    cin >> _in;
    
    cusum += _in;
    
    count[_in]++;
  }
  
  cin >> Q;
  
  for (int i = 0; i < Q; i++) {
    int in_B, in_C;
    
    cin >> in_B >> in_C;
    
    cusum += (in_C - in_B) * count[in_B];
    
    count[in_C] += count[in_B];
    count[in_B] = 0;
    
    cout << cusum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 7912
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    k = int(ipt())
    al = [False]*k
    nk = 7
    for i in range(1,k+1):
        nk %= k
        if nk == 0:
            print(i)
            exit()
        else:
            if al[nk]:
                print(-1)
                exit()
            else:
                al[nk] = True
        nk = (nk*10+7)%k

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 76572
import sys

def readint():
    for line in sys.stdin:
        yield map(int,line.split())

def gcd(x,y):
    [x,y] = [max(x,y),min(x,y)]
    while 1:
        z = x % y
        if z == 0:
            break
        [x,y] = [y,z]
    return y

for [x,y] in readint():
    GCD = gcd(x,y)
    mx = x/GCD
    print GCD,mx*y

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=(a[i]-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in int read()
	{
		int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
const int N=1e5+5;
int n,ans;
struct pii{int l,r;in bool operator<(pii a)const{return r^a.r?r<a.r:l<a.l;}}a[N];
int main()
{
	n=read();for(int i=1,x,y;i<=n;i++) x=read(),y=read(),a[i]={x-y,x+y};
	sort(a+1,a+n+1);
	for(int i=1,j=-1e9;i<=n;i++) if(a[i].l>=j) j=a[i].r,ans++;
	write(ans,'\n');
	return ot(),0;
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.


Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        String s = scan.next();
        String t = scan.next();
        int a = scan.nextInt();
        int b = scan.nextInt();
        String u = scan.next();
        
        if(s.equals(u)){
            a = a - 1;
            System.out.println(a + " " + b);
        }else{
            b = b - 1;
            System.out.println(a + " " + b);
        }
    }
}

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

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B,max;

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

            A = int.Parse(word[0]);
            B = int.Parse(word[1]);

            max = A + B;

            if (max < A - B) max = A - B;
            if (max < A * B) max = A * B;
        

            Console.WriteLine(max);

            Console.ReadKey();


        }
    }
}


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

string s;
int ans;

int main() {
	cin >> s;
	ans = s.length() / 2 + s.length() % 2;

	/*for (int i = 0; i < s.length() / 2; i++) {
		if (!(s[s.length() / 2 - i - 1] == s[s.length() / 2 - i] 
			&& s[s.length() / 2 + i + s.length() % 2] == s[s.length() / 2 + i + s.length() % 2 - 1] 
			&& s[s.length() / 2 - i - 1] == s[s.length() / 2 + i + s.length() % 2])) {
			break;
		}
		ans++;
	}*/
	ans = s.length();
	for (int i = 1; i < s.length(); i++) {
		if(s[i-1] != s[i])ans = min(ans, max(i, (int)(s.length() - i)));
	}

	//cout << ((ans != INT32_MAX)?ans:((s[0] == '0')?0:s.length())) << endl;
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdlib.h>

int main() {
	while (1) {
		// 入力
		std::string number;
		std::cin >> number;
		// 演算
		if (number == "0") return 0;
		int N = number.length();
		int dp[80001][11];
		int answer = 0;
		for (int i = 0; i < 11; i++) {
			dp[0][i] = 0;
		}
		for (int i = 0; i < N; i++) {
			int digit = number.at(i) - '0';
			for (int j = 0; j < 11; j++) {
				dp[i + 1][(j * 10 + digit) % 11] = dp[i][j];
			}
			if (digit != 0) {
				dp[i + 1][digit]++;
			}
			/* for (int j = 0; j < 11; j++) {
				std::cout << "dp[" << i + 1 << "][" << j << "]: " << dp[i + 1][j] << std::endl;
			} */
			answer += dp[i + 1][0];
		}
		// 出力
		/* for (int i = 0; i < 11; i++) {
			std::cout << "dp[" << N << "][" << i << "]: " << dp[N][i] << std::endl;
		} */
		std::cout << answer << std::endl;
	}
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	vvi a(n, vi(m));
	vi b(m);
	rep(i, n) {
		rep(j, m) {
			cin >> a[i][j];
		}
	}

	rep(i, m) cin >> b[i];

	rep(i, n) {
		int ans = 0;
		rep(j, m) {
			ans += a[i][j] * b[j];
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3184
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

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

int w, h, sx, sy, gx, gy, n;
int c, d, x, y, nx, ny;

int dat[110][110];
bool used[110][110];

bool outOfRange(int x, int y){
	if(x > w || x < 1 || y > h || y < 1) return true;
	return false;
}


int main(){
	while(cin>>w>>h && w && h){
		cin>>sx>>sy>>gx>>gy>>n;
		rep(i, 110) rep(j, 110) dat[i][j] = 0, used[i][j] = false;
		rep(i, n){
			cin>>c>>d>>x>>y;
			if(d == 0){
				for(int j = 0; j < 4; j++){
					for(int k = 0; k < 2; k++){
						dat[x+j][y+k] = c;
					}
				}
			}
			else{
				for(int j = 0; j < 4; j++){
					for(int k = 0; k < 2; k++){
						dat[x+k][y+j] = c;
					}
				}
			}
		}

		queue<pair<int, pii> > q;
		pair<int, pii> p;
		q.push(mp(0, mp(sx, sy)));
		used[sx][sy] = true;
		bool ans = false;

		while(!q.empty()){
			p = q.front(); q.pop();
			c = p.fi;
			x = p.se.fi;
			y = p.se.se;
			if(x == gx && y == gy){
				ans = true;
				break;
			}
			for(int i = 0; i < 4; i++){
				nx = x + dx[i];
				ny = y + dy[i];
				if(outOfRange(nx, ny) || used[nx][ny] == true) continue;
				if(dat[x][y]==dat[nx][ny]){
					q.push(mp(c+1, mp(nx, ny)));
					used[nx][ny] = true;
				}
			}
		}
		cout<<(ans?"OK":"NG")<<endl;
	}
}

Measured memory_bytes: 1268
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void){
int r,d,x;
int count;
int ans;
  scanf("%d %d %d",&r,&d,&x);
  ans=r*x-d;
printf("%d\n",ans);
for(count=0;count<9;count++){
    ans=r*ans-d;
printf("%d\n",ans);
}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#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 = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    set<int> st;
    int s;
    cin >> s;
    st.insert(s);
    int now = s;
    for(int i = 2;; i++){
        if(now % 2 == 0) now = now / 2;
        else now = now * 3 + 1;
        if(st.count(now)){
            cout << i << endl;
            return 0;
        }
        st.insert(now);
    }
}

Measured memory_bytes: 256
s=input()
l=len(s)
if s[l-1]=='2' or s[l-1]=='4' or s[l-1]=='5' or s[l-1]=='7'  or s[l-1]=='9':
    print('hon')
elif s[l-1]=='0' or s[l-1]=='1' or s[l-1]=='6' or s[l-1]=='8':
    print('pon')
else:
    print('bon')
    

Measured memory_bytes: 9116
#include<stdio.h>
#include<cmath>

int main(){
double x1,x2,y1,y2,r,R;
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
r=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
R=sqrt(r);
printf("%lf\n",R);
return 0;
}

Measured memory_bytes: 1080
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return(y)

def lcm(x, y):
    ans = (x * y) // gcd(x, y)
    return(ans)
l = 1
cnt = [0 for i in range(len(A))]
for i in range(len(A)):
    a = A[i]
    l = lcm(l, a)
    count = 0
    while True:
        if a % 2 == 0:
            a //= 2
            count += 1
        else:
            cnt[i] = count
            break
count = cnt[0]
flag = True
for i in range(len(A)):
    if cnt[i] != count:
        flag = False
        break
if flag:
    l = l // 2
    ans = M // l
    print((ans+1)//2)
else:
    print(0)

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

using namespace std;

const int N = 1e5 + 5 , MOD = 1e9 + 7;
int dp[N];
bool bad[N];

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

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

    for (int i = 0 ;i < m ;i++) {
        int x;
        cin >> x;
        bad[x] = 1;
    }

    dp[0] = !bad[0];
    for (int i = 1 ;i <= n ;i++) if (!bad[i]) {
        if (i > 0 && !bad[i - 1])
            dp[i] = (dp[i] + dp[i - 1]) % MOD;
        if (i > 1 && !bad[i - 2])
            dp[i] = (dp[i] + dp[i - 2]) % MOD;
    }

    cout << dp[n];
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <tuple>
 
using namespace std;
 
template<typename E>
using Matrix = std::vector<std::vector<E> >;
 
typedef long long LL;
typedef long double LD;
typedef std::pair<LL ,LL> LP;
 
#define INF		1e9
#define EPS		1e-9
#define gcd 	__gcd
#define make_matrix(rows, col, type, default) 			\
					std::vector< std::vector<type> >( 	\
						rows, 						  	\
						std::vector<type>(col, default) \
					);
 
#define repeat(n)	for(LL __x = 0; __x < n; __x++)
#define watch(x)	cout << (#x) << " is " << (x) << "\n";
#define DEG_TO_RAD(x) (x * PI / 180.0)
#define RAD_TO_DEG(x) (x * 180.0 / PI)

auto cost(LL i, LL j) -> LL {
    return abs(i-j);
}

auto main() -> int {
    LL n, yes_max;

    std::cin >> n;
    Matrix<LL> input = make_matrix(n, 3, LL, 0);
    Matrix<LL> memo  = make_matrix(n, 3, LL, 0); // Best he can do on day i if he takes j
    for(LL i = 0; i < 3*n; i++) {std::cin>>input[i/3][i%3];}

    for(LL c = 0; c < 3; c++) {  memo[0][c] = input[0][c]; }
    for(LL r = 1; r < n; r++) { //  day
        for(LL c = 0; c < 3; c++) { // choose activity j
            yes_max = 0;
            for(LL c1 = 0; c1 < 3; c1++) { yes_max = (c1 == c ?  yes_max : max(yes_max, memo[r-1][c1])); };
            memo[r][c] = input[r][c] + yes_max;
        }
    }
    yes_max = 0;
    for(LL c = 0; c < 3; c++) { yes_max = max(yes_max, memo[n-1][c]); };
    std::cout << yes_max;
}

Measured memory_bytes: 11136
#include"bits/stdc++.h"
using namespace std;
int main() {
	int a, b, c, d, p;
	cin >> a >> b >> c >> d >> p;
	if (p>= c) {
		cout << min(a*p, b + ((p - c)*d)) << endl;
	}
	else {
		cout << min(a*p, b) << endl;
	}
}

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

#define fio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define tc(t) int t; cin >> t; while (t--)
#define for0(i, n)  for(int i = 0; i < n; i++)
#define pb push_back
#define int long long 

void solve()
{
  int x, y;
  cin>>x>>y;
  if(y<2*x || (y - 2*x) % 2 != 0 || 4*x < y || (4*x -y) % 2 != 0) {
    cout<<"No";
    //return;
  }
  
  // int t = (y - 2*x) / 2;
  // int c = x - t;
  // if(c < 0) {
  //   cout<<"No";
  // }
  else {
    cout<<"Yes";
  }
}

signed main() {

  fio;
  //tc(tt) {
    solve();
    cout<<"\n";
  //}
  
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    map<string, int> look;
    int mx = 0;

    int n;
    cin >> n;

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

        string s;
        cin >> s;
        look[s]++;
        mx = max(mx, look[s]);
    }

    for (auto it : look)
    {
        if (it.second == mx)
        {
            cout << it.first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
const int N = 1e7 + 4;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

    if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(ll n)
{
    ll ans = 1 ;
    for(ll i = 1 ; i <= n ; ++i)
        ans *= i ;
    return ans ;
}

int arr[ N ];
int main()
{
    FastInputOutput() ;
    int n ;
    map < int, int > mp ;
    cin >> n ;
    for(int i = 0 ; i < n ; ++i)
    {
        cin >> arr[ i ] ;
        ++mp[arr[ i ]] ;
    }
    int cnt = 0 ;
    map < int, int > ::iterator it ;
    for(it = mp.begin() ; it != mp.end() ; ++it)
        if(it->second % 2 == 1)
            ++cnt ;
    cout << cnt << endl ;

}


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

int main() {
	int N;
  	cin >> N;
  
  	int A;
  	cin >> A;
  
  	if ( (N % 500) <= A) {
      	cout << "Yes" << endl;
    }
  	else {
      	cout << "No" << endl;
    }
}

Measured memory_bytes: 3492
#include<iostream>
#include<vector>
#include<cstdio>
#include<set>
#include<map>
#include<algorithm>
#include<string>
#include<iterator>
#include<utility>
#include<bitset>
#include<fstream>
#include<cstdio>
#include<list>
#include<functional>
#include<queue>
#include<iomanip>
#if !defined (HEADER)
#define  HEADER
#define FAST_IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define x40 long long
#define _d static_cast<x40>(1e9+7)
#define fr(p,q) for(int i=p;i<q;i++)
#define fr2(i,p,q) for(int i=p;i<q;i++)
#define iv(v) \
fr2(v_name,0,v.size()) input(v[v_name]);
#define ov(v,c) \
fr2(cfg,0,v.size())\
output(v[cfg],c);
#define arrange(func,v) func(v.begin(),v.end());
#endif
using namespace std;
template<typename type>
type input()
{
	type var;
	cin >> var ;
	return var;
}
template<typename type>
void input(type &var)
{
	cin >> var ;
	return ;
}
template<typename type>
void output(type &var,const char *ch)
{
	cout << var << ch;
}
struct subject
{
	x40 curr,max_allowed,dx;
};
struct compe
{
	bool operator()(subject A,subject B)
	{
		if(A.curr==A.max_allowed)
			return false;
		else 
			if(B.curr==B.max_allowed)
				return true;
		return A.dx>=B.dx;
	}
};
int main()
{
	list<char> L;
	string S;
	cin >> S;
	for(int i = 0 ; i < S.length();i++)
	{
		L.push_back(S[i]);
	}
	bool flag=0;
	list<char>::iterator it1=L.begin(),it2=it1,it3;;
	while(it1!=L.end())
	{
		it2=it1;
		++it2;
		if(it2!=L.end()&&*it1=='S'&&*it2=='T')
			{
				if(it1==L.begin())
				{
					flag=1;
				}
				else
				{
					it3=it1;--it3;
				}
				L.erase(it1),L.erase(it2);
				if(flag)
				{
					it1=L.begin();
				}
				else
					it1=it3;
			}
			else
				++it1;
	}
	cout << L.size();
	return 0;
}


Measured memory_bytes: 6660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i,N)cin >> v[i];
    sort(v.begin(),v.end());
    double ans = v[0];
    repX(i,N,1){
        ans = (ans + v[i])/2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from numpy import*
from copy import deepcopy

def main():
    n,a,b,*h=map(int,open(0).read().split())
    h=array(h)
 
    ok=-1
    ng=max(h)+10
    
    def judge(t):
        H=deepcopy(h)
        H-=b*t
        H=H[H>0]
        if sum((H-1)//(a-b)+1)<=t:
            return 1
        else:
            return 0
    
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if judge(mid):
            ng=mid
        else:
            ok=mid
    l=ok+1
    print(l)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int MAX_N = 300000;
int bit[MAX_N+1];

int sum(int i){
  i+=150000;
  int s=0;
  while(i>0){
    s+=bit[i];
    i-=i&-i;
  }
  return s;
}

void add(int i,int x){
  i+=150000;
  while(i<MAX_N){
    bit[i]+=x;
    i+=i&-i;
  }
}

int cal(vector<int> v){
  memset(bit,0,sizeof(bit));
  for(int i=1;i<v.size();i++)v[i]+=v[i-1];
  add(0,1);
  int res=0;
  for(int i=0;i<v.size();i++){
    res+=sum(v[i]-1);
    add(v[i],1);
  }
  return res;
}

signed main(){
  int n,a[100000];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int x=(n+1)*n/4+1;
  int l=0,r=1e9,m;
  while(l<r){
    m=(l+r)/2;
    vector<int> v(n);
    for(int i=0;i<n;i++)v[i]=(a[i]<=m)?1:-1;
    if(cal(v)>=x)r=m;
    else l=m+1;
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
 
int main() {
    // Write Your Code Below
    double a,b;
    cin >> a >> b;
    double c = 1/a + 1/b;
     cout << fixed << setprecision(10);
    cout << 1/c << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define int long long
#define all(arr) arr.begin(),arr.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(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]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define br '\n'
/*int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
int MOD = 100001;*/

void solve()
{
	int n,k;
	cin>>n>>k;
	vi arr(n);
	scan(arr,n);
	sort(all(arr));
	int sum = 0;
	loop(i,0,k)
		sum += arr[i];
	cout<<sum<<endl;
}

int32_t main()
{
	FastIO; PRECISION;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;
    for (int i = l; i <= r; i++){
        if (i % d == 0)
            ans += 1;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n 
#define pl(n) cout<<n<<" "
const int Nx=1e5+2;
const int inf=(int)(1e9+10LL);
void solve()
{
 string s,t;
 sl(s);sl(t);
 string ss=s+t[t.length()-1];
 if(ss==t){
 	cout<<"Yes"<<endl;
 	return;
 }
 cout<<"No"<<endl;
 return;

}

signed main(){
  int test=1;
// sl(test);
 while(test--){
 	solve();
 }
 
}

Measured memory_bytes: 3572
package main

import "fmt"
import "bytes"

func main() {
  var o, e string

  fmt.Scanln(&o)
  fmt.Scanln(&e)

  ans := make([]byte, len(o)+len(e))
  for i := 0; i < len(o); i++ {
    ans[2*i] = o[i]
  }
  for i := 0; i < len(e); i++ {
    ans[2*i+1] = e[i]
  }

  fmt.Print(bytes.NewBuffer(ans).String())
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
        long ans = 0;
      
        if(a == 0){
            ans = b / x + 1;
        }else{
            ans = b / x - (a - 1) / x;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35840
/****************************
https://atcoder.jp/contests/dp/tasks/dp_f

Time	66	  	ms
Memory	50120	KB
****************************/
# include <iostream>
# include <cstdio>
# include <cstring>

const int maxn = 4e3 + 5;
int L[maxn][maxn];

int lcs(char* X, char* Y, int m, int n) {
	/* Following steps build L[m+1][n+1] in bottom up fashion. Note
	  that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (X[i - 1] == Y[j - 1]) {
				L[i][j] = L[i - 1][j - 1] + 1;
			} else {
				L[i][j] = std::max(L[i - 1][j], L[i][j - 1]);
			}
		}
	}

	return L[m][n];
}

int main() {
	char* x = new char[maxn];
	char* y = new char[maxn];
	scanf("%s", x);
	scanf("%s", y);

	int m = strlen(x);
	int n = strlen(y);

	int index = lcs(x, y, m, n);

	char* lcc = new char[index + 1];
	lcc[index] = '\0';

	int i = m;
	int j = n;
	while (i > 0 && j > 0) {
		if (x[i - 1] == y[j - 1]) {
			lcc[index - 1] = x[i - 1];
			i--;
			j--;
			index--;
		} else if (L[i - 1][j] > L[i][j - 1]) {
			i--;
		} else {
			j--;
		}
	}

	printf("%s", lcc);

	return 0;
}


Measured memory_bytes: 50148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int height, width;
  cin >> height >> width;
  mint dp[width][height];
  bool sdp[width][height];  
  string s;
  for (int h=0; h<height; ++h) {
    cin >> s;
    for (int w=0; w<width; ++w) {
      sdp[w][h] = (s[w] == '#') ? true : false;
      dp[w][h] = 0;
    }
  }

  // intialize
  for (int w=0; w<width; ++w) {
    if (sdp[w][0]) {
      break;
    }
    dp[w][0] = 1;
  }
  for (int h=0; h<height; ++h) {
    if (sdp[0][h]) {
      break;
    }
    dp[0][h] = 1;
  }  
  
  for (int w=1; w<width; ++w) {
    for (int h=1; h<height; ++h) {
      if (!sdp[w][h]) {
	dp[w][h] = dp[w-1][h] * (!sdp[w-1][h]) + dp[w][h-1] * (!sdp[w][h-1]);
      }
    }
  }

  cout << dp[width-1][height-1] << endl;
  return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

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

	cin >> N >> A >> B;
	
	vector<long long> v(N);

	for (int i = 0;i < N;i++)
		cin >> v[i];
	
	// パスカルの三角形
	vector<vector<long long>> C(N + 1);

	for (int i = 0;i <= N;i++)
	{
		for (int j = 0;j <= N;j++)
		{
			if (j <= i)
			{
				// 三角形の最初と最後は1
				if (j == 0 || j == i)
					C[i].push_back(1);
				else // 左上と右上の二つの値を足す
					C[i].push_back(C[i - 1][j - 1] + C[i - 1][j]);
			}
			else 
				C[i].push_back(0);
		}
	}

	// 降順ソート
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	// 平均
	double ave = 0.0;
	for (int i = 0;i < A;i++)
		ave += v[i];
	ave /= A;
	
	// 組み合わせ
	int CountToN = 0;
	int CountToA = 0;
	for (int i = 0;i < N;i++)
	{
		// [A - 1] : 平均が最大(A)に含まれるギリギリの値
		if (v[i] == v[A - 1])
		{
			// すべての要素内で同じ値か
			CountToN++;

			// 平均が最大(A)の間で同じ値か
			if (i < A)
				CountToA++;
		}
	}
	
	long long Count = 0;
	// 平均が最大(A)の要素がすべて同じ
	if (CountToA == A)
	{
		// いくつ選んでも平均は最大なのでAからBまでの組み合わせを足す
		for(int i = A;i <= B;i++)
			Count += C[CountToN][i];
	}
	else
	{
		// 同じ値の中でどの要素を選ぶか
		Count = C[CountToN][CountToA];
	}

	cout << fixed << setprecision(20) << ave << endl;
	cout << Count << endl;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll A,B,L,R,L1,R1,ans;int k1,k2;
int main(){
	cin>>A>>B;if(A==B){puts("1");return 0;}
	rpd(i,60,1){
		ll a=A&(1LL<<i-1),b=B&(1LL<<i-1);
		if(a!=b){k1=i;break;}
		A-=a;B-=b;
	}
	rpd(i,k1-1,1){
		ll b=B&(1LL<<i-1);
		if(b){k2=i;break;}
	}
	L=A;R=(1LL<<k1-1)+(1LL<<k2)-1LL;
	L1=(1LL<<k1-1)+A;R1=(1LL<<k1)-1LL;
	ans+=(R-L+1LL)+(R1-L1+1LL);
	if(L1<=R)ans-=(R-L1+1LL);
	printf("%lld\n",ans);
	//system("pause");
	return 0;
}

Measured memory_bytes: 384
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const double PI = acos(-1);
typedef long long ll;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

void solve() {
    cini(n);
    cins(s);

    vector<char> cth={ 'R', 'G', 'B' };
    vector<int> rgb(256);
    rgb['R']=0;
    rgb['G']=1;
    rgb['B']=2;

    vvi pre(3, vi(n+1));  /* pre[i][j] == number of R=0 G=1 B=2 in postfix starting at j */

    for(int i=n-1; i>=0; i--) {
        for(int j=0; j<3; j++) {
            pre[j][i]=pre[j][i+1];
        }
        pre[rgb[s[i]]][i]++;
    }


    int ans=0;
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            if(s[i]==s[j])
                continue;
            int th=0;
            if((s[i]=='R' && s[j]=='G') || (s[i]=='G' && s[j]=='R'))
                th=2;
            else if((s[i]=='R' && s[j]=='B') || (s[i]=='B' && s[j]=='R'))
                th=1;
            else
                th=0;

            ans+=pre[th][j+1];
            if(j+(j-i)<n && s[j+(j-i)]==cth[th])
                ans--;
        }
    }
    cout<<ans<<endl;
}

signed main() {
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
}



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

int ilog2(long X, long Y) {
    int i = 0;
    while (Y >= X * 2) {
        i ++;
        Y /= 2;
    }
    return i;
}

int main() {
    long X, Y;
    std::cin >> X >> Y;

    std::cout << ilog2(X, Y) + 1 << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <set>

using namespace std;

int n;
std::set<string> words;

int main()
{
	words.clear();
	
	scanf("%d\n", &n);
	
	char tempWord[200][200];
	char lastCh = -1;
	
	for (int i = 0 ; i < n ; i++)
		scanf("%s\n", tempWord[i]);
		
	for (int i = 0 ; i < n ; i++)		
	{		
		string curWord = tempWord[i];
		
		if (words.find(curWord) != words.end())
		{
			printf("No\n");
			return 0;
		}
		
		if ((lastCh != -1) && (curWord[0] != lastCh))
		{
			printf("No\n");
			return 0;			
		}
		
		words.insert(curWord);
		lastCh = curWord[curWord.size() - 1];
	}
	
	printf("Yes\n");
		
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

ll gcd(ll a, ll b){
	if(b==0)return a;

	return gcd(b, a%b);
}


ll lcm(ll a, ll b){
	return a /gcd(a, b) * b;
}

int main(){
	ll n, t[100], ans, tmp;
	cin >> n;
	rep(i, n){
		scanf("%lld", &t[i]);
	}

	ans = 2000000000000000000;

	ans = t[0];
	rep(i, n-1){
		ans = lcm(ans, t[i+1]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define input_from_file  freopen("input.txt", "r", stdin);
ll ans=0;
ll dfs(vector<vector<ll>> &adj,vector<bool> vis,vector<ll> &dp,ll ctr,ll i){
  if(!vis[i]){
    vis[i]=1;
    if(adj[i].size()==0)  dp[i]=0;
    if(dp[i]!=-1) return  dp[i];
    for(auto itr:adj[i])
      dp[i]=max(dp[i],dfs(adj,vis,dp,ctr,itr)+1);
    ans=max(dp[i],ans) ; 
  }
  return dp[i];
}
int main()
{
  // input_from_file;
  ll n,k,m,u,v,ctr=0;
  cin>>n>>m;
  vector<vector<ll>> adj(n+1);vector<bool> vis(n+1,0);vector<ll> dp(n+1,-1);
  for(ll i=0;i<m;i++){
    cin>>u>>v;adj[u].pb(v);
  }
  // for(ll i=1;i<=n;i++){
  //   cout<<"i="<<i<<" : ";
  //   for(auto itr:adj[i])  cout<<itr<<" ";cout<<endl;
  // }
  for(ll i=1;i<=n;i++)  ll x=dfs(adj,vis,dp,ctr,i);
  // for(ll i=1;i<=n;i++) cout<<dp[i]<<" ";cout<<endl;
  cout<<ans;
  return 0;
}

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

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

	int i,k;
	ll N;
	ll ans=0;
	int ctr=0;
	const long long MOD=1e9+7;

	cin >> N;

	vector<ll> gv(N);
	vector<ll> s(N+1,0);

	rep(i,N) cin >> gv[i];
	for(i=N-1;i>0;i--) s[i-1]=(gv[i]+s[i])%MOD;

	for(i=0;i<N-1;i++){
		ans+=(gv[i]*s[i])%MOD;
	}
	
	cout << ans%MOD << endl;

	return 0;
}



Measured memory_bytes: 6364
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        String t=sc.next();
        int ans = 0;
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i) != t.charAt(i)){
                ans++;
            }
        }
        lp(ans);
    }
    public static void lp(Object o){
        System.out.println(o);
    }
}


Measured memory_bytes: 41368
import java.util.Scanner;
class Main {
	public static void main (String [] args){
		Scanner in = new Scanner(System.in);
		int t;
		
		t = in.nextInt();
		
		System.out.println((t / 3600) + ":" + (t % 3600 / 60) + ":" + (t % 3600 % 60));
		
	}
}

Measured memory_bytes: 26212
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int N, W;
vi w, v;
const int MAX_N = 101;  // MAX_Nくらい
const int MAX_V = 1010101; // MAX_N * MAX_Vくらい

ll dp[MAX_N + 1][MAX_V];
int main() {
    cin >> N >> W;
    w.resize(N); v.resize(N);
    rep(i, N) cin >> w[i] >> v[i];

    fill_n(dp[0], MAX_V * (MAX_N + 1), INF);
    dp[0][0] = 0;  // 0個で価値0を実現するには重さ0でOK

    rep(i, N) {
        // 価値の最大値はN * 1000
        for(int j = 0; j <= N * 1000; j++) {
            if (j < v[i]) {
                dp[i + 1][j] = dp[i][j];  // 入れたらjをオーバーしちゃう
            } else {
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }
    int res = 0;
    for (int i = 0; i <= MAX_V; i++) if (dp[N][i] <= W) res = i;
    cout << res << endl;
}

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

using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FOR(i, a) for (int i = 0; i < (a); i++)

const int N = int(1e3) + 7;

void init(){

}

void solve(){
    int n, l;
    scanf("%d %d", &n, &l);
    int ans = 0;
    FOR(i, n) ans += l+i;
    if(l+n <= 0) ans -= l+n-1;
    else if(l > 0) ans -= l;
    printf("%d\n", ans);

}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


Measured memory_bytes: 256
m,k=map(int,input().split())
if k<=2**m-1 and m>1:
    lists=[]
    for i in range(2**m-1,-1,-1):
        if i!=k:
            lists.append(i)
    lists.append(k)
    for i in range(2**m):
        if i!=k:
            lists.append(i)
    lists.append(k)
    print(*lists)
elif k<=2**m-1 and m==0:
    print(*[0,0])
    
elif k<=2**m-1 and m==1:
    if k==0:
        print(*[0,0,1,1])
    elif k==1:
        print(-1)

else:
    print(-1)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;
  unordered_set<string> s;
  string ans = "Yes";
  string w;
  cin >> w;
  s.insert(w);
  char c = w.back();
  for (int i = 1; i < n; ++i) {
    cin >> w;
    if (c != w[0] || s.count(w)) {
      ans = "No";
      break;
    }
    s.insert(w);
    c = w.back();
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>

using namespace std;
struct node{
    node *l,*p,*r;
    int key;
};
node *t ,*NIL;
void insert(int k){
    node *y=NIL;
    node *x=t;
    node *z;
    z = new node;
    z->key = k;
    z->l = NIL;
    z->r = NIL;
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->l;
        }
        else{
            x=x->r;
        }
    }
    z->p=y;
    if(y==NIL){
        t=z;
    }
    else {
        if(z->key<y->key)y->l=z;
        else y->r=z;
    }
}

void In(node *c){
    if (c== NIL){
        return;
    }
    In(c->l);
	printf(" %d",c->key);
    In(c->r);
}
void Pre(node *c){
    if (c== NIL){
        return;
    }
    printf(" %d",c->key);
	Pre(c->l);
    Pre(c->r);
	
}
int main(){
    int n;
    string com;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            int x;
            cin>>x;
            insert(x);
        }
        else{
            In(t);
            cout<<endl;
            Pre(t);
            cout<<endl;
        }
    }
    return 0;
}





Measured memory_bytes: 26776
//C:\Program Files(x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\x86_64-w64-mingw32\bits\stdc++.h
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<limits>
#include<list>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

using namespace std;

int k;
int cnt[256];
string s;
set<string> st;

int main(){
	cin>>s>>k;
	for(int i=0;i<s.size();i++){
		string str="";
		for(int j=i;j<s.size();j++){
			str+=s[j];
			if(st.find(str)!=st.end()) continue;
			st.insert(str);
			if(st.size()>k){
				set<string>::iterator it=st.begin();
				for(int i=0;i<k;i++,it++);
				st.erase(it,st.end());
			}
		}
	}
	set<string>::iterator it=st.begin();
	for(int i=0;i<k-1;i++,it++);
	cout<<(*it)<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

const int M = 1e9 + 7;

ll fast_pow(ll a, ll b) {
	ll ans = 1;
	while(b) {
		if(b&1) ans = ans * a % M;
		b >>= 1;
		a = a * a % M;
	}
	return ans;
}

ll f(int n, int k, int x) {
	return fast_pow(k/x, n);
}

const int N = 2e5 + 7;
ll F[N];

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

	int n, k; cin >> n >> k;

	ll ans = 0;
	for(int i = k; i >= 1; --i) {
		ll aux = 0;
		aux = f(n, k, i);
		for(int j = i + i; j <= k; j += i) {
			aux = (aux -  F[j] + M)%M;
		}
		ans += aux * i % M;
		ans %= M;
		F[i] = aux;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int ,int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	ll H;
	cin >> H;
	ll temp_H = H;
	ll ans = 0;
	ll enm = 1;
	while(temp_H > 1){
		temp_H/=2;
		ans+=enm;
		enm*=2;
	}
	ans+=enm;
	cout << ans << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256