akhauriyash/Code-Regression huggingface dataset:
using System;

class MainClass
{
    public static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int H = int.Parse(s[0]);
        int W = int.Parse(s[1]);
        int D = int.Parse(s[2]);
        int[] Ax = new int[H * W + 1];
        int[] Ay = new int[W * H + 1];

        int[,] magic = new int[H, W];
        for (int i = 0; i < H; i++)
        {
            s = Console.ReadLine().Split(' ');
            for (int j = 0; j < W; j++)
            {

                Ax[int.Parse(s[j])] = i;
                Ay[int.Parse(s[j])] = j;
            }
        }
        int Q = int.Parse(Console.ReadLine());
        int[] L = new int[Q];
        int[] R = new int[Q];

        for (int i = 0; i < Q; i++)
        {
            s = Console.ReadLine().Split(' ');
            L[i] = int.Parse(s[0]);
            R[i] = int.Parse(s[1]);
        }

        int[] magicSum = new int[H * W + 1];

        for (int i = D + 1; i < H * W + 1; i++)
        {
            magicSum[i] = magicSum[i - D] + Math.Abs(Ax[i]-Ax[i-D]) + Math.Abs(Ay[i] - Ay[i - D]);
        }

        for (int num = 0; num < Q; num++)
        {
            int ans = magicSum[R[num]] - magicSum[L[num]] ;

            Console.WriteLine(ans);
        }

    }
}


Measured memory_bytes: 18108
//Depth First Search
#include<stdio.h>

#define N 100
#define UNVISITED 0
#define VISITED 1
#define VISIT_COMP 2

//Depth First Search
void dfs_visit(int);
void dfs();

int n,M[N][N];
int color[N],d[N],f[N],tt;


int main(){
	int u,v,k,i,j;


	//input
	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]=VISITED;
	//最初の訪問
	d[u]= ++tt;
	for(v=0;v<n;v++){
		if(M[u][v]==0){
			continue;
		}
		if(color[v]==UNVISITED){
			dfs_visit(v);
		}
	}
	color[u]=VISIT_COMP;
	//訪問の完了
	f[u]= ++tt;
}

void dfs(){
	int u;

	//init
	for(u=0;u<n;u++){
		color[u]=UNVISITED;
	}
	tt=0;

	for(u=0;u<n;u++){
		//未訪問のuを始点として深さ優先探索
		if(color[u]==UNVISITED){
			dfs_visit(u);
		}
	}
	for(u=0;u<n;u++){
		printf("%d %d %d\n",u+1,d[u],f[u]);
	}
}



Measured memory_bytes: 2112
#include<iostream>
using namespace std;
int main()
{
	int n,m,c;
	int b[25];
	//int a[25];
	cin>>n>>m>>c;
	for(int i=0;i<m;i++){
		cin>>b[i];
	}	
	int num=0;
	for(int i=0;i<n;i++){
		int sum=0,x;
		for(int j=0;j<m;j++){
			cin>>x;
			sum+=x*b[j];
		}
		sum+=c;
		if(sum>0) num++;
	}
	cout<<num<<endl;
} 

Measured memory_bytes: 256
N=int(input())
tasks={}
for i in range(N):
    A,B=[int(i) for i in input().split(" ")]
    tasks[B]=tasks.get(B,0)+A

time=0
tasks=sorted(tasks.items(),key=lambda w:w[0])
for task in tasks:
    time+=task[1]
    if time>task[0]:
        print("No")
        break
