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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

ll N;
string P, Q;
ll p_c, q_c;
ll all_c;

void dp(ll len, string s) {
  if (len == N) {
    all_c++;

    if (P == s)
      p_c = all_c;
    if (Q == s)
      q_c = all_c;

    // cout << s << endl;
    return;
  }
  for (ll i = 1; i <= N; i++) {
    string c = to_string(i);
    if (s.find(c) == std::string::npos) {
      dp(len + 1, s + c);
    }
  }
}

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

  CIN(N);

  ll tmp;
  for (int i = 0; i < N; i++) {
    CIN(tmp);

    P += to_string(tmp);
  }

  for (int i = 0; i < N; i++) {
    CIN(tmp);

    Q += to_string(tmp);
  }

  ll count = 0;

  dp(0, "");

  cout << abs(p_c - q_c) << endl;
}


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

int main() {
    string s;
    cin >> s;
    if (s == "RRR") {
        cout << 3 << endl;
    } else if (s =="SRR") {
        cout << 2  << endl;
    } else if (s =="RSR") {
        cout << 1  << endl;
    } else if (s =="RRS") {
        cout << 2  << endl;
    } else if (s =="SSS") {
        cout << 0  << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    string s;cin>>s;
    int n=s.size();
    ll dp[4001][4001];
    memset(dp,0,sizeof dp);
  dp[0][0]=1;
    int nr=0,nb=0;
    rep(i,0,n){
        if(s[i]=='0')nr+=2;
        else if(s[i]=='1'){
            nr++;
            nb++;
        }
        else nb+=2;
        rep(j,0,i+1){
            ll k=i-j;
            if(k<nr){
                (dp[j][k+1]+=dp[j][k])%=mod2;
            }
            if(j<nb){
                (dp[j+1][k]+=dp[j][k])%=mod2;
            }
        }
        
    }
    rep(i,n,2*n){
        rep(j,0,i+1){
            ll k=i-j;
            if(k<nr){
                (dp[j][k+1]+=dp[j][k])%=mod2;
            }
            if(j<nb){
                (dp[j+1][k]+=dp[j][k])%=mod2;
            }
        }
    }
    cout<<dp[nb][nr]<<endl;
  /*rep(i,0,nb+1){
    rep(j,0,nr+1)cout<<dp[i][j]<<" ";
    cout<<endl;
  }*/
}



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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

int dp[27][100];
int main(){
  int N;
  cin >> N;
  map<int, int> mp;
  if(N == 1){
    cout << 0 << endl;
    return 0;
  }
  FOR(k, 2, N+1){
    int n = k;
    for(int i = 2; i * i <= k; i++){
      while(n % i == 0){
        mp[i]++;
        n /= i;
      }
    }
    if(n != 1){
      mp[n]++;
    }
  }
  dp[0][1] = 1;
  int idx = 0;
  for(auto p : mp){
    FOR(i, 1, p.second+2){
      FOR(j, 1, 76){
        if(dp[idx][j] == 0 || j * i > 75) continue;
        dp[idx+1][j*i] += dp[idx][j];
      }
    }
    idx++;
  }
  cout << dp[idx][75] << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

vector<ll> lay;
vector<ll> p;

//level n ,layer x

ll fun(ll n, ll x)
{
	if (x == 0)
		return 0;
	if (n == 0)
		return 1;
	if (x <= lay[n - 1] + 1)
		return fun(n - 1, x - 1) + (x == lay[n - 1] + 2?1:0);
	if (x < lay[n])
		return p[n - 1] + 1 + fun(n - 1, x - 1 - (lay[n - 1] + 1));
	return p[n];
}

int main()
{
	ll n, k;
	cin >> n >> k;
	lay.push_back(1);
	p.push_back(1);
	for (int i = 1; i <= n; i++)
	{
		ll l = lay[i - 1] * 2 + 3;
		ll pp = p[i - 1] * 2 + 1;
		lay.push_back(l);
		p.push_back(pp);
	}
	cout << fun(n, k) << endl;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String[] S = new String[N];
		int[] P = new int[N];
		int[] O = new int[N];
		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
			P[i] = sc.nextInt();
			O[i] = i + 1;
		}
		for (int i = 0; i < N; i++) {
			int minj = i;
			for (int j = i; j < N; j++) {
				if (S[j].compareTo(S[minj]) < 0) {
					minj = j;
				} else {
					if (S[j].compareTo(S[minj]) == 0) {
						if (P[j] > P[minj]) {
							minj = j;
						}
					}
				}
			}
			String tmpS = S[i];
			int tmpP = P[i];
			int tmpO = O[i];
			S[i] = S[minj];
			P[i] = P[minj];
			O[i] = O[minj];
			S[minj]=tmpS;
			P[minj]=tmpP;
			O[minj]=tmpO;
		}
		for(int i=0;i<N;i++) {
			System.out.println(O[i]);
		}

	}
}

