akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll N,M;
    cin >> N >> M;

    ll ans = 1;

    for (ll i=1; i<=M; i++) {
        if (i*i>M) {
            if (N==1) {
                ans = M;
            }
            break;
        }
        else {
            if (M%i==0) {
                if (M/i>=N) ans = max(ans,i);
                ll j = M/i;
                if (M/j>=N) ans = max(ans,j);
            }
        } 
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3640
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)

inf = 10 ** 15
mod = 10 ** 9 + 7

p = [] # i*2-1番までで取りうる最大の数
m = [] # i*2番までで取りうる最小の数
prep = 0
prem = 0
kaijou = []
for i in range(0,35,2):
    p.append(2**i+prep)
    m.append(2**(i+1)+prem)
    kaijou.append(2**i)
    kaijou.append(2**(i+1))
    prep = 2**i+prep
    prem = 2**(i+1)+prem

def getAns(n,i):

    if i == 0:
        if n == 0:
            return '0'
        if n == 1:
            return '1'
    else:
        if n == 0 or n == 1:
            return ''.join(['0', getAns(n, i-1)])
        elif n > 0:
            ind = bisect.bisect_left(p, n)
            if ind*2 == i:
                n -= kaijou[i]
                return ''.join(['1', getAns(n, i-1)])
            else:
                return ''.join(['0', getAns(n, i-1)])
        else:
            ind = bisect.bisect_left(m, abs(n))
            if ind*2+1 == i:
                n += kaijou[i]
                return ''.join(['1', getAns(n, i-1)])
            else:
                return ''.join(['0', getAns(n, i-1)])


n = int(input())
if n >= 0:
    ind = bisect.bisect_left(p, n)
    print(getAns(n,ind*2))
else:
    ind = bisect.bisect_left(m, abs(n))
    print(getAns(n,ind*2+1))

Measured memory_bytes: 40592
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;

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

