akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int N, i, ans, tmp;
  vector<int> B;
  // get input ---------------------------
  cin >> N;
  for(i = 0; i < N - 1; i++) {
    cin >> tmp;
    B.push_back(tmp);
  }
  // calc ---------------------------------
  ans = B[N-2];
  for(i = N - 2; i > 0; i--) {
    if(B[i] > B[i-1]) {
      ans += B[i-1];
    } else {
      ans += B[i];
    }
  }
  ans += B[0];
  // dips answer -------------------------
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7ll;


struct eg{int to;int cost;};
int n;
vector<eg> e[100005];
int g[100005];
int c[100005];

void dfs(int f,int w){
	if(c[f]==1) return;
	c[f]=1;
	for(int i=0; i<e[f].size(); i++){
		int to=e[f][i].to;
		int ct=e[f][i].cost;
		if(ct%2==0){
			g[to]=w%2;
			dfs(to,g[to]);
		}else{
			g[to]=(w+1)%2;
			dfs(to,g[to]);
		}
	}
	return;
}

int main(){

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

cin>>n;

for(int i=0; i<n-1; i++){
	int u,v,w;
	cin>>u>>v>>w;
	eg in1={v,w};
	eg in2={u,w};
	e[u].push_back(in1);
	e[v].push_back(in2);
}

dfs(1,1); g[1]=1;
for(int i=1; i<=n; i++){
	cout<<g[i]<<endl;
}

}



Measured memory_bytes: 8704
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <fstream>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

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

