akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  ll n;
  cin >> n;
  if (n % 2 == 0) P(n);
  else P(n * 2);
  return 0;
}



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

map<char, long long> counter(vector<string> s){
    map<char, long long> c;
    vector<char> march{'M', 'A', 'R', 'C', 'H'};
    for (auto i : s){
        if (find(march.begin(), march.end(), i[0]) != march.end()){
            c[i[0]]++;
        }
    }
    return c;
}

int main(){
    int n; cin>>n;
    vector<string> names(n); for (int i=0;i<n;i++){cin>>names[i];}

    auto freq = counter(names);
    if (freq.size() < 3){
        cout << 0 << endl;
        return 0;
    }
    long long ans;
    ans = freq['M'] * freq['A'] * freq['R'] + freq['M'] * freq['A'] * freq['C'] + freq['M'] * freq['A'] * freq['H'] + freq['M'] * freq['R'] * freq['C'] + freq['M'] * freq['R'] * freq['H'] + freq['M'] * freq['C'] * freq['H'] + freq['A'] * freq['R'] * freq['C'] + freq['A'] * freq['R'] * freq['H'] + freq['A'] * freq['C'] * freq['H'] + freq['R'] * freq['C'] * freq['H'];
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll x,y;
  cin >> x >> y;
  int ans = 0;
  while(x <= y){
    x *= 2;
    ans++;
  }
  cout << ans << endl;
}


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

int main(){
    string s;
    string t="YAKI";
    cin >> s;
    if(equal(t.begin(), t.end(), s.begin())){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import collections
A,B=map(int,input().split())

def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y,x%y)

n=gcd(A,B)
a=[]
while n%2==0:
  a.append(2)
  n//=2
f=3
while f*f<=n:
  if n%f==0:
    a.append(f)
    n//=f
  else:
    f+=2
if n!=1:
  a.append(n)

c=collections.Counter(a)
print(len(c.keys())+1)

Measured memory_bytes: 3316
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())