int main(void){

    long long r;
    cin >> r;

    long long circle = (long long)2.0 * r * M_PI;
    cout << setprecision(14);
    cout << (long long)2.0 * r * M_PI << endl;

    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >>a;
  if(a.at(2)!=a.at(3)){
    cout  <<"No" <<endl;
    return 0;
  }
  if(a.at(4)!=a.at(5)){
    cout  <<"No" <<endl;
    return 0;
  }
  cout <<"Yes" <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int field[10][6];
int height[5];
int H;


int del(){
	int score=0;
	rep(y,H){
		int seq=0;
		int prev=0;
		rep(x,6){
			if(prev==field[y][x]){
				seq++;
			}else{
				if(3<=seq){
					for(int i=1;i<=seq;i++){
						score+=field[y][x-i];
						field[y][x-i]=0;
					}
				}
				seq=1;
				prev=field[y][x];
			}
		}
	}
	return score;
}
void fall(){
	memset(height,0,sizeof(height));
	rep(y,H){
		rep(x,5){
			if(field[y][x]==0)continue;
			if(y!=height[x]){
				field[height[x]][x]=field[y][x];
				field[y][x]=0;
			}
			height[x]++;
		}
	}
}


int main(){
	while(cin>>H&&H){
		for(int y=H-1;y>=0;y--)
			for(int x=0;x<5;x++)cin>>field[y][x];
		int ans=0,t;

		while(t=del()){
			ans+=t;
			fall();
		}
		cout<<ans<<endl;
	}

	return 0;
}

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

string s;
string mem;
int main(){
    cin >> s;
    int bit = 0;
    long long ans = 0;
    for(int i = 0; i < (int)pow(2,s.length()-1); i++){
        mem = s[0];
        for(int j = s.length()-2; j >= 0; j--){
            if(i & (1<<j)){
                ans += stoll(mem);
                mem = "";
            }
            mem += s[s.length()-j-1] * 1LL;
        }
        ans += stoll(mem) * 1LL;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    x = 0
    y = 0
    for i in range(1, n+1):
        x += (n-i+1)*i
    for _ in range(n-1):
        u, v = map(int, input().split())
        if v < u:
            u, v = v, u
        y += u*(n-v+1)
    print(x-y)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9136
my ($a, $v) = glob <>;
my ($b, $w) = glob <>;
my $t = <>;

if ($b > $a) {
    print(($a + $v * $t >= $b + $w * $t) ? 'YES' : 'NO');
}
elsif ($a > $b) {
    print(($a - $v * $t <= $b - $w * $t) ? 'YES' : 'NO');
}

Measured memory_bytes: 5324
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
q = INT()
rev = 0
begg = []
end = []
for _ in range(q):
     temp = input()
     if(len(temp.split())==1):
         rev+=1

     else:
         t,f,c = temp.split()
         if(f=="1"):
             if(rev%2==0):
                 begg.append(c)
                 # s = c + s
             else:
                 end.append(c)
                 # s = s + c
         else:
             if(rev%2==0):
                 end.append(c)
                 # s = s + c
             else:
                 begg.append(c)
                 # s = c + s
abc = "".join(begg[::-1]) + s + "".join(end)
if(rev%2==0):
    print(abc)
else:
    print(abc[::-1])

Measured memory_bytes: 71768
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
using namespace std;
const int num = 5000;
vector<int> v[num];
int cnt = -1;
inline void merge(int a, int b) {
		int m = -1, n = -1;
		for (int i = 0; i <= cnt; i++) {
			for (int j = 0; j < v[i].size(); j++) {
				if (m != -1 && n != -1) break;
				if (v[i][j] == a) m = i;
				if (v[i][j] == b) n = i; 
			}
			if (m != -1 && n != -1) break;
		}
		if (m != -1 && n != -1 && m != n) {
			int x = v[n].size();
			for (int i = 0; i < x; i++) {
				v[m].push_back(v[n][0]);
				v[n].erase(v[n].begin());
			}
		}
		else if (m != -1 && n != -1 && m == n) return;
		else if (m != -1 && n == -1) v[m].push_back(b);
		else if (m == -1 && n != -1) v[n].push_back(a); 
		else {
			cnt++;
			v[cnt].push_back(a);
			v[cnt].push_back(b);
		}
}
inline void same(int a, int b) {
	int m = -1, n = -1;
	for (int i = 0; i <= cnt; i++) {
		for (int j = 0; j < v[i].size(); j++) {
			if (m != -1 && n != -1) break;
			if (v[i][j] == a) m = i;
			if (v[i][j] == b)  n = i;
			if (m != -1 && n != -1) break;
		}
	}
	if (m != -1 && n != -1 && m == n) cout << '1' << endl;
	else cout << '0' << endl;
}

int main() {
	int n, q,com, fi , se;
	cin >> n >> q;
	for (int i = 0; i < q; i++) {
		cin >> com >> fi >> se;
		if (com == 0) merge(fi, se);
		else same(fi, se);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

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


    return 0;
}



Measured memory_bytes: 256
using System;

class Pratice
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]), m = int.Parse(str[1]);
        int[,] A = new int[n, m];
        for (int i = 0; i < n; ++i)
        {
            string[] row = Console.ReadLine().Split(' ');
            for (int j = 0; j < m; ++j)
            {
                A[i, j] = int.Parse(row[j]);
            }
        }
        int[] B = new int[m];
        for (int i = 0; i < m; ++i)
        {
            B[i] = int.Parse(Console.ReadLine());
        }
        int[] C = new int[n];
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < m; ++j)
            {
                C[i] += A[i, j] * B[j];
            }
        }
        foreach (var i in C) Console.WriteLine(i);
    }
}


Measured memory_bytes: 17976
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
const int size=4000;
vi graph[size];
int lineDistances[size][size];
bool visited[size][size];
vi vertexA, vertexB;
int number, diameter;
int showMinValue(vi);
void dfs(int root, int start, int distanceInLines)
{
	//commandsBeforeVisitRecursion.
	visited[root][start]=true;
	lineDistances[root][start]=distanceInLines;
	for(int next : graph[start])
	{
		if(!visited[root][next])
		{
			dfs(root, next, distanceInLines+1);
		}
	}
	//commandsAfterVisitRecursion.
	return;
}
void usingDFS()
{
	cin>>number>>diameter;
	int vertex0, vertex1;
	for(int i=1; i<number; ++i)
	{
		cin>>vertex0>>vertex1;
		graph[vertex0].push_back(vertex1);
		graph[vertex1].push_back(vertex0);
		vertexA.push_back(vertex0);
		vertexB.push_back(vertex1);
	}
	for(int vertex=1; vertex<=number; ++vertex)
	{
		dfs(vertex, vertex, 0);
	}
	if(diameter%2==0)
	{
		vi counters;
		for(int i=1; i<=number; ++i)
		{
			int counter=0;
			for(int j=1; j<=number; ++j)
			{
				if(lineDistances[i][j]>diameter/2)
				{
					++counter;
				}
			}
			counters.push_back(counter);
		}
		cout<<showMinValue(counters)<<endl;
	}
	else
	{
		int dotA, dotB, tempMaxDist;
		vi counters;
		for(int i=0; i<vertexA.size(); ++i)
		{
			int counter=0;
			dotA=vertexA[i];
			dotB=vertexB[i];
			for(int j=1; j<=number; ++j)
			{
				tempMaxDist=min(lineDistances[j][dotA], lineDistances[j][dotB]);
				if(tempMaxDist>diameter/2)
				{
					++counter;
				}
			}
			counters.push_back(counter);
		}
		cout<<showMinValue(counters)<<endl;
	}
	return;
}
int showMinValue(vi initialVector)
{
	int minimum=initialVector[0];
	for(int i=1; i<initialVector.size(); ++i)
	{
		if(minimum>initialVector[i])
		{
			minimum=initialVector[i];
		}
	}
	return minimum;
}
int main()
{
    usingDFS();
	return 0;
}

