akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

void swap(int *x, int *y) {
  int tmp = *x;
  *x = *y;
  *y = tmp;
}

void partition(int a[], int p, int r) {
  int i = p - 1;
  for (int j = p; j <= r - 1; j++) {
    if (a[j] <= a[r]) {
      i++;
      // int tmp = a[i];
      // a[i] = a[j];
      // a[j] = tmp;
      swap(&a[i], &a[j]);
    }
  }
  swap(&a[i+1], &a[r]);
  // int tmp = a[i+1];
  // a[i+1] = a[r];
  // a[r] = tmp;

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



Measured memory_bytes: 2084
S = input()
S2 = "".join([s for s in S if s != "x"])

if S2 != S2[::-1]:
    print(-1)
    exit()

A = []
cnt = 0
for s in S:
    if s != "x":
        A.append(cnt)
        cnt = 0
    else:
        cnt += 1
A.append(cnt)

ans = 0
for i in range(len(A) // 2):
    ans += abs(A[i] - A[-i-1])
print(ans)


Measured memory_bytes: 3956
n, x, y = list( map( int, input().split() ) )

# 以下カンニング
ans = [ 0 ] * n
for i in range( 1, n + 1 ):
    for j in range( i + 1, n + 1 ):
        d = min( [ j - i,
                abs( x - i ) + 1 + abs( j - y ),
                abs( y - i ) + 1 + abs( j - x ) ] )
        ans[ d ] += 1

for k in range( 1, n ):
    print( ans[k] )

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    long a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    long dist = abs(a-b);
    if((v-w)*t>=dist){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int h,m,s;
        s = S % 60;
        m = S / 60;
        h = m / 60;
        m = m % 60;
        System.out.println( h + ":" + m + ":" + s );
      }
    }



Measured memory_bytes: 26168
# AOJ TP2_2_A: Stack
# Python3 2018.6.24 bal4u

n, q = map(int, input().split())
Q = [[] for i in range(n)]
for i in range(q):
	a, *b = map(int, input().split())
	if   a == 0: Q[b[0]].append(b[1])        # push
	elif a == 1 and Q[b[0]]: print(Q[b[0]][-1]) # top
	elif a == 2 and Q[b[0]]: Q[b[0]].pop()      # pop




Measured memory_bytes: 13436
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd


N = read_a_int()
mono = []
for _ in range(N):
    mono.append(read()[:-1])

print(len(set(mono)))


Measured memory_bytes: 98252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

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

vector<pair<ll,int>> factorize (ll n) {
  vector<pair<ll,int>> v;
  for (ll i=2; i*i<=n; i++) {
    if (n%i) continue;
    v.emplace_back(i,0);
    while (n%i==0) {
      v.back().second++;
      n/=i;
    }
  }
  if (n!=1) {
    v.emplace_back(n,1);
  }
  return v;
}
      
  
int main() {
  ll a,b;
  cin>>a>>b;
  ll g=gcd(a,b);
  auto f=factorize(g);
  cout<<f.size()+1<<endl;
  return 0;
}




Measured memory_bytes: 256
# include <iostream>
# include <vector>
# include <algorithm>
# include <set>
# include <map>
# include <iomanip>
# include <string>
# include <cmath>

using namespace std;


int main()
{
    int n, d;
    cin >> n >> d;
    int x = 1, cnt = 0;
    while( x <= n ){
        x += 2 * d+1;
        cnt ++;
        //cout << x << endl;
    }
    cout << cnt;
}


Measured memory_bytes: 256
fun main() {
    val input: List<Long> = readLine()!!.split(" ").map { it.toLong() }//条件入力
val homework: List<Long> = readLine()!!.split(" ").map { it.toLong() }//条件入力
var homework_sum=0L
for (i in homework){
    homework_sum+=i
}
val anwer=input[0]-homework_sum
when{
    anwer<0 ->{
        println("-1")
    }
    else ->{
        println(anwer)
    }
}
}

Measured memory_bytes: 39536
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define dl double
#define mod 100000007
#define sz 1005
#define szz 15005

using namespace std;

int main()
{
    ll n;

    scanf("%lld",&n);

    n++;

    while(n--)
    {
        ll m=sqrt(n);

        if(m*m==n)
        {
            printf("%lld\n",n);
            break;
        }
    }

    return (0);
}


Measured memory_bytes: 256
def resolve():
    import math
    A, B, C, X, Y = map(int, input().split())
    ans = []
    for i in range(max(X, Y)*2+1):
        ans.append(C*i + A*(max(X-i/2, 0)) + B*(max(Y-i/2, 0)))
    print(math.floor(min(ans)))
resolve()

Measured memory_bytes: 9368
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 a = Array(n + 1) { sc.nextLong() }
    val b = Array(n + 1) { 0L }
    if (n == 0) {
        println(if (a[0] == 1L) 1 else -1)
        return
    }
    for (i in n - 1 downTo 0) {
        b[i] = a[i + 1] + b[i + 1]
    }
    if (b[0] < 1 - a[0]) {
        println(-1)
        return
    }
    b[0] = 1 - a[0]
    for (i in 1..n) {
        b[i] = minOf(b[i], 2 * b[i - 1] - a[i])
    }
    b[n] = 0
    for (i in n - 1 downTo 0) {
        b[i] = minOf(b[i], a[i + 1] + b[i + 1])
    }
    if (b.any { it < 0 }) {
        println(-1)
        return
    }
    for (i in 0 until n) {
        if (b[i] > a[i + 1] + b[i + 1] || a[i + 1] + b[i + 1] > 2 * b[i]) {
            println(-1)
            return
        }
    }
    println(a.sum() + b.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: 60572
#include <bits/stdc++.h>

using namespace std;

#define INF 210000000
#define int long long

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

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

signed main() {
		vector<int> s;
		string a;
		cin >> a;
		for(int i=0;i<a.length();i++){
				s.push_back(a[i] - '0');
		}
		int ans = INF;
		for(int i=0;i<a.length()-2;i++){
				if(abs(753 - s[i]*100-s[i+1]*10-s[i+2]) < ans){
						ans = abs(753-s[i]*100-s[i+1]*10-s[i+2]);
				}
		}
		cout << ans;
}



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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<40;

int main() {
    int N, K; cin >> N >> K;
    vector<long long> maxd(N, -INF), vals;
    multiset<long long> se;
    for (int i = 0; i < N; ++i) {
        int s; long long v;
        cin >> s >> v;
        --s;
        chmax(maxd[s], v);
        vals.push_back(v);
    }
    sort(vals.begin(), vals.end(), greater<long long>());
    sort(maxd.begin(), maxd.end(), greater<long long>());
    long long sum = 0;
    for (int i = 0; i < K; ++i) sum += vals[i], se.insert(vals[i]);
        
    long long res = 0;
    long long tmp = sum;
    for (long long x = 1; x <= K; ++x) {
        long long add = maxd[x-1];
        long long back = *se.begin();
        tmp += add;
        if (back > add) {
            se.erase(se.begin());
            tmp -= back;
        }
        else {
            se.erase(se.find(add));
            tmp -= add;
        }
        chmax(res, tmp + x * x);
    }
    cout << res << endl;
}


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

int main(){
  int N,a,b,ans=0,tmp1,tmp2;
  cin >>N>>a>>b;
  for(int i=1;i<=N;i++){
    tmp2=0;
    tmp1=i;
    while(tmp1!=0){
      tmp2+=tmp1%10;
      tmp1/=10;
    }
    if(a<=tmp2&&tmp2<=b)
      ans+=i;
  }
  cout << ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int h,m,s;
	scanf("%d",&s);
	h=s/3600;
	s-=h*3600;
	m=s/60;
	s-=m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int cnt = 0;
  for (int i = a; i >= 1; i--) {
    if (a % i == 0 && b % i == 0) cnt++;
    if (cnt == c) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int a,b;
	cin>>a>>b;

	string grid[100];
	rep(i,100)grid[i].resize(100);
	for (int i = 0; i < 50; i++){
		rep(j,100)grid[i][j]='#';
	}
	for (int i = 50; i < 100; i++){
		rep(j,100) grid[i][j] = '.';
	}
	int cnt = 0;
	for (int i = 0; i < 49; i+=2){
		if(cnt==a-1)break;
		for (int j = (i%2==0?0:1); j < 100; j+=2){
			grid[i][j] = '.';
			cnt++;
			if(cnt==a-1)break;
		}
	}

	cnt=0;
	for (int i = 51; i < 100; i+=2){
		if(cnt==b-1)break;
		for (int j = (i%2==0?0:1); j < 100; j+=2){
			grid[i][j] = '#';
			cnt++;
			if(cnt==b-1)break;
		}
	}
	cout<<100<<" "<<100<<endl;
	rep(i,100){
		cout<<grid[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import fractions as fr
import math

A,B=map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

a=fr.gcd(A,B)
U=make_divisors(a)

JJ=0
for i in U:
    if is_prime(i)==True:
        JJ+=1
print(JJ+1)

Measured memory_bytes: 5216
n=int(input())
h=list(map(int,input().split()))

w=sorted(h)
flag=0
for i in range(n):
  if abs(h[i]-w[i])<=1:
    continue
    
  else:
    flag=1
    break
if flag==1:
  print('No')
  
else:
  print('Yes')
    
    

    

Measured memory_bytes: 20468
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,x,y = LI()
    x -= 1
    y -= 1
    ans = [0]*n
    for i in range(n):
        k = abs(x-i)
        for j in range(i+1,n):
            d = min(j-i,k+abs(j-y)+1)
            ans[d] += 1
    for i in ans[1:]:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }






  int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];
    ll ans = 0;
    for(int i = N - 1; 0 <= i; i--){
      ll s = (A[i] + ans) % B[i];
      if(s == 0) continue;
      ans += B[i] - s;
    }
    
    print(ans);
  }




Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int M1, M2, D1, D2;

	cin >> M1 >> D1 >> M2 >> D2;

	cout << (M1 == M2 ? "0" : "1") << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()


NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

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

    highest = 0

    step_sum = 0

    for a in A:
        if highest < a:
            highest = a
        else:
            step_sum += highest - a
    print(step_sum)


if __name__ == '__main__':
    main()

Measured memory_bytes: 34072
n,m=map(int,input().split())
lrc=[list(map(int,input().split())) for _ in range(m)]
lrc.sort(key=lambda x:x[0])
# 
inf=float('inf')
seen=[inf]*n
seen[0]=0
now=0
from heapq import heappop,heappush
from collections import deque
lrc=deque(lrc)
todo=[[0,now]]
while todo:
  d,v=heappop(todo)
  lst=[]
  while lrc and lrc[0][0]<=v+1:
    lst.append(lrc.popleft())
  for l,r,c in lst:
    if seen[r-1]>seen[v]+c:
      heappush(todo,[seen[v]+c,r-1])
      seen[r-1]=seen[v]+c
if seen[-1]!=inf:
  print(seen[-1])
else:
  print(-1)
#print(seen)


Measured memory_bytes: 45668
import math
import collections
import heapq
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def main():
    s = input()
    t = input()
    ans = 0
    for i in range(3):
        if s[i] == t[i]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> Vector;
typedef vector<vector<ll>> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX/3
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define rep(i,n)    repl(i,0,n-1)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<int>())
#define mkp(x,y)    make_pair(x,y)

int main(){
  cin.sync_with_stdio(false);
  int n,l,r;
  int c = 1000000;
  Vector a(c+1,0);
  cin >> n;
  rep(i,n){
    cin >> l >> r;
    a[l-1] ++;
    a[r]--;
  }
  repl(i,1,c)a[i] += a[i-1];
  int sum = 0;
  rep(i,c)sum+=a[i];
  cout << sum << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) {if (b<a) {a=b; return 1;} return 0;}

struct Edge { int to, id;};
vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
    int k = 1;
    for (int i = 0; i < g[v].size(); ++i) {
        int nv = g[v][i].to, ei = g[v][i].id;
        if (nv == p) continue;
        if (c == k) k++;
        ans[ei] = k;
        k++;
        dfs(nv, ans[ei], v);
    }
}

int main(){
    int n;
    cin >> n;
    g.resize(n);
    ans.resize(n-1);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back((Edge){b, i});
        g[b].emplace_back((Edge){a, i});
    }
    dfs(0);
    int mx = *max_element(ans.begin(), ans.end());
    cout << mx << endl;
    rep(i, n-1) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 8320
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
vint a;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    cin >> n >> x;
    vint a(n,0);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    int ans = 0;
    int sum =0;
    REP(i,n){
        sum+=a[i];
        if(sum>x){
            break;
        }
        ans++;
    }
    if(sum<x) ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr <<"\e[91m"<<__func__<<": "<< #x << " = " << x <<"\e[39m"<< "\n"
typedef pair<int, int> pii;
typedef long long ll;
const double eps = 1e-9;
const int inf = 0x3f3f3f3f;


int main()
{
#ifndef ONLINE_JUDGE
    freopen("../io/in.txt", "r", stdin);
    //freopen("../io/out.txt", "w", stdout);
#endif // ONLINE_JUDGE
    string a, b;
    cin >> a >> b;
    int dif = 0;
    for(int i=0; i<a.size(); i++) if(a[i] != b[i]) dif++;
    cout << dif << endl;
    return 0;
}


Measured memory_bytes: 3852
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		//??\??????????????????
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //????????????????????°?????????
        int num =Integer.parseInt(br.readLine());
        //??????????°???? ???????????????????¨??????????
        int min = Integer.parseInt(br.readLine());
        //?????§?????? ????????????????????????????????????????????§??????????????????????????????????¨??????????
        int maxProfit = -1000000000;
        int currentNum = 0;
        for(int i = 1 ; i < num ; i++){
        	currentNum = Integer.parseInt(br.readLine());
        	maxProfit = Math.max(maxProfit, currentNum - min);
        	min = Math.min(min, currentNum);
        }
        
        System.out.println(maxProfit);

	}

}

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