else:
    print("Yes")


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> H(N);

    REP(i, N){
        cin >> H[i];
    }
    ll maxH = H[0];
    ll ans = 1;
    for(ll i=1; i<N; i++){
        if(maxH <= H[i]){
            ans++;
            maxH = H[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
char c[1000000];
int pre[1000000][2],las[1000000][2];
int dp[1000000];
set<int> lie[1000000],hang[1000000];
int main(){
	fastio;
	int h,w,k,s[2],t[2];
	cin>>h>>w>>k>>s[0]>>s[1]>>t[0]>>t[1];
	s[0]--;
	s[1]--;
	t[0]--;
	t[1]--;
	rep(i,h)
		rep(j,w)
			cin>>c[i*w+j];
	rep(i,h){
		pre[i*w][0]=-1;
		rep(j,w){
			pre[i*w+j][0]=pre[i*w+max(0,j-1)][0];
			if(c[i*w+j]=='@'){
				pre[i*w+j][0]=j;
			}
		}
	}
	rep(j,w){
		pre[j][1]=-1;
		rep(i,h){
			pre[i*w+j][1]=pre[max(0,i-1)*w+j][1];
			if(c[i*w+j]=='@'){
				pre[i*w+j][1]=i;
			}
		} 
	}
	rep(i,h){
		las[i*w+w-1][0]=INF;
		rl(j,w-1,0){
			las[i*w+j][0]=las[i*w+min(w-1,j+1)][0];
			if(c[i*w+j]=='@'){
				las[i*w+j][0]=j;
			}
		}
	}
	rep(j,w){
		las[j+(h-1)*w][1]=INF;
		rl(i,h-1,0){
			las[i*w+j][1]=las[min(h-1,i+1)*w+j][1];
			if(c[i*w+j]=='@'){
				las[i*w+j][1]=i;
			}
		}
	}
	memset(dp,63,sizeof(dp));
	queue<int> q;
	dp[s[0]*w+s[1]]=0;
	q.push(s[0]*w+s[1]);
	rep(i,h)
		rep(j,w){
			if(c[i*w+j]!='@')
			hang[i].insert(i*w+j);
		}
	rep(j,w)
		rep(i,h){
			if(c[i*w+j]=='.')
			lie[j].insert(i*w+j);
		}
	set<int> :: IT ite,nex;
	while(!q.empty()){
		int x,y;
		x=q.front();
		q.pop();
		y=x%w;
		x=(x-y)/w;
//		cout<<x<<" "<<y<<" "<<dp[x*w+y]<<endl;
		int l,r;
		l=y-k;
		l=max(l,pre[x*w+y][0]+1);
		l=max(0,l);
		r=y+k;
		r=min(w-1,r);
		r=min(r,las[x*w+y][0]-1);
//		cout<<l<<" "<<r<<endl;
		ite=hang[x].lower_bound(x*w+l);
//		cout<<*ite<<endl;
		for(;ite!=hang[x].end()&&*ite<=x*w+r;ite=nex){
			if(dp[*ite]>dp[x*w+y]+1){
				dp[*ite]=dp[x*w+y]+1;
//				cout<<"!"<<endl;
				q.push(*ite);
			}
			ite++;
			nex=ite;
			ite--;
			hang[x].erase(ite);
		}
		l=x-k;
		l=max(l,pre[x*w+y][1]+1);
		l=max(0,l);
		r=x+k;
		r=min(h-1,r);
		r=min(r,las[x*w+y][1]-1);
		ite=lie[y].lower_bound(l*w+y);
		for(;ite!=lie[y].end()&&*ite<=r*w+y;ite=nex){
			if(dp[*ite]>dp[x*w+y]+1){
				dp[*ite]=dp[x*w+y]+1;
				q.push(*ite);
			}
			ite++;
			nex=ite;
			ite--;
			lie[y].erase(ite);
		}
	}
	if(dp[t[0]*w+t[1]]==INF){
		dp[t[0]*w+t[1]]=-1;
	}
	cout<<dp[t[0]*w+t[1]]<<endl;
	return 0;
}
/*
3 5 2
3 2 3 5
.....
.....
.....

*/


Measured memory_bytes: 211196
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF=1e9;
int dp[3][1000][80];
int main(){
  int n,m,k,x,d;
  while(cin>>n>>m&&(n||m)){
    vector<P>stone[150];
    REP(i,n){
      cin>>k;
      REP(j,k){
        cin>>x>>d;x--;
        stone[i].PB(MP(x,d));
      }
    }
    REP(i,3)REP(j,1000)REP(k,80)dp[i][j][k]=INF;
    REP(i,stone[0].size())dp[0][stone[0][i].first][0]=0;
    REP(i,stone[1].size())dp[1][stone[1][i].first][1]=0;
    REP(i,n-1){
      REP(j,1000)REP(x,80)dp[(i+2)%3][j][x]=INF;
      REP(j,stone[i].size()){
        REP(x,stone[i+1].size()){
          REP(y,m+1){
            dp[(i+1)%3][stone[i+1][x].first][y]=min(dp[(i+1)%3][stone[i+1][x].first][y],dp[i%3][stone[i][j].first][y]+(stone[i][j].second+stone[i+1][x].second)*abs(stone[i][j].first-stone[i+1][x].first));
          }
        }
        if(i==n-2){
          continue;
        }else{
          REP(x,stone[i+2].size()){
            REP(y,m){
              dp[(i+2)%3][stone[i+2][x].first][y+1]=min(dp[(i+2)%3][stone[i+2][x].first][y+1],dp[i%3][stone[i][j].first][y]+(stone[i][j].second+stone[i+2][x].second)*abs(stone[i][j].first-stone[i+2][x].first));
            }
          }
        }
      }
    }
    int ans=INF;
    REP(i,stone[n-2].size())REP(j,m)ans=min(ans,dp[(n-2)%3][stone[n-2][i].first][j]);
    REP(i,stone[n-1].size())REP(j,m+1)ans=min(ans,dp[(n-1)%3][stone[n-1][i].first][j]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 2168
/*
  Contest 071
  B - Not Found
  Rakesh Kumar --> 09/09/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    std::string s;
    std::getline(std::cin, s);
    std::vector<bool> dict(26, false);
    for (char c : s)
        dict[c - 'a'] = true;
    std::string r = "None";
    for (std::size_t i = 0; i < dict.size(); ++i) {
        if (!dict[i]) {
            r = i + 'a';
            break;
        }
    }
    std::cout << r << std::endl;

    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <bits/stdc++.h>
#define PB push_back
#define F(i,a,b)  for(i=a;i<b;i++)
#define FE(i,a,b)  for(i=a;i<=b;i++)
#define FR(i,a,b) for(i=a;i>b;i--)
#define LL long long
#define MAX(a,b) (a<b?b:a)
#define ABS(x) (x<0?(-x):x)
#define ALL(c) (c).begin(),(c).end()
#define WATCH(x) cout << (#x) << " is " << (x) << endl
#define vi vector<int>
#define vs vector<string>
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
using namespace std;
string ConvertToBin(LL s)
{
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}

void PrintVec(vector<int> &v)
{
    for(vector<int>::iterator it = v.begin() ; it != v.end(); ++it)
    cout<<*it<<" ";
}

vector<int> Populate(vector<int> &v,int n)
{
    int num;
    for(int i=0;i<n;i++)
    {
        cin>>num;
        v.push_back(num);
    }
    return(v);
}

int sumofdigits(int n)
{
    int sm=0;
    while(n)
    {
        sm=sm+(n-(n/10)*10);
         n=n/10;
    }
    return(sm);
}

bool isprime(int n)
{
    int i=0;
    FE(i,2,sqrt(n))
    {
        if(n%i==0)
        return(false);
    }
    return(true);
}


/*--------------------------time to code-------------------------------*/



int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int ans[n];
    ans[0]=0;
    ans[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
    {
        ans[i]=min(ans[i-1]+abs(arr[i]-arr[i-1]),ans[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<ans[n-1];
    return(0);
}









Measured memory_bytes: 1024
#!/usr/bin/perl
#abc081_b.pl
#Thu Feb  8 23:26:22 2018
#

use warnings;
use strict;

my $n = <STDIN>;
chomp $n;

my $temp = <STDIN>;
chomp $temp;

my @temps = split(" ",$temp);

my $minlog=10000000000;
my $log;

foreach my $num (@temps){
	$log = 0;
	while ($num%2==0){
		$log++;
		$num = $num/2;
	}
	if ($log < $minlog){
		$minlog = $log;
		if ($minlog == 0){
			last;
		}
	}
}

print $minlog,"\n";

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

using namespace std;
using ll = long long;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int K;
    cin >> s >> K;
    set<string> strs;
    for (char c='a'; c<='z'; ++c) {
        for (int pos=0; pos<s.length(); ++pos) {
            pos = s.find(c, pos);
            if (pos < 0) break;
            int len = min((int)s.length()-pos, 5);
            for (int i=1; i<=len; ++i) {
                strs.insert(s.substr(pos, i));
            }
        }

        if (strs.size() >= K) {
            auto it = strs.begin();
            for (int i=0; i<K-1; ++i) {
                ++it;
            }
            cout << *it << '\n';
            break;
        }
    }
    return 0;
}


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

using namespace std;

int main(){
	int n;
	string s, t;
	cin >>n >>s >>t;
	
	int ans = 0;
	for(int cmn = n; cmn >= 0; --cmn){
		string pfx = t.substr(0,cmn);
		string sfx = s.substr(n-cmn);
		if(pfx == sfx && 2*n-cmn >= n){
			ans = 2*n-cmn;
			break;
		}
	}
	cout <<ans <<'\n';
	return 0;
}


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

int main() {
	int H, W;
	cin >> H >> W;
  
    vector<vector<char>> s(H, vector<char>(W));

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          cin >> s.at(i).at(j);
        }
      }

  const vector<int> dx = {1, 0, -1, 0};
  const vector<int> dy = {0, 1, 0, -1};
  
  bool ans = true;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if( s.at(i).at(j) == '.' ) continue;
      int num = 0;
      
      for(int d = 0; d < 4; d++){  
        const int ni = i + dy.at(d);
        const int nj = j + dx.at(d);
        if (ni < 0 or H <= ni) continue;
        if (nj < 0 or W <= nj) continue;
        if (s.at(ni).at(nj) == '#') num++;
      }
      if(num == 0) ans = false;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,num;
    long long int res=0,input;
    scanf("%d",&num);
    for(i=0;i<num;i++)
    {
        scanf("%lld",&input);
        res+=input;
    }
    printf("%lld\n",res-num);
    return 0;
}


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

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

        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        int h = scanner.nextInt();
        int m = scanner.nextInt();

//        角度を求める
        double angle = (h * 30.0 + m * 0.5) - ( m * 6.0 );
        double angles = Math.abs(angle);

        double before = Math.sqrt(Math.pow(a,2) + Math.pow(b,2)
                                    - (2.0 * a * b * Math.cos(Math.toRadians(angles))));
        System.out.println(before);

        scanner.close();
    }

}

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

int main(){
    int n;
    cin>>n;
    int v[n], c[n];
    for (int i=0;i<n;i++){
        cin>>v[i];
    }
    for (int i=0;i<n;i++){
        cin>>c[i];
    }

    int ans=0;
    for (int i=0;i<n;i++){
        ans += (v[i] > c[i] > 0) ? v[i] - c[i] : 0;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include<string>
using namespace std;

class Dice{
public:
    Dice(){
        number = new int[6];
        work = new int[6];
    };
    ~Dice(){
        delete[] number;
        delete[] work;
    };

    void setLabel(int index,int num){
        number[index] = num;
    };

    void roll(char dst){
        for(int i = 0; i < 6; i++) work[i] = number[i];
        switch(dst){
        case 'E':
            setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
            break;
        case 'N':
            setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
            break;
        case 'S':
            setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
            break;
        case 'W':
            setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
            break;
        }
    };

    int returnPeek(){
        return number[0];
    }

private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }

private:
    int* number;
    int* work;
};

int main(int argc, const char * argv[]) {
       Dice dice;
       int label;
       char ch;
       for(int i = 0; i < 6; i++){
           scanf("%d",&label);
           dice.setLabel(i, label);
       }
       getchar();
       while((ch = getchar()) != '\n'){
           dice.roll(ch);
       }
       printf("%d\n", dice.returnPeek());
    return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main(){

int n,i,pe,count=0;
int max = INT_MAX; 
cin>>n;
int p[n]={0};
for(i=0;i<n;i++){
cin>>pe;
  p[i]=pe;
}  
  
for(i=0;i<n;i++){
if(p[i]<max){
count++;
  max = p[i];
}
}
 cout<<count; 

}

Measured memory_bytes: 1024
from collections import deque
n, m = map(int,input().split())
d = [[] for i in range(n)]
#print(d)
for i in range(m):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    d[a].append(b)
    d[b].append(a)
#print(d)
def bfs():
    flg = [True] * n
    ans = [0] * n
    flg[0] = False
    que = deque([0])
    #print(flg)
    while len(que) != 0:
        val = que.popleft()
        #print(d[val2])
        #print(flg)
        #print(ans)
        #print(val)

        for i in range(len(d[val])):
            if flg[d[val][i]] == True:
                que.append(d[val][i])
                flg[d[val][i]] = False
                ans[d[val][i]] = val
    return ans
ans = bfs()
#print(ans)
print('Yes')
for i in range(1,n):
    print(ans[i]+1)


Measured memory_bytes: 94544
let input=readLine()!.characters.split(" ").map{Int(String($0))!}
let N=input[0]
var x=input[1]
let a=readLine()!.characters.split(" ").map{Int(String($0))!}.sort()
var ans=N-1
for i in 0..<N {
  x-=a[i]
  if x<=0 {
    ans=i+(x<0 ?0:1)
    break
  }
}
print(ans)

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

using namespace std;

int main(void){
  int n, a, min=1001, max=-1;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a < min) {
      min = a;
    }
    if (a > max) {
      max = a;
    }
  }

  printf("%d", max - min);

  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
 
using namespace std; 

int gcd(int x,int y){
	return y==0?x:gcd(y,x%y);
}

int main(){

    int n;
    bool c[8]={},c2[8]={};

    cin>>n;
    int target=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;

        if(a<3200) c[a/400]=c2[a/400]=true;
        else target++;
    }

    //for(int i=0;i<8;i++) cout<<c[i]<<" ";
    //cout<<endl;

    int mi=0,ma=0;
    while(target--){

        //min
        int x=-1;
        for(int i=0;i<8;i++){
            if(c[i]){
                x=i;
                break;
            }
        }
        if(x==-1) c[0]=true; //all target

        ma++;

    }

    
    for(int i=0;i<8;i++) mi+=c[i],ma+=c2[i];
    cout<<mi<<" "<<ma<<endl;

	return 0;
}


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

using namespace std;

struct state{
	int y, x, d;
};

vector< string > field;
int x, y, d = 0;

void bfs(int H, int W, int n ) {

	vector< vector< int > > visited( H, vector< int >( W, 0 ) );

	int gx, gy;
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			if( field[i][j] == n + '0' ) {
				gy = i;
				gx = j;
			}
		}
	}

	queue< state > q;
	state s = { y, x, 0 };
	visited[y][x] = 1;
	q.push( s );
	while( !q.empty() ) {
		
		state p = q.front();
		q.pop();
		if( p.x == gx && p.y == gy ) {
			y = gy;
			x = gx;
			d += p.d;
			break;
		}
		for( int i = 0; i < 4; i++ ) {
			int d[4][2] = { { 1, 0 }, { -1, 0 }, {0, 1}, { 0, -1 } };
			state np;
			np.x = p.x + d[i][0];
			np.y = p.y + d[i][1];
			np.d = p.d + 1;
			if( np.x >= 0 && np.x < W && np.y >= 0 && np.y < H ) {
				if( !visited[np.y][np.x] ) {
					if( field[np.y][np.x] != 'X' ) {
						visited[np.y][np.x] = 1;
						q.push( np );
					}
				}
			}
		}
	}


}

int solve() {
	//幅優先探索で解ける？
	int H, W, N;
	cin >> H >> W >> N;
	field.resize(H);
	for( int i = 0; i < H; i++ )
		cin >> field[i];
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			if( field[i][j] == 'S' ) {
				x = j;
				y = i;
				field[i][j] = '.';
			}
		}
	}
	for( int i = 1; i <= N; i++ ) {
		bfs( H, W, i );
	}
	cout << d << endl;
	return 0;
}
     