graph = [0] + [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

def dfs(graph, queue, color):
    is_bigraph = True
    while queue:
        current = queue.pop()

        for _next in graph[current]:
            if color[_next] != -1:
                if color[_next] == color[current]:
                    is_bigraph = False
            else:
                color[_next] = 1 - color[current]
                queue.append(_next)
    return is_bigraph

queue = [1]
color = [-1] + [-1] * n
color[1] = 0

if dfs(graph, queue, color):
    print(color.count(0) * color.count(1) - m)
else:
    print((n * (n - 1)) // 2 - m)


Measured memory_bytes: 89816
N = int(input())
B=list(map(int,input().split()))
A=[0]*N

for i in range(N):
  if i==0:
    A[i] = B[i]
  elif i==N-1:
    A[i] = B[i-1]
  else:
  	A[i] = min(B[i],B[i-1]) 

print(sum(A))

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

using namespace std;
typedef long long ll;

ll n, V[100005], res;


int main() {
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin>>V[i];
    }
    sort(V+1, V+n+1);
    for (int i=1; i<=n; i++)
    {
        ll x = V[i]-V[i-1];
        if (x%2==1)
        {
            res ^= (n-i+1);
        }
    }
    if (res==0)
        cout<<"second";
    else
        cout<<"first";
    return 0;
}

Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for i in range(N):
    a=min(A[i],B[i])
    B[i]-=a
    b=min(A[i+1],B[i])
    A[i+1]-=b
    ans+=a+b
print(ans)

Measured memory_bytes: 18624
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;

int N,K,T,v1,v2,L;
int D[220];
double ans;
int now;
double up;
int yorn;
int have;


int main(){
	cin >> N >> K >> T >> v1 >> v2 >> L;
	for(int i=0;i<N;i++){
		cin >> D[i];
	}
	for(int i=0;i<N;i++){
		if(yorn==0){
			ans += 1.0*(D[i]-now)/v1;
			up = D[i] + T*v2;
			now = D[i];
			yorn = 1;
		}
		else if(yorn==1){
			if(D[i]>up){
				while(D[i]>up && have>0){
					have --;
					up += T*v2;
				}
				if(D[i]>up){
					ans += 1.0*(up-now)/v2;
					ans += 1.0*(D[i]-up)/v1;
					up = D[i]+T*v2;
					now = D[i];
				}
				else{
					have ++;
					have = min(have,K);
					ans += 1.0*(D[i]-now)/v2;
					now = D[i];
				}
			}
			else if(D[i]<up){
				if(have==K){
					ans += 1.0*(D[i]-now)/v2;
					up = D[i] + T*v2;
					now = D[i];
				}
				else{
					ans += 1.0*(D[i]-now)/v2;
					have++;
					now = D[i];
				}
			}	
			else{
				ans += 1.0*(D[i]-now)/v2;
				up = D[i] + T*v2;
				now = D[i];
			}
			
		}
			
	}
	while(have>0){
		have --;
		up += T*v2;
	}
	if(L > up){
		ans += 1.0*(up-now)/v2;
		ans += 1.0*(L-up)/v1;
	}
	else{
		ans += 1.0*(L-now)/v2;
	}
	printf("%.10lf\n", ans);
	return 0;
}




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

#define INF 1000000000000


int main()
{
	int n;
	int ans = 1;
	cin >> n;
  ans=(n/2)*(n-n/2);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
while True :
	m,f,r=map(int,raw_input().split())
	if m==-1 and f==-1 and r==-1:
		break
	else:
		if m==-1 or f==-1 :
			print 'F'
		elif m+f >= 80:
				print 'A'
		elif m+f >= 65:
			print 'B'
		elif m+f >= 50 or r>=50:
			print 'C'
		elif m+f >= 30:
			print 'D'
		else :
			print'F'

Measured memory_bytes: 6336
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string str; cin>>str;
	
	map<char,int>mp;
	for(int i=0;i<str.size();i++)
	{
		mp[str[i]]++;
	}
	int flag=0;
	for(char ch='a';ch<='z';ch++)
	{
		if(!mp[ch])
		{
			flag=1;
			cout<<ch<<endl;
			break;
		}
	}
	if(!flag) cout<<"None\n";
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;

const int N=100005;

int n,ans;
int a[N];

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	if (a[1]==1) swap(a[1],a[2]),ans++;
	for (int i=2;i<=n;i++)
		if (a[i]==i){
			ans++;
			if (a[i+1]==i+1) swap(a[i],a[i+1]);
			else{
				if (a[i-1]==i) swap(a[i],a[i+1]);
				else swap(a[i],a[i-1]);
			}
		}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 640
n,a,b = map(int,input().split())

def digitsum(num):
    s = str(num)
    r = 0
    for c in s:
        r += int(c)
    return r

res = 0
for i in range(1,n+1):
    if a<=digitsum(i)<=b:
        res += i
print(res)


Measured memory_bytes: 2940
k,n=map(int,input().split())
list=list(map(int,input().split()))
dif_list=[]

for i in range(n):
  if i == 0:
    dif_list.append(k-list[-1]+list[0])
  else:
    dif_list.append(list[i]-list[i-1])

print(k-max(dif_list))

Measured memory_bytes: 26444
import sys
N = int(input())

X = input()

o = 0
cnt = 0
for i in X:
    o *= 2
    if i == "1":
        o += 1
        cnt += 1

if cnt == 0:
    for i in range(N):
        print (1)
    sys.exit()
elif cnt == 1:
    orev = [o % (cnt+1) , None]
else:
    orev = [o % (cnt+1) , o % (cnt-1)]

for i in range(N):

    nb = int(X[i])

    if nb == 0:
        mod = cnt+1
        now = (orev[0] + pow(2,N-1-i,mod)) % mod

        ans = 1
        while now != 0:
            s = format( now , 'b' )
            one = 0
            for j in s:
                if j == "1":
                    one += 1
            now %= one
            ans += 1

        print (ans)

    else:
        if cnt == 1:
            print (0)
            continue
        
        mod = cnt-1
        now = (orev[1] - pow(2,N-1-i,mod)) % mod

        ans = 1
        while now != 0:
            s = format( now , 'b' )
            one = 0
            for j in s:
                if j == "1":
                    one += 1
            now %= one
            ans += 1

        print (ans)


Measured memory_bytes: 86468
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var C = new Array(N);
  var mod = Math.pow(10,9)+7;
  var map=new Array(2*Math.pow(10,5)+1).fill(-1);
  var l =new Array(N).fill(1);
  var prev=-1;
  for(var i=0;i<N;i++){
    C[i]=parseInt(input[i+1]);
    if(i!=0){
      if(map[C[i]]!=-1&&C[i]!=prev){
        l[i]=(l[map[C[i]]]+l[i-1])%mod;
      }else{
        l[i]=l[i-1];
      }
    }
      map[C[i]]=i;
      prev=C[i];
  }
  var ans=l[N-1];

  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	int n;
	cin >> n;
	double v[n];
	double r[n-1];
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	
	sort(v,v+n);
	r[0] = (v[0]+v[1])/2;

	for(int i=0;i<n-2;i++){
		r[i+1] = (r[i] + v[i+2])/2;
	}
	
	cout << r[n-2] << endl;	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

bool isUpper(char ch){
    return ch>='A' && ch<='Z';
}
int _find(string &str){
    if(str[0]!='A'){return 0;}
    int cntC=0;
    for(int i=1;i<str.l();i++){
        if(i>=2 && i<=str.l()-1-1){
            if(str[i]=='C'){
                cntC++;
            }
            else{
                if(isUpper(str[i])){
                    return false;
                }
            }
        }
        else{
            if(isUpper(str[i])){
                return false;
            }
        }
    }
    return cntC==1;
}



void solve(){
    
    string str;
    cin>>str;
    if(_find(str)){
        cout<<"AC";
    }
    else{
        cout<<"WA";
    }
}




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

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int X;
bool dp[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X;
	dp[0] = true;
	rep(x, 0, X) if(dp[x]) rep(d, 0, 6) dp[x + d + 100] = true;

	if (dp[X]) cout << "1" << endl;
	else cout << "0" << endl;
}







Measured memory_bytes: 384
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String ans = "No";
	for (int i = 0; i <= 15; i++) {
      for (int j = 0; j <= 25; j++) {
        if (N == (7 * i + 4 * j)) {
          ans = "Yes";
          break;
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const int MAXV = 1e5 + 5;
void marmot0814() {
    string s, t; cin >> s >> t;
    vector<vector<LL>> dp(s.size() + 1, vector<LL>(t.size() + 1,  0));
    vector<vector<LL>> pr(s.size() + 1, vector<LL>(t.size() + 1, -1));
    for (int i = 0 ; i < s.size() ; i++) {
        for (int j = 0 ; j < t.size() ; j++) {
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
                pr[i + 1][j + 1] = 2;
            } else {
                if (dp[i + 1][j] > dp[i][j + 1]) {
                    dp[i + 1][j + 1] = dp[i + 1][j];
                    pr[i + 1][j + 1] = 0;
                } else {
                    dp[i + 1][j + 1] = dp[i][j + 1];
                    pr[i + 1][j + 1] = 1;
                }
            }
        }
    }
    int i = s.size(), j = t.size(); string str;
    while (pr[i][j] != -1) {
        if (pr[i][j] == 2)
            str += s[i - 1], i--, j--;
        else if (pr[i][j] == 0)
            j--;
        else
            i--;
    }
    reverse(str.begin(), str.end());
    cout << str << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

Measured memory_bytes: 144124
#include<stdio.h>

int main(){
  int A[100];
  int i,j,N,k;
  int change=0;

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	k=A[j];
	A[j]=A[j-1];
	A[j-1]=k;
	change++;
      }
    }
  }

  for(i=0;i<N-1;i++)printf("%d ",A[i]);

  printf("%d\n",A[i]);
  printf("%d\n",change);


  return 0;
}

Measured memory_bytes: 600
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;
typedef vector< vector<int> > graph;

// G を連結成分に分解する
vector<graph> decomp(const graph &G){
	int n=G.size();
	vector<graph> cc;
	map<int,int> f; // G における頂点番号 -> 連結成分の番号
	map<int,int> g; // G における頂点番号 -> 連結成分における頂点番号

	int c_id=0;
	vector<bool> vis(n);
	rep(u,n) if(!vis[u]) {
		vis[u]=true;

		vector<int> tmp; // 今調べている連結成分
		queue<int> Q; Q.push(u);
		while(!Q.empty()){
			int v=Q.front(); Q.pop();
			tmp.push_back(v);
			rep(i,G[v].size()){
				int w=G[v][i];
				if(!vis[w]) vis[w]=true, Q.push(w);
			}
		}

		cc.push_back(graph(tmp.size()));
		rep(i,tmp.size()){
			f[tmp[i]]=c_id;
			g[tmp[i]]=i;
		}
		c_id++;
	}

	rep(u,n) rep(i,G[u].size()) {
		int v=G[u][i];
		cc[f[u]][g[u]].push_back(g[v]);
	}

	return cc;
}

bool is_bipartite(const graph &G,int &L_res,int &R_res){
	int n=G.size();
	int L=0,R=0;
	vector<int> color(n,-1);

	rep(u,n) if(color[u]==-1) {
		color[u]=2*(L++);

		queue<int> Q; Q.push(u);
		while(!Q.empty()){
			int v=Q.front(); Q.pop();

			rep(i,G[v].size()){
				int w=G[v][i];
				if(color[w]%2==color[v]%2) return false;
				if(color[w]==-1){
					if(color[v]%2==0) color[w]=2*(R++)+1;
					else              color[w]=2*(L++);
					Q.push(w);
				}
			}
		}
	}

	L_res=L;
	R_res=R;
	return true;
}

vector<int> unify_ones(const vector<int> &a){
	vector<int> res;
	int one=0;
	rep(i,a.size()){
		if(a[i]==1) one++;
		else        res.push_back(a[i]);
	}

	int two=1;
	while(one>0){
		res.push_back(min(two,one));
		one-=min(two,one);
		two<<=1;
	}
	return res;
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	graph G(n);
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	vector<graph> cc=decomp(G);

	vector<int> L(cc.size()),R(cc.size()); // 二部グラフの左右の頂点数
	rep(i,cc.size()){
		if(!is_bipartite(cc[i],L[i],R[i])) return puts("-1"),0;
		if(L[i]>R[i]) swap(L[i],R[i]);
	}

	int L_sum=0;
	vector<int> add(cc.size());
	rep(i,cc.size()){
		L_sum+=L[i];
		add[i]=R[i]-L[i];
	}

	// add[i]==1 がたくさんあると部分和問題を解くのに時間がかかりすぎるので, 適当にまとめる ( 個数制約があるナップザックと同じ tips )
	add=unify_ones(add);
	sort(add.begin(),add.end());

	// knapsack DP
	int N=L_sum; // 最適な左の頂点数 ( n/2 以下で最大になるよう振り分ける )
	int ub=0;
	vector<bool> dp(n+1); dp[0]=true;
	rep(i,add.size()){
		for(int j=min(ub,n/2-L_sum-add[i]);j>=0;j--){
			if(dp[j]){
				dp[j+add[i]]=true;
				if(abs(L_sum+j+add[i]-n/2.0)<abs(N-n/2.0)) N=L_sum+j+add[i];
				ub=max(ub,j+add[i]);
			}
		}
	}

	printf("%lld\n",(ll)N*(n-N)-m);

	return 0;
}

Measured memory_bytes: 22516
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

const int INF = 1e9 + 5;

int main(){

    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    int n;
    std::cin >> n;

    std::vector<int> stones(n);
    for(int& i : stones){
        std::cin >> i;
    }

    std::vector<int> dp(n , INF);  
    dp[0] = 0;
    for(int i = 0 ; i < n ; ++i){
        for(int j : {i + 1 , i + 2}){
            if(j < n){
                dp[j] = std::min(dp[i] + std::abs(stones[i] - stones[j]) , dp[j]);
            }
        }
    }

    std::cout << dp[n - 1] << '\n';

}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;

class xy{
public:
  int x, y;
  xy() {x = y = 0;}
  xy(int a, int b) {x = a; y = b;}
};

int abs_ma(xy a, xy b){
  return abs(a.x - b.x) + abs(a.y - b.y);
}

int main(){
  int N, M; cin >> N >> M;
  vector<xy> S(N);
  vector<xy> C(M);
  for(int i = 0; i < N; i++){
    int a, b; cin >> a >> b;
    S[i].x = a; S[i].y = b;
  }
  for(int i = 0; i < M; i++){
    int c, d; cin >> c >> d;
    C[i].x = c; C[i].y = d;
  }
  for(int i = 0; i < N; i++){
    int tmp = 0;
    for(int j = 1; j < M; j++){
      if(abs_ma(C[tmp], S[i]) > abs_ma(C[j], S[i])) tmp = j;
    }
    cout << tmp + 1 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

double t, x;

int main()
{
	cin >> t >> x;
	cout << fixed << std::setprecision(9) << t / x << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n)std::cin >> a[i];
	rep(i,n-1)std::cout << a[n-i-1] <<" ";
	std::cout << a[0] << std::endl;
}


Measured memory_bytes: 3016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;

		for (int x = Math.max(0, s - 2 * k); x <= k; x++) {
			for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21972
//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];

ll dp[N];

void solve(){
    ll n, W, x, y;
    cin >> n >> W;
    // dp[x] = minimum weight req for x value;
    vector<ll> dp(N, inf);
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        cin >> x >> y;
        for(int j = N - 2; j >= y; --j){
            dp[j] = min(dp[j], dp[j - y] + x);
        }
    }
    for(int i = 0; i < N; ++i){
        if(dp[i] <= W)  res = i;
    }
    cout << res;
}
 
int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro

Measured memory_bytes: 1792
import java.util.Scanner;
    public  class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            for(int i=1; ;i++){
                int x = sc.nextInt();
                if(x==0){
                    break;
                }else{
                    System.out.printf("Case %d: %d\n",i,x);
                }
            }
        sc.close();
        }
    }
    



Measured memory_bytes: 64132
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<iomanip>
#include<math.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;
#define INF 1000000000000000LL

int main(){
    ll N; cin >> N;
    ll a[N+1];
    ll node = 0;
    rep(i, N+1){
        cin >> a[i];
    }
    ll c[N+2];
    c[0] = 1;
    
    for(int i=0; i<N+1; i++){
        c[i+1] = min(2LL*(c[i]-a[i]), INF);
        // cout << a[i] << endl;
        // cout << "c[" << i << "] = " << c[i] << endl;
        if(c[i+1] < 0){
            cout << -1 << endl;
            return 0;
        }
    }

    node += a[N];
    ll now = a[N];
    
    // cout << "now "<< now << endl;
    for(int i=N-1; i>-1; i--){
        now += a[i];
        if(now < c[i]){
            node += now;
        }else{
            node += c[i];
        }
        // cout << "now "<< now << endl;
    }
    cout << node << endl;
}


Measured memory_bytes: 5164
using System;

public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            string[] s = line.Trim().Split(',');
            var gno = s[0];
            var w = double.Parse(s[1]);
            var h = double.Parse(s[2]);
            var bmi = w / (h * h);
            if (bmi >= 25) Console.WriteLine(gno);
        }
    }
}

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

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

