akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 1000000007  # type: int


def cmb(n, r):
    r = min(r, n-r)
    if r == 0:
        return 1
    if r == 1:
        return n

    numer = [n - r + k + 1 for k in range(r)]
    denom = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denom[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numer[k - offset] /= pivot
                denom[k] /= pivot

    result = 1
    for k in range(r):
        if numer[k] > 1:
            result *= int(numer[k])
            result %= MOD

    return result


def solve(n: int, a: int, b: int):

    ans = pow(2, n, MOD)-1
    ans -= cmb(n, a)
    ans %= MOD
    ans -= cmb(n, b)
    ans %= MOD
    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(n, a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 108236
import java.io.*;
public class Main {
 public static void main(String[] args){
  try{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   char botton[][]={{' '},
                            {'\'' , ',' , '.' , '!' , '?'},
                            {'a' , 'b' , 'c' , 'A' , 'B' , 'C'},
                            {'d' , 'e' , 'f' , 'D' , 'E' , 'F'},
                            {'g' , 'h' , 'i' , 'G' , 'H' , 'I'},
                            {'j' , 'k' , 'l' , 'J' , 'K' , 'L'},
                            {'m' , 'n' , 'o' , 'M' , 'N' , 'O'},
                            {'p' , 'q' , 'r', 's' , 'P' , 'Q' , 'R' , 'S'},
                            {'t' , 'u' , 'v' , 'T' , 'U' , 'V'},
                            {'w' , 'x' , 'y' , 'z' , 'W' , 'X' , 'Y' , 'Z'}};
    int n[]={0,5,6,6,6,6,6,8,6,8};
    while(true){
     String s=br.readLine();
     s+="x";
     int sl=s.length();
     int cnt=1;
     
     for(int i=1;i<sl;i++){
      char x,ch;
      int num,l,a;
      if(s.charAt(i-1)!=s.charAt(i)){
       x=s.charAt(i-1);
       if(x!='0'){
        num=Character.getNumericValue(x);
        l=n[num];
        if(cnt%l==0)a=l;
        else a=cnt%l;
        ch=botton[num][(cnt-1)%l];
        System.out.print(ch);
       }
       else if(x=='0')for(int j=0;j<cnt-1;j++)System.out.print(" ");
       cnt=0;
       cnt++;
      }
      else cnt++;
     }
     System.out.print("\n");
   }
  }
  catch(Exception e){return ;}
 }
}


Measured memory_bytes: 25300
// * It's time to PLAY !

#include <bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

void OPEN(string str)
{
    freopen((str + ".inp").c_str(), "r", stdin);
    freopen((str + ".out").c_str(), "w", stdout);
}

const int N = 1e5 + 7;

void PLAY()
{
    string s;
    cin >> s;
    int n = s.length();
    vector<int> comp, ans(N);
    for (int i = 0, cnt = 1; i < n; ++i)
    {
        if (s[i] != s[i + 1])
        {
            comp.push_back(cnt);
            cnt = 1;
        }
        else
        {
            ++cnt;
        }
    }
    for (int i = 0, l = 0; i < comp.size(); i += 2)
    {
        int odd, even;
        if ((comp[i] + comp[i + 1]) % 2 == 0)
        {
            odd = even = (comp[i] + comp[i + 1]) / 2;
        }
        else
        {
            if (l % 2 == 0)
            {
                even = (comp[i] + comp[i + 1] + 1) / 2;
                odd = even - 1;
            }
            else
            {
                odd = (comp[i] + comp[i + 1] + 1) / 2;
                even = odd - 1;
            }
        }
        if ((l + comp[i]) % 2 == 0)
        {
            ans[l + comp[i]] = even;
            ans[l + comp[i] - 1] = odd;
        }
        else
        {
            ans[l + comp[i]] = odd;
            ans[l + comp[i] - 1] = even;
        }
        l += comp[i] + comp[i + 1];
    }
    for (int i = 0; i < n; ++i)
    {
        cout << ans[i] << " ";
    }
}

signed main()
{
    fastio;
    PLAY();
    return 0;
}

Measured memory_bytes: 1480
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub fn rotate_ascii_lowercase_char(ch: char, n: isize) -> char {
    assert!(ch.is_ascii_lowercase());
    let base = 0x61_u8;
    let m = 26_isize;
    let ch_pos = ch as u8 - base;
    let offset = if n >= 0 {
        (ch_pos as isize + n) % m
    } else {
        (m - (ch_pos as isize - n.abs()).abs() % m) % m
    } as u8;
    char::from(base + offset)
}

fn solve() {
    input! {
        c: char
    };

    let res = rotate_ascii_lowercase_char(c, 1);
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

bool is_prime[1000001];
int prime_sum[1000001];
int main() {
	memset(is_prime, 1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	int p = 0, cnt = 0;
	for (int i = 2; i <= 1000000; i++) {
		if (is_prime[i]) {
			cnt += i;
			prime_sum[++p] = cnt;
			for (int j = i * 2; j <= 1000000; j += i)is_prime[j] = false;
		}
	}
	int n;
	while (scanf("%d", &n), n)printf("%d\n", prime_sum[n]);
	return 0;
}

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

int main()
{
    long long a,b;
    cin >> a >> b;
    long long temp1,temp2;
    if(b%2 == 0){
        if((b/2)%2 == 0){
            temp1 = b;
        }else{
            temp1 = b+1;
        }
    }else{
        if(((b+1)/2)%2 == 0){
            temp1 = 0;
        }else{
            temp1 = 1;
        }
    }
    if((a-1)%2 == 0){
        if(((a-1)/2)%2 == 0){
            temp2 = a-1;
        }else{
            temp2 = a;
        }
    }else{
        if((a/2)%2 == 0){
            temp2 = 0;
        }else{
            temp2 = 1;
        }
    }
    cout << (temp1^temp2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve(){
    string s; cin >> s;
    bool f = false;
    rep(i, 0, 3) if(s[i] == '7') f = true;
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

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

int main(){
    int N;
    scanf("%d",&N);

    int x[100],y[100],h[100];

    for(int i = 0;i< N;i++){
        scanf("%d%d%d",&x[i],&y[i],&h[i]);
    }

    int i,j,H;
    bool find;
    for(i = 0; i <= 100;i++){
        for(j = 0;j <= 100;j++){
            find  = true;
            for(int k = 0;k < N;k++){
                if(h[k] > 0)H = abs(i-x[k])+abs(j-y[k])+h[k];
            }

            for(int k = 0;k < N;k++){
                if(h[k] == 0 && H <= abs(i-x[k])+abs(j-y[k]))continue;
                if(H != abs(i-x[k])+abs(j-y[k])+h[k]){
                    find = false;
                    break;
                }
            }
            if(find == true)break;
        }
        if(find == true)break;
    }

    printf("%d %d %d",i,j,H);

    return 0;
}

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

int main()
{
    int a[100010];
    int dp[100010];
    int N, M;
    cin >> N >> M;
    for(int i=0;i<M;i++)
        cin >> a[i];
    dp[0] = 1;
    int index = 0;
    if(a[0] == 1)
    {
        dp[1] = 0;
        index = 1;
    }
    else
        dp[1] = 1;
    
    int temp, temp1;
    for(int i=2;i<=N;i++)
    {
        if(a[index] == i)
        {
            dp[i] = 0;
            index++;
        }else
            dp[i] = (dp[i-1] + dp[i-2]) % 1000000007;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int md=998244353;
struct Modint {
  int x;
  Modint() { x=0; }
  Modint(int v) { x=v; }
  Modint operator+=(const Modint& oth) {
    x+=oth.x;
    if (x>=md) x-=md;
    return *this;
  }
} dp[302][302][302],r;
int n,i,j,k,is0;
bool f[302][302][302];
char s[302];
int main() {
  scanf("%s",s);
  n=strlen(s);
  f[0][0][0]=true;
  for (i=0; i<n; i++) for (j=i; j>=0; j--) for (k=i-j; k>=0; k--) if (f[i][j][k]) {
    is0=int(s[i]=='0');
    if (j+k>1) {
      if (j>0) f[i][j-1][k]=true;
      if (k>0) f[i][j][k-1]=true;
    }
    if (j+k>0 || i+1<n) f[i+1][j][k]=true;
    if (j>0) f[i+1][j-1+is0][k+1-is0]=true;
    if (k>0) f[i+1][j+is0][k-is0]=true;
    if (i+1<n) {
      f[i+2][j+is0][k+1-is0]=true;
      is0=int(s[i+1]=='0');
      f[i+2][j+is0][k+1-is0]=true;
    }
  }
  dp[n][0][0]=1;
  for (i=n; i>=0; i--) for (j=0; j<=n; j++) for (k=0; k<=n; k++) if (dp[i][j][k].x) {
  //printf("%d %d %d = %d [%d]\n",i,j,k,dp[i][j][k].x,f[i][j][k]);
    if (f[i][j][k]) r+=dp[i][j][k];
    if (i==0) continue;
    is0=int(s[i-1]=='0');
    dp[i-1][j][k]+=dp[i][j][k];
    dp[i][j+1-is0][k+is0]+=dp[i][j][k];
  }
  printf("%d\n",r.x);
  return 0;
}


Measured memory_bytes: 119124
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        String s = scanner.next();
        for (int i = 1; i < s.length(); i++) {
            if (i < s.length() - 1 && s.charAt(i - 1) == s.charAt(i + 1)) {
                System.out.println(i + " " + (i + 2));
                return;
            }
            if (s.charAt(i - 1) == s.charAt(i)) {
                System.out.println(i + " " + (i + 1));
                return;
            }
        }
        System.out.println("-1 -1");
    }
}

Measured memory_bytes: 23712
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
string trans(int N)
{
        string S;
        while (N != 0)
        {
                if (N % 2 == 1)
                {
                        N--;
                        S = '1' + S;
                }
                else
                {
                        S = '0' + S;
                }
                N /= 2;
        }
        return S;
}

int main() //input->compute->output
{
        int s, t;
        cin >> s;
        vector<int> S(s);
        rep(i, s) { cin >> S[i]; }
        cin >> t;
        vector<int> T(t);
        rep(i, t) { cin >> T[i]; }
        int ans = 0;
        for (int i = 0; i < t; i++)
        {
                for (int j = 0; j < s; j++)
                {
                        if (T[i] == S[j])
                        {
                                ans++;
                                break;
                        }
                }
        }
        cout << ans << endl;

        return 0;
}



Measured memory_bytes: 3120
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
input = sys.stdin.readline

def inp():
    return int(input())
def inpl():
    return list(map(int,input().split()))
def inpm():
    return map(int,input().split())

ans = INF

n,m,x = map(int,input().split())
a = [inpl() for _ in range(n)]

for i in range(1<<n):
    money = 0
    score = [0] * m
    for j in range(n):
        if i>>j&1:
            money += a[j][0]
            for k in range(m):
                score[k] += a[j][k+1]
    for s in score:
        if s < x:
            break
    else:
        ans = min(ans,money)

print(ans if ans != INF else -1)


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

int main()
{
  int a;
  set<int> st;
  for (int i = 0; i < 3; i++)
  {
    cin >> a;
    if (st.count(a))
      st.erase(a);
    else
      st.insert(a);
  }
  for (auto s : st)
  {
    cout << s << endl;
  }
}

Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var q, h, s, d, n int
	fmt.Scan(&q, &h, &s, &d, &n)

	for _, v := range []int{4 * q, 2 * h} {
		s = min(s, v)
	}
	fmt.Println(min(2*s, d)*(n/2) + s*(n%2))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,aa[220000],cntl=0;
pair<int,int> p[220000];
string s,ss[220000];
char c,cc[5000][5000]={};
queue<int> que;
signed main(){
    cin>>n>>m;
    rep(i,m){
        cin>>o;
        cnt+=o;
    }
    if(cnt>n){
        cout<<-1;
    }else{
        cout<<n-cnt;
    }
}

Measured memory_bytes: 10516
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String ans = "";
    while(n != 0) {
      if(Math.abs(n) % 2 == 1) {
        ans = "1" + ans;
        n -= 1;
      } else {
        ans = "0" + ans;
      }
      n = n / (-2);
    }
    if(ans.equals("")) ans = "0";
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k,tmp;
    cin>>a>>b>>k;
    tmp=b-a+1-k*2;
    if(tmp<0)
        for(int i=a;i<=b;i++) cout<<i<<endl;
    else {
        for(int i=a;i<a+k;i++)
            cout<<i<<endl;
        for(int i=b-k+1;i<=b;i++)
            cout<<i<<endl;
    }
    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string S;
	cin >> S;

	int ans = 0;
	rep(i, 0, 1 << (SZ(S) - 1))
	{
		string ts;
		int res = 0;
		rep(j, 0, SZ(S))
		{
			ts += S[j];
			if ((i >> j) & 1) 
			{
				res += stoll(ts);
				ts.clear();
			}
		}
		res += stoll(ts);
		ans += res;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main(void) {
    s64 X;
    cin >> X;
    
    if(X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3644
void main()
{
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], k = tmp[1];

    long[] lists = new long[10^^5+1];
    foreach (i; 0 .. n)
    {
        tmp = readln.split.to!(long[]);
        long a = tmp[0], b = tmp[1];
        lists[a] += b;
    }

    long num = 1;
    foreach (i, x; lists)
    {
        if (num <= k && k < num + x)
        {
            i.writeln;
            break;
        }

        num += x;
    }
}


import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int main(){
    int n, k; cin >> n >> k;
    int h[n], i, dp[n], j; for(i = 0; i < n; i++) cin >> h[i], dp[i] = INT_MAX;
    dp[0] = 0;
    for(i = 1; i < n; i++){
        for(j = i-1; j >= max(i-k, 0); j--){
            dp[i] = min(dp[i], abs(h[i] - h[j]) + dp[j]);
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <time.h>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
typedef long long ll;
const ll MAXN=2e5+5;
const ll MAXR=60000;
const ll INF=1e18;
const ll MOD=1e9+7;
ll n,dp[MAXN][2],fac,cnt;
char str[MAXN];
ll mul(ll x,ll y)
{
    x%=MOD,y%=MOD;
    return x*y%MOD;
}
ll add(ll x,ll y)
{
    x%=MOD,y%=MOD;
    ll ret=x+y;
    if(ret>=MOD)
    {
        return ret-MOD;
    }
    return ret;
}
void getfac()
{
    fac=1;
    for(ll i=1;i<=n;i++)
    {
        fac=mul(fac,i);
    }
}
void solve()
{
    getfac();
    cnt=0;
    n*=2;
    ll now=1,ans=1;
    if(str[1]=='W')
    {
        printf("0\n");
        return;
    }
    for(ll i=2;i<=n;i++)
    {
        if(str[i]=='B')
        {
            if(now&1)
            {
                ans=mul(ans,now);
                now--;
                cnt++;
            }
            else
            {
                now++;
            }
        }
        else
        {
            if(now&1)
            {
                now++;
            }
            else
            {
                ans=mul(ans,now);
                cnt++;
                now--;
            }
        }
    }
   // getfac();
    ans=mul(ans,fac);
    if(now)
    {
        printf("0\n");
        return;
    }
    printf("%lld\n",ans);
}
int main()
{
//    freopen("c://duipai//data.txt","r",stdin);
//    freopen("c://duipai//wa.txt","w",stdout);
    while(~scanf("%lld",&n))
    {
//        string str2;
//        cin>>str2;
//      cout<<str2<<endl
        scanf("%s",str+1);
        solve();
    }
}
/*
*/


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,x) for(int i = 0; i<x; i++)

using namespace std;

int main(){
  string s;
  cin>>s;

  int max_length = 0;
  int now_left = 0;
  bool flg = false;

  rep(i,s.size()){
    if(flg){
      if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){

      }else{
        max_length = max(max_length, i-now_left);
        flg =false;
      }
    }else if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
       flg = true;
       now_left = i;
    }
  }

  int n = s.size();
  if(flg) max_length= max(max_length, n-now_left);

  cout<< max_length;
}


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

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

  string rev1 = s;
  reverse(rev1.begin(), rev1.end());
  if (s != rev1)
  {
    cout << "No" << endl;
    return 0;
  }
  string s2 = s.substr(0, (n - 1) / 2);
  string rev2 = s2;
  reverse(rev2.begin(), rev2.end());
  if (s2 != rev2)
  {
    cout << "No" << endl;
    return 0;
  }
  string s3 = s.substr(((n + 3) / 2) - 1, n);
  string rev3 = s3;
  reverse(rev3.begin(), rev3.end());
  if (s3 != rev3)
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

int n, a, b;

int main(){
	cin >> n >> a >> b;
	Int ans = 0;
	for(int i = 1; i <= n; i++){
		int d = 0, e = i;
		while(e != 0){
			d += e % 10;
			e /= 10;
		}
		if(a <= d && d <= b) ans += i;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
class Staff_manage
  def initialize()
    @arr = []
  end
  def set(size)
    @hash = Hash.new(0)
    size.times do
      @no, @price ,@num= gets.chomp.split(' ').each{|x| x.to_i}
      @hash[@no] += @price.to_i * @num.to_i
    end
  end

  def check()
    no_arr = []
    @hash.each do |key, value|
        if value >= 1000000
            no_arr << key
        end
    end
    no_arr << 'NA' if no_arr.size == 0
    @arr << no_arr
  end

  def output()
    @arr.each{|no| puts no}
  end
end

staff = Staff_manage.new()
loop do
  size = gets.chomp.to_i
  break if size == 0

  staff.set(size)
  staff.check()
end
staff.output()

Measured memory_bytes: 6108
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

const ll mod = 1000000007;

ll fc(vector<pair<ll, bool>> &all, int k, int nouseindex, int add){
  int n = all.size();
  ll ret = 1;
  rrep2(i, n-k, n){
    if(i == nouseindex) continue;
    ret *= all.at(i).first;
    ret %= mod;
  }
  ret *= add;
  ret %= mod;
  return ret;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<ll> plv, miv;
  vector<pair<ll, bool>> all;
  int pl = 0, mi = 0;
  rep(i, n){
    ll in;
    cin >> in;
    if(in >= 0){
      all.push_back({in, true});
      pl++;
    }else{
      miv.push_back(in*-1);
      all.push_back({in*-1, false});
      mi++;
    }
  }
  sort(miv.begin(), miv.end());
  sort(all.begin(), all.end());
  if(k % 2 == 1 && pl == 0){//必ず負
    ll ans = 1;
    rep(i, k){
      ans *= miv.at(i);
      ans %= mod;
    }
    ans = mod - ans;
    ans %= mod;
    cout << ans << endl;
    return 0;
  }
  ll ans = 1;
  pl = 0, mi = 0;
  int mindex = -1, pindex = -1;
  rrep2(i, n-k, n){
    ans *= all.at(i).first;
    ans %= mod;
    if(all.at(i).second == true){
      pl++;
      pindex = i;
    }else{
      mi++;
      mindex = i;
    }
  }
  if(mi % 2 == 0 || n == k){
    if(mi % 2 == 1){
      ans = mod - ans;
      ans %= mod;
    }
    cout << ans << endl;
    return 0;
  }
  int smindex = -1, spindex = -1;
  rrep(i, n-k){
    if(smindex == -1 && all.at(i).second == false) smindex = i;
    if(spindex == -1 && all.at(i).second == true) spindex = i;
  }
  if((smindex == -1) || (pindex == -1) || (spindex != -1 &&  all.at(pindex).first * all.at(spindex).first > all.at(mindex).first * all.at(smindex).first)){
    ans = fc(all, k, mindex, all.at(spindex).first);
  }else{
    ans = fc(all, k, pindex, all.at(smindex).first);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9288
package main

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

func main() {
	s := readS()
	l := len(s)

	if s == reverseS(s) && s[:(l-1)/2] == reverseS(s[:(l-1)/2]) && s[(l+3)/2-1:] == reverseS(s[(l+3)/2-1:]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func reverseS(s string) string {
	rs := []rune(s)
	for i := 0; i < len(s)/2; i++ {
		rs[i], rs[len(s)-1-i] = rs[len(s)-1-i], rs[i]
	}
	return string(rs)
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 1808
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;

#define rep(i,N) for (int i = 0; i < N; i++)
#define llong long long
#define ldouble long double

#define int long long

int A, B;

int gcd(int a, int b) {
    while(a%b) {
        a = a%b;
        swap(a, b);
    }
    return b;
}

signed main() {
    cin >> A >> B;
    cout << A*B/gcd(A, B) << endl;
    return 0;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  string str;
  
  if(n==0){
    cout << 0 << endl;
    return 0;
  }
  
  int i=0;
  long int tmp = 1;
  while(n!=0){
    tmp = tmp * (-2);
    //cout << "tmp = " << tmp << endl;
    if(n%tmp != 0){
      str = "1" + str;
      n = n - (tmp/(-2));
    } else {
      str = "0" + str;
    }
    
    i++;
  }
  
  cout << str << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

ll dp[110][100010];

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

  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j <= 100000; ++j)
    {
      if (j == v[i] || (j >= v[i] && dp[i][j - v[i]] > 0))
        if (dp[i][j] > 0)
          dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
        else
          dp[i + 1][j] = dp[i][j - v[i]] + w[i];
      else
        dp[i + 1][j] = dp[i][j];
    }
  }

  int vmax = 0;
  for (int i = 0; i <= 100000; ++i)
  {
    if (0 < dp[n][i] && dp[n][i] <= W)
      vmax = max(vmax, i);
  }
  cout << vmax << endl;

  return 0;
}


Measured memory_bytes: 79360
#include <stdio.h>
#include <stdlib.h>
long long a(long h, long w, long long m)
{
    long i;
    long long S[3],x=m;
    for(i=1;i<=h-1;i++){
        S[0]=i*w;
        S[1]=(h-i)*(w/2);
        S[2]=(h-i)*(w-w/2);
        if(llabs(S[0]-S[1])>=llabs(S[1]-S[2]) && llabs(S[0]-S[1])>=llabs(S[0]-S[2])) x=llabs(S[0]-S[1]);
        else if(llabs(S[1]-S[2])>=llabs(S[0]-S[1]) && llabs(S[1]-S[2])>=llabs(S[0]-S[2])) x=llabs(S[1]-S[2]);
        else x=llabs(S[0]-S[2]);
        if(m>x) m=x;
        S[1]=(h-i)/2*w;
        S[2]=(h-i-(h-i)/2)*w;
        if(llabs(S[0]-S[1])>=llabs(S[1]-S[2]) && llabs(S[0]-S[1])>=llabs(S[0]-S[2])) x=llabs(S[0]-S[1]);
        else if(llabs(S[1]-S[2])>=llabs(S[0]-S[1]) && llabs(S[1]-S[2])>=llabs(S[0]-S[2])) x=llabs(S[1]-S[2]);
        else x=llabs(S[0]-S[2]);
        if(m>x) m=x;
    }
    return m;
}
int main()
{
    long H,W;
    scanf("%ld %ld",&H,&W);
    if(H*W%3==0) puts("0");
    else printf("%lld\n",a(W,H,a(H,W,H*W)));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  ll K;
  cin >> K;
  ll a = 7%K;
  for (ll i=1; i<=K; i++) {
    if (a==0) {
      cout << i << endl;
      return 0;
    }
    else a = (10*a+7)%K;
  }
  cout << -1 << endl;
  return 0;
}

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

//--> definitions
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=b-1;i>=a;i--)

//--> typedef
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<pii,int> piii;
typedef tuple<int,int,int> tiii;

#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define INF 1e9

const int maxN = 2e5+11;

int parent[maxN];
int rankofpar[maxN];

void make_set(){
    FOR(i,0,maxN)
        parent[i]=i,rankofpar[i]=1;
}

int find_set(int x){
    if(parent[x]==x)
        return x;
    return parent[x]=find_set(parent[x]);
}

void union_set(int x,int y){
    x=find_set(x);
    y=find_set(y);
    
    if(x!=y){
        rankofpar[x]+=rankofpar[y];
        parent[y]=x;
    }
}

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

    int n,m;
    cin>>n>>m;
    
    FOR(i,0,m){
        int x,y;
        cin>>x>>y;
        union_set(x,y);
    }
    FOR(i,1,n+1)
        find_set(i);
    int depth=0;
    FOR(i,1,n+1)
        depth=max(depth,rankofpar[i]);
    
    cout<<depth<<"\n";

	return 0;
}

Measured memory_bytes: 6084
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: k, n, ans
    logical,allocatable:: kishutu(:)

    read*, k
    allocate(kishutu(0:k), source = .false.)
    if (mod(k,7)==0) k=k/7
    n = mod(1,k)
    ans=1
    do while(n /= 0)
        if (kishutu(n)) then
            print'(i0)', -1
            stop
        end if
        kishutu(n) = .true.
        n = mod(n*10+1,k)
        ans=ans+1
    end do
    print'(i0)', ans
end program main

Measured memory_bytes: 6660
import sys

input = sys.stdin.readline

def main():
  N,M = map(int,input().split())
  m = set()
  for _ in range(M):
    a,b = map(int,input().split())
    if a < b:
      m.add((a,b))
    else:
      m.add((b,a))
  for i in range(2,N):
    if (1,i) in m and (i,N) in m:
      print('POSSIBLE')
      break
  else:
    print('IMPOSSIBLE')

main()

Measured memory_bytes: 37440
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#include <set>
//#include <fstream>

#define ll long long int
using namespace std;

void Solve()
{
    string s;
    cin >> s;
    int maxa = 0;
    for(int i=0; i<s.size(); i++)
    {
        int cnt = 0;
        while(s[i] == 'R' && i<s.size())
        {
            cnt++;
            i++;
        }
        if(cnt > maxa) maxa = cnt;
    }
    cout << maxa;
}

int main()
{
    ios_base::sync_with_stdio( false );
    cin.tie( nullptr );
    //freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
    //int t;
    //cin >> t;
   // while(t--)
    {
        Solve();
        cout << '\n';
    }
    return 0;
}



Measured memory_bytes: 3608
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk

using namespace std;

inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ll S;
    cin >> S;
    ll a = 1000000000;
    ll b = (S + a - 1) / a;
    ll c = 1;
    ll d = a * b - S;
    cout << 0 << " " << 0 << " " << a << " " << d << " " << c << " " << b << "\n";
    return 0;
}

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

using namespace std;

int main()
{
	long a, b;
	char c;
	scanf("%ld %c %ld", &a, &c, &b);
	
	if(c == '+')
		printf("%ld\n", (a+b));
	else if(c == '-')
		printf("%ld\n", (a-b));
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  int n, ans = -1000000000;
  cin >> n;
  vector<int> shop(n, 0);
  rep(i, n) {
    rep(j, 10) {
      int x;
      cin >> x;
      shop[i] += pow(2, j) * x;
    }
  }
  int P[n][11];
  rep(i, n) rep(j, 11) cin >> P[i][j];
  for (int bit = 1; bit < (1 << 10); ++bit) {
    int res = 0;
    rep(i, n) {
      int tmp = bit & shop[i];
      int cnt = 0;
      rep(j, 10) {
        if (tmp & (1 << j)) cnt++;
      }
      res += P[i][cnt];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
int main(void)
{
int i,h,w,t;
char a[101][105];
while(~scanf("%d%d",&h,&w))
{
t=w+2;
for(i=1;i<=h;i++)
scanf("%s",a[i]);
while(t--)
printf("#");
printf("\n");
for(i=1;i<=h;i++)
printf("#%s#\n",a[i]);
t=w+2;
while(t--)
printf("#");
printf("\n");
return 0;
}
}

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

int nibn(int a[], int s, int e, int k);
int nibn(int a[], int s, int e, int k){
	if(s>e) return 0;
	if(a[(s+e)/2] == k){
		return 1;
	}
	else if(a[(s+e)/2] < k){
		return 1 + nibn(a,(s+e)/2+1,e,k);
	}
	else if(a[(s+e)/2] > k){
		return 1 + nibn(a,s,(s+e)/2-1,k);
	}
}


int main(){
	int n, a[150], k;
	while(cin >> n){
		if(!n) break;
		for(int i = 0;i<n;i++){
			cin >> a[i];
		}
		cin >> k;
		cout << nibn(a,0,n-1,k) << endl;
	}
	return 0;
}

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

bool isPrime(int n){
	if(n <= 1){
		return false;
	}
	for(int i = 2; i*i <= n; i++){
		if(n%i == 0){
			return false;
		}
	}
	return true;
}

int main(){
	int Cheat[1000000],cnt = 0;
	Cheat[0]=0;Cheat[1]=0;
	for(int i = 0; i < 1000000; i++){
		if(isPrime(i)){
			cnt++;
		}
		Cheat[i] = cnt;
	}
	while(true){
		int n;
		cin >> n;
		if(cin.eof()){
			break;
		}
		cout << Cheat[n] << endl;
	}
	return 0;
}


Measured memory_bytes: 5064
#include <assert.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define F first
#define S second
#define qq queue
#define dq deque
#define vc vector
#define INF ((int)(2e9))
#define LINF ((int)(1e18))
#define fir for( int i = 1 ; i <= n ; i++ )
#define fjr for( int j = 1 ; j <= n ; j++ )
#define fkr for( int k = 1 ; k <= n ; k++ )
#define firx( _x ) for( int i = 1 ; i <= _x ; i++ )
#define fjrx( _x ) for( int j = 1 ; j <= _x ; j++ )
#define fkrx( _x ) for( int k = 1 ; k <= _x ; k++ )
#define fir0x( _x ) for( int i = 0 ; i < _x ; i++ )
#define fjr0x( _x ) for( int j = 0 ; j < _x ; j++ )
#define fkr0x( _x ) for( int k = 0 ; k < _x ; k++ )
#define out cout <<
#define ln  << endl
#define pb push_back
#define mp make_pair
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define mp make_pair
#define sint short int
#define ull unsigned long long
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define ll long long
#define B out "BreakPoint\n";
#define read(_nowans) scanf("%d",&_nowans)
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define read2(_nowans1,_nowans2) scanf("%d %d",&_nowans1,&_nowans2)
#define msn(_data,_nowans) memset(_data,_nowans,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define read3(_nowans1,_nowans2,_nowans3) scanf("%d %d %d",&_nowans1,&_nowans2,&_nowans3)
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print( ll _x ){ cout << _x << endl; }
_tp<_tyn T>void print( T _data[] , int _size ){
	firx( _size )
		cout << _data[i] << " ";
	cout << endl;
}
#define MOD 1000000007

int n;
string u , d;
string stat;
int len = 0;

ll ans;
int main(){
	//fin( "D.txt" );
	stat = "";

	cin >> n;
	cin >> u;
	cin >> d;

	for( int i = 0 ; i < n ; i++ ){
		if( u[i] == d[i] ) stat += '|';
		else{
			stat += '-';
			i++;
		}
	}

	ans = stat[0]=='-'  ?  6LL  :  3LL;
	len = stat.length();
	for( int i = 1 ; i < len ; i++ ){
		if( stat[i-1] == '|' ) ans *= 2;
		else if( stat[i] == '-' ) ans *= 3;
		ans %= MOD;
	}

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


Measured memory_bytes: 256
s = input()
s = s[::-1]
ans = 0

for mask in range(1 << (len(s) - 1)):
    rate = 1
    for i in range(len(s)):
        ans += int(s[i]) * rate
        if mask >> i & 1 == 1:
            rate = 1
        else:
            rate *= 10

print(ans)


Measured memory_bytes: 9176
#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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

	if (a == 'D'){
		if (b == 'H') cout << 'D' << endl;
		else cout << 'H' << endl;
	}
	else cout << b << endl;
}


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

signed main(){
	int n,c[25],v[25],ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> v[i];
	for(int i = 0;i < n;i++) cin >> c[i];
	for(int i = 0;i < n;i++){
		ans += max(0ll,v[i] - c[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,q,h,t,sum=0;
  pair<string,int> a[200000];
  cin>>n>>q;
  for(int i=0;i<n;i++)cin>>a[i].first>>a[i].second;
  h=0;
  t=n-1;
  while(1){
    if(h==t){
      cout<<a[h].first<<' '<<sum+a[h].second<<endl;
      break;
    }
    if(a[h].second-q<=0){
      sum+=a[h].second;
      cout<<a[h].first<<' '<<sum<<endl;
      h++;
    }
      else{
	a[h].second-=q;
	sum+=q;
	if(t+1==200000)t=-1;
	a[t+1].first=a[h].first;
	a[t+1].second=a[h].second;
	if(h+1==200000)h=-1;
	h++;t++;
      }
  }
  return 0;
}



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

int main(){
    int N;
    int64_t X, x[200001];
    cin >> N >> X;
    for(int i=1; i<=N; i++) cin >> x[i];
    int64_t accum[200001] = {0};
    for(int i=1; i<=N; i++) accum[i] = x[i] + accum[i-1];

    int64_t ans = 2e15;
    for(int k=1; k<=N; k++){
        int64_t result = (N+k) * X;
        for(int j=0; j<(N-1)/k+1; j++){
            int M = N - j*k;
            int m = max(0, M-k);
            int c = j==0 ? 5 : 2*j+3;
            result += c * (accum[M] - accum[m]);
            if(result >= ans) break;
        }
        ans = min(ans, result);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;
public class Main{
     
    public void solve(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a>=0 && a<86400){
            int h = a / 3600;
            int m = a % 3600 / 60;
            int s = a % 60;
            System.out.println(h+":"+m+":"+s);
        }
    }
     
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17344
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long  ll;
const int N = 1e5 + 4;

int h[N] , n , k , memo[N];

int solve(int indx){
    if(indx == n - 1)
        return 0;

    int &ret = memo[indx];
    if(~ret)
        return ret;

    ret = inf;
    for(int i = 1 ; i <= k && indx + i < n ; ++i)
        ret = min(ret , solve(indx + i) + abs(h[indx] - h[indx + i]));
    return ret;
}

int main() {
    ios::sync_with_stdio() , cin.tie(0) , cout.tie();
    cin >> n >> k;
    for(int i = 0 ; i < n ; ++i)
        cin >> h[i];

    memset(memo , -1 , sizeof memo);
    cout << solve(0) << '\n';
}


Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
#include<numeric>
#include<limits>
#include<type_traits>
using namespace std;

int main(void){
  long long int N, P;
  cin >> N >> P;
  int ans = 1;
  if(N == 1){cout << P << endl;}
  //Nが2個以上なら10^6まで探索範囲を落とせる
  else{
    for(int i = 1; i < pow(static_cast<long long int>(P), 1 / static_cast<long double>(N) )+ 1; i++){
      long long int temp = pow(static_cast<long long int>(i), static_cast<long long int>(N));
      if(temp > P) break;
      if(P % temp == 0) ans = i;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main (void)


{


double r;


double R=3.14159265359,menseki=0,enshu=0;


scanf("%lf",&r);


menseki=r*r*R;


enshu=2*r*R;


printf("%.6lf %.6lf\n",menseki,enshu);


return 0;


}

Measured memory_bytes: 652
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 22 21:53:54 2020

@author: naoki
"""

N = int(input())
A = list(map(int,input().split()))
count = 0 
for i in range(N-1):
    if A[i] > A[i+1]:
        count = count + A[i] - A[i+1]
        A[i+1] = A[i]
print(count)
    

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

int main(){
  string text;
  getline(cin,text,'\n');
  int k=0;
  while(true){
    if(text.find("apple",k)!=-1&&text.find("apple",k)<text.find("peach",k)){
      k = text.find("apple",k);
      text = text.substr(0,k)+"peach"+text.substr(k+5);
      k++;
    }
    else{
      if(text.find("apple",k)==text.find("peach",k))
	break;
      k = text.find("peach",k);
      text = text.substr(0,k)+"apple"+text.substr(k+5);
      k++;
    }
  }
  cout << text << endl;
  return 0;
}

Measured memory_bytes: 0
import sys
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


N, K = map(int, input().split())		# 5 7
a = sorted(list(map(int, input().split())))	# 1 2 3 4 5 ...

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

g=a[0]
for i in range(1,N):
	g = gcd(g,a[i])

if K%g==0:
	ans=PO
else:
	ans=IM


print(ans)


Measured memory_bytes: 16276
l = input().split()
a = int(l[0])
b = int(l[1])
c = int(l[2])
d = int(l[3])
m = "No"
if abs(a-c)<=d:
	m = "Yes"
elif abs(a-b)<=d and abs(c-b)<=d:
	m = "Yes"
print(m)

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  char s[4];
  char flag[1]; 
  int ans = 0;
  scanf("%c%c%c%c",&s[0],&s[1],&s[2],&s[3]);
  if(s[0] == s[1] || s[0] == s[2] || s[0] == s[3]){
    ans += 1;
  }
  if(s[1] == s[2] || s[1] == s[3])if(s[1] != s[0])ans+=1;
  if(s[2] == s[3])if(s[2] != s[0] && s[2]!= s[1])ans+=1;
  if(ans == 2) printf("Yes\n");
  else printf("No\n");
  return 0;
}


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

using namespace std;


const int N=3100;

int	f[N][N];   

char ans[N];int pos;
int main()
{
	char s[N],t[N];
	cin>>s+1>>t+1;
	int n=strlen(s+1);
	int m=strlen(t+1);
	string x="";
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(s[i]==t[j])
			{
				f[i][j]=f[i-1][j-1]+1;
			}
			else{
					f[i][j]=max(f[i-1][j],f[i][j-1]);
				}
		}
	   int len=f[n][m];
    int i=n,j=m;pos=len-1;
    while(f[i][j])
    {
        if(f[i][j]==f[i-1][j]) i--;
        else if(f[i][j]==f[i][j-1]) j--;
        else ans[pos--]=s[i],i--,j--;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 37120
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int gcd(int a, int b){return b ? gcd(b, a % b): a;}
void yes(){cout<<"Yes"<<endl;return;}
void no(){cout<<"No"<<endl;return;}

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    int g = gcd(a, b);
    vi d;
    for(int i = g; i > 0; i--){
        if(g % i == 0){
            d.push_back(i);
        }
    }
    cout << d[k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
        int table[] = new int[128];
 
        for(int i = 0; i < table.length; i++){
            table[i] = 0;
        }
 
        StringBuilder sb = new StringBuilder();
 
        while(scanner.hasNext()){
            sb.append(scanner.nextLine());
        }
 
        String line = sb.toString();
 
        for(int i = 0; i < line.length(); i++){
            table[line.charAt(i)]++;
        }
 
        for(int i = 0; i < 26; i++){
            System.out.printf("%c : %d\n", 'a'+i,table['a'+i]+table['a'+i-32]);
        }
    }
}


Measured memory_bytes: 26220
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

  int n, x, t; cin >> n >> x >> t;
  cout << ((n/x)+(n%x > 0))*t << endl;

  return 0;
}

Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
import numpy as np
import math

N,M = map(int, raw_input().split())
a = np.zeros(N,dtype='int')
b = np.zeros(N,dtype='int')
c = np.zeros(M,dtype='int')
d = np.zeros(M,dtype='int')
for i in range(N):
    a[i],b[i] = map(int, raw_input().split())
for i in range(M):
    c[i],d[i] = map(int, raw_input().split())
    
for i in range(N):
    MinDist = 999999999
    CheckPoint = -1
    for j in range(M):
        ManhattanDist = math.fabs(a[i]-c[j])+math.fabs(b[i]-d[j])
        if(MinDist>ManhattanDist):
            MinDist = ManhattanDist
            CheckPoint = j+1
    print(CheckPoint)    
        

Measured memory_bytes: 17904