Measured memory_bytes: 21716
fun main() = Thread(null, ::abc172b, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc172b() {
    val s = readLine()!!
    val t = readLine()!!

    val answer = (s.indices).count { s[it] != t[it] }

    println(answer)
}


Measured memory_bytes: 42088
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    a,b=map(int,input().split())
    cnt=0
    for i in range(a,b+1):
        if str(i)==str(i)[::-1]:
            cnt+=1
    print(cnt)


resolve()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  vi a(n),b(n);
  REP(i,n) cin>>a[i]>>b[i];
for(ll i=0;i<n;i++){
	if ((a[i]*a[i]+b[i]*b[i])<=k*k){
		ans++;
	}
}

  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int main() {
	int a[26]{0};
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)a[s[i] - 'a']++;
	int cnt;
	for (int i = 0; i < 26; i++) {
		if (a[i] == 0) {
			cnt = i;
			break;
		}
		else if (i == 25) {
			cout << "None" << endl;
			return 0;
		}
	}
	char ans = 'a';
	ans += cnt;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  ll n,r=0,g=0,b=0,ans=0,co=0;cin>>n;
  string s;cin>>s;
  for(ll i=0;i<n;i++){
    if(s.at(i)=='R'){r++;}
    if(s.at(i)=='G'){g++;}
    if(s.at(i)=='B'){b++;}
  }
  for(ll i=0;i<n;i++){
    for(ll j=1;j<(n-i+1)/2;j++){
      if(s.at(i)!=s.at(i+j)&&s.at(i)!=s.at(i+2*j)&&s.at(i+2*j)!=s.at(i+j))co++;
    }
  }
  cout << r*g*b-co<<endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;


int main()
{
	int t; cin>>t;
	if(t>=1800) cout<<"1";
	else if(t>=1600) cout<<"2";
	else if(t>=1400) cout<<"3";
	else if(t>=1200) cout<<"4";
	else if(t>=1000) cout<<"5";
	else if(t>=800) cout<<"6";
	else if(t>=600) cout<<"7";
	else if(t>=400) cout<<"8";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 3620
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var h = int.Parse(Console.ReadLine());
            var w = int.Parse(Console.ReadLine());
            var n = int.Parse(Console.ReadLine());
            var total = 0;
            var ans = 0;
            var loopCount = Math.Min(h, w);
            var max = Math.Max(h, w);
            
            for(var i = 0; i < loopCount; i++)
            {
                total += max;
                ans++;
                if(n <= total)
                {
                    break;
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{

int k;
cin >> k;
if (k % 2 ==0){
   int ans = k / 2;
    cout << ans * ans << endl;
}
else {
 int ans = k / 2;
 cout << ans * (ans+1) << endl;
}

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n; cin >> n;
  VI a(n);
  REP (i, n) cin >> a[i];
  VVI dp(n, VI(n));
  REP (i, n) {
    dp[i][i] = a[i];
  }
  REPI (k, 1, n) {
    REP (i, n) {
      int j = i + k;
      if (j >= n) continue;
      dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
      dump(i, j, dp[i][j]);
    }
  }
  cout << dp[0][n - 1] << endl;
}


Measured memory_bytes: 70784
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int[] d = {Math.abs(a - b), Math.abs(b - c), Math.abs(c - a)};
		Arrays.sort(d);

		System.out.println(d[0] + d[1]);
	}
}

Measured memory_bytes: 35636
#include <iostream>

using namespace std;

int main(){
	int N, D, X;
	int A[100];
	int n = 1;
	
	cin >> N >> D >> X;
	
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	for (int i = 0; i < N; i++){
		do {
			 n += A[i];
			 X++;
		}while (D >= n);
		n = 1;
	}
	cout << X << endl;
	
	return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        for (int i = 0; i < a; i++){
            cout << b;
        }
    }else{
        for(int i = 0; i < b; i++){
            cout << a;
        }
    }
    cout << endl;
    return 0;
}

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

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
//const------------------------------------------------------------------------------------------------------------------------
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;

//global-----------------------------------------------------------------------------------------------------------------------
int a, b;
VI ar;
//function--------------------------------------------------------------------------------------------------------------------
int main() {
	scanf( "%d", &a );
	rep( i, a ) {
		scanf( "%d", &b );
		ar.PB( b );
	}
	ROF( i, a - 1, 1 ) {
		printf( "%d ", ar[ i ] );
	}
	printf( "%d\n", ar[ 0 ] );
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#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)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

int main() {
  int n;
  cin >> n;
  bool flag = false;
  FOR(i, 1, 10) {
    int q = n / i;
    if (n % i == 0 && 1<= q && q <= 9) flag = true;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n,a[100];
    cin>>n;
    int cnt=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i==0)continue;
        else if(a[i]==a[i-1]){
            a[i]=i*-1;
            cnt++;
        }
    }
    cout<<cnt<<endl;
        
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<string> blue(N);
  
  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }
  
  int M;
  cin >> M;
  
  vector<string> red(M);
  
  int point = 0;
  
  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }
  
  
  for (int i = 0; i < N; i++) {
    string test = blue.at(i);
    
    int countBlue = 0;
    
    for (int j = 0; j < N; j++) {
      if (test == blue.at(j)) {
        countBlue ++;
      }
    }
    
    int countRed = 0;
    
    for (int j = 0; j < M; j++) {
      if (test == red.at(j)) {
        countRed ++;
      }
    }
    
    int pointSub = countBlue - countRed;
    
    if (pointSub > point) {
      point = pointSub;
    }
  }
  
  cout << point << endl;
}