ll factorial(ll n) {//階乗
	ll ret = 1;
	rep(i, 1, n + 1)
		ret = (ret *i) % MODU;

	return ret;
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
ll ncr(ll n, ll r) {
	return divmod(factorial(n), (factorial(r) * (factorial(n - r))) % MODU, MODU);
}


signed main() {
	int n;
	string s, t;
	cin >> n >> s >> t;

	REP(i, n) {
		cout << s[i] << t[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

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

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define deb(x) cout<<#x<<" "<<x<<"\n"
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}
ll pr[1000001];
int main()
{
	checkpoint1();
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	Clear(pr);
	bool pc=1,sc=1;
	ll op=a[0];
	for(ll i=0;i<n;i++)
	{
		ll k=a[i];
		for(ll j=2;j*j<=k;j++)
		{
			if(k%j==0)
			{
				pr[j]++;
				if(pr[j]>1)
				{
					pc=0;
					break;
				}
				while(k%j==0)
				{
					k/=j;
				}
			}
		}
		if(k>1){
			pr[k]++;
			if(pr[k]>1)
				pc=0;
		}
		if(!pc)
			break;
	}
	if(pc){
		cout<<"pairwise coprime";
		return 0;
	}
	for(ll i=0;i<n;i++)
		op=__gcd(a[i],op);
	if(op==1)
		cout<<"setwise coprime";
	else
		cout<<"not coprime";
	return 0;
}

Measured memory_bytes: 19272
C=[]
for i in range (3):
	C.append(list(map(int,input().split())))
count=0
if C[0][0]+C[2][2]!=C[2][0]+C[0][2]:
	count+=1
D=[]
E=[]
F=[]
for i in range (3):
	D.append(C[i][0]-C[i][1])
	E.append(C[i][1]-C[i][2])
	F.append(C[i][2]-C[i][0])
if len(set(D))!=1 or len(set(E))!=1 or len(set(F))!=1:
	count+=1
G=[]
H=[]
I=[]
for i in range (3):
	G.append(C[0][i]-C[1][i])
	H.append(C[1][i]-C[2][i])
	I.append(C[2][i]-C[0][i])
if len(set(G))!=1 or len(set(H))!=1 or len(set(I))!=1:
	count+=1	
if count==0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
p=lambda n:2**(n+1)-1
a=lambda n:2**(n+2)-3
def f(n,x):
    if n==0:
        return 0 if x<=0 else 1
    if x>1+a(n-1):
        return p(n-1)+1+f(n-1,x-2-a(n-1))
    return f(n-1,x-1)
n,x=map(int,input().split())
print(f(n,x))

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

int main() {
  int A;
  int B;
  cin >> A >> B;
  
  int x=0;
 for(int i=0; ; i++){
   if((A-1)*i+1>B-1){
     break;
   }
     x++;
 } 
  cout << x << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static class Trie {
		public class Node {
			HashMap<Character, Node> child;
			int[] count;
			Node parent;

			public Node() {
				child = new HashMap<>();
				count = new int[26];
			}
			public Node(Node parent) {
				child = new HashMap<>();
				count = new int[26];
				this.parent = parent;
			}
		}
		
		Node root;
		public Trie() {
			root = new Node();
		}
		
		void setString(char[] c) {
			Node cur = root;
			for(int i=c.length-1; i>=0; i--) {
				if(cur.child.get(c[i])==null) {
					cur.child.put(c[i], new Node(cur));
				}
				cur = cur.child.get(c[i]);
			}
			int bit = 0;
			int index=0;
			while(cur!=null) {
				for(int i=0; i<26; i++)
					if(((1<<i)&bit)!=0)
						cur.count[i]++;
				if(index<c.length)
					bit |= 1<<(c[index]-'a');
				index++;
				cur = cur.parent;
			}
		}
		
		int getCount(char[] c) {
			Node cur = root;
			for(int i=c.length-1; i>=1; i--) {
				cur = cur.child.get(c[i]);
			}
			return cur.count[c[0]-'a'];
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		char[][] s = new char[N][];
		Trie trie = new Trie();
		for(int i=0; i<N; i++) {
			s[i] = sc.next().toCharArray();
			trie.setString(s[i]);
		}
		
		long ans = 0;
		for(int i=0; i<N; i++)
			ans += trie.getCount(s[i]);
		
		System.out.println(ans - N);
		sc.close();
	}
}


Measured memory_bytes: 412308
import java.util.Scanner;
public class Main {

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

		int c=0;
		for(int i=0;i<n;i++) {
			int b=sc.nextInt();
			if(a<=b)
				c++;
		}
		System.out.println(c);

	}

}


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

using namespace std;

typedef long long ll;

int main()
{
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll hist[100001] = {0};
    ll summ = 0;
    for (int i = 0; i < n; i ++) {
      int t;
      cin >> t;
      summ += t;
      hist[t] ++;
    }
    ll q;
    cin >> q;
    for (int i = 0; i < q; i ++) {
      ll b, c;
      cin >> b >> c;
      if (b != c){
        summ -= hist[b] * b;
        summ += hist[b] * c;
        hist[c] += hist[b];
        hist[b] = 0;
      }
      cout << summ << endl;
    }

    return 0;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

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

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

int dp[100001][3];

signed main(){
    int N; cin >> N;
    vector<array<int, 3> > happy( N );
    REP( i, N ){
        REP( j, 3 ){
            cin >> happy[i][j];
        }
    }

    REP( i, 3 ){
        dp[0][i] = happy[0][i];
    }

    FOR( i, 1, N ){
        REP( j, 3 ){
            if( j == 0 ) chmax( dp[i][0], happy[i][0] + max( dp[i - 1][1], dp[i - 1][2] ) );
            if( j == 1 ) chmax( dp[i][1], happy[i][1] + max( dp[i - 1][0], dp[i - 1][2] ) );
            if( j == 2 ) chmax( dp[i][2], happy[i][2] + max( dp[i - 1][0], dp[i - 1][1] ) );
        }
    }

    cout << max( { dp[N - 1][0], dp[N - 1][1], dp[N - 1][2] } ) << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

const int mod=100000;

signed main(){
  int w,h;
  while(cin>>w>>h,w){

    int dp[101][101][2][2]={};
  //  rep(j,2)dp[0][0][0][j]=1;
    dp[0][1][0][1]=1;
    dp[1][0][0][0]=1;
    rep(i,h){
      rep(j,w){
        (dp[i+1][j][0][0]+=dp[i][j][1][0])%=mod;
        (dp[i][j+1][0][1]+=dp[i][j][1][1])%=mod;
        (dp[i+1][j][1][0]+=dp[i][j][0][1])%=mod;
        (dp[i][j+1][0][1]+=dp[i][j][0][1])%=mod;
        (dp[i+1][j][0][0]+=dp[i][j][0][0])%=mod;
        (dp[i][j+1][1][1]+=dp[i][j][0][0])%=mod;

      }
    }

    int ans=0;
    rep(i,2)rep(j,2){
      ans+=dp[h-1][w-1][i][j];
      ans%=mod;
    }
    cout<<ans<<endl;

  }

  return 0;
}



Measured memory_bytes: 3400
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if n >= m:
    print(0)
else:
    x_distance = [x2 - x1 for x1, x2 in zip(x, x[1:])]
    x_distance.sort()
    print(sum(x_distance[:m-n]))


Measured memory_bytes: 13968
def search(code):
    for i in range(len(code)):
        if code[i] == 0:
            return i
    else:
        return -1

s = raw_input()

code = [0 for i in range(26)]

for i in range(len(s)):
    key = ord(s[i]) - 97
    code[key] += 1

rt = search(code)

if rt >= 0:
    print chr(rt + 97)
else:
    print "None"

Measured memory_bytes: 5892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int K = Integer.parseInt(in.nextLine());
		int oddNum, evenNum;
		if (K % 2 == 0) {
			oddNum = K / 2;
			evenNum = K / 2;
		} else {
			oddNum = (K + 1) / 2;
			evenNum = oddNum - 1;
		}
		System.out.println(oddNum * evenNum);
		in.close();
	}
}

Measured memory_bytes: 23380
// 2018/01/23 未完成

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
typedef long long int ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define FOREQ(i, a, b) for (int i = (a); i <= (b); i++)
#define REPEQ(i, n) FOREQ(i, 0, n)

int main()
{
	int A, B;
	string S;
	cin >> A >> B;
	cin >> S;

	bool flag = true;

	if (S.size() != A + B + 1) // 文字列長判定
	{
		flag = false;
	}
	if (S[A] != '-') // ハイフンが規定の位置にあるか
	{
		flag = false;
	}
	int count = 0;
	REP(i, A + B + 1) // ハイフンの個数を数える
	{
		if (S[i] == '-')
		{
			count++;
		}
	}
	if (count != 1)
	{
		flag = false;
	}

	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int n;
long long pos[100005],a,b,ans=0;
int main()
{
	scanf("%d%lld%lld",&n,&a,&b);
	for(int i=1;i<=n;i++)
		scanf("%lld",&pos[i]);
	for(int i=2;i<=n;i++)
	{
		ans+=min((pos[i]-pos[i-1])*a,b);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    s = int(input())

    if s < 1200:
        print("ABC")
    elif 1200 <= s < 2800:
        print("ARC")
    else:
        print("AGC")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N, D = gets.chomp.split.map(&:to_i)
X = []
N.times do
  X << gets.chomp.split.map(&:to_i)
end

r = 0
(0.upto(N-1)).each do |i1|
  (i1 + 1).upto(N-1).each do |i2|
    x1 = X[i1]
    x2 = X[i2]
    dis = x1.zip(x2).map { |a, b| (a - b) ** 2 }.inject(&:+)
    # p [x1, x2]
    # p Math.sqrt(dis)
    # p (Math.sqrt(dis) % 1) == 0
    r += 1 if ((Math.sqrt(dis) % 1) == 0)
  end
end

p r

Measured memory_bytes: 3836
N = int(input())
A = list(map( int, input().split()) )
from collections import defaultdict
d = defaultdict(int)

lst = []
i = 0
while i <= N-2:
  a = A[i]
  cnt = 1
  for j in range(i+1, N):
    if a == A[j]:
      cnt += 1
    else:
      break
  lst.append(cnt)
  #print(i,j)
  i = j
  


# print(lst)

ans = 0
def kf(x):
  if x  == 1:
    return 0
  elif x == 0:
    return 0
  elif x % 2 == 1:
    return x//2
  elif x % 2 == 0:
    return x//2
for k in lst:
  ans += kf( k )
print(ans)

Measured memory_bytes: 3316
N = gets.to_i
F = []
P = []
answer = []
b = []
for i in 0..N-1
    F[i] = gets.strip.split.map(&:to_i)
end

for i in 0..N-1
    P[i] = gets.strip.split.map(&:to_i)
end

a = []
i = 0

[0, 1].repeated_permutation(10) do |bits|
    a[i] = bits 
    i += 1
end

for i in 1..1023

    answer[i-1] = 0

    for j in 0..N-1

        b[j] = 0

        for k in 0..9


            if a[i][k] == 1 && F[j][k] == 1

                b[j] += 1

            end

        end

    end

    for j in 0..N-1

        answer[i-1] += P[j][b[j]]

    end

end

puts answer.max

                



        

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  deque<ll> b;
  bool isHead = false;
  for(int i=0;i<n;i++){
    if(isHead) b.push_front(a[i]);
    else b.push_back(a[i]);
    isHead = !isHead;
  }

  if(isHead){
    for(auto itr=b.end()-1;itr!=b.begin()-1;itr--){
      cout << *itr;
      if(itr == b.begin()) cout << endl;
      else cout << " ";
    }
  }else{
    for(auto itr=b.begin();itr!=b.end();itr++){
      cout << *itr;
      if(itr == b.end()-1) cout << endl;
      else cout << " ";
    }
  }
}


Measured memory_bytes: 5376
import math
N,A,B = map(int,input().split())
V = list(map(int,input().split()))
V.sort()
S = V[-A:]
avgmax = sum(S) / A
print(avgmax)

Vs = V.count(min(S))
Ss = S.count(min(S))
if min(S) != max(S):
	C = math.factorial(Vs) // (math.factorial(Vs -Ss) * math.factorial(Ss))
	print(C)
else:
	i = A
	C = 0
	while i <= B and V[-i] == min(S):
		c = math.factorial(Vs) // (math.factorial(Vs -i) * math.factorial(i))
		C = C + c
		i = i + 1
	print(C)

Measured memory_bytes: 3064
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LS()
    if a[-1] == b[0] and b[-1] == c[0]:
        print("YES")
    else:
        print("NO")
    return

#B
def B():
    a, b, c = LI()
    for i in range(1, b):
        if a * i % b == c:
            print("YES")
            return
    print("NO")
    return

#C
def C():
    _, T = LI()
    t = LI()
    ans = 0
    now = t[0]
    for i in t[1:]:
        if now + T <= i:
            ans += T
        else:
            ans += i - now
        now = i
    print(ans + T)

    return

#D
def D():
    n, W = LI()
    wv = LIR(n)
    wv.sort()
    dp = [-inf] * ((3 * n + 1) * n + 1)
    dp[0] = 0
    minw =  wv[0][0]
    if minw <= 3 * n:
        for w, v in wv:
            for i in range((3 * n + 1) * n, w - 1, -1):
                dp[i] = max(dp[i - w] + v, dp[i])
        print(max(dp[:W + 1]))
    else:
        for w, v in wv:
            w -= minw
            for i in range(min(W // minw, n - 1), 0, -1):
                for k in range(3 * n, w - 1, -1):
                    dp[(3 * n + 1) * i + k] = max(dp[(3 * n + 1) * (i - 1) + k - w] + v, dp[(3 * n + 1) * i + k])
        print(max(dp[:W // minw * (3 * n + 1) + W % minw + 1]))
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 47068
import copy

def calc(wk, kouho, G):
    ans = 0
    for i in range(D):
        if kouho[i] == 1:
            G -= wk[i][1] + 100*(i+1)*wk[i][0]
            ans += wk[i][0]
            wk[i][0] = 0
    if G <= 0:
        return ans
    solve = D-1
    while G > 0 and solve >= 0:
        if wk[solve][0] >= 2: #2問以上問題が残っていれば
            wk[solve][0] -= 1 #その問題を1つ解き
            G -= 100*(solve+1) #得点を加算する
            ans += 1
        if wk[solve][0] <= 1: #残りが一問or既に問題をコンプしていたら
            solve -= 1 #解く問題を変える
    return ans if G <= 0 else 10000

D, G = map(int,input().split())
#100-100*Dの問題をコンプリートするかどうか
zenbu = 2**D
prob = []
min = 10000
for i in range(D):
    prob.append(list(map(int,input().split())))
for i in range(zenbu):
    work = copy.deepcopy(prob)
    kouho = []
    key = i
    for j in range(D):
        kouho.append(key % 2)
        key //= 2
    res = calc(work, kouho, G)
    if res < min:
        min = res
print(str(min))

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	if (A <= 9 && B <= 9)
	{
		cout << A * B << endl;
	}
	else
	{
		cout << -1 << endl;
	}

	return 0;
}


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

int main()
{
    unsigned int n;
    std::cin >> n;
    std::vector<unsigned int> l(n * 2);
    for(auto &i : l)
        std::cin >> i;
    std::sort(l.begin(), l.end());
    std::size_t sum = 0;
    for(std::size_t i = 0; i < n; i++)
        sum += l[i * 2];
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char c;
	int ar[27]={0},i;
	while(~scanf("%c", &c))
		ar[c-97]++;
	for(i=0; i<26; i++)
		if(ar[i]%2)
			break;
	if(i==26) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int V = scanner.nextInt();
        int E = scanner.nextInt();
        scanner.nextLine();

        FordFulkerson fordFulkerson = new FordFulkerson();
        for (int i = 0; i < E; i++) {
            int[] e = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            fordFulkerson.addEdge(e[0], e[1], e[2]);
        }

        System.out.println(fordFulkerson.run(0, V - 1));
    }

}

class FordFulkerson {
    Map<Integer, Map<Integer, Integer>> edges;

    public FordFulkerson() {
        edges = new HashMap<>();
    }

    public void addEdge(int from, int to, int cost) {
        if (!edges.containsKey(from)) {
            edges.put(from, new HashMap<>());
        }
        edges.get(from).put(to, cost);

        if (!edges.containsKey(to)) {
            edges.put(to, new HashMap<>());
        }
        edges.get(to).put(from, 0);
    }

    public long run(int s, int e) {
        long totalFlow = 0;
        List<Integer> path = findPath(s, e, new HashSet<>());
        while (!path.isEmpty()) {
            int maxFlow = Integer.MAX_VALUE;
            for (int i = 0; i < path.size() - 1; i++) {
                maxFlow = Math.min(maxFlow, edges.get(path.get(i)).get(path.get(i + 1)));
            }
            for (int i = 0; i < path.size() - 1; i++) {
                int curr = edges.get(path.get(i)).get(path.get(i + 1));
                edges.get(path.get(i)).put(path.get(i + 1), curr - maxFlow);
                curr = edges.get(path.get(i + 1)).get(path.get(i));
                edges.get(path.get(i + 1)).put(path.get(i), curr + maxFlow);
            }
            totalFlow = totalFlow + maxFlow;
            path = findPath(s, e, new HashSet<>());
        }
        return totalFlow;
    }

    private List<Integer> findPath(int s, int e, Set<Integer> visited) {
        if (s == e) {
            List<Integer> res = new ArrayList<>();
            res.add(s);
            return res;
        }

        if (visited.add(s)) {
            for (Map.Entry<Integer, Integer> entry : edges.getOrDefault(s, Collections.emptyMap()).entrySet()) {
                int to = entry.getKey();
                int cost = entry.getValue();
                if (cost == 0) {
                    continue;
                }
                List<Integer> res = findPath(to, e, visited);
                if (!res.isEmpty()) {
                    res.add(0, s);
                    return res;
                }
            }
        }
        return Collections.emptyList();
    }

}





Measured memory_bytes: 81692
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a, b, c;
  cin >> a >> b >> c;
  if (4 * a * b < (c - a - b) * (c - a - b) && c - a - b > 0){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

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

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    string s;
    cin >> s;

    Int cnt = 0;
    for (Int i = 0; i < 6; ++i) {
        if (s[i] == '1') {
            cnt ++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3568
h = int(input())
w = int(input())
n = int(input())

hw = max(h,w)

tmp = 0
cnt = 0

if hw == h:
    for i in range(w):
        tmp += h
        cnt += 1
        if tmp >= n:
            print(cnt)
            exit()
else:
    for i in range(h):
        tmp += w
        cnt += 1
        if tmp >= n:
            print(cnt)
            exit()
        


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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int n, a, b;
    int x = 0;
    int y = 0, z = 0;
    cin >> n >> a >> b;
    vector<int> p(n);
    rep(i, n) {
        cin >> p.at(i);
        if (p.at(i) <= a) x++;
        else if (p.at(i) <= b) y++;
        else z++;
    }
    cout << min(x, min(y, z)) << endl;
}

Measured memory_bytes: 3564
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <ostream>
using namespace std;

template <typename T>
struct Edge { int src, dst; T cost;
    Edge(int dst, T cost) : src(-1), dst(dst), cost(cost) { }
    Edge(int src, int dst, T cost) : src(src), dst(dst), cost(cost) { }
};
template <typename T> using Edges = vector<Edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
template <typename T> using Matrix = vector<vector<T>>;

template <typename T>
pair<vector<T>, vector<int>> dijkstra(const WeightedGraph<T> &g, int s) {
    const T INF = numeric_limits<T>::max();
    vector<T> dist(g.size(), INF);
    vector<int> prev(g.size(), -1);
    using Pi = pair<T, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> que;
    dist[s] = 0; que.emplace(dist[s], s);
    while (!que.empty()) {
        T cost; int u; tie(cost, u) = que.top(); que.pop();
        if (dist[u] < cost) continue;
        for (auto &e: g[u]) {
            int v = e.dst; T nc = e.cost;
            if (dist[v] <= dist[u] + nc) continue;
            dist[v] = dist[u] + nc; prev[v] = u;
            que.emplace(dist[v], v);
        }
    }
    return {dist, prev};
}
template <typename T>
vector<int> build_path(vector<T> &dist, vector<int> &prev, int t) {
    const T INF = numeric_limits<T>::max();
    if (dist[t] == INF) return {};
    vector<int> path;
    for (int u = t; u >= 0; u = prev[u]) path.emplace_back(u);
    reverse(path.begin(), path.end());
    return path;
}


#include <cmath>
template<class T> T dist2(T x, T y) { return x * x + y * y; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
int main() {
    int n;
    while (cin >> n, n) {
        WeightedGraph<double> g(n + 1);
        vector<int> b(n), x(n), y(n);
        for (int i = 0; i < n; i++) cin >> b[i] >> x[i] >> y[i];
        for (int i = 0; i < n; i++) for (int j = 0; j < i; j++) {
            int d2 = dist2(x[i] - x[j], y[i] - y[j]);
            if (d2 <= 50 * 50) {
                g[b[i]].emplace_back(b[j], sqrt(d2));
                g[b[j]].emplace_back(b[i], sqrt(d2));
            }
        }
        int m; cin >> m;
        while (m--) {
            int ss, gg; cin >> ss >> gg;
            vector<double> dist;
            vector<int> prev;
            tie(dist, prev) = dijkstra(g, ss);
            auto res = build_path(dist, prev, gg);
            if (res.empty()) {
                cout << "NA" << endl;
            } else {
                for (int i = 0; i < res.size(); i++) cout << res[i] << " \n"[i == res.size() - 1];
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3012
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  LL x,n; cin>>x>>n;
  vector<LL> v(n);
  set<int> s;
  forn(i,n){
  	cin>>v[i];
  	s.insert(v[i]);
  }
  LL dis = 0;
  while(1){
  	if(s.count(-dis+x)==0){
  		cout<<-dis+x<<endl;
  		return 0;
  	}
  	if(s.count(dis+x)==0){
  		cout<<dis+x<<endl;
  		return 0;
  	}
  	dis++;
  }
  return 0;
}

Measured memory_bytes: 3660
s1=input()
s2=input()
s3=input()
x=s1[0]
s1=s1[1:]
while (len(s1)!=0 or x!="a") and (len(s2)!=0 or x!="b") and (len(s3)!=0 or x!="c") :
    if x=="a":
        x=s1[0]
        s1=s1[1:]
 
    elif x=="b":
        x=s2[0]
        s2=s2[1:]
  
    else:
        x=s3[0]
        s3=s3[1:]
    
if len(s1)==0 and x=="a":
    print("A")
elif len(s2)==0 and x=="b":
    print("B")
else:
    print("C")
  



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

int main(){
  int a,b,c,x,y; cin>>a>>b>>c>>x>>y;
  long long ans=0;
  if(x<y){
    ans+=min(a+b,c*2)*x;
    y-=x;
    ans+=min(b,c*2)*y;
  }else{
    ans+=min(a+b,c*2)*y;
    x-=y;
    ans+=min(a,c*2)*x;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <ld> dp(n + 1);
    dp[0] = 1;
    forn (i, 0, n) {
        ld p;
        cin >> p;
        vector <ld> new_dp(n + 1);
        forn (j, 0, n + 1)
            new_dp[j] += dp[j] * (1 - p);
        forn (j, 1, n + 1)
            new_dp[j] += dp[j - 1] * p;
        swap(dp, new_dp);
    }
    ld ans = 0;
    forn (i, n / 2 + 1, n + 1)
        ans += dp[i];
    cout << fixed << setprecision(10) << ans;
    return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


int main() {
	string s;
	cin >> s;

	if (s == "ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main(){
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int s = sc.nextInt();
    int w = sc.nextInt();
    System.out.println(s <= w ? "unsafe" : "safe");
  }
}

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

int main(){
    int N,a,b;
    int max,min;
    cin>>N>>a>>b;

    if(N>a+b){
        min = 0;
        if(a>b)
            max = b;
        else
            max = a;
    }   
    else{
        min = (a+b)-N;
        if(a>b)
            max = b;
        else
            max = a;
    }   
    cout<<max<<' '<<min<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
#define ll long long
#define i1 int128_t
#define vi vector<long long>
#define st set<long long>
#define uset unordered_set<long long>
#define si set<long long>:: iterator
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(long long i=a; i<b; i++)
#define fs(i,a,s) for(long long i=a; s[i]!='\0'; i++)
#define endl "\n"

int main(){

	

	ll t;
	cin>>t;
	ll wa=0, tle=0, ac=0, re=0;
	
	while(t--){

		string s;
		cin>>s;

		if(s[0]=='A')
			ac++;
		else if(s[0]=='W')
			wa++;
		else if(s[0]=='T')
			tle++;
		else
			re++;
	 }

	 cout<<"AC x "<<ac<<endl;
	 cout<<"WA x "<<wa<<endl;
	 cout<<"TLE x "<<tle<<endl;
	 cout<<"RE x "<<re<<endl;

}

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

long long N, A[400], SUM[410] = {};
static long long DP[410][410] = {};
bool used[410][410] = {};

long long DFS(long long L, long long R) {
	if (L + 1 == R) return 0;
	if (used[L][R]) return DP[L][R];
	long long RET = 1000000000000000000;
	for (int i = L + 1; i < R; i++) RET = min(RET, DFS(L, i) + DFS(i, R));
	used[L][R] = true;
	return DP[L][R] = RET + SUM[R] - SUM[L];
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i], SUM[i + 1] = SUM[i] + A[i];
	cout << DFS(0, N) << endl;
}

Measured memory_bytes: 1664
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b;
    cin>>a>>b;
    if(a==1||b==1) cout<<1<<endl;
    else cout<<(a*b+1)/2<<endl;

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,i,j,a[2010],p[2010][2]={};
  long k,t,s,ans=0;
  const int mod=1e9+7;
  cin >> n >> k;
  t=k*(k-1)/2%mod;
  s=k*(k+1)/2%mod;
  for (i=0;i<n;i++) cin >> a[i];
  for (i=0;i<n;i++){
    for (j=0;j<i;j++) if (a[i]>a[j]) p[i][0]++;
    for (j=i+1;j<n;j++) if (a[i]>a[j]) p[i][1]++;
  }
  for (i=0;i<n;i++) ans=(ans+p[i][0]*t+p[i][1]*s)%mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
c = list(s)
ans_list = []

for i in range(len(s)):
    if(c[i]=="0" or c[i]=="1"):
        ans_list.append(c[i])
    else:
        try:
            ans_list.pop(-1)
        except:
            a = 0

print("".join(ans_list))


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

int main() {
   char s;
   cin >> s;

   if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }

   return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e2+5;
ll n,a[N][N],f[N];
struct node{
	ll u,v,d;
	node(){}
	node(ll uu,ll vv,ll dd){
		u=uu,v=vv,d=dd;
	}
};
vector<node> v;
bool cmp(node a,node b){
	return a.d>b.d;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	bool flag=true;
	for(int i=1;i<=n&&flag;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			bool ned=true;
			for(int k=1;k<=n;k++)
			{
				if(k==j||k==i)	continue;
				if(a[i][j]>a[i][k]+a[k][j])
					flag=false;
				if(a[i][j]==a[i][k]+a[k][j]) 
					ned=false; 
			}		
			if(ned)	v.push_back(node(i,j,a[i][j]));
		}
	} 
	if(v.size()<n-1||flag==false)	cout<<-1<<'\n';
	else{
		ll res=0;
		sort(v.begin(),v.end(),cmp);
		for(int i=0;i<v.size();i++)
		{
			ll x=v[i].u,y=v[i].v,val=v[i].d;
		//	cout<<x<<' '<<y<<' '<<val<<'\n';
			res+=val;
		}
		cout<<res<<'\n';
	}
	return 0;
}

Measured memory_bytes: 1024
import Text.Printf

ans :: (Double,Double) -> (Double,Double) -> Double
ans (x1,y1) (x2,y2) = sqrt ( (x1-x2)^2 + (y1-y2)^2 )

main = do
  l <- getLine
  let (x1:y1:x2:y2:_) = map read $ words l :: [Double]
      o = ans (x1,y1) (x2,y2)
  printf "%.8f\n" o

Measured memory_bytes: 4004
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n,m;
	while(cin>>n>>m&&!(n==0&&m==0)){
		int num=n/m;
		vector<int> v;
		for(int i = 0; i < n; i++){
			int t;
			cin>>t;
			v.push_back(t);
		}
		sort(v.begin(),v.end(),greater<int>());

		int sum=0;
		for(int i = 0; i < n; i++){
			if((i+1)%m==0){

			}
			else
				sum+=v[i];
		}
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int U[2003][2003];

int main() {
  ll A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A,A+3);
  cout << A[0]*A[1]/2 <<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)

int c[4][4];

int main(void)
{
    bool ok = true;
    REP(i,3){ REP(j,3){ cin >> c[i][j];}}
    REP(i,3) {
        int i2 = (i + 1)%3;
        REP(j, 3) {
            int j2 = (j + 1)% 3;
            if(c[i][j]-c[i][j2] != c[i2][j]-c[i2][j2]) ok = false;
        }
    }
    if(ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	register int x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x*f;
}
const int N=3e5+5;
int n,L,x[N],t[N],l[N],r[N],vi[N];
int main(){
	int ans=0;
	n=read(),L=read(),ans=n+1;
	for(int i=1;i<=n;i++)	x[i]=read();
	for(int i=1;i<=n;i++){
		ans+=(t[i]=read())/(2*L);
		t[i]%=2*L;
	}
	for(int i=1;i<=n;i++)	l[i]=(x[i]*2>=t[i]);
	for(int i=1;i<=n;i++)	r[i]=((L*2-x[i]*2)>=t[i]);
	for(int i=1;i<=n;i++){
		if(!t[i])	vi[i]=1,--ans;
		if(!r[i]&&!l[i])	vi[i]=1;
	}
	if(t[n])	ans-=r[n];
	int sum=0,pos=n,top=0;
	for(int i=1;i<n;i++){
		if(vi[i])	continue;
		if(!r[i]){
			pos=i; break;
		}
		l[i]?++top:(top?--top,--ans:0);
	}
	sum=top,top=0;
	for(int i=n-1;i>=pos;i--){
		if(vi[i])	continue;
		r[i]?++top:(top?--top,--ans:0);
	}
	printf("%lld\n",2LL*L*(ans-(sum+top)/2));
	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n; ll c,k;
  cin>>n>>c>>k;
  vector<ll> t(n);
  rep(i,n)cin>>t[i];
  sort(t.begin(),t.end());
  ll T = t[0];
  ll C = 1;
  ll ans=1;
  repeat(i,1,n) {
    if(T+k<t[i]||C>=c) {
      T = t[i];
      C=1;
      ans++;
    } else {
      C++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    int N;
    cin >> N;
    vector<ll> begin(5,0);

    for(int i=0; i<N; i++) {
        string s;
        cin >> s;
        switch (s[0])
        {
        case 'M':
            begin[0]++;
            break;
        case 'A':
            begin[1]++;
            break;
        case 'R':
            begin[2]++;
            break;
        case 'C':
            begin[3]++;
            break;
        case 'H':
            begin[4]++;
            break;
        default:
            break;
        }
    }

    ll ans = 0;
    for(int i=0; i<5; i++) {
        for(int j=i+1; j<5; j++) {
            for(int k=j+1; k<5; k++) {
                ans += begin[i] * begin[j] * begin[k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
<?php
$N = intval(fgets(STDIN));
for($i = 0; $i < $N; $i++)$map[] = trim(fgets(STDIN));

$max = -1;
for($i = 0; $i < $N; $i++){
    $distance = array_fill(0, $N, 300);
    $current = [$i];
    $d = 0;
    $distance[$i] = $d;
    while($current){
        $d++;
        $next = [];
        foreach($current as $c){
            for($j = 0; $j < $N; $j++){
                if($map[$c][$j] == "1"){
                    if($distance[$j]==300){
                        $distance[$j] = $d;
                        $next[] = $j;
                    }elseif($distance[$j] == $d-2 || $distance[$j] == $d){
                    }else{
                        continue 4;
                    }
                }
            }
        }
        $current = $next;
    }
    if($d > $max){
        $max = $d;
    }
}
echo $max,"\n";



Measured memory_bytes: 4728
def getScore(xs, b):
    return sum(abs(x - b) for x in xs)

def solve(xs, n):
    xs = sorted([x - i for (x, i) in zip(xs, range(1, n + 1))])
    if n % 2 == 0:
        return getScore(xs, xs[n // 2])
    return min(getScore(xs, xs[n // 2 - 1]), getScore(xs, xs[n // 2]))

if __name__ == "__main__":
    n = int(input())
    xs = [int(s) for s in input().split()]
    print(solve(xs, n))


Measured memory_bytes: 25836
N = int(input())
restran_dict = {}
for i in range(N):
  city, score = input().split()
  try: 
    restran_dict[city].append((i+1,int(score)))
  except :
    restran_dict[city] = []
    restran_dict[city].append((i+1,int(score)))

sorted_city_names = sorted(restran_dict.keys())

def get_score_id(dict_,key_):
    return [(i,v, key_) for i,v in reversed(sorted(dict_[key_],key=lambda x:x[1]))]
result_list = []
for k in sorted_city_names:
  result_list.extend(get_score_id(restran_dict,k))
for i in result_list:
  print(i[0])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int n, m;

bool c[710][710];

V g[710];

int color[710];

vector<P> p;

bool check;

void dfs(int s, int t)
{
    if (color[s] != -1)
    {
        if (color[s] != t)
            check = false;
        return;
    }

    color[s] = t;

    if (t == 0)
        p[p.size() - 1].first++;
    else
        p[p.size() - 1].second++;

    for (int i : g[s])
        dfs(i, 1 - t);

    return;
}

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

    cin >> n >> m;

    REP(i, n)
    REP(j, n)
    c[i + 1][j + 1] = i + 1 == j + 1;

    REP(i, m)
    {
      int a,b;
        cin >> a >> b;

        c[a][b] = true;
        c[b][a] = true;
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            if (!c[i][j])
            {
                g[i].push_back(j);
                g[j].push_back(i);
            }
        }
    }

    memset(color, -1, sizeof(color));

    check = true;

    while (true)
    {
        bool ch = false;
        for (int i = 1; i <= n; i++)
        {
            if (color[i] == -1)
            {
                p.push_back({0, 0});
                dfs(i, 0);
                ch = true;
            }
        }

        if (!ch)
            break;
    }

    if (!check)
    {
        cout << -1 << endl;
        return 0;
    }

    bool dp[2][1000];

    auto *cur = dp[0];
    auto *nex = dp[1];

    fill(cur, cur + n + 1, false);
    fill(nex, nex + n + 1, false);

    cur[0] = true;

    V num;

    REP(j, p.size())
    {
        for (int i = 0; i < 1000; i++)
        {
            if (!cur[i])
                continue;

            if (i + p[j].first < 1000)
                nex[i + p[j].first] = true;

            if (i + p[j].second < 1000)
                nex[i + p[j].second] = true;
        }

        swap(cur, nex);
        fill(nex, nex + n + 1, false);
    }

    int res = INT_MAX;

    for (int i = 0; i <= n; i++)
    {
        if (!cur[i])
            continue;

        int tmp = (i * (i - 1) / 2) + ((n - i) * (n - i - 1) / 2);
        res = min(res, tmp);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3712