akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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;
}
#define NIL -1
struct Node {
    int parent;
    int left;
    int right;
};

void print(int i, Node arr[], int ds[]) {
    cout << "node " << i << ": ";
    cout << "parent = " << arr[i].parent;
    cout << ", depth = " << ds[i];
    cout << ", ";

    if (arr[i].parent == NIL) cout << "root";
    else if (arr[i].left == NIL) cout << "leaf";
    else cout << "internal node";
    cout << ", [";

    if (arr[i].left != NIL) {
        int current = arr[i].left;
        cout << current;

        while (arr[current].right != NIL) {
            current = arr[current].right;
            cout << ", " << current;
        }
    }
    cout << "]" << endl;
}
void depth(int n, int d, Node nodes[], int ds[]) {
    ds[n] = d;
    if (nodes[n].right != NIL) depth(nodes[n].right, d, nodes, ds);
    if (nodes[n].left != NIL) depth(nodes[n].left, d+1, nodes, ds);
}
int main() {
    int n, id, k, c, root;
    Node T[100001];
    int D[100001];
    cin >> n;
    rep(i, 0, n) T[i].parent = T[i].left = T[i].right = NIL;
    rep(i, 0, n)  {
        cin >> id >> k;
        int left;
        rep(j, 0, k) {
            cin >> c;
            if (j == 0){ 
                T[id].left = c;
            } else {
                T[left].right = c;
            }
            T[c].parent = id;
            left = c;
        }
    }

    rep(i, 0, n) {
        if (T[i].parent == NIL) {
            root = i;
            break;
        }
    }

    depth(root, 0, T, D);
    rep(i, 0, n) print(i, T, D);
    

    return 0;
}


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

long long n=1e4,k,cont,mod=1e9+7ll,dp[100][65000];

vector<long long> v;

int main(){

    cin>>n>>k;
    
    v.push_back(0);
	for(long long i=1;i<=n;i++){
	    i=n/(n/i);
	    v.push_back(i);
    }
    
    for(int i=k-1;i>=0;i--){
        for(int j=v.size()-1;j>0;j--){
            
            if(i==k-1)dp[i][j]=v[j];
            else
            dp[i][j]=dp[i+1][v.size()-j];
            
            //cout<<i<<" "<<j<<" "<<v[j]<<endl;
            //cout<<dp[i][j]<<endl;
            dp[i][j]*=(v[v.size()-j]-v[v.size()-j-1])%mod;
            //cout<<dp[i][j]<<endl;
            dp[i][j]%=mod;
            dp[i][j]+=dp[i][j+1];
            dp[i][j]%=mod;
        }
    }
    
    
    cout<<dp[0][v.size()-1]<<"\n";

return 0;
}


Measured memory_bytes: 51576
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
ll K;

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

bool solve()
{
	ll a,b,c,d,t;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	if(b>d || a<b){
		return false;
	}
	if(c>=b){
		return true;
	}
	ll g = gcd(d,b);
	if(b-g+a%g>c){
		return false;
	}else{
		return true;
	}
}

