akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  string S;
  cin>>S;
  ll a=0;
  ll b=0;
  FOR(i,0,S.size()-1){
  if(S[i]=='0'){
    a++;
  }else{
    b++;
  }
  }


  cout<<min(a,b)*2<<endl;



  return 0;
}
 


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

  int p[100001];
  int sz[100001];

int root(int x)
{
  if (p[x]!=x) p[x] = root(p[x]);
  return p[x];
}

bool same(int x, int y)
{
  return root(x) == root(y);
}

void unite(int x, int y)
{
  x=root(x);y=root(y);
  if(x==y) return;
  if (sz[x] > sz[y]) swap(x,y);
  p[x] = y;
  sz[y] += sz[x];
  
  return;
}



int main()
{
  int N, M, K;
  cin >> N >> M >> K;  
    
  int minus[N+1];
  
  for(int i=0;i<N+1;i++)
  {
    p[i]=i;
    sz[i]=1;
    minus[i]=0;
  }

  for(int i=0;i<M;i++)
  {
    int k,j;
    cin >> k >> j;
    unite(k,j);
    minus[k]++;
    minus[j]++;
  }

  for(int i=0;i<K;i++)
  {
    int k,j;
    cin >> k >> j;
    
    if (same(k,j))
    {
      minus[k]++;
      minus[j]++;
    }
  }

  for(int i=1;i<N+1;i++)
  {
    if(i!=1) cout << " ";
    //printf("i: %d, root: %d, sz: %d, minus: %d\n",i,root(i),sz[root(i)],minus[i]);
    cout << sz[root(i)] - minus[i] - 1;
  }
  
  cout << endl;
  
    return 0;
}




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

#define int long long

using namespace std;

int a[100010],n;

int solve(int m) 
{
    vector<int> s(2 * n + 1);
    
    int sum = n;
    int result = 0;
    s[sum] = 1;
    int add = 1;

    for(int i=1;i<=n;i++)
    {
        if (a[i] < m)
            add -= s[sum], sum--;
        else
            sum++, add += s[sum];
            
        result += add;
        s[sum]++;
        add++;
    }
    return result;
}