int main(){
  long long int a,b;
  cin >> a >> b;
  long long int k=a*b;
  cout << k/gcd(a,b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int a, b;
  cin >> a >> b;
  
  if(a > 12)
    cout << b << endl;
  if((5 < a) && (a < 13))
    cout << b / 2 << endl;
  if(a < 6)
    cout << 0 << endl;
}
  
    
    

Measured memory_bytes: 256
#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 whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    int ans = 0, locA, locZ;
    bool fdA = 0;
    REP(i, s.size()){
        if(fdA == 0 and s[i] == 'A'){
            locA = i;
            fdA = 1;
        }
        if(s[i] == 'Z') locZ = i;
    }
    cout << locZ - locA + 1 << endl;    
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main (void) {
    bool judge = false;
    int count = 0, n, a, b;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &a, &b);
        if (a == b) count++;
        else count = 0;
        if (count >= 3) judge = true;
    }
    if (judge) printf("Yes\n");
    else printf("No\n");

    return 0;
}

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

public class Main {

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



	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long a[] = new long[n];
		for(int i=0; i<n; i++) {
			a[i]=sc.nextLong();
		}
		Arrays.sort(a);
		long h=0;
		long w=0;
		for(int i=n-2; i>=0; i--) {
			if(a[i+1] == a[i] && h==0) {
				h=a[i+1];
				i--;
			}
			else if(a[i+1] == a[i] && w==0) {
				w=a[i+1];
				i--;
			}
			if(h>0 && w>0) {
				break;
			}
		}
		System.out.println(h*w);
		sc.close();
	}

}


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