int main(){
	int y;
	scanf("%d",&y);
	while(y--){
		if(solve())printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var output = "";
            for (var i = 0; i < s.Length; i++)
            {
                if ((i + 1) % 2 != 0)
                {
                    output += s[i];
                }
            }

            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 34772
N, M = map(int, input().split())
A = list(set(map(lambda x : int(x)//2, input().split())))
def gcd(x, y):
  return x if y == 0 else gcd(y, x % y)
def lcm(x, y):
  return (x * y) // gcd(x, y)
l = A[0]
for a in A[1:]:
  l = lcm(l, a)
ans = (M // l + 1) // 2
for a in A[1:]:
  if (l // a) % 2 == 0:
    ans = 0
    break
print(ans)


Measured memory_bytes: 11132
#include<bits/stdc++.h>
using namespace std;
#define sz 100005
typedef long long ll;
int arr[101];
int brr[101];
ll dp[101][sz];

ll cal(int n, int val){
    if(n<=0)return 0;
    if(val<=0)return 0;
    if(dp[n][val]!=-1)return dp[n][val];

    ll a=cal(n-1,val);
    ll b=0;
    if(val-arr[n]>=0){
        b=brr[n]+cal(n-1,val-arr[n]);
    }
    return dp[n][val]=max(a,b);
}

int main(){

    int n,val;
    cin>>n>>val;
    for(int i=1;  i<=n; i++){
        cin>>arr[i]>>brr[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<cal(n,val);

    return 0;
}


Measured memory_bytes: 82428
s = input()

while True:
  if s == "":
    print('YES')
    break
  elif s[-7:] == 'dreamer':
    s = s[:-7]
  elif s[-6:] == 'eraser':
    s = s[:-6]
  elif s[-5:] == 'dream' or s[-5:] == 'erase':
    s = s[:-5]
  else:
    print('NO')
    break
      

Measured memory_bytes: 3188
#???
n=int(input())
a=list(map(int,input().split()))
MOD=10**9+7

def gcd(x,y):
  if x<y:x,y=y,x
  if y==0:return x
  return gcd(x%y,y)

def lcm(x,y):
  return x*y//gcd(x,y)

def inv(x):
  return pow(x,MOD-2,MOD)

L=1
for i in a:
  L=lcm(L,i)

L=L%MOD
ans=0
for i in a:
  ans=(ans+L*inv(i))%MOD
  

print(ans)

Measured memory_bytes: 4084
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
        int maisu = calcMaisu(n);
         
      	System.out.println(maisu * 1000 - n);
    }

    private static int calcMaisu(int n) {
        int maisu = 0;
        do {
            maisu++;
        }while(n > maisu * 1000);
      	return maisu;
    }
  
}

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

int main()
{
  int N; cin >> N;
  vector<int> B(N-1);
  for (int i = 0; i < N-1; i++)
  {
    cin >> B[i];
  }
  int ans = 0;
  for (int i = 0; i < N-2; i++)
  {
    ans += min(B[i], B[i + 1]);
  }
  ans += B[0];
  ans += B[N - 2];
  cout << ans << endl;

}

Measured memory_bytes: 256
require 'matrix'

N, D = gets.split.map(&:to_i)
Xs = STDIN.each_line.to_a.map { |l| Vector[*l.split.map(&:to_i)] }.to_a

out = Xs.combination(2).select { |(x_i, x_j)|
  d = Math.sqrt((x_j - x_i).map { |d| d ** 2 }.reduce(&:+))
  d.to_i == d
}.count

puts out


Measured memory_bytes: 2684
#include<stdio.h>
int main(){
    char s[200001], t[200001];
    scanf("%s", s);
    scanf("%s", t);
    long int i, cnt=0;
    for(i=0; i<strlen(s); i++){
        if(s[i] != t[i]) cnt++;
    }
    printf("%ld", cnt);
    return 0;
}

Measured memory_bytes: 2116
//InTheNameOfGod
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
const int maxn =400 ;
int n;
string s[maxn];
int re=0;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    rep(i,0,n)
    {
        cin>>s[i];
    }
    rep(rot,0,n)
    {
        bool f=true;
        rep(i,0,n)
        {
            rep(j,0,n)
            {
                int x=(i+rot)%n,y=(j+rot)%n;
                if(s[x][j]!=s[y][i])f=false;
            }
        }
        if(f)re+=n;
    }
    cout<<re;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

ll n,x;

int main(){
  cin>>n>>x;

  cout<<3*(n-__gcd(n,x))<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int ha=INT_MAX, dif=INT_MAX;
		int n,z,za,x;
		cin>>x>>n;
		set<int> s;
		for(int i=0;i<200;i++){
			s.insert(i);
		}
		for(int i=0;i<n;i++){
			cin>>za;
			s.erase(za);			
		}
		for(auto z:s){
			if(abs(z-x)<dif){
				ha=z;
				dif=abs(z-x);
			}
		}
		cout<<ha;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

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

typedef pair<int, int> P;

int H, W, N;

char v[1001][1001];
bool visit[1001][1001];

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int bfs(P s, P g){
	memset(visit, 0, sizeof(visit));
	queue<pair<int, P> > q;
	q.push(make_pair(0, s));
	int res = 0;
	while(!q.empty()){
		P p = q.front().second;
		int d = q.front().first;
		q.pop();

		if(visit[p.second][p.first]) continue;
		visit[p.second][p.first] = true;
		if(p == g) return d;

		rep(i, 4){
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
			if(v[ny][nx] == 'X') continue;
			q.push(make_pair(d+1, make_pair(nx, ny)));
		}
	}

	return -1;
}

int main(){
	cin >> H >> W >> N;
	vector<P> pos(10);
	rep(i, H) rep(j, W){
		cin >> v[i][j];
		if(v[i][j] == 'S') pos[0] = make_pair(j, i);
		for(int k = '1'; k <= '9'; k++){
			if(v[i][j] == k) pos[k-'0'] = make_pair(j, i);
		}
	}
	int ans = 0;
	rep(i, N){
		ans += bfs(pos[i], pos[i+1]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x0, r, d;
  cin >> r >> d >> x0;
  vector<int> x(10);
  for(int i = 0; i < 10; i++){
    x.at(i) = r*x0 - d;
    x0 = x.at(i);
    cout << x.at(i) << endl;
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

void print_vector(vector<ll>& a){
    REP(i, a.size()){
        cout << a.at(i);
        if(i + 1 < a.size()){
            cout << ' ';
        }
    }
    cout << endl;
}

void insertion_sort(vector<ll>& a){
    print_vector(a);
    for(ll i = 1; i < a.size(); ++i){
        const ll v = a.at(i);
        ll j;
        for(j = i - 1; j >= 0 && a.at(j) > v; --j){
            a.at(j + 1) = a.at(j);
        }
        a.at(j + 1) =  v;
        print_vector(a);
    }
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    insertion_sort(a);
    return 0;
}



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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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; }

#define DEBUG

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

	int m;
	int cnt = 0;
	for(int i = 1; i <= n; i++)
	{
		int c = 0;
		int ite = i;
		while(ite != 0)
		{
			ite /= 2;
			c++;
		}
		if(c > cnt)
		{
			cnt = c;
			m = i;
		}
	}

	cout << m << endl;
	return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<int> a(n,0);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end(),greater<int>());
    int alice = 0;
    int bob = 0;
    rep(i,n){
        if(i%2 == 0)alice += a[i];
        else bob += a[i];
    }
    cout << alice - bob << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int R = sc.nextInt();

        if (N > 10) {
            System.out.println(R);
        } else {
            System.out.println((R + 100 * (10 - N)));
        }
    }
}


Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

struct task{
	int cost;
	int deadLine;
};

bool myComp(task left,task right){
	return (left.deadLine < right.deadLine);
}

int main()
{
	int n;
	cin>>n;
	int ans = 0;
	int ansNum = 1;
	for(int i = 1; i <= n; i++){
		int temp = i;
		int num = 0;
		while( temp % 2 == 0 ){
			num++;
			temp /= 2;
		}
		if( num >= ans){
			ans = num;
			ansNum = i;
		}
	}
	cout<<ansNum<<endl;
	return 0;
}



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

int main() {
    double L;
    cin >> L;
    double ans = L/3 * L/3 * L/3;
    printf("%.12lf\n",ans);
}


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}



//---------------------------------------------------------------

int main(){
  int N;
  cin>>N;
  string S;
  vector<vector<int>>T(N,vector<int>(26,0));
  rep(i,N){
    cin>>S;
    sort(S.begin(),S.end());
    rep(j,S.size()){
      T.at(i).at(S.at(j)-'a')++;
    }
  }
  vector<int>A(26,100);
  rep(i,N){
    rep(j,26){
      A.at(j)=min(T.at(i).at(j),A.at(j));
    }
  }
  string ans;
  rep(j,26){
    if(A.at(j)>1){
      rep(i,A.at(j)){
        ans.push_back('a'+j);
      }
    }else if(A.at(j)==1){
      ans.push_back('a'+j);
    }

  }

  cout<<ans<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int data = scan.nextInt();
			for(int Case = 0;Case < data;Case++){
				int x = scan.nextInt();
				int y = scan.nextInt();
				int w = scan.nextInt();
				int h = scan.nextInt();
				int cat = scan.nextInt();
				int count = 0;
				int cx;
				int cy;
				for(int i = 0;i < cat;i++){
					cx = scan.nextInt();
					cy = scan.nextInt();
					if(x <= cx && x+w >= cx && y <= cy && y+h >= cy){
						count++;
					}
				}
				System.out.println(count);
			}
		}
	}
}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long ll;

vector<int> k;
int n, d;

ll memo[10005][105];

const ll mod = 1e9 + 7;

ll dp(int pos, int curmod){
	if(pos==n and curmod%d == 0)	return 1;
	if(pos==n)	return 0;
	if(memo[pos][curmod] != -1)	return memo[pos][curmod];
	memo[pos][curmod] = 0;
	for(int i = 0; i < 10; i++){
		memo[pos][curmod] = (memo[pos][curmod]+dp(pos+1, (curmod+i)%d))%mod; 
	}
	return memo[pos][curmod];
}

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

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

	string s;
	cin >> s;
	cin >> d;
	n = s.length();

	for(int i = 0; i < s.length(); i++){
		k.PB(s[i] - '0');
	}

	ll ans = 0;
	int curmod = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < k[i]; j++){
			ans = (ans + dp(i+1, (curmod + j)%d))%mod;
		}
		curmod = (curmod + k[i])%d;
	}
	if(curmod == 0)	ans = (ans + 1)%mod;

	cout << (ans-1 + mod)%mod << "\n";

	return 0;
}

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {
	
	static class State{
		int x, y;
		State(int x, int y){
			this.x=x;
			this.y=y;
		}
	}
	
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			while(sc.hasNext()) {
				int N=sc.nextInt();//PC数
				int M=sc.nextInt();//学生数
				if(N==0) break;
				int r=sc.nextInt();
				
				int[][] startpc=new int[N+1][M+1];
				int[][] timepc=new int[N+1][1300];
				int[] time=new int[M+1];
				
				for(int i=0; i<r; i++) {
					int t=sc.nextInt();
					int n=sc.nextInt();
					int m=sc.nextInt();
					int s=sc.nextInt();
					if(s==1) {
						startpc[n][m]=t;
					}
					else if(s==0) {
						for(int j=startpc[n][m]; j<t; j++) {
							timepc[n][j]=m;
						}
					}
				}
				int q=sc.nextInt();
				for(int i=0; i<q; i++) {
					int ts=sc.nextInt();
					int te=sc.nextInt();
					int m=sc.nextInt();
					int num=0;
					int sum=0;
					for(int j=ts; j<te; j++) {
						num=0;
						for(int k=1; k<=N; k++) {
							if(timepc[k][j]==m) {
								num=1;
							}
						}
						sum+=num;
					}
					System.out.println(sum);
					
				}
				
				
				
			}
			
			
		}
	}
} 