int32_t main()
{
    cin >> n;

    for(int i=1;i<=n;i++)
        cin >> a[i];

    int total = n*(n+1)/2;
    total = total/2 + 1;
    total = n*(n+1)/2-total;

    int l = *min_element(a+1,a+n+1);
    int h = *max_element(a+1,a+n+1);

    if(l == h)
    {
        cout << l << endl;
        return 0;
    }

    //cout << total << endl;

    int ans = INT_MIN;

    while(l <= h)
    {
        int mid = (l+h)/2;

        int temp = solve(mid);

        //cout << mid << " " << temp << endl;

        if(temp < total)
            h = mid-1;
        else
        {
            l = mid+1;

            ans = max(ans,mid);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const string YES = "YES";
const string NO = "NO";

void solve(long long N, long long M, std::vector<long long> a,
           std::vector<long long> b) {
  vl sum(N);
  rep(i, M) {
    sum[--a[i]]++;
    sum[--b[i]]++;
  }

  itrep(s, sum) {
    if (*s % 2 != 0) {
      print(NO);
      return;
    }
  }
  print(YES);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> a(M);
  std::vector<long long> b(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
  }
  solve(N, M, std::move(a), std::move(b));
  return 0;
}


Measured memory_bytes: 2560
(let ((l (read))
      (r (read))
      (s 0)
      (e 2018)
      (ans 2019))
  (cond ((<= (+ 2018 l) r)
         (setf s 0 
               e 2018))
        ((<= (mod l 2019) (mod r 2019))
         (setf s (mod l 2019)
               e (mod r 2019)))
        (t
         (setf s (mod l 2019)
               e (+ 2019 (mod r 2019)))))
  (loop :for i :from s :to (1- e)
        :do (loop :for j :from (1+ i) :to e
                  :do (setf ans (min ans (mod (* i j) 2019)))))
  (format t "~A~%" ans))


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

int main(){
  
  int N;
  string* S;
  cin >> N;
  S = new string[N];
  for(int i=0;i<N;i++)
    cin >> S[i];
  
  int C[4] = {0};
  for(int i=0;i<N;i++){
    if(S[i] == "AC") C[0]++;
    else if(S[i] == "WA") C[1]++;
    else if(S[i] == "TLE") C[2]++;
    else if(S[i] == "RE") C[3]++;
  }
  
  cout << "AC x " << C[0] << endl;
  cout << "WA x " << C[1] << endl;
  cout << "TLE x " << C[2] << endl;
  cout << "RE x " << C[3] << endl;
  return 0;
}

Measured memory_bytes: 6712
#include <stdio.h>
#define DATAS 10

int main(void){
    int height[DATAS], tmp, minID;

    // input
    for (int i=0; i<DATAS; i++){
        scanf("%d", &height[i]);
    }
    // sort
    for (int i=0; i<DATAS; i++){
        minID = i;
        for (int j=i; j<DATAS; j++){
            if (height[j]<height[minID]) minID=j;
        }
        tmp = height[i];
        height[i] = height[minID];
        height[minID] = tmp;
    }

    for (int i=0; i<3; i++){
        printf("%d\n", height[DATAS-1-i]);
    }
   return 0;
}

Measured memory_bytes: 1028
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int N = s.length;

        int i = 0;
        long ans = 0;
        int aNum = 0;
        while (i < N) {
            if (s[i] != 'A') {
                i++;
                aNum = 0;
                continue;
            }
            while (i < N && s[i] == 'A') {
                aNum++;
                i++;
            }
            while (i < N-1 && s[i] == 'B' && s[i+1] == 'C') {
                ans += aNum;
                i += 2;
            }
        }

        System.out.println(ans);
    }
}



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

using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
const int N=1e5+5;



int32_t main() {
    faster;

    int x;
    cin>>x;

    int tmp=x/500;
    x%=500;
    int tmp1=x/5;

    cout<<tmp*1000+tmp1*5<<endl;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def max(a,b)
  return a>b ? a : b
end

def min(a,b)
  return a>b ? b : a
end
N,W=get_i
wv=array(N,1)
N.times do|i|
  wv[i]=get_i
end
wv.sort!{|x,y| x[1]<=>y[1]}
MAX_V=10**3*N
INF=Float::INFINITY
#dp=array(MAX_V+1,N+1,INF)
#dp[0][0]=0
v_sum=0
#N.times do|i|
  #w,v=wv[i]
  #v_sum+=v
  #0.upto(v_sum) do|j|
    #dp[i+1][j]=dp[i][j]
    #dp[i+1][j]=dp[i][j-v]+w if j-v>=0 and dp[i+1][j]>dp[i][j-v]+w
  #end 
#end
#max=0
#MAX_V.times do|i|
  #max=i+1 if dp[N][i+1]<=W
#end
#puts max

dp=array(MAX_V+1,1,INF)
dp[0]=0
wv.each do|w,v|
  v_sum+=v
  v_sum.downto(v) do|j|
    dp[j]=dp[j-v]+w if dp[j]>dp[j-v]+w
  end 
end
max=0
MAX_V.times do|i|
  max=i+1 if dp[i+1]<=W
end
puts max

Measured memory_bytes: 2556
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (n, k) = (nk[0], nk[1]);
        var seqP = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        Array.Sort(seqP);

        var min = seqP.Take(k).Sum();

        Console.WriteLine(min);
    }
}


Measured memory_bytes: 28376
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long X){
  for (int i = -1000; i < 1000; i++) {
    for (int l = -1000; l < 1000; l++) {
      if(pow(i,5) - pow(l,5) == X){
        cout << i << " " << l << endl;
        return;
      }
    }
  }
}

int main(){
    long long X;
	scanf("%lld",&X);
    solve(X);
}


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

int main(){
    int n, l;
    cin >> n >> l;
    int min = 1000;
    int sum = 0;
    for(int i = 0; i < n; i++){
        int taste = l + (i + 1) - 1;
        if(abs(min) > abs(taste)){
            min = taste;
        }
        sum += taste;
    }
    cout << sum - min << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, M, i, S=0, X=0; cin >> N >> M; vector<int> A(N);
for(i=0; i<N; i++){ cin >> A[i]; S+=A[i]; }
int T=(S+4*M-1)/(4*M);
for(i=0; i<N; i++){ if(A[i]>=T){ X++; } }
string ans="";
if(M<=X){ ans="Yes"; }else{ ans="No"; }
cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n,a,b,c,d;
    cin >>n >>a >>b >>c >>d;

    int x = (n+a-1)/a, y = (n+c-1)/c;
    cout << min(b*x, d*y) << endl;
    return 0;
}



Measured memory_bytes: 3112
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            for (int j = 0; j < h; j++) {
                String s = "";
                for (int i = 0; i < w; i++) {
                    if (j == 0 || j == h - 1) {
                        s = s + "#";
                    } else if (i == 0 || i == w - 1) {
                        s = s + "#";
                    } else {
                        s = s + ".";

                    }

                }
                System.out.println(s);

            }
            if (h == 0 || w == 0) {
                break;
            }
            System.out.print("\n");

        }

    }

}

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