int main(void){
	while(1){
		solve();
		break;
	}
    return 0;
}

Measured memory_bytes: 7804
#include<bits/stdc++.h>
using namespace std;
bool inclu3(int n){
    int r;
    while( n > 0){
        r = n%10;
        if(r==3){
            return true;
        }
        n /= 10;
    }
    return false;
}
int main() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%3==0 || inclu3(i)) cout << " " << i;
    }
    cout << endl;
}


Measured memory_bytes: 3096
from collections import Counter
n = int(input())
s = []
for _ in range(n):
    s.append(input())
m = int(input())
t = []
for _ in range(m):
    t.append(input())

d = {x: 0 for x in s}
for x in s:
    d[x] += 1

for y in t:
    if y in d.keys():
        d[y] -= 1

ans = max(d.values())

print(max(ans,0))

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int x, a;
	cin >> x >> a;
	if (x < a)cout << 0;
	else cout << 10;
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <math.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ept 1e-9

using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
const int mod = 1e9 + 7;
const int N = 3010;
int n, m;
int One[N], dp[N][N], rht[N];
char str[N];

int main()
{
	scanf("%d%d", &n, &m);
	scanf("%s", str);
	rep(i, 0, n - 1)
	{
		One[i] = (i ? One[i - 1] : 0) + str[i] - '0';
		rht[i] = i;
	}
	rep(i, 1, m)
	{
		int l = read(), r = read();
		l --;
		r --;
		rep(j, l, r)
			rht[j] = max(rht[j], r);
	}
	dp[0][0] = 1;
	rep(i, 0, n - 1)
		rep(now, 0, i)
		{
			int r = rht[i];
			int rest = One[r] - now;
			if(rest < 0) continue;
			if(rest > 0) (dp[i + 1][now + 1] += dp[i][now]) %= mod;
			if(r - i + 1 != rest) (dp[i + 1][now] += dp[i][now]) %= mod;
		}
	printf("%d\n", dp[n][One[n - 1]]);
	return 0;
}