//#define for(i,n) for(int i=1;i<=n;i++)
//#define czyt for(i,n) cin>>a[i];


using namespace std;

const int nax=1e5+5;
int a[nax];
int n;

int main()
{
    cin>>n; int t; cin>>t;
    for(int i=1;i<=n;i++) cin>>a[i];
    int naj=0;
    int cnt=0;
    int dif=0;
    for(int i=n;i>=1;i--)
    {
        if(a[i]>naj)
        {
            naj=a[i];
            continue;
        }
        else
        {
            int akt=naj-a[i];
            if(akt==dif)
            {
                cnt++;
            }
            else if(akt>dif)
            {
                cnt=1;
                dif=akt;
            }
            naj=max(naj,a[i]);
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCollectingBallsEasyVersion solver = new BCollectingBallsEasyVersion();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCollectingBallsEasyVersion {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] x = new int[n];
            for (int i = 0; i < n; i++) x[i] = in.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
                int mn = Math.min(x[i], k - x[i]);
                sum += 2 * mn;
            }
            out.println(sum);
        }

    }
}



Measured memory_bytes: 21972
#include<iostream>

using namespace std;

int int_sort(const void * a, const void * b){
  if(*(int *)a < *(int *)b ) {
    return -1;
  }else if(*(int *)a == *(int *)b ){
    return 0;
  }
  return 1;
}