//#define USE_FILES 1

#ifdef USE_FILES
ifstream fin("tmp.in");
ofstream fout("tmp.out");
#define cin fin
#define cout fout
#endif // USE_FILES

int n, x, nr, v[103];

int main() {
    cin >> n >> x;
    for (int i = 1; i <= n; ++i) {
        cin >>v[i];
    }
    sort(v + 1, v + n + 1);
    for (int i = 1; i < n; ++i) {
        if (x < v[i]) {
            x = 0;
            break;
        }
        ++nr;
        x -= v[i];
    }
    if (x == v[n]) {
        ++nr;
    }
    cout << nr;
    return 0;
}



Measured memory_bytes: 256
// O(N)で実行できるコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int n,sum=0,partsum=0,ans;
  cin >> n;
  vector<int> w(n);
  for(int i=0;i<n;i++){
    cin >> w[i];
    sum += w[i];
  }
  ans = sum;
  for(int i=0;i<n;i++){
    partsum += w[i];
    ans = min(ans, abs(partsum-(sum-partsum)));
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

const long double PI=acos(-1.0);

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

  long double a=A,b=B,x=X;
  x/=a;

  long double ok=PI/2,ng=0;
  while(ok-ng>1e-8){
    long double mid=(ok+ng)/2;
    long double v;
    if(b*tan(PI/2-mid)<=a){
      long double h=b*tan(PI/2-mid);
      v=h*b/2;
    }else{
      long double l=a/tan(PI/2-mid);
      v=a*l/2+a*(b-l);
    }
    if(v>=x) ng=mid;
    else ok=mid;
  }

  long double ans=(ok/PI)*180.0;
  cout<<fixed<<setprecision(10)<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b;
  cin >> a >> b;
  if((a+b)%2 != 0) cout << "IMPOSSIBLE" << endl;
  else cout << (a+b)/2 << endl;

  }


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
n,m = list(map(int,input().split()))

d = {}
for i in range(m):
    fr, to = list(map(int,input().split()))
    d[fr] = d.get(fr, []) + [to]
    d[to] = d.get(to, []) + [fr]
    
visited = [0 for i in range(n+1)]

def connect(node, i):
    visited[node] = i
    
    if node in d:
        for neig in d[node]:
            if visited[neig] == 0:
                connect(neig, i)
ans = 1
for key in range(1,n+1):
    if visited[key] == 0:
        connect(key, ans)
        ans += 1

print(max(visited)-1)



Measured memory_bytes: 48340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 2003;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> t(n),a(n);
	FOR(i,0,n)cin>>t[i];
	FOR(i,0,n)cin>>a[i];
	if(t[n-1]!=a[0]){
		pri(0);
		return 0;
	}
	ll k1[n],k2[n];
	bool b1[n]={false},b2[n]={false};
	//true *1
	FOR(i,0,n){
		ll j = n-1-i;
		if(i==0){
			b1[i]=true;
			b2[j]=true;
		}else{
			if(t[i]!=t[i-1])b1[i] = true;
			if(a[j]!=a[j+1])b2[j] = true;
		}
	}
	ll ans = 1;
	FOR(i,0,n){
		if(b1[i]&&b2[i]){
			if(a[i]!=t[i]){
				pri(0);
				return 0;
			}
		}else if(b1[i]){
			if(t[i]>a[i]){
				pri(0);
				return 0;
			}
		}else if(b2[i]){
			if(a[i]>t[i]){
				pri(0);
				return 0;
			}
		}else{
			ans *= min(a[i],t[i]);
			ans %= MOD;
		}
	}
	pri(ans);
}

Measured memory_bytes: 2048
# -*- coding: utf-8 -*-
k,n = list(map(int,input().split()))
a = list(map(int,input().split()))
#一番遠いところを回らない
b = a+[a[0]+k]
longest_distance = 0
for bi,ai in zip(b[1::],a):
    longest_distance=max(longest_distance,bi-ai)
print(k-longest_distance)

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

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define all(v) (v).begin(),(v).end()
typedef long long ll;

const int N = 1e5+10;
ll va[N], vb[N], vc[N];