using namespace std;

int main() {
    long long int A; cin >> A;
    long long int B; cin >> B;
    long long int K;
    bool flag = false;

    //vector<long long int> A(N);
    //for(int i=0;i<N;i++) cin >> A[N];

    for(K=0; K<1000000000 ;K++) {
        if(abs(A-K) == abs(B-K)){ flag = true; cout << K << endl; return 0;}
    }

    if(!flag) {cout << "IMPOSSIBLE" << endl;}

    return 0;
}

Measured memory_bytes: 256
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll n,k;
    std::cin >> n>>k;
    
    vector<bool> ok(n,false);
    
    for (int i = 0; i < k; i++) {
        ll d;
        std::cin >> d;
        for (int j = 0; j < d; j++) {
            ll tmp;
            std::cin >> tmp;
            tmp--;
            ok[tmp] = true;
        }
    }
    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        if(!ok[i])cnt++;
    }
    
    std::cout << cnt << std::endl;
}

Measured memory_bytes: 3632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  int x, y, n = 600;

  while(cin >> x) {
    int result = 0;
    for(int i = x; i < n; i += x) {
      y = i*i;
      result = result + x*y;
    }
    cout << result << endl;
  }
}

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

 
int main() {
    int n,m;
    cin>>n>>m;
    vector<ll> H(n);
    rep(i,n)cin>>H[i];
    vector<int> N(n);//悪い展望台はプラス(０のものが良い)
    rep(i,m){
        int a,b;
        cin>>a>>b;
        if(H[a-1]>H[b-1])N[b-1]++;
        if(H[a-1]<H[b-1])N[a-1]++;
        if(H[a-1]==H[b-1]){
            N[a-1]++;
            N[b-1]++;
        }
    }
    int ans=0;
    rep(i,n){
        if(N[i]==0)ans++;
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4260
#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>;


void Main()
{
  string S;
  cin >> S;
  int zeroStart = 0;
  int oneStart = 0;
  rep(i,S.size()){
    if (S[i] == '0') {
      if (i%2 == 1) zeroStart++;
      else oneStart++;
    }
    if (S[i] == '1') {
      if (i%2 == 0) zeroStart++;
      else oneStart++;
    }
  }
  cout << min(zeroStart, oneStart) << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 512
from itertools import product

n = int(input())
info = {}
for p in range(n):
    a = int(input())
    L = []
    for _ in range(a):
        x,y = list(map(int, input().split()))
        x,y = x-1, y
        L.append((x,y))
    info[p] = L

ans = 0
for bit_pattern in product(range(2), repeat=n):
    for p,bit in enumerate(bit_pattern):
        if bit:
            if not all([bit_pattern[x] == y for x,y in info[p]]):
                break
    else:
        ans = max(ans, sum(bit_pattern))

print(ans)

Measured memory_bytes: 9168
/*
				C++
				encoding: UTF-8
				Last Modified: 2019/09/01 17:47:50

*/

#include <bits/stdc++.h>
#ifdef LOCAL_PROJECT
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		 ll                     long long
#define		 ve                     vector
#define		 pb                     push_back
#define		 endl                   "\n";
#define		 ff                     first
#define		 ss                     second
#define		 pii                    pair<int, int>
#define		 len(v)                 int(v.size())
#define		 all(v)                 v.begin(), v.end()
#define		 reset(a, b)            memset(a, b, sizeof(a));
#define		 fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		 dfr(i, s, n)           for (int i = s ; i > n ; --i)

void pr () {
    cout << "\n";
}

template < typename T, typename... ARGS > void pr (const T& t, ARGS... args) {
    cout << t << " ";
    pr (args...);
}

// clang-format on

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n;
	cin >> n;
	int arr[n];
	fr (i, 0, n) cin >> arr[i];
	ve< int > chk (n, 0);
	int ans = 0;
	fr (i, 1, n) {
		if (arr[i] <= arr[i - 1]) chk[i] = 1 + chk[i - 1];
		ans = max (ans, chk[i]);
	}
	pr (ans);
	return 0;
}


Measured memory_bytes: 1024
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	vector<int> v(3);
	for (auto& x : v) cin >> x;
	sort(v.begin(), v.end());
	int k;
	cin >> k;
	v.back() <<= k;
	cout << v[0] + v[2] + v[1] << endl;
	return 0;
}


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

int main(){
	while(1){
	int n;
	std::cin>>n;
	if(n==0)break;
	int ans=1;
	std::vector<int> vec(6);
	for(int i=0;i<6;i++)vec[i]=i+1;
	for(int i=0;i<n;i++){
		std::string str;
		std::cin>>str;
		if(str[0]=='N'){
			int a=vec[1];
			vec[1] = vec[5];
			vec[5] = vec[4];
			vec[4] = vec[0];
			vec[0] = a;
			ans += vec[0];
		}else if(str[0] == 'E'){
			int a=vec[3];
			vec[3] = vec[5];
			vec[5] = vec[2];
			vec[2] = vec[0];
			vec[0] = a;
			ans += vec[0];
		}else if(str[0] == 'W'){
			int a=vec[0];
			vec[0] = vec[2];
			vec[2] = vec[5];
			vec[5] = vec[3];
			vec[3] = a;
			ans += vec[0];
		}else if(str[0] == 'S'){
			int a=vec[1];
			vec[1] = vec[0];
			vec[0] = vec[4];
			vec[4] = vec[5];
			vec[5] = a;
			ans += vec[0];
		}else if(str[0] == 'R'){
			int a=vec[1];
			vec[1] = vec[2];
			vec[2] = vec[4];
			vec[4] = vec[3];
			vec[3] = a;
			ans += vec[0];
		}else if(str[0] == 'L'){
			int a=vec[1];
			vec[1]=vec[3];
			vec[3]=vec[4];
			vec[4]=vec[2];
			vec[2]=a;
			ans += vec[0];
		}
	}
	std::cout<<ans<<std::endl;
	}
	return 0;
}

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

#define endl "\n"
#define MOD 1000000007

#define forn(i, a, n) for (int i = a; i < n; i++)
#define forns(i, a, n, step) for (int i = a; i < n; i += step)
#define fornr(i, a, n) for (int i = n; i > a; --i)
#define fornrs(i, a, n, step) for (int i = n; i > a; i -= step)
#define forlimits(i, l, r) for (int i = l; i <= r; i++)

// Choose auto x when you want to work with copies.
#define foritc(i, v) for (auto i = v)
// Choose auto &x when you want to work with original items and may modify them.
#define foritm(i, v) for (auto &i = v)
// Choose auto const &x when you want to work with original items and will not modify them.
#define forit(i, v) for (auto const &i = v)

#define all(v) (v).begin(), (v).end()

#define fill(arr, n, k) \
    forn(i, 0, n) { arr[i] = k; }

#define print(arr, n)                        \
    forn(i, 0, n) { cout << arr[i] << " "; } \
    cout << endl;

#define intersection(a, b, out) set_intersection(all(a), all(b), out.begin())

#define sum_n(n) ((n) * (n + 1) / 2)
typedef long long ll;
void solve();

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
    // return 0;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    ll arr[n];
    vector<ll> ans(n, INT_MAX);
    ans[0] = 0;
    forn(i, 0, n) cin >> arr[i];

    forn(i, 0, n) {
        forn(j, (i + 1), (i + k + 1)) {
            if (j < n)
                ans[j] = min(ans[j], ans[i] + abs(arr[i] - arr[j]));
        }
    }
    cout << ans[n - 1] << endl;
}