Measured memory_bytes: 34176
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;
int a,b,c;

int main()
{
    cin>>a>>b>>c;
    a=a*100+b*10+c;
    if(a%4==0) cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

S,W=MI()
if S<=W:
    print("unsafe")
else:
    print("safe")


Measured memory_bytes: 9524
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define rep(i, n) for (int i=0; i<n; ++i)
#define FOR(i, a, b) for (int i=a; i<b; ++i)
#define pb(x) push_back(x)
#define ll long long
#define ul unsigned long long
#define dbg(x) cout  << #x << " : " << (x) << endl
#define out(x) cout << (x)
#define outl(x) cout << (x) << endl
#define int(n); int n; cin >> n;
#define long(n); long long n; cin >> n;
#define dbl(f); double f; cin >> f;
#define s(s); string s; cin >> s;
#define into(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
using namespace std;

const int inf =1500000000;

char f[100][100];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int w,h;
int cnt=0;

void dfs(int x,int y,char tmp) {
  if (x<0||x>=w||y<0||y>=h||f[x][y]!=tmp) return;
   f[x][y]='-';
   rep(i, 4) {
     int nx=x+dx[i],ny=y+dy[i];
     if (f[nx][ny]==tmp) dfs(nx, ny, tmp); 
   }
}

int main () {
  while (true) {
    cin>>h>>w;
    if (w==0&&h==0) break;
    rep(i, h) rep(j, w)  cin>>f[j][i];
    cnt=0;
    rep(i, h){
      rep(j, w) {
        if (f[j][i]!='-') {
          ++cnt;
          dfs(j, i,f[j][i]);
        }
      }
   }
    outl(cnt);
  }
  return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> vecA(N); for(int i=0; i<N; i++){ cin >> vecA[i]; }
    
    std::sort(vecA.begin(), vecA.end(), std::greater<int>());
    
    int Alice=0;
    int Bob  =0;
    for(int i=0; i<vecA.size(); i+=2){
        Alice += vecA[i  ];
        Bob   += vecA[i+1];
    }
    
    cout << (Alice-Bob);
    
    return 0;
}

Measured memory_bytes: 256
from collections import deque

N, M, R = map(int, input().split())
Rs = set(map(int, input().split()))

mp = [[float('inf')]*(N+1) for _ in range(N+1)]

for i in range(1,N+1):
  mp[i][i] = 0

for _ in range(M):
  a,b,c = map(int, input().split())
  mp[a][b] = c
  mp[b][a] = c
  
for k in range(1,N+1):
  for i in range(1,N+1):
    for j in range(1,N+1):
      mp[i][j] = min(mp[i][j], mp[i][k]+mp[k][j])

rlt = float('inf')
h = deque([])
for r in Rs:
  h.append([r])
  
while h:
  t = h.pop()
  if len(t) == R:
    tmp = 0
    for i in range(R-1):
      tmp += mp[t[i]][t[i+1]]
    rlt = min(rlt, tmp)
  else:
    for r in Rs:
      if r not in t:
        u = t + [r]
        h.append(u)

print(rlt)

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> p(N);
  for (int i = 0; i < N; i++) {
    string a;
    int b;
    cin >> a >> b;
    p.at(i) = make_tuple(a, 100 - b, i + 1); 
  }

  sort(p.begin(), p.end());

  for (int i = 0; i < N; i++) {
    string a;
    int b, c;
    tie(a, b, c) = p.at(i); 
    cout << c << endl;
  }
}


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