int main(){
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	
	fr(i,a) scanf("%lld", va+i);
	fr(i,b) scanf("%lld", vb+i);
	fr(i,c) scanf("%lld", vc+i);
	
	sort(va,va+a);
	sort(vb,vb+b);
	sort(vc,vc+c);
	reverse(va,va+a);
	reverse(vb,vb+b);
	reverse(vc,vc+c);
	
	ll ans = 0;
	
	vector<ll> cur;
	
	fr(i,x){
		cur.push_back(va[i]);
		ans+=va[i];
	}
	
	fr(i,y){
		cur.push_back(vb[i]);
		ans+=vb[i];
	}
	
	sort(all(cur));
	
	int ic = 0;
	int icur = 0;
	while(ic<c and icur<sz(cur)){
		if(vc[ic]<=cur[icur]){
			break;
		}
		ans+=vc[ic]-cur[icur];
		ic++, icur++;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 4724
from fractions import gcd
import math

def lcm(l):
  x = l[0]
  for i in range(1, len(l)):
    x = (x * l[i]) // gcd(x, l[i])
  return x  

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*N
cnt = [0]*N

for i in range(N):
  a = A[i]
  B[i] = a//2
  while a % 2 == 0:
    a /= 2
    cnt[i] += 1

cnt = set(cnt)
if len(cnt) != 1:
  print(0)
  exit()

x = lcm(B)
ans = 0

a = M//x
if a % 2:
  a += 1
print(a//2)

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

#define ll long long int

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(),(v).end()

using namespace std;
///////////////////////////////////////////////////////

string s;
map<char,char> M;

int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin>>s;

	REP(i,s.size()){
		if(M[s[i]]){
			cout<< "no"<<endl;
			return 0;
		}
		else{
			M[s[i]] = 1;
		}
	}

	cout<<"yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
using namespace std;
int main() {
    int N;
  	cin >> N;
    vector<int> v(N);
  	vector<int> p(N);
  	vector<int> q(N);
    for(int i=0;i<N;i++) v[i] = i+1;      // v に 1, 2, ... N を設定
    for(int i=0;i<N;i++) cin >> p[i];
    for(int i=0;i<N;i++) cin >> q[i];
  	int count = 0;
  	int n_p, n_q;
    do {
      	count++;
        for(int i=0;i<N;i++){
          if(v[i] != p[i]) break;
          if(i==N-1) n_p = count;
        }
      	for(int i=0;i<N;i++){
          if(v[i] != q[i]) break;
          if(i==N-1) n_q = count;
        }
    } while( next_permutation(v.begin(), v.end()) );// 次の順列を生成
  	if(n_p >= n_q) cout << n_p - n_q << endl;
  	else cout << n_q - n_p << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;

int main(void){
    long long int a, b;
    cin >> a >> b;
    long long int check = 1;
    for(int i = 2; i <= min(a, b); i++){
        if(a%i==0 && b%i==0)
            check = i;
        
    }
    //cout << check << endl;
    cout << (a/check)*(b/check)*check << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;

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

    ll dp[W+1];
    memset(dp, 0, sizeof(dp));

    ll w, v;
    for(int i = 0; i < n; i++){
        cin >> w >> v;
        for(int j = W; j >= w; j--){
            dp[j] = max(dp[j], dp[j-w]+v);
        }
    }

    cout << dp[W] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<P,int>PP;

signed main() {
	int n; cin >> n;
	string s, t; cin >> s >> t;
	rep(i, n)cout << s[i] << t[i];
	cout << endl;
}

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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    int N; cin >> N;
    vector<int> cnt(N+1);

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = i; j <= N; j += i) {
            cnt[j]++;
        }
        ans += (ll)cnt[i] * i;
    }

    cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  
  int max_A, min_A;
  int A;
  cin >> A;
  max_A = min_A = A;

  for (int i=1;i<N;i++) {
    cin >> A;
    max_A = (max_A<A)? A : max_A;
    min_A = (min_A>A)? A : min_A;
  }

  cout << max_A - min_A << endl;
}
  
  

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
void dfs_visit(int);
void dfs(void);
int n,M[N][N];
int color[N],d[N],f[N],tt;
int main(){
  int u,v,k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
	for(j=0;j<n;j++) M[i][j]=0;
  }
  for(i=0;i<n;i++){
	scanf("%d %d",&u,&k);
	u--;
	for(j=0;j<k;j++){
	  scanf("%d",&v);
	  v--;
	  M[u][v]=1;
	}
  }
  dfs();
  return 0;
}

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
	if(M[u][v]==0) continue;
	if(color[v]==WHITE){
	  dfs_visit(v);
	}
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(void){
  int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  tt=0;
  for(u=0;u<n;u++){
	if(color[u]==WHITE) dfs_visit(u);
  }
  for(u=0;u<n;u++){
	printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}



Measured memory_bytes: 2108
n = int(input())

count1 = 0

for i in range(1,n+1):
  a = i%2
  b = i/2
  count = 1
  while a ==0:
    a = b%2
    b = b/2
    count += 1
  if count > count1:
    count1 = count
    max_num = i
print(max_num)

Measured memory_bytes: 3060
# AGC031A - Colorful Subsequence
def main():
    _ = int(input())
    S = input().rstrip()
    MOD = 10 ** 9 + 7
    ans = 1
    for i in set(S):
        ans = (ans * (S.count(i) + 1)) % MOD
    print(ans - 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
def A(x):
  return x + x**2 + x**3


def B(s, t):
  ans = 0
  for i in range(len(s)):
    if s[i] != t[i]:
      ans += 1
  return ans


def C(n, m, k, a, b):

  def _get_acc(x):
    acc = [0]
    for idx in range(len(x)):
      acc.append(x[idx] + acc[idx])
    return acc

  acc_a = _get_acc(a)
  acc_b = _get_acc(b)

  pa = 0
  pb = 0

  while pa <= n and acc_a[pa] <= k:
    pa += 1
  pa -= 1

  max_num = 0
  while True:
    if pa < 0 or pb > m:
      break
    if acc_a[pa] + acc_b[pb] <= k:
      if max_num < pa + pb:
        max_num = pa + pb
      pb += 1
    else:
      pa -= 1

  return max_num


def main():
  n, m, k = map(int, input().split())
  a = list(map(int, input().split()))
  b = list(map(int, input().split()))
  print(C(n, m, k, a, b))


if __name__ == '__main__':
  main()


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

using namespace std;
using ll = long long;

int main(){

ll N;
string S;

cin >> N;

set<string> setS;

for(ll i = 0;i < N;++i){
  cin >> S;
  setS.insert(S);
}

ll ans = setS.size();

cout << ans << endl;

return 0;

}

Measured memory_bytes: 19132
import java.math.BigInteger;
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger a[] = new BigInteger[n];
        BigInteger stool = BigInteger.ZERO;
        for(int i=0;i<n;i++)
            a[i] = sc.nextBigInteger();

        for(int i=1;i<n;i++){
        	if(a[i].compareTo(a[i-1])==-1){
        		BigInteger x = (a[i-1].subtract(a[i]));
        		stool = stool.add(x);
        		a[i] = a[i-1];
        	}
        }
        System.out.println(stool);

  	}
}



Measured memory_bytes: 73872
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head
template<class T>T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<class T>T lcm(T a, T b) { return a*b / gcd(a,b); }

template<class T> vector<pair<T,int>> prime_factor(T n){
    vector<pair<T, int>> result;
    for (int i=2; i<=sqrt(n); i++){
        int count = 0;
        while (n % i == 0) { count ++; n /=i; } 
        if (count) { result.push_back(make_pair(i, count)); }
    }if (n != 1) { result.push_back(make_pair(n, 1)); }
    return result;
}

int main(){
    long long a,b;
    cin >> a >> b;
    long long g=gcd(a,b);
    vector<pair<long long, int>> pr = prime_factor(g);
    cout  << pr.size()+1 << endl;
}

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

int main(){

	int N ; 
	int i ;
	int outputNum = 1 ;
	
	cin >> N ;

	//10の6乗は100万。2の20乗は100万より少し大きい
	for( i =0 ; i <= 20; ){

		if( N < outputNum ){
		cout << outputNum / 2 << endl ;
		break;  //For文から抜ける
		}else{ //何もしない
		}

	outputNum = outputNum * 2 ;
	i = i + 1;
	}
	

}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000005
int ct[MAX];

int main() 
{
    int n,x;
    cin >> n;
    
    for(int i=0;i<n;i++) {
        cin >> x;
        
        for(int j=2;j*j<=x;j++){
            if(x%j==0){
                ct[j]++;
                while(x%j==0){
                    x/=j;
                }
            }
        }
        if(x>1) ct[x]++;
    }
    
    bool isPairwise = true;
    for(int i=2;i<MAX;i++){
        if(ct[i]>=2){
            isPairwise = false;
            break;
        }
    }
    
    if(isPairwise) {
        cout<<"pairwise coprime\n";
        return 0;
    }
    bool isSetwise = true;
    for(int i=2;i<MAX;i++){
        if(ct[i]==n){
            isSetwise = false; 
            break;
        }
    }
    
    if(isSetwise) {
        cout<<"setwise coprime\n";
        return 0;
    }
    
    cout<<"not coprime\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

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

ll n;

int main(){
	cin >> n;
	vector<P> vp(n);
	rep(i,n)cin >> vp[i].second >> vp[i].first;
	sort(ALL(vp));
	ll now = 0;
	rep(i,n){
		ll w = vp[i].second;
		ll e = vp[i].first;
		if(now+w <= e)now += w;
		else {
			cout << "No" << endl;
			return 0;
		}
	}	
	cout << "Yes" << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n,d;
	cin>>n>>d;
	cout<<ceil((n)/(1.0+2*d))<<endl;
}

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

using namespace std;

void solve()
{
	string str;
	getline(cin, str);
	int size = str.size();
	for(int i = 0; i < size; ++i)
	{
		if(str[i] == 'p' && str[i + 1] == 'e' && str[i + 2] == 'a' && str[i + 3] == 'c' && str[i + 4] == 'h')
		{
			str[i] = 'a';
			str[i + 1] = 'p';
			str[i + 2] = 'p';
			str[i + 3] = 'l';
			str[i + 4] = 'e';
		}
		else if(str[i] == 'a' && str[i + 1] == 'p' && str[i + 2] == 'p' && str[i + 3] == 'l' && str[i + 4] == 'e')
		{
			str[i] = 'p';
			str[i + 1] = 'e';
			str[i + 2] = 'a';
			str[i + 3] = 'c';
			str[i + 4] = 'h';
		}
	}
	cout << str << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.IO;
using System.Text;

public class Solver
{
    public void Solve()
    {
        Console.WriteLine((ri - 2) * 180);
    }

    int ri { get { return sc.Integer(); } }
    long rl { get { return sc.Long(); } }
    double rd { get { return sc.Double(); } }
    string rs { get { return sc.Scan(); } }
    public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());

    private const int mod = 1000000007;
    int PowUpper(int n, int b) { int p = 1; while (p <= n) { p *= b; } return p; }
    int Abs(int n) { return (n > 0) ? n : -n; }
    int Gcd(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = Gcd(p, n[i]); } return p; }
    int Gcd(int a, int b) { return (a == 0) ? b : Gcd(b % a, a); }
    int Lcm(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = Lcm(p, n[i]); } return p; }
    int Lcm(int a, int b) { return a * b / Gcd(a, b); }
    int Max(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = (p > n[i]) ? p : n[i]; } return p; }
    int Min(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = (p < n[i]) ? p : n[i]; } return p; }
    void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
    void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
    void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
}