Measured memory_bytes: 43008
#include <stdio.h>
#include <stdlib.h>

#define WHITE 0   //未発見
#define GRAY 1    //発見
#define BLACK 2   //終了

char a[100][100]; //隣接行列
int n;            //行列のサイズ
int d[100];       //発見時刻
int f[100];       //終了時刻
int color[100];   //探索状況
int time;         //現在時刻



void init() {
  short i, j;

  for( i=0; i<n; i++ ) {
    for( j=0; j<n; j++ ) {
      a[i][j] = 0;
    }
  }

  return;
}


void visit( short u ) {
  short v;

  color[u] = GRAY;     //uを発見状態に
  d[u] = ++time;       //発見時刻をセット
  
  for( v=0; v<n; v++ ) {
    if( a[u][v] == 1 && color[v] == WHITE ) { //頂点vが現在地uからつながっていて未発見なら
      visit( v );                             //vを訪問する
    }
  }

  color[u] = BLACK;
  f[u] = ++time;

  return;

}


void dfs() {
  short i;
  
  for( i=0; i<n; i++ ) {
    if( color[i] == WHITE ) {
      visit( i );
    }
  }
  return;
}
  

void print() {
  short i;

  for( i=0; i<n; i++ ) {
    printf("%d %d %d\n", i+1, d[i], f[i] );
  }

  return;
}



main() {

  int i, j;
  int u, k, v;

  scanf( "%d", &n );
  
  init();

  
  for( i=0; i<n; i++ ) {
    scanf( "%d%d", &u, &k );
    
    for( j=0; j<k; j++ ) {
      scanf( "%d", &v );
      a[u-1][v-1] = 1;
    }
    
  }

  dfs();
  
  print();
  
  return 0;

} 
  

Measured memory_bytes: 604
#include <iostream>
#include <map>

using namespace std;

int main(){
    int N;
    cin >> N;

    string S[N];
    for(int i=0; i<N; i++){
        cin >> S[i];
    }

    map<string, long> m;
    for(int i=0; i<N; i++){
        for(int j=0; j<10; j++){
            for(int k=9; k>0; k--){
                if(S[i][k] < S[i][k-1]){
                    string t1 = S[i].substr(k, 1);
                    string t2 = S[i].substr(k-1, 1);
                    S[i].replace(k, 1, t2);
                    S[i].replace(k-1, 1, t1);
                }
            }
        }

        auto it = m.find(S[i]);
        if(it == m.end()){
            m[S[i]] = 1;
        }else{
            m[S[i]] += 1;
        }

    }

    long cnt = 0;
    for(auto it = m.begin(); it != m.end(); it++){
        if(it->second != 0) cnt += it->second*(it->second-1)/2;
    }
    
    cout << cnt;

    return 0;
}