int N, H, W;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> H >> W;
    int ans = 0;
    rep(i, 0, N) {
        int A, B; cin >> A >> B;
        if (H <= A and W <= B) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	as := make([]int, n)
	cm := make(map[int]int)
	for i := 0; i < n; i++ {
		as[i] = nextInt()
		cm[as[i]]++
	}
	sort.Ints(as)

	ans := 0
	for i := 0; i < n; i++ {
		a := as[n-i-1]
		if cm[a] == 0 {
			continue
		}

		cm[a]--
		b := 1
		for b <= a {
			b *= 2
		}
		if cm[b-a] > 0 {
			cm[b-a]--
			ans++
		}
	}
	fmt.Println(ans)
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 14640
import kotlin.math.sqrt

fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val q = readLine()?.toInt() ?: return
    val likes = Array(100000 + 2) { 0 }
    var p = 0
    var prime = generatePrime(p)
    var i = 1
    var count = 0
    while (i <= 100000) {
        val diff = prime * 2 - i
        when {
            diff < 0 -> {
                p++
                prime = generatePrime(p)
            }
            else -> {
                if (diff == 1L && isPrime(i.toLong())) {
                    count++
                }
                likes[i] = count
                likes[i + 1] = count
                i += 2
            }
        }
    }
    buildString {
        repeat(q) {
            val (l, r) = intList()
            appendln(likes[r] - likes[l - 1])
        }
    }.let {
        println(it.trimIndent())
    }
}