static class Program
{
    static public void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}

public class StreamScanner
{
    public StreamScanner(Stream stream) { str = stream; }
    private readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public bool IsEndOfStream { get { return isEof; } }
    private byte read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
    public char Char()
    {
        byte b = 0;
        do b = read();
        while (b < 33 || 126 < b);
        return (char)b;
    }
    public string Scan()
    {
        var sb = new StringBuilder();
        for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
            sb.Append(b);
        return sb.ToString();
    }
    public long Long()
    {
        long ret = 0; byte b = 0; var ng = false;
        do b = read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-') { ng = true; b = read(); }
        for (; true; b = read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }
    public int Integer() { return (int)Long(); }
    public double Double() { return double.Parse(Scan()); }
}


Measured memory_bytes: 11092
// aribon2-6-4_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

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

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

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

int euler_totient(int n){
    int x=n;
    int sqrt_n = (int) sqrt(n);
    int ret = n;
    REPN(p, 2, sqrt_n+1){
        if (n % p == 0){
            ret = (ret / p) * (p-1);
            while (n % p == 0) n /= p;
        }
    }
    if (n > 1) {
        ret = (ret / n) * (n-1);
    }

    return ret;
}

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

    int t;
    cin >> t;
    vector<ll> farey(1000001);
    farey[0] = 1;
    REPN(i, 1, 1000001) {
        farey[i] = farey[i-1] + (ll)euler_totient(i);
    }