int main(){
	int N, A[100000];
	int ans = 0;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	qsort((void *)A , N , sizeof(A[0]), int_sort);
	int buff = 1;
	int num = 0;
	for(int i = 0; i < N; i++){
		if(buff == A[i]){
			num = (num + 1) % 2;
			if(num == 1){
				ans++;
			}else{
				ans--;
			}
		}else{
			buff = A[i];
			ans++;
			num = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector> 
using namespace std;

int main() {
	vector<int> vc;
	int n;
	int l;
	scanf("%d", &n);
	scanf("%d", &l);
	
	for (int i = 0; i < n; i++) {
		vc.push_back(l + i);
	}

	int sum = 0;
	int min = abs(vc[0]);
	for (int i = 0; i < n; i++) {
		if (abs(min) > abs(vc[i])) {
			min = vc[i];
		}
		sum += vc[i];
	}
	printf("%d", sum - min);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
signed main(){
  int a,b;
  while(scanf("%d%d",&a,&b),a||b){
      for(int c=0;c<a;c++){
	  for(int d=0;d<b;d++){
	    if(c==0||a-1==c||d==0||b-1==d)  printf("#");
	    else printf(".");
	      }
	      printf("\n");
	  }
	  printf("\n");
      }
}

Measured memory_bytes: 3072
#include <cstdint>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); i++)

using namespace std;
using pii = pair<int, int>;

const int N = 100000;
pii mem[N];
vector<int> tree[N + 1];
int max_color = 0;

void dfs(pii now) {
  int next_color = 1;
  for (auto child : tree[now.first]) {
    if (next_color == now.second)
      next_color += 1;
    max_color = max(max_color, next_color);
    mem[child].second = next_color;
    dfs(mem[child]);
    next_color += 1;
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b)
      swap(a, b);
    mem[i] = {b, 0};
    tree[a].push_back(i);
  }
  dfs({1, 0});
  printf("%d\n", max_color);
  for (int i = 0; i < n - 1; i++) {
    printf("%d\n", mem[i].second);
  }
}


Measured memory_bytes: 7680
#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main() {
    int N, K;
    string S;

    cin >> N >> S >> K;

    string s = S.substr(K - 1, 1);

    for (int i = 0; i < N; ++i) {
        if (S.substr(i, 1) != s) {
            S.replace(i, 1, "*");
        }
    }

    cout << S << endl;

    return 0;
}



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

int main() {
  int a, b ,c ,d;
  cin >> a >> b >> c >> d;
  
  int REC = a * b;
  int REC2 = c * d;
  
  if (REC > REC2){
    cout << REC << endl;    
  }
  else{
    cout << REC2 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
  int i,a[200002],t,n,sum;
  scanf ("%d%d",&n,&t);
  for (i=0;i<n;i++){
  scanf ("%d",&a[i]);
  }
  for (i=0;i<n-1;i++){
  if (a[i+1]-a[i]>t){
  sum=sum+t;
  }
    else{
    sum=sum+a[i+1]-a[i];
    }
  }
  printf ("%d",sum+t);
return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a>=k){
    cout<<k<<endl;
  }else if(a+b>=k){
    cout<<a<<endl;
  }else{
    cout<<a-(k-a-b)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fo(i, x, y)   for (__typeof(x) i = x; i < y; ++i)
#define fr(i, x, y)   for (__typeof(x) i = x; i > y; i--)
#define vdp(n,x) vector<vector<ll>>dp(n+1,vector<ll>(x+1));
const ll mod=1000000007;
const ll AM=2e5+5;
using namespace std;
int main()
{
    fast;
    ll n,k; cin>>n>>k;
    ll a[n+1];
    fo(i,1,n+1) cin>>a[i];
    vector<ll>dp(n+1,1e9);
    dp[1]=0;
    fo(i,2,n+1)
    {
    	fr(j,i-1,max((ll)0,i-k-1))
    	{
    		dp[i]=min(dp[j]+abs(a[i]-a[j]),dp[i]);
    	}
    }
    //fo(i,1,n+1) cout<<dp[i]<<" ";
    cout<<dp[n];
}

Measured memory_bytes: 1792
N=parse(readline())
x=Int[]
y=Int[]
for s=readlines()
  X,Y=map(x->parse(Int,x),split(s))
  push!(x,X)
  push!(y,Y)
end
sum=0
for i=1:N,j=1:N
  sum+=sqrt((x[i]-x[j])^2+(y[i]-y[j])^2)
end
println(sum/N)

Measured memory_bytes: 168232
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    BX = 0
    XA = 0
    BA = 0
    AB = 0
    for _ in range(N):
        S = readline().decode('utf-8').strip()
        if S[0]=='B' and S[-1]=='A':
            BA += 1
        elif S[0]=='B':
            BX += 1
        elif S[-1] == 'A':
            XA += 1
        AB += S.count('AB')
    if BA==0:
        ans = AB + min(BX,XA)
    else:
        if XA+BX>0:
            ans = AB + BA + min(BX, XA)
        else:
            ans = AB + BA-1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
#define vi vector <int>
#define si set <int>
#define mii map <int,int>
#define pii pair <int,int>
#define endl "\n"
#define ZERO 0ll
#define FOR(P,Q) for(int P=0;P<(Q);P++)
#define FORR(P,Q) for(int P=1;P<=(Q);P++)
#define rep(P,R,Q) for(int P=(R);P<=(Q);P++)
#define repb(P,R,Q) for(int P=(R);P>=(Q);P--)
#define pb push_back
#define eb emplace_back
#define bug(j) cerr<<j<<" "
#define NL cerr<<endl
#define D1(arr,a) rep(i,1,a) bug(arr[i]) 
typedef long long ll;
typedef long double ld;
using namespace std;


    
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("error.txt","w",stderr);
	#endif
	//change ll to int before using string builtin operations
	int tces=1;
	//cin>>tces;
	while(tces--){
		int n,k;
		cin>>n>>k;
		mii m;
		FORR(i,n){
			m[i]=0;
		}
		while(k--){
			int a;
			cin>>a;
			while(a--){
				int r;
				cin>>r;
				m[r]++;
			}
		}
		int ans=0;
		FORR(i,n){
			if(m[i]==0)
				ans++;
		}
		cout<<ans;
	}
	
return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i = (l); i < (r); ++i)
using ll = long long;
template<class T,class U>using umap = unordered_map<T,U>;
template<class T>using uset = unordered_set<T>;
template<class T>using max_heap = priority_queue<T>;
template<class T>using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class T>inline bool Chmax(T&a, const T&b){
  if(b > a){    a = b;    return true;  }
  return false;
}
template<class T>inline bool Chmin(T&a, const T&b){
  if(a > b){    a = b;    return true;  }
  return false;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k,ans(0);cin >> n >> k;
  rep(i,0,n){
    int x; cin >> x;
    if(x >= k)ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def calc(i, a, b)
    return a + b*10 + $s[i] if i == $n
    calc(i+1, a + b*10 + $s[i], 0) + calc(i+1, a, b*10 + $s[i])
end

$s = gets.chomp.chars.map(&:to_i)
$n = $s.size - 1
puts calc(0, 0, 0)

Measured memory_bytes: 1788
N,A,B = map(int,input().split())
MOD = 10**9+7
p = pow(2,N,MOD)

MAXN = B+3
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD

def comb(n,r):
    ret = 1
    for i in range(r):
        ret *= n-i
        ret *= inv[i+1]
        ret %= MOD
    return ret
ans = p-1 - comb(N,A) - comb(N,B)
ans %= MOD
print(ans)

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

int main() {
	int sl, tl, match = 0, ans;
	string s, t;
	cin >> s >> t;
	sl = s.length();
	tl = t.length();
	for (int i = 0; i <= sl - tl; i++) {
		string a = s.substr(i, tl);
		int count = 0;
		for (int j = 0; j < tl; j++) {
			if (t[j] == a[j]) {
				count++;
				if (count > match) {
					match = count;
				}
			}
		}
		ans = tl - match;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
    int n;
    scanf("%d",&n);
    int ans=n;
    int e[n],w[n];
    char s[n] ;
    scanf("%s",s) ;
    
    if (s[0]=='W'){
        w[0]=1;
    } else {
        w[0]=0;
    }
    for (int i=1; i<n; i++){
        if (s[i]=='W'){
            w[i]=w[i-1]+1;
        } else {
            w[i]=w[i-1];
        }
    }
    
    if(s[n-1]=='E'){
        e[n-1]=1;
    } else {
        e[n-1]=0;
    }
    for  (int i=n-2; i>=0; i--){
        if (s[i]=='E'){
            e[i]=e[i+1]+1;
        } else {
            e[i]=e[i+1];
        }
    }
    
    int tmp ;
    for (int i=0; i<n; i++){
        if (i==0){
            tmp = e[1] ;
            
        } else if (i==n-1){
            tmp = w[n-2] ;
            
        } else {
            tmp=e[i+1]+w[i-1];
        }
        if (ans>tmp){
            ans=tmp ;
        }
    }
    printf ("%d\n",ans);
    return 0 ;
}

Measured memory_bytes: 2816
MOD = 1000000007
def solve(n, m, a):
    a = set(a)
    dp = [0] * (n+1)
    dp[n] = 1
    for i in range(n-1, -1, -1):
        for d in range(1, 3):
            j = i + d
            if (j <= n) and (not j in a):
                dp[i] = (dp[i] + dp[j]) % MOD
    return dp[0]

n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
print(solve(n, m, a))

Measured memory_bytes: 13192
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yay!")
    else:print(":(")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
#n = ip()                                     #入力整数1つ
#n,q= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#b = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
a=[ip() for i in range(5)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
n = ip()
for i in range(5):
    for k in range(5):
        if a[k]-a[i] > n: j(0)
j(1)

Measured memory_bytes: 13904
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> L(M), R(M);
	vector<ll> C(M);
	vector<vector<int>> ls(N), rs(N);
	for(int i=0; i<M; i++){
		cin >> L[i] >> R[i] >> C[i];
		L[i]--; R[i]--;
		ls[L[i]].push_back(i);
		rs[R[i]].push_back(i);
	}

	vector<vector<pair<int, ll>>> graph(2*M+N);
	for(int i=0; i<M; i++){
		graph[i].push_back({i+M, C[i]});
		graph[i].push_back({2*M+L[i], 0});
		graph[2*M+L[i]].push_back({i, 0});
		graph[i+M].push_back({2*M+R[i], 0});
		graph[2*M+R[i]].push_back({i+M, 0});
	}
	for(int i=0; i<N-1; i++){
		graph[2*M+i+1].push_back({2*M+i, 0});
	}

	for(int i=0; i<2*M+N; i++){
		for(auto p: graph[i]){
			debug(i, p.first, p.second);
		}
	}

	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
	que.push({0, 2*M});
	vector<ll> dist(2*M+N, 1e16);
	dist[2*M] = 0;
	while(!que.empty()){
		auto p = que.top();
		que.pop();
		ll d = p.first;
		int u = p.second;
		if(dist[u]<d) continue;
		dist[u] = d;
		for(auto q: graph[u]){
			ll v = q.first;
			ll c = q.second;
			if(dist[v]>dist[u]+c){
				dist[v] = dist[u]+c;
				que.push({dist[v], v});
				//debug(u, d);
			}
		}
	}

	if(dist[2*M+N-1] < 1e16){
		cout << dist[2*M+N-1] << endl;
	} else {
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 41472
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>

using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926535;

ll fast(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	if (k == 1) {
		return n;
	}
	if (k % 2 == 0) {
		ll tmp = fast(n, k / 2);
		return tmp * tmp % MOD;
	}
	else {
		ll tmp = fast(n, k / 2);
		tmp = tmp * tmp % MOD;
		return n * tmp % MOD;
	}
}

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

	bool ok = false;
	for (ll i = A; i <= B; i++)
	{
		if (i % K == 0)
			ok = true;
	}

	if (ok) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}
}

Measured memory_bytes: 3676
#include <iostream>
#include <string>

using namespace std;

int main(){
  string S;
  int flg=0;
  cin >> S;
  for (int i = 0; i < S.size() - 1; i++){
    for (int j = i+1; j < S.size(); j++){
      if (S[i]==S[j]){
        flg = 1;
      }
    }
  }
  if (flg==1){
    printf("no\n");
  }else{
    printf("yes\n");
  }
  
  
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
#define ll long long int
using namespace std;
#define MAX 100005


int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll aa=b*d;
	ll bb=a*c;
	ll cc=a*d;
	ll dd=b*c;
	cout<<max(aa,max(bb,max(cc,dd)))<<endl;
}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX_N 1000

int n, a[MAX_N];

void solve() {
    reverse(a, a+n);
    for(int i = 0; i < n-1; i++) cout << a[i] << " ";
    cout << a[n-1] << endl;
    return;
}

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


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;
template <class T>
T gcd(T a, T b) {
    if (b > a) T tmp = a, a = b, b = tmp;
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

//最小公倍数を求めるO(1)
template <class T>
T lcm(T a, T b) {
    if (a == 0 || b == 0)
        return 0;
    else {
        T g = gcd(a, b);
        return g * (a / g) * (b / g);
    }
}
// template <class T>
// T gcd_n(const vector<T> &V) {
//     T tmp = V[0];
//     for (auto v : V)
//         tmp = gcd(tmp, v);
//     return tmp;
// }
// // n要素の最小公約数を求める
// template <class T>
// T lcm_n(const vector<T> &V) {
//     T gcd_ = gcd_n(V);
//     T tmp  = V[0];
//     for (auto v : V)
//         tmp = lcm(tmp, v);
//     return tmp;
// }

lint num(lint x) {
    lint c = 0;
    while (x % 2 == 0) {
        c++;
        x /= 2;
    }
    return c;
}

int main() {
    lint n, m;
    cin >> n >> m;
    vector<lint> a(n, 0);
    rep(i, n) {
        cin >> a[i];
        a[i] /= 2;
    }

    lint num_of_fact_2 = num(a[0]);
    bool ok            = true;
    for (auto x : a) {
        if (num(x) == num_of_fact_2) {
            continue;
        } else {
            ok = false;
            break;
        }
    }

    if (not(ok)) {
        cout << 0 << endl;
        return 0;
    }
    lint llcm = a[0];
    for (auto x : a) {
        llcm = lcm(x, llcm);
        if (llcm > m) {
            cout << 0 << endl;
            return 0;
        }
    }
    dd(llcm, m);
    lint s = (m / llcm);
    if (s % 2 == 0) {
        s /= 2;
    } else {
        s = (s + 1) / 2;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
c1 = []
c2 = []
c3 = []
for i in range(m):
  sc = list(map(int,input().split()))
  if sc[0] == 1:
    c1.append(sc[1])
  elif sc[0] == 2:
    c2.append(sc[1])
  else:
    c3.append(sc[1])

if len(set(c1)) <= 1 and len(set(c2)) <= 1 and len(set(c3)) <= 1:
  if 0 in list(set(c1)):
    if n == 1 and len(set(c1)) == 1 and len(set(c2)) == 0 and len(set(c3)) == 0:
      print('0')
      exit()
    else:
      print('-1')
      exit()
  elif not c1 and not c2 and not c3:
    if n == 1:
      print('0')
      exit()
    elif n == 2:
      print('10')
      exit()
    else:
      print('100')
      exit()
  else:
    if list(set(c1)):
      ans_c1 = list(set(c1))[0]
    else:
      ans_c1 = 1
    if list(set(c2)):
      ans_c2 = list(set(c2))[0]
    else:
      ans_c2 = 0
    if list(set(c3)):
      ans_c3 = list(set(c3))[0]
    else:
      ans_c3 = 0
else:
  print('-1')
  exit()

if n == 1:
  print(ans_c1)
elif n == 2:
  print(ans_c1*10 + ans_c2)
else:
  print(ans_c1*100 + ans_c2*10 + ans_c3)

Measured memory_bytes: 9160
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val k = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    a.sortDescending()
    println(a.take(k).sum())
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 33868
import java.util.Scanner;

public class Main {

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

		String[] abc = sc.nextLine().split(" ");
		int a = Integer.parseInt(abc[0]);
		int b = Integer.parseInt(abc[1]);
		int c = Integer.parseInt(abc[2]);

		IntPointer pa = new IntPointer(a);
		IntPointer pb = new IntPointer(b);
		IntPointer pc = new IntPointer(c);

		sorting3(pa, pb, pc);

		System.out.println(pa.ast + " " + pb.ast + " " + pc.ast);
	}

	static void sorting3(IntPointer pa, IntPointer pb, IntPointer pc) {
		if (pa.ast > pb.ast) {
			int temp = pa.ast;
			pa.ast = pb.ast;
			pb.ast = temp;
		}
		if (pb.ast > pc.ast) {
			int temp = pb.ast;
			pb.ast = pc.ast;
			pc.ast = temp;
		}
		if (pa.ast > pb.ast) {
			int temp = pa.ast;
			pa.ast = pb.ast;
			pb.ast = temp;
		}

	}
}

class IntPointer {
	int ast; //value
	IntPointer(int n) {
		this.ast = n;
	}
}

Measured memory_bytes: 26144
// diverta2019_2_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 30)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    vector<int> A(N);
    REP(i, N) cin >> A[i];
    sort(ALL(A));

    int sm = accumulate(ALL(A), 0);

    int ans = -INF;
    int split_idx = -1;
    int tmp_sm = 0;
    REP(i, N-1){
        tmp_sm += A[i];
        if (sm - 2 * tmp_sm >= ans) {
            ans = sm - 2 * tmp_sm;
            split_idx = i;
        }
    }

    print(ans);

    int x = A[0];
    REPN(i, split_idx+1, N-1){
        print(x, A[i]);
        x -= A[i];
    }

    print(A[N-1], x);
    x = A[N-1] - x;

    REPN(i, 1, split_idx+1){
        print(x, A[i]);
        x -= A[i];
    }


    return 0;
}


Measured memory_bytes: 2304