val memo = hashMapOf<Int, Long>()
fun generatePrime(index: Int): Long {
    if (index == 0) {
        return 2
    }
    if (index == 1) {
        return 3
    }
    memo[index]?.let {
        return it
    }
    val prev = generatePrime(index - 1)
    var next = prev + 2
    var i = 0
    var prime = 0L
    var l = sqrt(next.toDouble()).toLong()
    while (i < index - 1 && l >= prime) {
        prime = generatePrime(i++)
        if (next % prime == 0L) {
            next += 2
            i = 1
            l = sqrt(next.toDouble()).toLong()
        }
    }
    memo[index] = next
    return next
}

fun isPrime(candidate: Long): Boolean {
    var i = 0
    var prime = 0L
    val l = sqrt(candidate.toDouble()).toLong()
    while (l > prime) {
        prime = generatePrime(i++)
        if (candidate % prime == 0L) {
            return false
        }
    }
    return true
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define f0(i,b)   for(int i=0;i<(b);i++)
#define f1(i,b)   for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define forr(i,n)    for(i=0; i<n; i++)
#define whilee(i,t)  while(i!=t)
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld",a)

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);
//scanf("%d",&x);
//printf("%d\n",x);

//vector <int> A;
//deque <int> A;
//queue <int> A;
//stack <int> A;
//set <int> A;
//map <int,int> A;
//pair <int,int> A ;
//vector <pair <int,int>> A ;
//bitset<32> bset1;
//char ch;
//string S, T, U;
ll i, j, k, a, b, c, d, f, g, h, l, m, n, p, q, r, s, t, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL
    //int A[n];
    //scan(n);
    cin>>a>>b>>c;

    cout<<0.5*a*b<<endl;

    return 0;
}