Measured memory_bytes: 147012
N, M, X = map(int, input().split())

A = [[] for _ in range(N)]
c = [0] * N

for i in range(N):
    c_as = list(map(int, input().split()))
    c[i], A[i] = c_as[0], c_as[1:]

INF = 10 ** 9
ans = INF

for s in range(0, 1 << N):
    smart = [0] * M
    cost_sum = 0
    for i in range(N):
        if (s >> i) % 2 == 0: continue
        cost_sum += c[i]
        for j in range(M):
            smart[j] += A[i][j]
    ok = True
    for j in range(M):
        if smart[j] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)

if ans == INF:
    ans = -1

print(ans)




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

class UnionFind{
public:
    vector<int> tree;

    void init(){
        for(int i = 0;i < tree.size();i++){
            tree[i] = -1;
        }
        return;
    }

    UnionFind(int n){
        n++;
        tree.resize(n);
        init();
        return;
    }

    int root(int i){
        if(tree[i] < 0) return i;
        return tree[i] = root(tree[i]);
    }

    bool unite(int i, int j){
        i = root(i);
        j = root(j);
        if(i == j) return false;

        tree[i] += tree[j];
        tree[j] = i;
        return true;
    }

    int size(int i){
        return -tree[root(i)];
    }

    bool same(int i, int j){
        return root(i) == root(j);
    }
};