Measured memory_bytes: 256
#n = int(input())
n, d = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
    x, y= map(int,input().split())
    if x**2 + y**2 <= d**2:
        ans+=1
print(ans)

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

typedef long long ll;

ll d;
int n, m;

std::vector<int> ds;

ll ans = 0;

int main() {
	while (1) {
		ans = 0;
		std::cin >> d;
		if (d == 0)
			break;
		std::cin >> n >> m;
		ds.clear();
		ds.push_back(0);
		ds.push_back(d);
		ll in;
		for (int i = 0; i < n - 1; ++i) {
			std::cin >> in;
			ds.push_back(in);
		}
		std::sort(ds.begin(), ds.end());
		ll k;
		for (int i = 0; i < m; ++i) {
			std::cin >> k;
			auto it = std::lower_bound(ds.begin(), ds.end(), k);
			int x[2];
			x[0] = (*it);
			--it;
			x[1] = (*it);
			ans += std::min(x[0] - k, k - x[1]);
		}
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3524
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
    public static void main(String args[]){
	String str;
	try{
	    InputStreamReader is = new InputStreamReader(System.in);
	    BufferedReader br = new BufferedReader(is);
	    str = br.readLine();
	    while(str !=null){
	    String[] strary = str.split(" ");
	    int n1 = Integer.parseInt(strary[0]);
	    int n2 = Integer.parseInt(strary[1]);
	    int sum = n1 + n2;
	    String s = Integer.toString(sum);
	    System.out.println((s.length()));
	    str = br.readLine();
	    }
	}
	catch(Exception e){
	    System.exit(0);
	}
    }
}

Measured memory_bytes: 17000
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = collections.Counter(str(input().rstrip('\n')))
    cnt = 1
    for k, v in s.items():
        cnt *= (v + 1)
        cnt %= (10 ** 9 + 7)
    print(cnt - 1)


if __name__ == '__main__':
    slove()


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

int main(){
    int n;
    string s;

    cin >> n >> s;

    string out;
    out = s.substr(0 ,n);
    cout << out;
    if(s.size() > n){
        cout << "...";
    }
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0, left, right;
    vector<int> V(3);
    char tmp, tmp2;
    string S, S2;
    bool flag=true;
    
    cin >> S;
    // ans = 24 + (24-A);
    S[3]='8';
    cout << S << endl;

    // if(left <right )
    // 	cout << "Right" <<endl;
    // else if(left > right)
    // 	cout << "Left" <<endl;
    // else
    // 	cout << "Balanced" <<endl;


    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


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

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    string t;
    for (char c : s) {
        if (t.empty()) {
            t.push_back(c);
            continue;
        }
        if (t.back() == '(' && c == ')') {
            t.pop_back();
            continue;
        }
        t.push_back(c);
    }
    int cnt1 = 0, cnt2 = 0;
    for (char c : t) {
        if (c == '(')
            cnt1++;
        else
            cnt2++;
    }
    string ans(cnt2, '(');
    ans += s;
    ans += string(cnt1, ')');
    cout << ans << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  while(1){
    int n,x;
    cin>>n>>x;
    if(n==0&&x==0) break;
    int cnt=0;
    FOR(i,1,n)FOR(j,i+1,n)FOR(k,j+1,n){
      if(i+j+k==x) cnt++;
    }
    cout<<cnt<<endl;
  }
  return 0;
}



Measured memory_bytes: 3092
#!/usr/bin/ruby -Ku

require 'pp'

def check_lowest(item, shop, recipe)
  if recipe.include?(item) then
    sum = 0
    recipe[item].each{ |it|
      tmp = check_lowest(it, shop, recipe)
      sum += tmp
    }
    return [sum, shop[item]].min
  else
    return shop[item] || 0
  end
end

loop do
  n = gets.to_i
  break if n == 0
  
  shop = Hash.new
  n.times{
    data = gets.split(nil)
    shop[data[0]] = data[1].to_i
  }
  
  m = gets.to_i  
  
  recipe = Hash.new
  m.times{
    data = gets.split(nil)
    item, n = data
    recipe[item] = data.slice(2, n.to_i)
  }
  
  item = gets.split(nil)[0]
  
  puts check_lowest(item, shop, recipe)
end

Measured memory_bytes: 6260
#include <bits/stdc++.h>
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod 1000000007
using namespace std;
vector<ll> prime,sfac;
vector<ll>ps;
void sieve(ll n)
{
	prime.assign(n+1,1);
	sfac.assign(n+1,1);    
    for (int p=2; p*p<=n; p++) 
    {         
        if (prime[p] == 1) 
        { 	sfac[p]=p;  			  
            for (int i=p*p; i<=n; i += p) 
              {  prime[i] = 0; sfac[i]=p;}
        } 
    } 
	for(ll i=2;i<=n;i++)
	{
		if(prime[i])
			ps.push_back(i);
	}
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll power(ll x, ll y) 
{ 
    ll res = 1;    
    while (y > 0) 
    { 
        ll k=y&1LL;
        if (k) 
            res = res*x;      
        y = y>>1LL;
        x = x*x;  
    } 
    return res; 
}
 
int isPrime(ll n) 
{ 
    if (n <= 1)  return 0; 
    if (n <= 3)  return 1; 
    if (n%2 == 0 || n%3 == 0) 
        return 0;   
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return 0;  
    return 1; 
} 
int main()
{
    sync
    string s,t;
    cin>>s>>t;
    ll c=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            c++;
    }
    cout<<c<<endl;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int P[N], Q[N];
    for (int i=0; i <N; i++){
        cin >> P[i];
    }
    for (int i=0; i<N; i++){
        cin >> Q[i];
    }
    int p = 1;
    int q = 1;
    vector<int> s(N);
    for (int i=0 ;i<N; i++){
        s[i] = i+1;
    }
    for(int i=0 ;i<N; i++){
        int l = find(s.begin(), s.end(), P[i]) - s.begin();
        s.erase(find(s.begin(), s.end(), P[i]));
        for (int j = 1; j<N-i; j++){
            l *= j;
        }
        p += l;        
    }
    vector<int> t(N);
    for (int i=0 ;i<N; i++){
        t[i] = i+1;
    }
    for(int i=0 ;i<N; i++){
        int l = find(t.begin(), t.end(), Q[i]) - t.begin();
        t.erase(find(t.begin(), t.end(), Q[i]));
        for (int j = 1; j<N-i; j++){
            l *= j;
        }
        q += l;        
    }
    cout << max(p-q, q-p) << endl;
    return 0;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())

D = [[0]*(N+1) for i in range(N+1)]
for i in range(M):
    L, R = map(int, input().split())
    L, R = sorted([L, R])
    D[L][R] += 1

for i in range(0, N+1):
    for j in range(1, N+1):
        D[i][j] += D[i][j-1]

for i in range(N-1, -1, -1):
    for j in range(0, N+1):
        D[i][j] += D[i+1][j]

for i in range(Q):
    p, q = map(int, input().split())
    p, q = sorted([p, q])
    print(D[p][q])



Measured memory_bytes: 9460
#include<iostream>
int main(){
	int x;

  std::cin >> x;
  int A;
    int g;
  for(int i; i<x; i++){
    
    std::cin >> A;
    if(A%2==0){ 
      if(A%3!=0 && A%5!=0)
        g+=1;
      }
  }
  if(g>=1) std::cout << "DENIED" << std::endl;
      else std::cout << "APPROVED" << std::endl;
    
  return 0;
}

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

int main() {
  int l,r; cin>>l >>r;
  int ans;
  if(r-l>=2018){ans=0;}
  else{
    l%=2019; r%=2019;
    if(l>=r){ans=0;}
    else{
      ans=2019;
      for(int i=l; i<r; i++){
        for(int j=i+1; j<=r; j++){
          int a=(i*j)%2019;
          ans=min(ans,a);
          
        }
      }
    }
  }
  cout<<ans;
}



Measured memory_bytes: 3636
import sys
import bisect
input = lambda: sys.stdin.readline().rstrip()


def solve():

    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    S = [0 for _ in range(N + 1)]

    for i in range(N):
        S[i + 1] = S[i] + A[i] - 1

    d = dict()
    for i in range(N + 1):
        k = S[i] % K
        if k in d:
            d[k].append(i)
        else:
            d[k] = [i]

    # print(d)

    ans = 0
    for k, v in d.items():
        if len(v) <= 1:
            continue
        else:
            for i in range(len(v)):
                s = v[i] + K - 1
                si = bisect.bisect_right(v, s)
                ans += (si - i) - 1
                # print(i, si)

    print(ans)


if __name__ == '__main__':
    solve()


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


void solve(long long H, long long W){
    if (H==1){
        printf("1\n");
    }else if(W==1){
        printf("1\n");
    }else{
        printf("%lld\n",(W/2+W%2)*(H/2+H%2) + (W-W/2-W%2)*(H-H/2-H%2));
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    solve(H, W);
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  xs <- rgetl n $ split toInt
  putStrLn .  unwords . map show $ solve xs

solve :: [[Int]] -> [Int]
solve = head . sortBy (\a b -> if (a !! 1) == (b !! 1) then (a !! 0) `compare` (b !! 0) else (b !! 1) `compare` (a !! 1))

toInt :: String -> Int
toInt s = read s

split :: (String -> a) -> String -> [a]
split f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

rgetl :: Int -> (String -> a) -> IO [a]
rgetl n f = map f <$> replicateM n getLine

Measured memory_bytes: 3824
#include <cstdio>
#include <algorithm>
using namespace std;

int n,k,ans;
char c[100005];

int main(void){
	scanf("%d %d",&n,&k);
	scanf("%s",c);
	for(int i=1;i<n;i++){
		if(c[i]==c[i-1])ans++;
	}
	printf("%d\n",min(n-1,ans+k*2));
}

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

using namespace std;

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

const int N = 2000 + 5;

int n, m;
char a[N][N];
int up[N][N], dw[N][N], lf[N][N], rg[N][N];

int main() {
  scanf("%d %d", &n, &m);
  for(int i = 1; i <= n; i++)
    scanf("%s", a[i] + 1);
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= m; j++) {
      up[i][j] = (up[i - 1][j] + 1) * (a[i][j] == '.');
      lf[i][j] = (lf[i][j - 1] + 1) * (a[i][j] == '.');
    }
  }
  int ans = 0;
  for(int i = n; i >= 1; i--) {
    for(int j = m; j >= 1; j--) {
      dw[i][j] = (dw[i + 1][j] + 1) * (a[i][j] == '.');
      rg[i][j] = (rg[i][j + 1] + 1) * (a[i][j] == '.');
      ans = max(ans, up[i][j] + lf[i][j] + dw[i][j] + rg[i][j] - 3);
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 66944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
typedef complex<double> P;
double dot(P a, P b){ //内積
    return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a, P b){ //外積
    return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_orth(P a1, P a2, P b1, P b2){ //垂直か
    return EQ(dot(a1 - a2, b1 - b2), 0.0);
}

bool is_para(P a1, P a2, P b1, P b2){ //平行か
    return EQ(cross(a1 - a2, b1 - b2), 0.0);
}

bool is_online(P a, P b, P c){ //cが線分上か
    return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}

bool distance_lp(P a, P b, P c){ //直線abと点cの距離
    return abs(cross(b-a, c-a)) / abs(b-a);
}

double norm(P a){
  return a.real() * a.real() +a.imag() *a.imag();
}

ll ccw(P p0,P p1,P p2){
  P a = p1-p0;
  P b = p2-p0;
  if(cross(a,b) > EPS) return 1;
  if(cross(a,b) < -EPS) return -1;
  if(dot(a,b) < -EPS) return 2;
  if(abs(a) < abs(b)) return -2;
  return 0;
}

bool is_intersect(P p1, P p2, P p3, P p4){
  return (ccw(p1,p2,p3) * ccw(p1,p2,p4) <= 0 &&
      ccw(p3,p4,p1) * ccw(p3,p4,p2) <= 0 );
}

P intersect_pos(P a1, P a2, P b1, P b2){ //直線同士の交点
    P a = a2 - a1;
    P b = b2 - b1;
    return a1 + a * cross(b, b1 - a1) / cross(b, a);
}

double getDistanceLP(P a1, P a2, P b){
    return abs(cross(a2-a1, b-a1) / abs(a2 - a1));
}

double getDistanceSP(P a1, P a2, P b){
    if(dot(a2 - a1, b - a1) < EPS) return abs(b - a1);
    if(dot(a1 - a2, b - a2) < EPS) return abs(b - a2);
    return getDistanceLP(a1, a2, b);
}
double getDistance(P a1, P a2, P b1, P b2){
    if(is_intersect(a1, a2, b1, b2)) return 0.0;
    double v1 = min(getDistanceSP(a1, a2, b1), getDistanceSP(a1, a2, b2));
    double v2 = min(getDistanceSP(b1, b2, a1), getDistanceSP(b1, b2, a2));
    return min(v1,v2);
}

#define printP(P) cout << "(" << P.real() << ", " << P.imag() << ")" << endl;




int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    double x[110], y[110];
    vector<P> p;
    rep(i,0,N){
        cin >> x[i] >> y[i];
        P t(x[i], y[i]);
        p.push_back(t);
    }
    ll q;
    cin >> q;
    P pd(12345, 13547);
    while(q--){
        double a,b;
        cin >> a >> b;
        P p2(a,b);
        bool online = false;
        rep(i,0,N){
            if(is_online(p[i], p[(i+1)%N], p2)){
                online = true;
            }
        }
        if(online){
            print(1);
            continue;
        }
        ll cnt = 0;
        rep(i,0,N){
            if(is_intersect(p[i], p[(i+1)%N], p2, pd)){
                cnt++;
            }
        }
        if(cnt % 2 == 1){
            print(2);
        }else{
            print(0);
        }
    }


}


Measured memory_bytes: 3360
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[101];
	double b=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b+=1.0/a[i];
	}
	b=1.0/b;
	printf("%.5f",b);
	return 0;
}

Measured memory_bytes: 384
import math
n,k = map(int,input().split())
ans = 0
def count(i):
    min_a = ((i - 1) * i )// 2
    max_a = ((n - i + 1 + n) * i) // 2
    return max_a - min_a + 1

for i in range(k,n + 2):
    ans += count(i)
print(ans % (10 ** 9 + 7))

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

using namespace std;
typedef long long ll;
map<string, ll> mp;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for (auto i : mp) {
        ans += i.second * (i.second-1) / 2;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N;
  int i;
  
  cin >> N;
  
  if(N % 2 == 0){
    i = N / 2;
  }
  else{
    i = N / 2 + 1;
  }
  
  cout << i;
}

Measured memory_bytes: 256
from collections import deque
n,m = map(int,input().split())
# ab = [list(map(int,input().split())) for i in range(m)]
v = [[0]]*2 + [[10**9] for i in range(n-1)]
# print(v)
for i in range(m):
    a,b = map(int,input().split())
    v[a].append(b)
    v[b].append(a)
q = deque([1])
# print(v)
while q:
    temp = q.popleft()
    for i in v[temp][1:]:
        if v[i][0] == 10**9:
            v[i][0] = temp
            q.append(i)
print("Yes")
for i in v[2:]:
    print(i[0])

Measured memory_bytes: 36044
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

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

    map<int, int> m;
    rep(i, K) {
        int d;
        cin >> d;

        rep(j, d) {
            int v;
            cin >> v;
            m[v]++;
        }
    }

    int ans = 0;
    rep(i, N) {
        if (m[i+1] == 0) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(B, A * N) << endl;
    return 0;
}

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 K = sc.nextInt();
        long[] A=new long[N];
        for(int i=0; i<N; i++){
            A[i]=sc.nextLong();
        }

        //long res = 0;
        
        for(int i=0; i<N-K; i++){
            if(A[i]<A[i+K]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }

        
        //System.out.println(res);
        
        }
    }

Measured memory_bytes: 61632
#include <stdio.h>
#include <cstdlib>


int head=0;
int tail=0;
int const MAX=10005;
struct Node{
    int key;
    Node *prev, *next;
};
Node *nil;
void init() {
    nil = (Node *) malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key){
    Node *x=(Node *) malloc(sizeof(Node));
    x->key=key;
    x->next=nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}

Node* listSearch(int key){
    Node *cur = nil->next;
    while (cur != nil&& cur->key != key) {
        cur = cur->next;
    }
    return cur;
}
void deleteNode(Node *t){
    if (t==nil) return;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}
void deleteLast(){
    deleteNode(nil->prev);
}
void deleteKey(int key){
    deleteNode(listSearch(key));
}
void printList(){
    Node *cur = nil->next;
    int isf=0;
    while (1){
        if (cur==nil) break;
        if (isf++ >0 ) printf(" ");
        printf("%d", cur->key);
        cur=cur->next;
    }
    printf("\n");
}
int main()
{
    int n,key,i;
    scanf("%d",&n);
    char command[100];
    init();
    for(i=0;i<n;i++){
        scanf("%s",command);
        scanf("%d",&key);
        if(command[0]=='i'){
            insert(key);
        }else if(command[6]=='F'){
            deleteFirst();
        }else if(command[6]=='L'){
            deleteLast();
        }else{
            deleteKey(key);
        }
    }
    printList();
    return 0;
}


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

main(){
    string w ; //w文字列
    bool flg = true;
    //全ての文字要素が偶数回登場する
    //
    //先頭からA-Zが何回出てくるか数える
    //
    //いきなり文字コードの話が出てきて草
    ///////
    cin >> w;
    int data[26] ={0};

    for(int i = 0; i < w.size(); i++){//1文字ずつ舐めていく 最大100
        int index = w.at(i) - 'a';
        //char z - a = 25
        data[index]++;   //該当文字のカウンターを1回す     
    }

    for(int i = 0 ; i < 26 ; i++){
        if(data[i]%2 != 0){
            flg = false;
        }
    }

    if(flg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;  
}

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

bool solve(string s)
{
	int len = s.size();
	bool l = true, r = true;

	s+='!';

	for(int i=0; i<len; i++) {
		if(s[i]==s[i+1]) return false;

		if(s[i] == 'L' && i%2 == 1) l = false; 
		if(s[i] == 'R' && i%2 == 0) l = false;

		if(s[i] == 'L' && i%2 == 0) r = false; 
		if(s[i] == 'R' && i%2 == 1) r = false; 

	}

	return (l|r);
}

int main()
{
	int N;
	cin >> N;
	while(N--) {
		string s;
		cin >> s;

		cout << (solve(s)? "Yes":"No") << endl;
	
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>

int main(){
	char s[11], t[11];

	scanf("%s%s", s,t);
	int l = strlen(s);

	for(int i = 0; i < l; i++){
		if(s[i] != t[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int main(){
	int a,h,m,s,l,o,p;
	cin>>a;
	l=a%3600;
	h=(a-l)/3600;
	o=l%60;
	m=(l-o)/60;
	s=a-h*3600-m*60;
	cout<<h<<":"<<m<<":"<<s<<endl;
}


Measured memory_bytes: 3108
#include<iostream>

using namespace std;

int main () {
	
	int b1,b2,b3;
	cin>>b1>>b2>>b3;

	if((b1==1 && b2==1)||b3==1){
		cout<<"Open"<<endl;
	}else{
		cout<<"Close"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);

//ダイクストラ法:スタートから任意の地点での最短距離、最短パスを求める
//計算量:(頂点+辺)log(頂点) 
//100(100+1000)log(100)
//始点,終点,隣接リスト(pathlist[edge.A]=(edgeB,legth))-->距離(notfound:INFLL),previous(notfound:INF);
vector<pair<long long,int>> Dikstra(int start,vector<vector<pair<int,long long>>>&pathlist){
	int edge=pathlist.size();
	pair<long long, int> cerching;
	priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q; //start to distance,[ditance ,islandNo.]
	vector<pair<long long,int>> D(edge,mp(INFLL,INF)); //distance (ans), preious path
	vector<bool>had(edge,false);
	D[start] = mp(0, -1); //distance ,Previous egdg
	q.emplace(0LL, start);
	while (!q.empty()){
		cerching = q.top();
		q.pop();
		if (had[cerching.second] == false){
			had[cerching.second] = true;
			for (auto i = pathlist[cerching.second].begin(); i != pathlist[cerching.second].end(); i++){
				if (had[i->first] == false){
					if(chmin(D[i->first].F, (cerching.first) + (i->second))){
						D[i->first].S=cerching.second;
					}
					q.emplace(D[i->first].F, i->first);
				}
			}
		}
	}


return D;
}
int main(){
	int n,m;
	int ans=0;
	cin >>n>>m;
	int a,b,c;
	vector<vector<pair<int,ll>>>path(n);
	rep(i,m){
		cin>>a>>b>>c;
		a--;
		b--;
		path[a].emplace_back(b,c);
		path[b].emplace_back(a, c);
	}
	set<pair<int,int>>dis;
	vector<pair<long long, int>> res;
	queue<int>q;
	int at;
	rep(i,n){
		res=Dikstra(i,path);
		rep(j,n){
			q.push(j);
		}
		while(!q.empty()){
			at=q.front();
			if(at==-1 or at==INF){
				q.pop();
				continue;
			}
			a=res[at].S;
			if (at != a and a != -1 and a != INF)
			{
			//	clog<<at<<" "<<a<<endl;
				if(a <at ){
					dis.insert(mp(a,at));
				}else{
					dis.insert(mp(at,a));
				}
			}
			q.push(a);
			q.pop();
		}
		res.clear();
	}
	cout << m-dis.size() << endl;
}

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

#define rep(i,n)  for(int i=0;i<n;++i)
#define per(i,n)  for(int i=n-1;i>=0;--i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define sl1(a)  scanf("%lld",&a)
#define sl2(a,b)  scanf("%lld %lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define PI 3.1415926535897932


int main(){
    int mod=1000000007;
    for (;;) {
        int n,x,ans=0;
        sc2(n,x);
        if (n==0 && x==0) break;
        for (int i=1;i<n-1;i++) for (int j=i+1;j<n;j++) for (int k=j+1;k<=n;k++) {
            if (i+j+k==x) ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


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

using namespace std;

#define MAX 10100
 
bool prime[MAX];

void make()
{
    fill(prime, prime + MAX, 1);
    prime[0] = prime[1] = 0;
     
    for (int i = 2; i*i < MAX; i++) {
        if (prime[i]) {
            for (int j = i*2; j < MAX; j += i) {
                prime[j] = 0;
	    }
	}
    }
}
 
int main()
{
    int n;
     
    make();
    while (cin >> n, n) {
        int a, b;
        for (int i = 0 ; i <= n; i++) {
            if (i >= 2 && prime[i] && prime[i-2]) {
                a = i-2;
                b = i;
            }
        }
        cout << a << ' ' << b << endl;
    }
    return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N;
    cin >> N;
    vi a(N);
    in(N,a);
    double mid = 0;
    rep(i,N) mid += (double)a[i];
    mid /= (double)N;
    
    double d = 1000000;
    int ans = 0;
    rep(i,N) {
        if(abs((double)a[i]-mid) < d){
            d = abs((double)a[i]-mid);
            ans = i;
        }
    }
    cout << ans << endl;

    
    
    
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int maki=m/n,niko=int(sqrt(m));
    set<int> s;
    for(int i=1;i<=niko;i++){
    	if(m%i==0)s.insert(i),s.insert(m/i);
    }
    auto itr=s.end();
    while(1){
    	itr--;
    	if(*itr<=maki){
    		cout << *itr <<endl;
    		return 0;
    	}
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
 
using namespace std;
 
struct P{int c,r;};
struct State{
  int t,pos, remain;
  bool operator < (const State& st) const {
    if(t != st.t) return t > st.t;
    return pos > st.pos;
  }
};
 
const int MAX = 5001;
const int INF = (1<<25);
int T[MAX][MAX];
vector<int> Edge[MAX];
P price[MAX];
int N,K;
 
void input(){
  scanf("%d %d",&N,&K);
  for(int i = 0; i < N; i++) scanf("%d %d",&price[i].c, &price[i].r);
  for(int i = 0; i < K; i++){
    int a,b;
    scanf("%d %d",&a, &b);
    a--;b--;
    Edge[a].push_back(b);
    Edge[b].push_back(a);
  }
}
 
int solve(){
  memset(T, -1, sizeof(T));
  T[0][0] = 0;
  priority_queue<State> Q;
  Q.push((State){0,0,0});
  while(!Q.empty()){
    const State now = Q.top();
    Q.pop();
     
    if(now.t > T[now.pos][now.remain]) continue;
    
    if(now.pos == N-1) return now.t;
    if(now.remain > 0){
      for(int i = 0; i < (int)Edge[now.pos].size(); i++){
    State nex = now;
    nex.pos = Edge[now.pos][i];
    nex.remain--;
     
    if(T[nex.pos][nex.remain] == -1 || T[nex.pos][nex.remain] > nex.t){
      T[nex.pos][nex.remain] = nex.t;
      Q.push(nex);
    }
      }
    }
 
    if(T[now.pos][price[now.pos].r] == -1 || T[now.pos][price[now.pos].r] > now.t+price[now.pos].c){
      T[now.pos][price[now.pos].r] = now.t+price[now.pos].c;
      Q.push((State){now.t+price[now.pos].c, now.pos, price[now.pos].r});
    }
  }
  return INF;
}
 
int main(){
 
  input();
  printf("%d\n",solve());
  return 0;
}

Measured memory_bytes: 99400