    REP(i, t){
        int n;
        cin >> n;
        print(farey[n]);
    }

    return 0;
}



Measured memory_bytes: 10636
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#include <set>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){

  int m;
  cin >> m;
  
  cout << 48 - m << endl;


 return 0;
}

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


#define M 10

using namespace std;

int NUM[M]={0,1,2,3,4,5,6,7,8,9};
int ans;




int Combination(int n, int i, int j, int kumi[M]){
    int br=0;
    /*
    for(int c=0; c<n; c++){
        cout<<kumi[c]<<" ";
    }cout<<endl;
     */
    /*for(int k=0; k<i; k++){
        cout<<kumi[k]<<" ";
        br+=(i-k)*kumi[k];
        
    }
    cout<<" br :"<<br<<endl;
    if(br>n)return 0;
    */
    if(i==n){
        int ret=0;
        int br=0, br2=0;
        for(int c=0; c<n; c++){
            //cout<<kumi[c]<<" ";
            br+=(n-c)*kumi[c];
            br2+=(c+1)*kumi[c];
            
        }//cout<<br<<endl;
        if(br>ans)return 0;
        if(br2<ans)return 0;
        do{
            int s=0;
            int k=1;
            for(int c=0; c<n; c++){
                s+=k*kumi[c];
                k++;
            }
            if(ans==s)ret++;
            
        }while(next_permutation(kumi, kumi+n));
        return ret;
    }
    if(j==M){
        return 0;
    }
    int ret1,ret2;
    ret1=Combination(n, i, j+1, kumi);
    kumi[i]=NUM[j];
    ret2=Combination(n, i+1, j+1, kumi);
    return ret1+ret2;
}