int main(){
    int n;
    string s;
    cin >> s;
    n = s.size();

    UnionFind uf(n);
    for(int i = 0;i < n-1;i++){
        if(s[i] == s[i+1]){
            uf.unite(i, i+1);
        }
    }

    int ans[200010] = {};
    for(int i = 0;i < n-1;i++){
        if(s[i] == 'R' && s[i+1] == 'L'){
            ans[i] += (uf.size(i)+1) / 2 + uf.size(i+1) / 2;
            ans[i+1] += (uf.size(i+1)+1) / 2 + uf.size(i) / 2;
            i++;
        }
    }

    cout << ans[0];
    for(int i = 1;i < n;i++){
        cout << " " << ans[i];
    }

    cout << endl;

    return 0;
}



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

using ll = long long;
using P = pair<int, int>;

int main()
{
    string S;
    cin >> S;
    int maxNum = 0;
    rep(i, S.length())
    {
        int tempMaxNum = 0;
        int j = i;
        while (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T')
        {
            j++;
            tempMaxNum++;
        }
        maxNum = max(maxNum, tempMaxNum);
    }
    cout << maxNum << endl;
    return 0;
}

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

using namespace std;

int main() {

    string s;
    cin >> s;

    vector<int> direction(4);
    fill(direction.begin(), direction.end(), 0);
    for (int i = 0; i < s.size(); i++) {
        switch (s[i]) {
            case 'E':
                direction[0]++;
                break;
            case 'W':
                direction[1]++;
                break;
            case 'S':
                direction[2]++;
                break;
            case 'N':
                direction[3]++;
                break;
        }
    }

    if (((direction[0] == 0 && direction[1] == 0) || (direction[0] != 0 && direction[1] != 0))
            && ((direction[2] == 0 && direction[3] == 0) || (direction[2] != 0 && direction[3] != 0))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int h,w;

int main(){
	cin>>h>>w;
	int ans=0;
	REP(i,h){
		REP(j,w){
			char t;
			cin>>t;
			if(t=='#'){
				ans++;
			}
		}
	}
	if(ans==h+w-1)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define LEN 100005


//?§???????
typedef struct pp{
  char name[100];
  int time;
}Process;


//?????°??£?¨?
Process process[LEN+1];
int head=0,tail=0,num;


//??¢??°??£?¨?
void enqueue(Process);
Process dequeue(void);


int main(){
  int time=0;
  int i,quantum,count=0;
  Process k;
  k.time = 0;


  //??\???
  scanf("%d %d",&num,&quantum);
  for(i = 0; i < num; i++){
      scanf("%s",process[i].name);
      scanf("%d",&process[i].time);
    }
  head = 0;
  tail = num;

  while(head != tail){
    k = dequeue();

    if(k.time > quantum){
      time += quantum;
      k.time -= quantum;
      enqueue(k);
    }
    else{
      time += k.time;
      printf("%s %d\n",k.name,time);
      count++;
    }
  }

  return 0;
}


  //??¢??°
void enqueue(Process x){
  process[tail] = x;
  if( tail+1 == LEN){
    tail = 0;
  }
  else{
    tail++;
  }
}
Process dequeue(void){
  Process x;
  x = process[head];
  if( head+1 == LEN){
    head = 0;
  }
  else{
    head++;
  }
  return x;
}

Measured memory_bytes: 10756
def main():
    h,w = map(int, input().split())

    A = []
    grid = []
    for i in range(h):
        A.append(input())
    gird = []

    for i in range(h):
        if A[i] != '.'*w:
            grid.append(A[i])

    A = grid.copy()
    w_tmp = len(A[0])
    h_tmp = len(A)
    grid = ['' for _ in range(h_tmp)]
    for i in range(w_tmp):
        tmp = 0
        for j in range(h_tmp):
            if A[j][i] == '.':
                tmp += 1
        if tmp != h_tmp:
            for j in range(h_tmp):
                grid[j] += A[j][i]
    for i in range(len(grid)):
        print(grid[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  
  int N, M, a;
  vector<int> X;

  cin >> N >> M;
  for(int i=0;i<M;i++){
  	cin >> a;
  	X.push_back(a);
  }
  sort(X.begin(), X.end());

  vector<int> interval;
  for(int i=0;i<M-1;i++){
  	interval.push_back(X[i+1]-X[i]);
  }

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

  int sum = 0;
  for(int i=0;i<N-1;i++){
    if(M-2-i>=0) sum += interval[M-2-i];
  }

  cout << X[M-1]- X[0]-sum <<endl;
  

  return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin >> n;
   n -= (n / 10) * 10;
   if(n == 0 || n == 1 || n == 6 || n == 8){
     cout << "pon" << endl;
   }
   else if(n == 3){
     cout << "bon" << endl;
   }else{
     cout << "hon" << endl;
   }
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            if ((Math.Abs(a[1] - a[0]) <= a[3] && Math.Abs(a[2] - a[1]) <= a[3]) || Math.Abs(a[2]- a[0]) <= a[3]) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long int
#include<list>
#include<algorithm>
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LP lower_bound
#define UP upper_bound
#define MP make_pair
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define EF else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define UMP unordered_map
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
void printArray(vector<ll> arr, ll n) 
{ 
    for (ll i = 0; i < n; i++) 
        cout << arr[i] << " "; 
    cout << endl; 
} 
void printSubsequences(vector<ll> arr, ll index,  
                       vector<ll> subarr) 
{ 
    // Prll the subsequence when reach 
    // the leaf of recursion tree 
    if (index == arr.size()) 
    { 
        ll l = subarr.size(); 
  
        // Condition to avoid printing 
        // empty subsequence 
        if (l != 0) 
            printArray(subarr, l); 
    } 
    else
    { 
        // Subsequence without including 
        // the element at current index 
        printSubsequences(arr, index + 1, subarr); 
  
        subarr.push_back(arr[index]); 
  
        // Subsequence including the element 
        // at current index 
        printSubsequences(arr, index + 1, subarr); 
    } 
    return; 
} 
int main()
{
    fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;

    /*
    **  author : mahiman12
    **  created : 2020-05-10 18:24 
    */
    cin>>n>>k;
    ll arr[n+1];
    rep(i,1,n+1)
    {
        cin>>arr[i];
    }
    ll before = 1;
    ll next = arr[1];
    ll vis[n+1];
    memset(vis, false, sizeof(vis));
    vis[1]=true;
    while(vis[next]==false)
    {
        vis[next]=true;
        next = arr[next];
        before++;
    }
    ll after = 1;
    ll nxt = arr[next];
    while(nxt!=next)
    {
        after += 1;
        nxt = arr[nxt];
    }
    if(before>=k)
    {
        nxt = 1;
        while(k--)
        {
            nxt = arr[nxt];
        }
        cout<<nxt;
    }
    else
    {
        k = (k-before)%after;
        // cout<<res<<endl;
        nxt = next;
        while(k--)
        {
            nxt = arr[nxt];
        }
        cout<<nxt;
    }
}




Measured memory_bytes: 6760
a, b, c = map(int,input().split())
k = int(input())
count = -1

if a >= b:
    for i in range(k):
        b = 2*b
        if a < b:
            count = i
            break
if b >= c:
    for j in range(count+1, k):
        c = 2*c
        if b < c:
            break
if a < b and b < c:
        print("Yes")
else:
    print("No")

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

using namespace std;

struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

int main(void) {
    int64_t N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for(int i=0; i<M; i++) {
        cin >> A[i] >> B[i];
        --A[i];
        --B[i];
    }

    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());

    UnionFind uf(N);
    vector<int64_t> ans(M);
    ans[0] = N*(N-1) / 2L;
    for(int i=0; i<M-1; i++) {
        if(uf.find(A[i]) != uf.find(B[i])) {
            ans[i+1] = ans[i] - uf.size(A[i]) * uf.size(B[i]);
            uf.unite(A[i], B[i]);
        } else {
            ans[i+1] = ans[i];
        }
    }

    reverse(ans.begin(), ans.end());
    for(auto e: ans) {
        cout << e << endl;
    }
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define debug(x) {cerr<<#x<<" = "<<(x)<<endl;}
#define M(x) memset(x,0,sizeof(x))
#define dalao main
using namespace std;
int dalao()
{
    ios::sync_with_stdio(false);
    int d,t,s;
    cin>>d>>t>>s;
    if(1.0*d/s <= t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3604
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]:
   if A[i][2]>A[i+1][2]:return 0
 return 1
n=int(input())
f=lambda x,y:(x,int(y))
A=[(*f(*e.split()),i)for i,e in enumerate(sys.stdin)]
k(A,0,n-1)
print(['Not s','S'][s(A)]+'table')
for e in A:print(*e[:2])


Measured memory_bytes: 20332
// Shift-JIS（シフトジス）

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

int gcd(int a, int b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

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

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

int main()
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    cout << *max_element(A, A + N) - *min_element(A, A + N) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=100005;
int n,a[MAXN],ans;
int gcd(int x,int y){
	if(x==0)return y;
	else return gcd(y%x,x);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);ans=a[1];
	for(int i=1;i<=n;i++)
		ans=gcd(ans,a[i]);
	printf("%d\n",ans);
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,temp,ans=0;
    cin>>n;
    for(ll i=105;i<=n;i+=2){
        temp=0;
        for(ll j=1;j*j<=i;j++){
            if(!(i%j)){
                temp++;
                if(i/j!=j)temp++;
            }
        }
        if(temp==8)ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
ll MOD = 1000000007;
 
using namespace std;
 
int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int changes = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'L' && i > 0 && s[i - 1] == 'L') {
            ans++;
        }
        if (s[i] == 'R' && i < n - 1 && s[i + 1] == 'R') {
            ans++;
        }
        if (i > 0 && s[i] != s[i - 1]) changes++;
    }
    
    if (k >= ( (changes + 1) / 2 ) ) {
        ans = n-1;
    } else {
        ans += (2 * k);
    }
    cout << ans;
  
    return 0;
}


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

int main() {
  int i, n, sub, ans = 1000, diff;
  string S, str;
  cin >> S;
  n = S.size();
  for (i = 0; i + 3 <= n; i++) {
    str = S.substr(i, 3);
    sub = stoi(str);
    diff = abs(753 - sub);
    ans = min(ans, diff);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>
#include<stack>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> lltpl;

int dy8[8] = { 2,2,-2,-2,1,1,-1,-1 };
int dx8[8] = { 1,-1,1,-1,2,-2,2,-2 };
int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };


/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = 1e17 + 7;
constexpr ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

// vector
template <typename T>
istream& operator>>(istream & is, vector<T> & vec) { for (T& x : vec) is >> x; return is; }
// pair
template <typename T, typename U>ostream& operator<<(ostream & os, pair<T, U> & pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; }
// vector
template <typename T>ostream& operator<<(ostream & os, const vector<T> & vec) { os << "{";	for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : ", "); }os << "}"; return os; }
// map
template <typename T, typename U>ostream& operator<<(ostream & os, map<T, U> & map_var) { os << "{";	repi(itr, map_var) { os << *itr; itr++; if (itr != map_var.end()) os << ", "; itr--; }os << "}"; return os; }
// set
template <typename T>ostream& operator<<(ostream & os, set<T> & set_var) { os << "{"; repi(itr, set_var) { os << *itr; itr++; if (itr != set_var.end()) os << ", "; itr--; }os << "}"; return os; }


int main() {

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

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

	sort(A.begin(), A.end());
	
	int ans = 0;

	for (int mid = N - 1; mid >= 0; mid--) {
		for (int low = mid - 1; low >= 0; low--) {
			auto itr = lower_bound(A.begin(), A.end(), A[mid] + A[low]);
			int ng = distance(itr, A.end());
			ans += (N - 1 - mid) - ng;
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<pair<int,pair<int,int> > >points;
vector<pair<int,pair<int,int> > > edge;
int par[100005];
bool cmp(pair<int,pair<int,int> > &a,pair<int,pair<int,int> > &b ){
	return a.second.first<b.second.first;
}
bool cmp2(pair<int,pair<int,int> > &a,pair<int,pair<int,int> > &b ){
	return a.second.second<b.second.second;
}
void init(){
	for(int i=1;i<=100000;i++){
		par[i]=i;
	}
}
int find(int i){
	if(par[i]==i) return par[i];
	return par[i]=find(par[i]);
}
void dsu(int i,int j){
	par[find(i)]=find(j);
}
bool same(int i,int j){
	return find(i)==find(j);
}
signed main(){
//	freopen("plantree.inp","w",stdin);
//	freopen("plantree.out","r",stdout);
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x,y;
		cin>>x>>y;
		points.push_back(make_pair(i,make_pair(x,y)));
	}	
	init();
	sort(points.begin(),points.end(),cmp);
	for(int i=1;i<points.size();i++){
		edge.push_back(make_pair(points[i].second.first-points[i-1].second.first,make_pair(points[i].first,points[i-1].first)));
	}
	sort(points.begin(),points.end(),cmp2);
	for(int i=1;i<points.size();i++){
		edge.push_back(make_pair(points[i].second.second-points[i-1].second.second,make_pair(points[i].first,points[i-1].first)));
	}
	sort(edge.begin(),edge.end());
	int ans=0;
	
	for(int i=0;i<edge.size();i++){
		if(!same(edge[i].second.second,edge[i].second.first)){
			ans+=edge[i].first;
			dsu(edge[i].second.second,edge[i].second.first);
		}
	}
	cout<<ans;
}

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

ll ans,ans2,suf,gao=1;
int n,p,cnt[200005];
char s[200005];

int main()
{
    scanf("%d%d%s",&n,&p,s);
    cnt[0]=1;
    for(int i=0;i<n;i++) ans2+=((s[i]-'0')%p==0)*(i+1);
    for(int i=n-1;i>=0;i--)
    {
        suf=(suf+(s[i]-'0')*gao)%p;
        gao=10*gao%p;
        ans+=cnt[suf];
        cnt[suf]++;
    }
    printf("%lld",p==2||p==5?ans2:ans);
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define PI 3.14159265358979323846264338327950288

using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;

int main(){
    FAST_IO ;
    bigint a , b , c , d ; cin >> a >> b >> c >> d ;
    bigint ans = -1e18 ;
    ans = max( ans , a * c ) ;
    ans = max ( ans , a * d ) ;
    ans = max ( ans , b * d ) ;
    ans = max ( ans , b * c ) ;
    cout << ans << endl ;
    
    return 0 ;
  }





// dp[x] = represents the expected value of steps to get gcd = 1 when current gcd = x


// Exepected Value  = 1 + sigma ( dp[i] / M ) from i = 1 to M ;

// 001
// 110
// 011
// 100




Measured memory_bytes: 3636
#include<stdio.h>

int main(){
 int S,h,m,s;

 scanf("%d",&S);

 h=S/3600;
 S=S-h*3600;
 
 m=S/60;
 S=S-m*60;
 s=S;


 printf("%d:%d:%d\n",h,m,S);
 return 0;

}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)

ll dp[3005][3005], mm = 1e9+7;
//dp[i][j] = fixed all before i, from [i, n] there are j 1's
int n, m, num[3005], r[3005], a, b;
string s;
vector<pi> v;

void add(ll &a, ll b) {
	b %= mm;
	a += b;
	a %= mm;
}

int main() {
	cin >> n >> m >> s;
	FOR(i, 0, n-1) r[i] = i;
	FOR(i, 1, m) {
		cin >> a >> b; a--; b--;
		if (v.empty()) v.pb(pi(a, b));
		else if (v.back().f == a) v.back().s = max(v.back().s, b);
		else if (v.back().s < b) v.pb(pi(a, b));
	}
	for(auto it:v) r[it.f] = it.s;
	FOR(i, 1, n-1) r[i] = max({i, r[i], r[i-1]});
	
	num[0] = (s[0] == '1');
	FOR(i, 1, n-1) num[i] = num[i-1] + (s[i] == '1');

	dp[0][num[n-1]] = 1;
	FOR(i, 0, n-1) FOR(j, 0, num[n-1]) {
		if (dp[i][j] == 0) continue;
		int inr = j - (num[n-1] - num[r[i]]);
		if (inr > 0) add(dp[i+1][j-1], dp[i][j]);
		if (r[i] - i + 1 > inr) add(dp[i+1][j], dp[i][j]);
	}
	cout << dp[n][0];
}


Measured memory_bytes: 68480
#include <iostream>

using namespace std;

int main()
{
	int N, Y;
	cin >> N >> Y;
	for (int x = 0; x <= N; ++x) {
		for (int y = 0; y <= N; ++y) {
			int z = N - x - y;
			if (z < 0) {
				continue;
			}
			if (9000 * x + 4000 * y == Y - 1000 * N) {
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
n=gets.to_i
p=gets.split.map &:to_i

answer = 0

n.times do |i|
  next if i == 0 || i == n - 1
  answer += 1 if (p[i+1] > p[i] && p[i-1] < p[i]) || (p[i+1] < p[i] && p[i-1] > p[i])
end

puts answer


Measured memory_bytes: 3836
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string a;
    cin>>a;
    if(a=="Sunny"){
        cout<<"Cloudy";
        return 0;
    }else if(a=="Cloudy"){
        cout<<"Rainy";
        return 0;
    }else if(a=="Rainy"){
        cout<<"Sunny";
        return 0;
    }
}


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

using namespace std;

const int MAX_N = 86;
int n;
long int memo[MAX_N+1];


long int lucas(int n){
    if (memo[n] != 0) return memo[n];
    else return memo[n] = lucas(n-1) + lucas(n-2);
}


int main(){
    scanf("%d", &n);
    fill(memo, memo + n + 1, 0);
    memo[0] = 2;
    memo[1] = 1;
    long int ans = lucas(n);
    printf("%ld\n", ans);
}

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

ll score = 0;




int main(){
    int D;
    cin>>D;
    int N = 26;


    vector<int> c(N+1);
    vector<vector<int>> s(D+1, vector<int>(N+1));
    vector<int> t(D+1);
    vector<int> last(N+1, 0);

    for(int i=1; i<=N; i++){
        cin>>c[i];
    }

    for(int i=1; i<=D; i++){
        for(int j=1; j<=N; j++){
            cin>>s[i][j];
        }
    }

    for(int d = 1; d <= D; d++){
        ll max_score = -1e9;
        vector<int> max_last;
        for(int n = 1; n <= N; n++){
            ll tmp_score = 0;
            vector<int> tmp_last(N+1);
            tmp_last = last;
            
            tmp_score +=  s[d][n];
            tmp_last[n] = d;
     
            int penalty = 0;
            for(int i = 1; i <= N; i++){
                penalty += c[i]*(d-tmp_last[i]);    
                
            }
            
            tmp_score -= penalty;

            if(max_score < tmp_score){
                max_score = tmp_score;
                max_last = tmp_last;
                t[d] = n;
            }                    
            
        }
        
        last = max_last;
        
    }

   
    for(int i=1; i<=D; i++){
                    
        cout<<t[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int ans = 0;

		if(b <= c || d <= a){
			ans = 0;
		}
		else if(c <= a && b <= d){
			ans = b - a;
		}
		else if(a <= c && d <= b){
			ans = d - c;
		}
		else if( a <= c && c <= b && b <= d){
			ans = b - c;
		}
		else if( c <= a && a <= d && d <= b){
			ans = d-a;
		}
		System.out.println(ans);
	}
}

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

int main(void){
    deque<int> v;
    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int num, d, x;
        cin >> num;
        if(num==0){
            cin >> d >> x;
            if(d==0) v.push_front(x);
            else v.push_back(x);
        }
        else if(num==1){
            cin >> x;
            cout << v.at(x) << "\n";
        }
        else{
            cin >> d;
            if(d==0) v.pop_front();
            else v.pop_back();
        }
    }
    
    
    return 0;
}



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

using namespace std;
typedef long long ll;
ll a,b,c;
inline int read() {
	char ch = getchar();
	int x = 0, f = 1;
	while (ch < '0' || ch > '9')
		f = (ch == '-' ? -1 : 1), ch = getchar();
	while (ch >= '0' && ch <= '9')
		x = x * 10 + ch - 48, ch = getchar();
	return x * f;
}
int main() {
	cin>>a>>b>>c;
	if(c-a-b<=0) cout<<"No";
	else {
		if(4ll*a*b<(c-a-b)*(c-a-b)) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}

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

int main() {
    int N, M;
    cin>>N>>M;
    vector<pair<int, int>> jobs;
    jobs.resize(N);
    for(int i=0; i<N; i++)
        cin>>jobs[i].first>>jobs[i].second;
    sort(jobs.begin(), jobs.end());

    priority_queue<int> Q;
    int j = 0;
    int tot = 0;
    for(int i=M-1; i>=0; i--) {
        while(j <= N-1 && jobs[j].first + i <= M)
            Q.push(jobs[j++].second);
        if(!Q.empty()) {
            tot += Q.top();
            Q.pop();
        }
    }
    
    cout<<tot;
    return 0;
}

Measured memory_bytes: 1660
//Hina Arare
//https://atcoder.jp/contests/abc073/tasks/abc073_b

#include <cstdio>
#include <string>

int main()
{
  int N;
  int f = 0;

  scanf("%d", &N);
  int Ns = N;
  for (int i = 0; i < 8; i++)
  {
    int rem;
    rem = Ns % 10;
    f += rem;
    Ns /= 10;
  }
  if (N % f == 0)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
}


Measured memory_bytes: 128