Measured memory_bytes: 256
d = input()

if(d == "SAT"):
  print(1)
elif(d == "SUN"):
  print(7)
elif(d == "MON"):
  print(6)
elif(d == "TUE"):
  print(5)
elif(d == "WED"):
  print(4)
elif(d == "THU"):
  print(3)
elif(d == "FRI"):
  print(2)

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

int main(){
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

using namespace std;


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

    string s;
    cin >> s;
  
    int m = atoi(s.substr(0,2).c_str());
	int y = atoi(s.substr(2,2).c_str());
  
	if ( (m >= 01 and m <= 12) and (y >= 01 and y <= 12) ) {
		cout << "AMBIGUOUS" << endl;
	} else if ( ( m >= 01 and m <= 12 ) ) {
		cout << "MMYY" << endl;
	} else if (y >= 01 and y <= 12) {
		cout  << "YYMM" << endl;
	} else {
		cout << "NA" << endl;
	}
	
    return 0;
}


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

using namespace std;

int par[10000];

void init(int n) {
    for(int i = 0; i < n; ++i) {
        par[i] = i;
    }
}

int find(int x) {
    if(par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x != y) par[x] = y;
}

int main() {

    int n, q, com, x, y;

    cin >> n >> q;

    init(n);

    for(int i = 0; i < q; ++i) {
        cin >> com >> x >> y;
        if(com == 0) {
            unite(x, y);
        } else {
            if(same(x, y) == true) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }

}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long k;
	cin >> k;
	string ns;
	cin >> ns;
	if (ns != ""){
		for (long long j = 0; j < k&&j < ns.length(); j++){
			cout << ns[j];
		}
		if (k<ns.length())cout << "...";
	}
	else cout << "";
	//system("pause");
	return 0;
}

Measured memory_bytes: 3644
#include <string>
#include <iostream>
#include <set>
#include <array>
 
using namespace std;
 
// 文字列一つ受け取る場合
// string s;
// 整数(max 2^31-1 or 10^9)一つ受け取る場合
// int x;
int k;
 
int main(){
  cin >> k;
  array<int, 200> t{1,9,30,76,141,267,400,624,885,1249,1590,2208,2689,3411,4248,5248,6081,7485,8530,10248,11889,13687,15228,17988,20053,22569,25242,28588,31053,35463,38284,42540,46581,50893,55362,61824,65857,71247,76884,84388,89349,97881,103342,111528,120141,128047,134580,146316,154177,164817,174438,185836,194157,207927,218812,233268,245277,257857,268182,288216,299257,313635,330204,347836,362973,383709,397042,416448,434025,456967,471948,499740,515581,536073,559758,583960,604833,633651,652216,683712,709065,734233,754734,793188,818917,846603,874512,909496,933081,977145,1006126,1041504,1073385,1106467,1138536,1187112,1215145,1255101,1295142,1342852,1373253,1422195,1453816,1502376,1553361,1595437,1629570,1691292,1726717,1782111,1827492,1887772,1925853,1986837,2033674,2089776,2145333,2197483,2246640,2332104,2379085,2434833,2490534,2554600,2609625,2693919,2742052,2813988,2875245,2952085,3003306,3096024,3157249,3224511,3306240,3388576,3444609,3533637,3591322,3693924,3767085,3842623,3912324,4027884,4102093,4181949,4270422,4361548,4427853,4548003,4616104,4718640,4812789,4918561,5003286,5131848,5205481,5299011,5392008,5521384,5610705,5739009,5818390,5930196,6052893,6156139,6239472,6402720,6493681,6623853,6741078,6864016,6953457,7094451,7215016,7359936,7475145,7593865,7689630,7886244,7984165,8130747,8253888,8403448,8523897,8684853,8802826,8949612,9105537,9267595,9376656,9574704,9686065,9827097,9997134,10174780,10290813,10493367,10611772,10813692};
    cout << t[k-1];
}


Measured memory_bytes: 3188
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < 101; i++) {
            int mans = 0;
            for (int j = 0; j < x.length; j++) {
                mans += Math.pow(x[j] - i, 2);
            }
            min = Math.min(min, mans);
        }

        System.out.println(min);
    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


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

int main(void)
{
	int s, h, m;
	cin >> s;
	h = s / 3600;
	s = s - h*3600;
	m = s / 60;
	s = s - m*60;
	cout << h << ":"<< m << ":"<< s << endl;
}