int main()
{
    int kumi[M]={0};
    int n;
    while(cin>>n>>ans){
        cout<<Combination(n,0,0,kumi)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import numpy as np 
h, w, k = map(int, input().split())
s = [list(input()) for _ in range(h)]
moves = ((1, 0), (-1, 0))
ans = [[0]*w for _ in range(h)]


def dfs(y, x, col):
  ans[y][x] = col
  for dy, dx in moves:
    ny = y + dy 
    nx = x + dx 
    if 0 <= ny < h and 0 <= nx < w and ans[ny][nx] == 0 and s[ny][nx] == '.':
      dfs(ny, nx, col)

col = 1
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      dfs(i, j, col)
      col += 1

ans = np.array(ans)
"""
for i in range(1, w):
  if sum(ans[:,i]) == 0:
    for j in range(h):
      ans[j][i] = ans[j][i-1]"""
for i in range(1, w):
  if 0 in ans[:,i]:
    for j in range(h):
      if ans[j][i] == 0:
        ans[j][i] = ans[j][i-1]
for i in range(w-1, -1, -1):
  if 0 in ans[:,i]:
    for j in range(h):
      if ans[j][i] == 0:
        ans[j][i] = ans[j][i+1]
if 0 in ans[:,0]:
    for j in range(h):
      if ans[j][0] == 0:
        ans[j][0] = ans[j][1]

for i in range(h):
  for j in range(w):
    print(ans[i][j], end=" ")
  print()

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

template<typename T>
inline T pow(T a, long long n) {
    T ret = 1; while (n) { if (n & 1) ret *= a; n >>= 1; a *= a; }
    return ret;
}

int main() {
    int n; cin >> n;
    if (n <= 2) return !(cout << vector<int>{1, 2, 1}[n] << endl);
    cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 3112
A, B, C, K = map(int, input().split())

mx  = 0
rk = K

if rk > 0:
  mx += 1*min(A,rk)
  rk = rk - A
  
if rk >0:
  rk = rk - B
  
if rk>0:
  mx += -1*min(C,rk)
  
print(mx)

Measured memory_bytes: 9172
import java.util.*;

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

        int N = sc.nextInt();
        int A = sc.nextInt();
        
        N = N % 500;
        
        if(A < N)
            System.out.println("No");
        else
            System.out.println("Yes");

    }
}

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

using namespace std;
int rs=0,n;
void solve1()
{
    rs = (n-1)*((n-3)/2+1);
    cout << rs << '\n';
    for(int i=0; i<n-1; ++i)
    {
        for(int j = i+1; j < n; j++) if(i+j != n-2)
            cout << (i+1) << " " << (j+1) << '\n';
    }
}
void solve2()
{
    rs = n*(n-2)/2;
    cout << rs << '\n';
    for(int i=0; i<n; ++i)
    {
        for(int j = i+1; j < n; j++)
        if(i+j != n-1) cout << (i+1) << " " << (j+1) << '\n';
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    cin >> n;
    if (n%2==1) solve1();
    else solve2();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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

















int main(){
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    bool f = false;
    for(ll i = n - m; i >= 0; i--){
        bool ok = true;
        REP(j, m){
            if(s[i + j] == '?') continue;
            if(s[i + j] != t[j]){
                ok = false;
                break;
            }
        }
        if(ok){
            REP(j, m){
                s[i + j] = t[j];
            }
            f = true;
            break;
        }
    }
    if(!f){
        cout << "UNRESTORABLE"<< endl;
        return 0;
    }
    REP(i, n){
        if(s[i] == '?') s[i] = 'a';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#define int long long
using namespace std;
set<int>s, t;
int n, p;
signed main() {
	cin >> n; for (int i = 0; i < n; i++) {
	    cin >> p; s.insert(p); 
	}
	cin >> n; for (int i = 0; i < n; i++) { 
	    cin >> p; if (s.count(p))t.insert(p); 
	    
	}
	for (int i : t)
	cout << i << endl;
	return 0;
}


Measured memory_bytes: 14320
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll a[100001];
ll b[100001];
map<ll,ll> mp;
int main() {
  ll n, m;
  scanf("%lld%lld", &n, &m);
  rep(i, n){
   scanf("%lld",&a[i]);
  }
  reps(i, n){
    b[i] = b[i-1] + a[i-1];
  }

  mp[0] = 1;
  reps(i, n){
    mp[b[i] % m]++;
  }
  ll sum = 0;
  for(auto at : mp){
    sum += at.second*(at.second-1)/2;
  }
  cout << sum << endl;
}


Measured memory_bytes: 5760
p=*0..gets.to_i
s=0
f=->a{a>p[a]?p[a]=f[p[a]]:a}
a,b=$<.map(&:split).transpose.map{|a|i=0
a.map{[_1.to_i,i+=1]}.sort.each_cons(2).map{[_2[0]-_1[0],_1[1],_2[1]]}}
(a+b).sort.map{|c,*a|a,b=a.map(&f).sort
a<b&&(s+=c
p[b]=a)}
p s

Measured memory_bytes: 52124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
const long double PI=(acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int cnt=0;
  for(int i=100;true;i--){
    if((a%i==0)&&(b%i==0)){
      cnt++;
    }
    if(cnt==k){
      cout<<i<<endl;
      break;
    }
  }
  
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_string();

    if line == "ABC"{
        println!("ARC");
    }else{
        println!("ABC");
    }
}


Measured memory_bytes: 2108
a=input()
#b=reversed(a)
c=a[0:int((len(a)-1)/2)]
b=''.join(list(reversed(a)))
d=a[int((len(a)+3)/2)-1:]

if a!=b:
  print("No")
elif c!=d:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
    
#define int long long
    
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
    
using namespace std;
    
int dy[4]={1, 0, -1, 0};
int dx[4]={0, 1, 0, -1};

int32_t main(){
    int n;
    cin >> n;
    int v[n][10];
    REP(i, n){
        REP(j, 10){
            cin >> v[i][j];
        }
    }

    int p[n][11];
    REP(i, n){
        REP(j, 11){
            cin >> p[i][j];
        }
    }   

    int ans=-INF;
    FOR(i, 1, (1 << 10)){
        int cnt=0;
        REP(j, n){
            int c=0;
            REP(k, 10){
                if((i & (1 << k)) && v[j][k]){
                    c++;
                }
            }
            cnt+=p[j][c];
        }
        ans=max(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
program ARC068C
    implicit none
    integer(8)::x
    integer(8)::result=0
    read(5,*)x

    result=x/11
    result=result*2

    if(mod(x,11)>=7)then
        result=result+2
    else if(mod(x,11)/=0)then
        result=result+1
    end if

    print'(i0)',result
    
end program ARC068C

Measured memory_bytes: 640
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def battle(enemy, r, s, p):
    if enemy == "r":
        return p
    if enemy == "s":
        return r
    if enemy == "p":
        return s


def main():
    N, K = MI()
    r, s, p = MI()
    t = input()
    splited_t = [[] for i in range(K)]

    for i in range(N):
        amari = i % K
        splited_t[amari].append(t[i])

    ans = 0
    for i in range(K):
        targets = splited_t[i]
        score = battle(targets[0], r, s, p)
        ans += score
        won = True
        for j in range(1, len(targets)):
            if targets[j] == targets[j - 1] and won:
                won = False
                continue
            score = battle(targets[j], r, s, p)
            won = True
            ans += score
    print(ans)


main()


Measured memory_bytes: 84512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a<b){
			System.out.println("a < b");
		}else if (a==b){
			System.out.println("a == b");
		}else{
			System.out.println("a > b");
		}
	}
}

Measured memory_bytes: 26232
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

s = input()
ans = 0
for i in range(len(s)):
    if s[i] == "+":
        ans+=1
    else:
        ans-=1
print(ans)

Measured memory_bytes: 3316