Measured memory_bytes: 18176
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n,m,k;
string grid[8];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m>>k;
	rep(x,0,n) cin>>grid[x];
	
	int ans=0;
	
	rep(bm1,0,1<<n){
		rep(bm2,0,1<<m){
			int curr=0;
			rep(x,0,n){
				rep(y,0,m){
					if ((bm1&(1<<x))==0 && (bm2&(1<<y))==0 && grid[x][y]=='#') curr++;
				}
			}
			
			if (curr==k) ans++;
		}
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      //取得
	  int[][] c = new int[3][3];
      for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
          c[i][j]=sc.nextInt();
        }
      }
      String ans = "Yes";
      for(int i=0;i<2;i++){
        if(!((c[0][i]-c[0][i+1]==c[1][i]-c[1][i+1]) 
           && (c[0][i]-c[0][i+1]==c[2][i]-c[2][i+1]))){
           ans = "No";
        }
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 35608
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n;cin >> n;
  int d[n];
  rep(i,n){
    cin >> d[i];
  }
  int ans = 0;
  rep(i,n){
    for(int j = i+1; j<n; j++){
      ans += d[i]*d[j];
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int n;



signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

    int N;

    cin >> N;

    vector<int> A;

    for(int i=0;i <N; i++){
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    std::sort(A.begin(), A.end());

    for(int i=0; i<N-1; i++){
        if(A[i] == A[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 2420
n = gets.to_i
p = gets.split(" ").map(&:to_i)

dp = Array.new(n)
dp[0] = p.first
(0..(n - 2)).each do |i|
  dp[i + 1] = [p[i + 1], dp[i]].min
end

count = 1
(1..(n - 1)).each do |i|
  count += 1 if dp[i - 1] >= p[i]
end

puts count

Measured memory_bytes: 22788
(defparameter N (read))

(defun get-order (num)
  (length (write-to-string num)))

(defun max-order-num (num)
  (- num 
     (1- (expt 10 
               (1- (get-order num))))))

(defun count-up (num)
  (labels ((f (n ord)
             (if (< ord (get-order n))
                 (+ (* 9 (expt 10 (1- ord)))
                    (f n (+ ord 2)))
                 0)))
    (f num 1)))

(defun answer (num)
  (if (oddp (get-order num))
      (format t "~a" (+ (max-order-num num)
                        (count-up num)))
      (format t "~a" (count-up num))))

(answer N)

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

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

    if ( a == b ) {
        cout << 0 << endl;
    }
    else if ( ( b + a ) % 2 == 0 ) {
        cout << ( b + a ) / 2 << endl; 
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
  string n;
  cin >> n;
  
  int red, blue;
  red = 0; blue = 0;
  
  for(int i=0; i<(int)n.size(); i++){
    if(n[i] == '0') red++;
    else blue++;
  }
  
  int ans;
  ans = red < blue ? red*2 : blue*2;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 512
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

string s[505];
//??°???????????£??\?????????
VI g[30];
//???????????\?¬???°?????????
int h[30];
signed main(void)
{
  while(true) {
    int n;
    cin >> n;
    if(!n) break;
    REP(i, n) cin >> s[i];
    memset(h, 0, sizeof(h));
    REP(i, 30) g[i].clear();

    bool flg = false;
    REP(i, n-1) {
      int sz = min(s[i].size(), s[i+1].size());
      bool update = false;
      REP(j, sz) {
        if(s[i][j] != s[i+1][j]) {
          // s[i][j] ?????? s[i+1][j]???????????????
          g[s[i][j]-'a'].PB(s[i+1][j]-'a');
          h[s[i+1][j]-'a']++;
          update = true;
          break;
        }
      }
      if(!update && s[i].size() > s[i+1].size()) {
        cout << "no" << endl;
        flg = true;
        break;
      }
    }
    if(flg) continue;

    //??\?¬???°???0??????????????????
    stack<int> st;
    //??\?¬???°???0???????????§????????°st?????????
    REP(i, 26) if(h[i] == 0) st.push(i);

    //??????????????????????????°??????
    VI ans;
    //st????????????????????§?????????
    while(st.size()) {
      //st????????????????????????????????????
      int i = st.top(); st.pop();
      ans.push_back(i);
      for(auto& j: g[i]) {
        //??£??\?????????????????\?¬???°???????????????1
        h[j]--;
        //??????????????£?????\?¬???°???0???????????°st?????????
        if(h[j] == 0) st.push(j);
      }
    }

    if(ans.size() == 26) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}

Measured memory_bytes: 3144
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int sum = sc.nextInt();
        int h = sum/3600;
        int m = (sum%3600)/60;
        int s = ((sum%3600)%60);
        System.out.println(h+":"+m+":"+s);
    }
}


Measured memory_bytes: 26180
def main():
    _ = int(input())
    ds = list(map(int, input().split()))
    ds = sorted(ds)
    midpoint = len(ds) // 2
    if ds[midpoint] == ds[midpoint - 1]:
        score = 0
    else:
        score = ds[midpoint] - ds[midpoint - 1]

    print(score)


main()

Measured memory_bytes: 14396
def dfs(v,n,visited):
    all_visted=True
    for i in range(n):
        if visited[i]==False:
            all_visted=False
    if all_visted==True:
        return 1
    ret=0
    for i in range(n):
        if path[v][i]==False:
            continue
        if visited[i]==True:
            continue
        visited[i]=True
        ret+=dfs(i,n,visited)
        visited[i]=False
    return ret
n,m=map(int,input().split())
path=[[False]*n for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    path[a-1][b-1]=True
    path[b-1][a-1]=True
visited=[False]*n
visited[0]=True
print(dfs(0,n,visited))


Measured memory_bytes: 3188
n,m = map(int,input().split())
p = [0] * n
k = [1] * n
p[0] = 1
for i in range(m):
  x,y = map(int,input().split())
  k[x-1],k[y-1] = k[x-1]-1,k[y-1]+1
  if p[x-1] == 1:
    p[y-1] = 1
    if k[x-1] == 0:
      p[x-1] = 0
print(sum(p))

Measured memory_bytes: 51672
#include<iostream>
#include<cmath>
#include <limits>

using namespace std;

int main(){
    long long int a,b,c;

    cin >> a >> b >> c;

    if((c-a-b)>= 0 &&4*a*b < (c-a-b)*(c-a-b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
      int n; cin>>n;
      vector<int> l(n);
      rep(i,0,n) cin>>l[i];
      sort(all(l));
      int sum=0;
      rep(i,0,n-1){
            sum+=l[i];
      }
      if(sum>l[n-1]) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
}

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

signed main(){

  int n;
  cin>>n;

  vector<vector<int>> a(1<<n);

  int k;
  cin>>k;
  vector<int> t(k);
  for(auto& ti:t)cin>>ti;

  for(int b=0;b<(1<<n);++b){
    bitset<20> bit(b);
    a[b].resize(bit.count()+1);
    a[b][0] = bit.to_ulong();
    int idx = 1;
    for(int i=0;i<n;++i){
      if(bit[i])a[b][idx++]=i;
    }
  }
  sort(a.begin(),a.end(),[](auto& a,auto& b){return a[0]<b[0];});

  for(auto v:a){
    vector<int> res;
    set_intersection(
      v.begin()+1,v.end(),
      t.begin(),t.end(),
      back_inserter(res)
    );
    if(res!=t)continue;
    cout<<v[0]<<":";
    for(int i=1;i<v.size();++i){
      cout<<" "<<v[i];
    }
    cout<<endl;
  }

}


Measured memory_bytes: 22912
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans = "";

    ans += 'D';
    rep(i, 0, tx - sx + 1) ans += 'R';
    rep(i, 0, ty - sy + 1) ans += 'U';
    ans += 'L';
    ans += 'U';
    rep(i, 0, tx - sx + 1) ans += 'L';
    rep(i, 0, ty - sy + 1) ans += 'D';
    ans += 'R';
    rep(i, 0, tx - sx) ans += 'R';
    rep(i, 0, ty - sy) ans += 'U';
    rep(i, 0, tx - sx) ans += 'L';
    rep(i, 0, ty - sy) ans += 'D';

    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long n, ans = 0;

bool is_ok(long long n) {
  bool f1 = false, f2 = false, f3 = false;
  while (n != 0) {
    if (n % 10 == 7) {
      f1 = true;
    }
    if (n % 10 == 5) {
      f2 = true;
    }
    if (n % 10 == 3) {
      f3 = true;
    }
    n /= 10;
  }
  return f1 && f2 && f3;
}
void dfs(long long cur, int depth) {
  if (cur <= n && is_ok(cur)) {
    ans++;
  }
  if (depth == 10) {
    return;
  }
  dfs(cur * 10 + 7, depth + 1);
  dfs(cur * 10 + 5, depth + 1);
  dfs(cur * 10 + 3, depth + 1);
}

int main() {
  cin >> n;
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
        if(i%3!=0&&i%5!=0)sum+=i;
    cout<<sum<<endl;
}


Measured memory_bytes: 3536
#include <stdio.h>
#include <stdlib.h>

int main(void)
{	
	int a[30],b[100],c[100];
	int n,ans = 0,before = -5,dishnum = -1;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<n-1;i++){
		scanf("%d",&c[i]);
	}
	for(i=0;i<n;i++){
		dishnum = a[i] - 1;
		if(dishnum - 1 == before){
			ans += c[dishnum-1];
//			printf("ボーナス%d",ans);
		}
		ans += b[dishnum];
		before = dishnum;
//		printf("合計%d 料理名%d 前の料理 %d\n",ans,dishnum,before);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>

using namespace std;

char s[100005];
char temp;
int ans;

int main()
{
    scanf("%s",s);
    temp=s[0];
    for(int i=1;i<strlen(s);i++)
    {
        if(temp!=s[i])
        {
            ans++;
            temp=s[i];
        }
    }
    printf("%d\n",ans);
}

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

int main(){
    int a, b;
    cin >> a >> b;
    cout << (int)a/b << endl;
    cout << (int)a%b << endl;
    cout << fixed << setprecision(5) << (double)a/b << endl;
    return 0;
}


Measured memory_bytes: 3268
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val S = scanner.nextInt()
    val h = S / 60 / 60
    val m = (S - h * 60 * 60) / 60
    val s = (S - h * 60 * 60 - m * 60)
    println("${h}:${m}:${s}")
}


Measured memory_bytes: 25632
# -*- coding: utf-8 -*-
# 標準入力を取得
N, M = list(map(int, input().split()))
requests = []
for i in range(M):
    a_i, b_i = list(map(int, input().split()))
    requests.append((a_i, b_i))

# 求解処理
requests = sorted(requests, key=lambda x: x[1])
bridges = [requests[0][1] - 1]
for i in range(M):
    a_i, b_i = requests[i]
    if (bridges[-1] < a_i) or (b_i <= bridges[-1]):
        bridges.append(b_i - 1)
ans = len(bridges)

# 結果出力
print(ans)


Measured memory_bytes: 24820
#include <stdio.h>
#include <math.h>

#define DEBUG

#ifndef DEBUG 
#define fprintf (void)
#endif 

int main(void){
	
	int a,b,sum,i;
	
	while(scanf("%d",&a)!=EOF){
		scanf("%d",&b);
		sum=a+b;
	
		for(i=0;sum>0;i++){
			sum/=10;
		}
		printf("%d\n",i);
	}
	
	return 0;
}

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

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	int h,n;
	cin>>h>>n;
	vi a(n);
	cin>>a;
	ll sum=accumulate(all(a),0ll);
	if(h<=sum){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

    /* チェックリスト
     * 結果はintの範囲を超えていませんか？(必要な時以外はlongを使いましょう)
     * TLEしそうな処理はありませんか？
     */
    public static void main(String args[]){
        Scanner s = new Scanner(System.in);
        int a = Integer.parseInt(s.nextLine());
        String color = s.nextLine();
        System.out.println(a >= 3200 ? color:"red");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int kN = 3e5 + 10;

int n, m, k;
int row[kN], col[kN];
int main() {
	scanf("%d%d%d", &n, &m, &k);
	set<pair<int, int>> s;
	for(int i = 0; i < k; i++) {
		int x, y; scanf("%d%d", &x, &y);
		x--, y--;
		row[x]++, col[y]++;
		s.insert({x, y});
	}
	int ans = 0;
	int mx = -1;
	vector<int> x_pos, y_pos;
	for(int i = 0; i < n; i++) {
		if(row[i] > mx) {
			mx = row[i];
			x_pos.clear();
			x_pos.push_back(i);
		}
		else if(row[i] == mx) x_pos.push_back(i);
	}
	ans += mx;
	mx = -1;
	for(int i = 0; i < m; i++) {
		if(col[i] > mx) {
			mx = col[i];
			y_pos.clear();
			y_pos.push_back(i);
		}
		else if(col[i] == mx) y_pos.push_back(i);
	}
	ans += mx;
	//printf("now = %d\n", ans);

	if(1LL * int(x_pos.size()) * int(y_pos.size()) > k) {
		printf("%d\n", ans);
		return 0;
	}
	for(int i : x_pos) {
		for(int j : y_pos) {
			if(s.find({i, j}) == s.end()) return printf("%d\n", ans), 0;
		}
	}
	printf("%d\n", ans - 1);
	return 0;
}


Measured memory_bytes: 23872
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define sht short
    #define MB template <class T>il
    #define Fur(i,x,y) for(int i=x;i<=y;i++)
    #define Fdr(i,x,y) for(int i=x;i>=y;i--)
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define fcin ios::sync_with_stdio(false)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 10000011
int n,a[N];
int main(){
    in>>n;
    int old=-(1<<30),x;
    Fur(i,1,n){
        in>>x;
        if(x>old)x--;
        if(x<old)return out<<"No\n",0;
        old=x;
    }
    out<<"Yes\n";
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int** dp = new int*[n+1];
    for(int i=0;i<=n;i++)
        dp[i] = new int[3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>dp[i][j];
            if(i!=0)
            {
                int val = INT_MIN;
                for(int k=0;k<3;k++)
                {
                    if(k==j)
                        continue;
                    val = max(val,dp[i-1][k]);
                }
                dp[i][j]+=val;
            }
        }
    }
    int ans = INT_MIN;
    ans = max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
cout<<ans<<endl;

    return 0;
}

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

int main(){
	long long n, a, min = 1000000, max = -1000000, sum = 0;
	cin >> n;

	for(int i = 1; i <= n; i++){
		cin >> a;
		sum += a;
		min = (min < a)?min:a;
		max = (max > a)?max:a;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
    int R[MAX], n;

    cin >> n;
    for ( int i = 0; i < n; i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for ( int i = 1; i < n; i++)
    {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3860
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	int A, B, C;

	scanf("%d%d", &A, &B);
	printf("%d", A*A - B);


}

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

#define MOD 1000000007
#define debug(x) cout << (#x) << " is " << (x) << endl
typedef long long int ll;
#define int ll
typedef pair < ll, ll > pll;
typedef vector < vector < ll > > matrix;
typedef vector < ll > vll;

#define pi 3.1415926536
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    int a[n] = {0};
    int dec[n] = {0};

    int ans = 0;

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

    for(int i = 0; i < n-1; i++){
        if(a[i+1] <= a[i]){
            dec[i+1] = dec[i] + 1;
        }
    }

    for(int i = 0; i < n; i++){
        ans = max(ans, dec[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
n = int(input())
AL = list(map(int, input().split()))
BL = list(map(int, input().split()))
ans = 0
for i in range(n):
    if BL[i] <= AL[i]:
        ans += BL[i]
    elif BL[i] > AL[i] and BL[i] <= AL[i]+AL[i+1]:
        ans += BL[i]
        AL[i+1] = AL[i+1] - BL[i] + AL[i]
    else:
        ans += AL[i]+AL[i+1]
        AL[i+1] = 0
print(ans)


Measured memory_bytes: 82020
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

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

int main(void) {
    int n;
    vector<char> s;
    cin >> n;
    char c; cin >> c;
    s.push_back(c);
    REP(i, n - 1) {
        cin >> c;
        if (s[s.size() - 1] != c) s.push_back(c);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 512
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
s = list(map(ord, ns()))
d = dict()
for x in map(ord, list('RGB')):
    d[x] = s.count(x)
tot = sum(map(ord, list('RGB')))
ans = 0
for i in range(n-1):
    for j in range(i):
        if s[i] != s[j]:
            t = tot - s[i] - s[j]
            ans += d[t] - ((2*i - j) < n and t == s[2*i - j])
    d[s[i]] -= 1
print(ans)


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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += to_string(i).size() & 1;
	}
	cout << ans;
	return 0;
}



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

int main()
{
    char a0, b0, c0;
    string a, b, c;
    cin >> a >> b >> c;
    a0 = a[0] - 32;
    b0 = b[0] - 32;
    c0 = c[0] - 32;
    cout << a0 << b0 << c0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int X, T; cin >> X >> T;
  cout << std::max(0, X-T) << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: i32 = read();
    let M: i32 = read();
    let mut cards: Vec<i32> = vec![];
    let mut replaces: Vec<(i32, i32)> = vec![];

    for _ in 0..N {
        cards.push(read());
    }
    cards.sort();
    let mut cards = VecDeque::from(cards);

    for _ in 0..M {
        let b: i32 = read();
        let c: i32 = read();
        replaces.push((b, c));
    }
    replaces.sort_by(|a, b| a.1.partial_cmp(&b.1).unwrap());
    replaces.reverse();

    let mut sum: i64 = 0;
    for (count, num) in replaces {
        for _ in 0..count {
            if cards[0] < num {
                sum += num as i64;
            } else {
                sum += cards[0] as i64;
            }
            cards.pop_front();
            if cards.len() == 0 {
                println!("{}", sum);
                return;
            }
        }
    }
    for card in cards {
        sum += card as i64;
    }
    println!("{}", sum);
}


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

int t[5 * maxn], lazy[5 * maxn];

int doit(int a, int b) {
    return a + b;
}

void build(int start, int end, int index = 1) {
    if (start == end) {
        t[index] = INT_MAX;
        return;
    }

    int mid = start + end >> 1;
    build(start, mid, index << 1);
    build(mid + 1, end, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

void propagate(int start, int end, int index) {
    t[index] = lazy[index];
    if (start != end) {
        lazy[index << 1] = lazy[index];
        lazy[index << 1 | 1] = lazy[index];
    }
    lazy[index] = -1;
}

int query(int start, int end, int l, int r, int index = 1) {
    if (lazy[index] != -1)
        propagate(start, end, index);
    //Invalid range
    if (r < start or l > end)
        return 0;

    //In range
    if (l <= start and end <= r) {
        return t[index];
    }

    int mid = start + end >> 1;
    return doit(query(start, mid, l, r, index << 1), query(mid + 1, end, l, r, index << 1 | 1));
}

void pUpdate(int start, int end, int point, int val, int index = 1) {
    if (start == end) {
        t[index] += val;
        return;
    }

    int mid = start + end >> 1;
    if (point <= mid)
        pUpdate(start, mid, point, val, index << 1);
    else
        pUpdate(mid + 1, end, point, val, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

void rangeUpdate(int start, int end, int l, int r, int val, int index) {
    if (lazy[index] != -1)
        propagate(start, end, index);
    if (l > end or r < start)
        return;

    if (l <= start and end <= r) {
        lazy[index] = val;
        propagate(start, end, index);
        return;
    }

    int mid = start + end >> 1;
    rangeUpdate(start, mid, l, r, val, index << 1);
    rangeUpdate(mid + 1, end, l, r, val, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

void solve() {
    int n, q;
    cin >> n >> q;

    build(0, n - 1, 1);
    memset(lazy, -1, sizeof lazy);

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

        if (a == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            rangeUpdate(0, n - 1, s, t, x, 1);
        } else {
            int t;
            cin >> t;

            cout << query(0, n - 1, t, t, 1) << endl;
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vi count(m, 0);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      count[a - 1]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (count[i] == n) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int n,array[100],sum=0,ans=1e9;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
    sum+=array[i];
  }
  for(int i=0;i<n;i++){
    int summae=0;
    for(int j=0;j<=i;j++){
      summae+=array[j];
    }
    int sumushiro=sum-summae;
    ans=min(ans,abs(summae-sumushiro));
  }
  cout<<ans<<endl;
}
      

Measured memory_bytes: 256
S = list(input())
T = list(input())
L = []
M = []
al = list('abcdefghijklmnopqrstuvwxyz')

for i in range(len(al)):
    l = []
    for j in range(len(S)):
        if al[i] == S[j]:
            l.append(j)
        else:
            pass
    L.append(l)
i = 0
for i in range(len(al)):
    l = []
    for j in range(len(T)):
        if al[i] == T[j]:
            l.append(j)
        else:
            pass
    M.append(l)
if sorted(L)==sorted(M):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 72392
package main;
import "fmt";
import "math";

func main()  {
	var N int
	var ans,S1,S2 float64;
	fmt.Scan(&N);
	
	var W = make([]float64,N)
	for i:=0;i<N;i++{fmt.Scan(&W[i]);}

	ans = math.Inf(0);
	for i:=0;i<N;i++{
		for j:=0;j<i;j++{S1 += W[j]}
		for k:=i;k<N;k++{S2 += W[k]}
		ans = math.Min(math.Abs(S1-S2),ans)

		S1 = 0;S2 = 0;
	}
	fmt.Println(ans);	
}

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

int main()
{
    int B[12][10] = {0};
    int n;
    int b, f, r, v;
    cin >> n;
    while(n--)
    {
        cin >> b >> f >> r >> v;
        B[3*(b-1) + f - 1][r-1] += v;
    }
    
    for (int i = 0; i < 12; i++)
    {
        if (i && !(i%3))
        {
            n = 20;
            while(n--) cout <<"#";
            cout << endl;
        }
        for (int j = 0; j < 10; j++)
        {
            cout << " " << B[i][j];
        }
        cout << endl;
    }
    return 0;
            
}




Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cfenv>
using ll = unsigned long long;
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int m=(k-1)*2+1;
    if(m<=n){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

#define FOR(idx, begin, end) for(int idx = (begin); idx < (end); ++idx)
#define DBG(x) cerr << #x << ": " << x << "\n"

using namespace std;
typedef long long lint;
const int MOD = 1000000007;

int main() {

	cin.tie(0);

	int N, L;
	cin >> N >> L;

	vector<string> words(N);
	FOR(i, 0, N) cin >> words[i];

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

	FOR(i, 0, N) cout << words[i];
	return 0;
}

Measured memory_bytes: 256