Measured memory_bytes: 4752
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=500005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}

int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int BIT[N];
void update(int x, int delta)
{
      for(; x <N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
     int sum = 0;
     for(; x > 0; x -= x&-x)
        sum += BIT[x];
     return sum;
}
int32_t main()
{
    IOS;
    int n,qq;
    cin>>n>>qq;
    int seq[n+1],ans2[qq+1];
    bool ch[n+1];
    fill(ch, false);
    for(int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        seq[i]=a;
    }
    vector <tuple <int, int, int> > q;
    for(int i=1;i<=qq;i++)
    {
        int l,r;
        cin>>l>>r;
        q.pb({r, l, i});
    }
    sort(all(q));
    fill(BIT, 0);
    int vis[n+1];
    fill(vis, -1);
    int lim=q.size(),x=0;
    //cout<<lim<<"\n";
    for(int i=1;i<=n&&x<lim;i++)
    {
        //cout<<i<<' ';
        if(vis[seq[i]]!=-1)
        {
            update(vis[seq[i]], -1);
        }
        vis[seq[i]]=i;
        update(i, 1);
        int r,l,a;
        tie(r, l, a)=q[x];
        //cout<<r<<" "<<l<<" "<<a<<"\n";
        while(x<lim&&r==i)
        {
            //cout<<i<<" "<<a<<' '<<l<<' '<<r<<' '<<query(r)<<" "<<query(l)<<"\n";
            ans2[a]=query(r)-query(l-1);
            x++;
            if(x<lim)
            tie(r, l, a)=q[x];
        }
    }
    for(int i=1;i<=qq;i++)
    cout<<ans2[i]<<"\n";
}

Measured memory_bytes: 31732
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int n;
    cin >> n;
	bool flag = true;
    //処理
  	while(true){
      int sq=sqrt(n);
      if(n==sq*sq) break;
      n--;
    }
    //出力
    cout << n << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;
int main()
{
	int n, l;
	cin >> n >> l;
	vector<int> a(n);
	deque<pair<int, int>> ic, ic2;
	ll sum = 0;
	rep(i, n)
	{
		cin >> a[i];
		//ic.push_back(make_pair(i, a[i]));
		//sum += a[i];
	}
	bool ok=false;
	int ite=0;
	rep(i,n-1){
		if(a[i]+a[i+1]>=l){
			ok=true;
			ite=i;
		}
	}
	if (ok)
	{
		cout << "Possible" << endl;
		rep(i,ite){
			printf("%d\n",i+1);
		}
		rep(i,n-ite-1){
			printf("%d\n",n-1-i);
		}
	}
	else
	{
		cout << "Impossible" << endl;
	}
}


Measured memory_bytes: 1152
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <cstdint>
using namespace std;

#define N 1000

long long xa[N];
long long ya[N];
long long za[N];
long long ta[N];

int compare_long_long(const void *a, const void *b)
{
	long long ans = *(long long*)b - *(long long*)a;
    return ans == 0 ? 0 : ans > 0 ? 1: -1 ;
}

int main() {
	int n, m;
	long long ans = INT64_MIN;

	cin >> n >> m;
	for( int i = 0; i < n; i++ ) {
		cin >> xa[i] >> ya[i] >> za[i];
	}

	for( int i = -1; i < 2; i+=2 ) {
		for( int j = -1; j < 2; j+=2 ) {
			for( int k = -1; k < 2; k+=2 ) {
				for( int l = 0; l < n; l++ ) {
					ta[l] = xa[l]*i + ya[l]*j + za[l]*k;
				}
				qsort(ta, n, sizeof(long long), compare_long_long);
				long long sum = 0;
				for( int l = 0; l < m; l++ ) {
					sum += ta[l];
				}
				ans = max(sum, ans);
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[10][11], sum[11];
int idx, k;
void dfs(int pos, int pre) {
	if (pos > idx)
		return;
	if (pos == 1) {
		for (int i = 1; i <= 9; i++) {
			if (k > dp[i][idx - pos + 1])
				k -= dp[i][idx - pos + 1];
			else {
				printf("%d", i);
				dfs(pos + 1, i);
				return;
			}
		}
	}
	else {
		for (int i = pre - 1; i <= pre + 1; i++) {
			if (i < 0 || i>9)
				continue;
			if (k > dp[i][idx - pos + 1])
				k -= dp[i][idx - pos + 1];
			else {
				printf("%d", i);
				dfs(pos + 1, i);
				return;
			}
		}
	}
}
int main()
{
	scanf("%d", &k);
	for (int i = 0; i <= 9; i++)
		dp[i][1] = 1;
	sum[1] = 9;
	for (int j = 2; j <= 10; j++) {
		for (int i = 0; i <= 9; i++) {
			if (i == 0)
				dp[i][j] = dp[i][j - 1] + dp[i + 1][j - 1];
			else if (i == 9)
				dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
			else
				dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1] + dp[i + 1][j - 1];
			if (i != 0)
				sum[j] += dp[i][j];
		}
	}
	for (int i = 1; i <= 10; i++) {
		if (k > sum[i])
			k -= sum[i];
		else {
			idx = i;
			break;
		}
	}
	dfs(1, 0);
}

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

const int MOD = 1e9 + 7;

int power(int a, int b) {
    if (b == 0)
        return 1;
    int result = power(a, b / 2);
    return result * result % MOD * (b % 2 == 1 ? a : 1) % MOD;
}

void solve_test() {
    int n;
    cin >> n;
    
    int answer = power(10, n);
    cout << (power(10, n) - power(9, n) * 2 + power(8, n) + 2 * MOD) % MOD << '\n';
}

int32_t main() {
	int T; 
	// cin >> T;
	T = 1;
	while (T--)
		solve_test();

	return 0;
}


Measured memory_bytes: 3632
N,K=list(map(int,input().split()))

d=[0]*K
A=[[0]*K]*100
sunuke=[0]*N
count=N

for i in range(K):
    d[i]=int(input())
    A[i]=list(map(int,input().split()))
    for j in range(d[i]):
        if sunuke[A[i][j]-1]==0:
            sunuke[A[i][j]-1]=1
            count-=1

print(count)

Measured memory_bytes: 9208
#include<cstdio>
#define LL long long
const LL mod=998244353;
LL fac[500010],inv[500010],N,K,ans=0;
void pre()
{
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(LL i=2;i<=500000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(LL i=2;i<=500000;i++) fac[i]=fac[i-1]*i%mod,inv[i]=inv[i-1]*inv[i]%mod;
}
LL C(LL m,LL n) {return fac[m]*inv[m-n]%mod*inv[n]%mod;}
int main()
{
	pre();
	scanf("%lld %lld",&N,&K);
	if(N>K) return puts("0"),0;
	for(int i=N;i<=K;i++) (ans+=C(K-1,i-1))%=mod;
	printf("%lld",ans);
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf =2e5+9,mod = 1e9+7;
ll n,a[inf];
int main(){

    cin>>n;
    ll sum = 0,ans = 0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        ans = (ans + (sum*a[i] )%mod )%mod;
        sum = (sum + a[i])%mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5152
//??：3s   空?：256MB
//?意:?定一??,要求从1到n找到一条路径,使得路径上的点以及与路径
//相?接的点的??和最小
//算法:dp
//?段:?于?一个i 
//状?:dp[i]表示1~n点的最?解
//决策:dp[i]=value(allson)
//在?移?,需要保存当前路径上以及与路径相?的点,由于点的?个数
//比?小,所以可以使用二?制?行状???
//若?于或者等于当前i的最?解,?允??行下一?循? 
#include<cstdio> 
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
#include<iostream>
#define ll long long
using namespace std;
vector<int>G[45];
map<ll,bool>visit;
int dp[45],a[45];
int n,m;
void add(ll & x,int w){
	x|=(1LL<<w);
}
int update(ll x){
	int sum=0;
	for(int i=1;i<=n;i++)
		if(x&(1LL<<i))sum+=a[i];
	return sum;
}
void dfs(int u,ll now){	
	visit[now]=true;//?行状?的??,避免多次?? 
//	cout<<now<<endl;
	int lena=G[u].size();
	for(int i=0;i<lena;i++){
		ll tmp=now;
		int v=G[u][i];
		int lenb=G[v].size();
		for(int j=0;j<lenb;j++){
			int w=G[v][j];
			add(tmp,w);
		}
		add(tmp,v);
		int tot=update(tmp);
		if(tot<=dp[v]){
			dp[v]=tot;
			if(visit[tmp])continue;
			dfs(v,tmp);
		}
	}
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int j=1;j<=m;j++){
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	memset(dp,127,sizeof(dp));
	G[0].push_back(1);
	dfs(0,0);
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 3308
// pdf
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define MOD 1e9+7
using namespace std;

int main() {
  string a, b; // これ天才か？
  cin >> a >> b;
  if (a.size() > b.size()) cout << "GREATER" << endl;
  else if (a.size() < b.size()) cout << "LESS" << endl;
  else {
    if (a > b) cout << "GREATER" << endl;
    if (a == b) cout << "EQUAL" << endl;
    if (a < b) cout << "LESS" << endl;
  }
}

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

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

int dp[101][4][2];
string S;
int K;

int dfs(int n, int k, bool f) {
  if ( dp[n][k][f] >= 0 ) return dp[n][k][f];

  if ( n == S.size() ) {
    if ( k == K ) return 1;
    else return 0;
  }

  int ret = 0;
  if ( k < K ) {
    if ( !f ) {
      for ( int i = 1; i <= (S[n]-'0'); i++ ) {
	if ( i == (S[n]-'0') ) ret += dfs(n+1, k+1, f);
	else ret += dfs(n+1, k+1, true);      
      }
    } else {
      for ( int i = 1; i <= 9; i++ ) {
	ret += dfs(n+1, k+1, true);	
      }
    }
  }
  if ( (S[n]-'0') == 0 ) ret += dfs(n+1, k, f);
  else ret += dfs(n+1, k, true);

  return dp[n][k][f] = ret;  
}

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

  cin >> S >> K;
  fill_n(**dp, 101*4*2, -1);

  cout << dfs(0, 0, 0) << endl;
  
  return 0;
}


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


int main(){
    int N,X,T;
    cin>>N>>X>>T;
    if(N%X>0){
        cout<<(N/X+1)*T<<endl;
    }
    else{
        cout<<(N/X)*T<<endl;
    }
    
}


Measured memory_bytes: 3564
import numpy as np
N = int(input())
A = np.array([int(_) for _ in input().split()], dtype=np.int64)
mod = 10**9 + 7
ans = 0
for b in range(60):
    B = (A >> b) & 1
    M = np.count_nonzero(B)
    ans += 2**b * M * (N - M)
    ans %= mod
print(ans)


Measured memory_bytes: 48836
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[1001];
  for(int i=1;i<=n;i++)
    cin>>a[i];
  sort(a,a+(n+1));
  int sum=0;
  for(int i=1;i<=k;i++)
    sum+=a[i];
  cout<<sum<<"\n";
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int inf = 1e9;

vector<int> bfs(vector<vector<int> > &adj, int s){
	vector<int> ret(adj.size(), inf);
	ret[s] = 0;
	queue<pair<int,int> > wait;
	wait.push(make_pair(s, 0));
	while(!wait.empty()){
		int pos = wait.front().first;
		int cost = wait.front().second;
		wait.pop();
		for(int i=0; i<(int)adj[pos].size(); i++){
			if(ret[adj[pos][i]] == inf){
				ret[adj[pos][i]] = cost+1;
				wait.push(make_pair(adj[pos][i], cost+1));
			}
		}
	}
	return ret;
}

int main(){
	int n,m,s,t;
	cin >> n >> m >> s >> t;
	vector<vector<int> > adj(n+1);
	vector<int> x(m),y(m);
	for(int i=0; i<m; i++){
		cin >> x[i] >> y[i];
		adj[x[i]].push_back(y[i]);
		adj[y[i]].push_back(x[i]);
	}
	
	vector<int> froms = bfs(adj, s);
	vector<int> fromt = bfs(adj, t);
	int dist_st = froms[t];
	vector<long long int> bsums(n+1, 0), bsumt(n+1, 0);
	for(int i=1; i<n+1; i++){
		if(froms[i]!=inf) bsums[froms[i]]++;
		if(fromt[i]!=inf) bsumt[fromt[i]]++;
	}
	
	long long int ans = 0;
	for(int i=0; i<dist_st -1; i++){
		int j=dist_st -i -2;
		if(i<j){
			ans += bsums[i]*bsumt[j] +bsums[j]*bsumt[i];
		}else if(i==j){
			ans += bsums[i]*bsumt[j];
		}
	}
	for(int i=0; i<m; i++){
		if(froms[x[i]] + fromt[y[i]] == dist_st-2 ||
		froms[y[i]] + fromt[x[i]] == dist_st-2){
			 ans--;
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

int main() {
	// your code goes here
	
	while(true){
	int m,n,oyatu[1001][5],maxim[4];
	cin >> n;
	if(n==0)
	break;
	for(int i=1;i<=n;i++)
		for(int j=0;j<4;j++){
			cin >> oyatu[i][j];
			oyatu[i][4]=oyatu[i][1]*4+oyatu[i][2]*9+oyatu[i][3]*4;
		}
		for(int j=0;j<4;j++)
			cin >> maxim[j];
	int outputed=0;
	for(int i=1;i<=n;i++){
		int ans=1;
		for(int j=0;j<4;j++)
			if(maxim[j]<oyatu[i][j+1])
				ans=0;
		if(ans){
		cout << oyatu[i][0] << endl;
		outputed=1;
		}
	}
	if(!outputed)
	cout << "NA" << endl;
	}
	return 0;
}

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

int main(){
	int x, y, temp;

	while(1){
		cin >> x >> y;

		if(x == 0 && y == 0) break;

		if(x > y){
			temp = x;
			x = y;
			y = temp;
		}

		cout << x << " " << y << endl;
	}

	return 0;
}

Measured memory_bytes: 3036
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
using namespace std;

int main(void){
	int N,K,i;
	cin >> N >> K;
	string s;
	unordered_set<int> D;
	while(getline(cin, s, ' ')){
		D.insert(stoi(s));
	}
	int n = N;
	int a,b,c,d,e;
	int num;
	for(;n <= 100000;++n){
		num = n;
		d = num % 10;
		num /= 10;
		c = num % 10;
		num /= 10;
		b = num % 10;
		num /= 10;
		a = num % 10;
        num /= 10;
        e = num % 10;
		if(n < 10){
			a = -1;
			b = -1;
			c = -1;
            e = -1;
		}else if(n < 100){
			a = -1;
			b = -1;
            e = -1;
		}else if(n < 1000){
			a = -1;
		    e = -1;
        }else if(n < 10000){
            e = -1;
        }
		if(D.find(a) == D.end() && D.find(b) == D.end() && D.find(c) == D.end() && D.find(d) == D.end() && D.find(e) == D.end()){
			cout << n;
			break;
		}
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    long long int a, b, c, d, ans;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    ans = a * c;
    if(a * d > ans) ans = a * d;
    if(b * c > ans) ans = b * c;
    if(b * d > ans) ans = b * d;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1716
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
bool BinarySerach(const vector<int> &S,int key)
{
    int start = 0;
    int end = S.size() - 1;
    int middle;
     
    while(1){
        middle = ceil((end - start)/2.) + start;
        if(S[middle] == key){
            return true;
        }else if(start == end){
            return false;
        }else if(S[middle] < key){
            start = middle + 1;
        }else if(S[middle] > key){
            end = middle - 1;
        }
    }
} 
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int n,q;
    vector<int> S;
     
    cin >> n;
    S.resize(n);
     
    for(int i=0; i<n; i++){
        cin >> S[i];
    }
    cin >> q;
    int count = 0;
    for(int i=0; i<q;i++){
        int key;
        cin >> key;
        if(std::binary_search(S.begin(), S.end(), key)){
            count++;
//          cout << "key:" << key << endl;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 1532