Measured memory_bytes: 1164
x,y,a,b,c = map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))
ans = []
P.sort()
Q.sort()
R.sort()
for i in range(x):
    ans.append(P[a-i-1])
for i in range(y):
    ans.append(Q[b-i-1])
flag = True
ans.sort()
ans_sum = sum(ans)
cur = c-1
temp = 0
for i in range(c):
    if cur >= 0 and temp <= (x+y-1):
        if R[cur] >= ans[temp]:
            ans_sum += R[cur]-ans[temp]
            cur -= 1
            temp += 1
print(ans_sum)


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  int count = 0;
  for(int i = 1; i < n-1; i++){
    if(p.at(i) > p.at(i-1) && p.at(i) < p.at(i+1)){
      count++;
    }
    else if(p.at(i) < p.at(i-1) && p.at(i) > p.at(i+1)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector <int> x(N);
  int sum = 0;
  
  for (int i=0;i<N;i++) {
     cin >> x.at(i); 
     int d = min(x.at(i),max(K-x.at(i),x.at(i)-K));
     sum += 2*d;
  }
  cout << sum << endl;
  }


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int B[22222];

signed main(){
    cin>>N;
    rep(i,N){
        int p;
        scanf("%lld",&p);
        p--;
        B[p]=i;
    }

    rep(i,N){
        if(i)printf(" ");
        printf("%lld",(i+1)*N);
    }
    puts("");

    rep(i,N){
        if(i)printf(" ");
        printf("%lld",(N-i)*N+B[i]);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 768
n = int(input())
l = list(map(int,input().split()))

ans = 0

#for k in range(min(l)+1, max(l)):
#    l_abc = [i for i in l if i < k]
#    l_arc = [i for i in l if i >= k]
#    if len(l_abc) == len(l_arc):
#        ans += 1
        
l_s = sorted(l)
diff = l_s[int(len(l_s)/2)] - l_s[int(len(l_s)/2)-1]
if diff > 0:
    print(diff)
else:
    print(0)

Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin>>t;
	while (t--)
	{
		int n, k;
		cin >> k >> n;
		int arr[n], dis[n];
		for (int i = 0; i < n; i++) {
			cin >> arr[i];
			if (i != 0) {
				dis[i] = arr[i] - arr[i - 1];
			}
			else dis[0] = arr[0];
		}
		dis[0] += k - arr[n - 1];
		cout << k - *max_element(dis, dis + n) << "\n";
	}
	return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>

using namespace std;

typedef long long    ll;
typedef long double  ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template <typename T> bool chmax(T &a, T& b) {if (a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, T& b) {if (a > b) {a = b; return true;} return false;}
#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define mset(x, val) memset(x, (val), sizeof(x))
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


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

ll solve(ll X) {
  ll res = 1;
  ll tmp = X;

  while (tmp%360 != 0)
    tmp+=X, res++;
  
  return res;
}

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

  ll X;
  cin >> X;

  auto ans = solve(X);
  cout << ans << endl;

  return 0;
}


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

void func(vector<int> &P, vector<int> &Q, int N, int i, int &a);

int main()
{
    int N;
    cin >> N;
    int a = 0;
    int count = 0;
    vector<int> P(N), Q(N);
    rep(i, N)
    {
        cin >> P.at(i);
    }
    rep(i, N)
    {
        cin >> Q.at(i);
    }
    func(P, Q, N, 0, a);
    if (a == 0)
    {
        cout << a << endl;
    }
    else if (a == 1)
    {
        while (1)
        {
            next_permutation(all(P));
            count++;
            rep(i, N)
            {
                if ((i == N - 1) && (P.at(i) == Q.at(i)))
                {
                    cout << count << endl;
                    return 0;
                }
                else if (P.at(i) == Q.at(i))
                {
                    continue;
                }
                break;
            }
        }
    }
    else if (a == -1)
    {
        while (1)
        {
            next_permutation(all(Q));
            count++;
            rep(i, N)
            {
                if ((i == N - 1) && (P.at(i) == Q.at(i)))
                {
                    cout << count << endl;
                    return 0;
                }
                else if (P.at(i) == Q.at(i))
                {
                    continue;
                }
                break;
            }
        }
    }
}

void func(vector<int> &P, vector<int> &Q, int N, int i, int &a)
{
    if (i == N)
    {
        a = 0;
        return;
    }
    else if (P.at(i) < Q.at(i))
    {
        a = 1;
        return;
    }
    else if (P.at(i) > Q.at(i))
    {
        a = -1;
        return;
    }
    else if (P.at(i) == Q.at(i))
    {
        func(P, Q, N, i + 1, a);
    }
}

Measured memory_bytes: 256