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

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

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

    vector<ll> lun(max(11, K+3));

    rep1(i, 10) {
        lun[i] = i;
    }

    int i = 1, j = 10;
    while (j <= K) {
        int r = lun[i] % 10;
        ll x10 = lun[i] * 10;
        if (r != 0) lun[j++] = x10 + r - 1;
        lun[j++] = x10 + r;
        if (r != 9) lun[j++] = x10 + r + 1;
        i++;
    }

    cout << lun[K] << endl;
}


Measured memory_bytes: 1024
import sys;input=sys.stdin.readline
N, M = map(int, input().split())
inf = 10**18
dp = [inf]*(1<<N)
dp[0] = 0
for i in range(M):
    a, b = map(int, input().split())
    Cs = list(map(int, input().split()))
    bb = 0
    for c in Cs:
        bb += 2**(c-1)
    for x in range((1<<N)-1, -1, -1):
        dp[bb|x] = min(dp[x]+a, dp[bb|x])

#print(dp)
r = dp[(1<<N)-1]
if r != inf:
    print(dp[(1<<N)-1])
else:
    print(-1)


Measured memory_bytes: 42732
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    A, B = map(int, input().split())

    for i in range(0, 100000):
        if int(i * 0.08) == A and int(i * 0.1) == B:
            print(i)
            return

    print(-1)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9884
N, K = map(int, input().split())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
    
x2 = Base_10_to_n(N, K)
print(len(x2)) 

Measured memory_bytes: 9104
import java.io.*;
class Main{
public static void main(String[] args)throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str1=br.readLine();
int n=Integer.parseInt(str1);
String str2=br.readLine();
String[] arr=str2.split(" ");
int[] arr2 =new int[n];
for(int k=0; k<n; k++){
arr2[k]=Integer.parseInt(arr[k]);
}
long sum=0;
for(int i=0; i<n; i++){
sum +=arr2[i];
}
int min=arr2[0], max=arr2[0];
for(int j=1; j<n; j++){
if(min > arr2[j]) min=arr2[j];
if(max < arr2[j]) max=arr2[j];
}
System.out.println(min+" "+max+" "+sum);
br.close();
}
}

Measured memory_bytes: 28700
import java.util.Scanner;
 public class Main{
	public static void main(String [] args){
    	Scanner sc=new Scanner(System.in);
      	
      	int n=sc.nextInt();
      	int a[]=new int[n];
      	int b[]=new int[n];
      	int c[]=new int[n];
      	
      for(int i=0;i<n;i++){
      	a[i]=sc.nextInt();
        b[i]=sc.nextInt();
        c[i]=sc.nextInt();
      }
      
      int dp[][]=new int[3][n];
      dp[0][0]=a[0];
      dp[1][0]=b[0];
      dp[2][0]=c[0];
      for(int i=1;i<n;i++){
      		dp[0][i]=Math.max(a[i]+dp[1][i-1],a[i]+dp[2][i-1]);
        	dp[1][i]=Math.max(b[i]+dp[0][i-1],b[i]+dp[2][i-1]);
        	dp[2][i]=Math.max(c[i]+dp[1][i-1],c[i]+dp[0][i-1]);
      }
      
      int res=Math.max(Math.max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]);
      System.out.println(res);
      
    }
}

Measured memory_bytes: 93712
#include<cstdio>
int main()
{
	int n,sum;
	scanf("%d%d",&n,&sum);
	for(int i=n;i>=0;--i)
    	for(int j=n-i;j>=0;--j)
    		for(int k=n-i-j;k>=0;--k)
				if(i+j+k==n && i*10000+j*5000+k*1000==sum){
					printf("%d %d %d",i,j,k);
					return 0;   
				}
    printf("-1 -1 -1");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int Power(ll a,int b)
{
  ll res=1;
  while(b>0)
  {
    if (b%2!=0)
      res=res*a;
    a=a*a;
    b/=2;
  }
  return res;
}
int main()
{
  int x;
  scanf("%d",&x);
  ll a[241];
  a[0]=0;
  for (int i=1;i<=120;i++)
  {
    a[2*i-1]=i;
    a[2*i]=-i;
  }
  int c=0;
  for (int i=0;i<=240;i++)
  {
    for (int j=0;j<=240;j++)
    {
      if ((Power(a[i],5)-Power(a[j],5))==x)
      {
        printf("%d %d",a[i],a[j]);
        c++;
        break;
      }
    }
    if (c!=0)
      break;
  }
  return 0;
}

Measured memory_bytes: 3792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!

/*int main(void){
    ll N, taka, aoki, T[1001], A[1001];
    scanf("%lld", &N);
    rep(i, N) scanf("%lld %lld", T+i, A+i);
    taka = T[0]; aoki = A[0];
    for(ll i=1; i<N; i++) {
        if(T[i]==A[i]) {//1:1
            ll w=max(taka,aoki);
            taka = w;
            aoki = w;
        }
        else {
            if(taka>aoki) {
                while(taka%T[i]) taka++;
                aoki = taka / T[i] * A[i];
            }
            else {
                while(aoki%A[i]) aoki++;
                taka = aoki / A[i] * T[i];
            }
        }
    }
    printf("%lld\n", taka+aoki);
    return 0;
}*/

//解説AC
int main(void){
    ll N, taka=1, aoki=1, T[1001], A[1001], nt, na;
    scanf("%lld", &N);
    rep(i, N) scanf("%lld %lld", T+i, A+i);
    rep(i, N) {
        nt = (taka%T[i]) ? taka/T[i]+1 : taka/T[i];
        na = (aoki%A[i]) ? aoki/A[i]+1 : aoki/A[i];
        taka = max(na,nt) * T[i];
        aoki = max(na,nt) * A[i];
    }
    printf("%lld\n", taka+aoki);
    return 0;
}


Measured memory_bytes: 128
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0008
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.toInt)
      .map((n) => {
        (for (a <- 0 to 9; b <- 0 to 9; c <- 0 to 9; d <- 0 to 9)
          yield {
            a + b + c + d
          })
          .count(_ == n)
      })
      .foreach(println)
  }
}

Measured memory_bytes: 82100
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    int res = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]) res++;
    }
    cout << res;
    cout << endl;
    return 0;
}


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

a = [1]
p = [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)


def calc(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + a[n - 1]:
        return calc(n - 1, x - 1)
    else:
        return p[n - 1] + 1 + calc(n - 1, x - 2 - a[n - 1])


def solve():
    ans = calc(N, X)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3316
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor, log
import numpy as np
from collections import defaultdict, deque,Counter
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    x = int(input())
    now = 100
    ans = 0
    while floor(now * 1.01) < x:
        ans += 1
        now = floor(now * 1.01)
        # print(now)
    print(ans+1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 27152
#include<iostream>
#include<cstdio>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<deque>
#include<utility>
#include<cctype>
#include<bitset>
#include<time.h>
#define ll long long
#define mp make_pair
using namespace std;
const int INF=1e9;
/*--------main part---------*/

vector<int> edg[100005];
int dat[100005];
int r[100005];
int l[100005];
bool ans=true;
void solve(int x,int p)
{
	r[x]=INF+1;
	l[x]=-INF-1;
	if(dat[x]!=-1)
	{
		l[x]=dat[x];
		r[x]=dat[x];
	}
	for(int i=0;i<edg[x].size();i++)
	{
		int nx=edg[x][i];
		if(nx!=p)
		{
			solve(nx,x);
			if(l[nx]<=-INF/2)
			{
				continue;
			}
			if(l[x]<-INF/2)
			{
				l[x]=l[nx]-1;
				r[x]=r[nx]+1;
			}
			else
			{
				if(abs(l[nx])%2==abs(l[x])%2)
				{
					ans=false;
					return;
				}
				l[x]=max(l[x],l[nx]-1);
				r[x]=min(r[x],r[nx]+1);
			}
		}
	}
	if(l[x]>r[x])
		ans=false;
}
void make(int x,int p)
{
	if(x==1 and dat[x]==-1)
	{
		dat[x]=l[x];
	}
	for(int i=0;i<edg[x].size();i++)
	{
		int nx=edg[x][i];
		if(nx!=p)
		{
			if(dat[nx]==-1)
			{
				if(l[nx]<=dat[x]-1 and dat[x]-1<=r[nx])
				{
					dat[nx]=dat[x]-1;
				}
				else
				{
					dat[nx]=dat[x]+1;
				}
			}
			make(nx,x);
		}
	}
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		edg[x].push_back(y);
		edg[y].push_back(x);
	}
	memset(dat,-1,sizeof(dat));
	int m;
	cin>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		dat[x]=y;
	}
	solve(1,-1);
	if(!ans)
	{
		cout<<"No"<<endl;
	}
	else
	{
		make(1,-1);
		cout<<"Yes"<<endl;
		for(int i=1;i<=n;i++)
		{
			cout<<dat[i]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 15360
import java.util.*;
import java.util.stream.*;
import java.util.function.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		Stream.generate(sc::next)
		.limit(n)
		.collect(Collectors.groupingBy(Function.identity(),
                                       Collectors.counting()))
		.entrySet().stream()
		.collect(Collectors.groupingBy(Map.Entry::getValue))
		.entrySet().stream()
		.max(Map.Entry.comparingByKey())
		.map(Map.Entry::getValue)
		.get()
		.stream()
		.map(Map.Entry::getKey)
		.sorted()
		.forEach(System.out::println);
	}
}

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

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

using namespace std;

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

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

  string result;
  if (a <= 0 && b >= 0) {
    result = "Zero";
  } else {
    int negativeCount = 0;
    for (int i = a; i <= b; i++) {
      if (i < 0) {
        negativeCount++;
      } else {
        break;
      }
    }
    if (negativeCount == 0 || negativeCount % 2 == 0) {
      result = "Positive";
    } else {
      result = "Negative";
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
N = gets.to_i
a = gets.split.map(&:to_i)

a = a.sort

i = N-1
edge_1, edge_2 = 0, 0
while i>0 do
  if a[i]==a[i-1] then
    if edge_1==0 then
      edge_1 = a[i]
    else
      edge_2 = a[i]
      break
    end
    i -= 2
  else
    i -= 1
  end
end
p edge_1 * edge_2

Measured memory_bytes: 10096
#include<stdio.h>
#define NIL -1 

static const int MAX = 500;
static const int INFTY = (1<<21);


main(){
  int n, i, j, k,c;
  int u,v;
  int minv = INFTY;
  int M[MAX][MAX],vis[MAX],d[MAX],pi[MAX];
  
  /* your code */

  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

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

 
  /* your code */
  for (u = 0; u<n; u++ ){
    d[u] = INFTY;
    vis[u] = 0;  
    pi[u] = NIL;
    
  }

  d[0] = 0;
  
  
  while ( 1 ){
    u = NIL;
    minv = INFTY;

    for (i = 0; i<n; i++ ){
      if (d[i] < minv && !vis[i]){
	u = i;
	minv = d[i];
      }
    }
    
    if (u  == NIL ) break;
    
    vis[u] = 1; 
    
    for (v = 0; v<n; v++ ){
      
      if ( d[v] > d[u]+M[u][v] && !vis[v]){
	d[v] = d[u]+M[u][v];
	pi[v] = u;
      }
    }
  }
  
 
 for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }
  
  return 0;
}

Measured memory_bytes: 804
// 1_1_D
#include <stdio.h>
#include <math.h>
#include <limits.h>

int main(){
    long n, i, price;
    long min_price = LONG_MAX, max_prof = LONG_MIN;
    scanf("%ld", &n);
    for(i = 0; i < n; i++){
        scanf("%ld", &price);
        max_prof = fmaxl(max_prof, price - min_price);
        min_price = fminl(min_price, price);
    }

    printf("%ld\n", max_prof);
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+100;
long long d[N],c[N];
int main(){
  int n;
  cin>>n;
  unsigned long long ans=0;
  for(int i=1;i<=n;i++){
    cin>>d[i]>>c[i];
    ans+=c[i];
  }
  ans--;
  long long res=0;
  for(int i=1;i<=n;i++){
    res+=(d[i]*c[i]);
  }
  cout<<ans+(res-1)/9<<endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d1(n),d2(n);
  rep(i,n) cin >> d1[i] >> d2[i];

  int v = 0;
  rep(i,n){
    if(d1[i]==d2[i])++v;
    else v = 0;
    if(v==3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll x;
	cin>>x;
	bool ctr;
	bool ct=0;
	vector<unsigned long long> p(1e3+1);
	for(int i=0;i<p.size();i++)
	{
		p[i]=pow(i,5);
	}
	int i,j;
	for(i=0;i<=1000;i++)
	{
		for(j=i+1;j<=1000;j++)
		{
			if(p[j]-p[i]==x)
			{
				ctr=0;
				ct=1;
				break;
			}
			if(p[j]+p[i]==x)
			{
				ctr=1;
				ct=1;
				break;
			}
		}
		if(ct) break;
	}
	
	if(ctr)
	{
		cout<<j<<" "<<-1*i<<"\n";
	}
	else cout<<j<<" "<<i<<"\n";
	
	return 0;
}

Measured memory_bytes: 4068
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for (int i = 0; i < 3; i++)
	{
		if (s.at(i) == t.at(i))
			cnt++;
	}
	cout << cnt << endl;
}

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

const int INF = 1001001001;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  vector<vector<int>> dp(h, vector<int>(w, INF));
  // rep(i, h) rep(j, w) printf("%d%c", dp[i][j], (j == w - 1 ? '\n' : ' '));

  auto ok = [&](int i, int j) { return (0 <= i && i < h && 0 <= j && j < w); };

  // if (s[0][0] != s[h - 1][w - 1]) {
  //   init_cost++;
  //   s[0][0] = '.';
  //   s[h - 1][w - 1] = '.';
  // } else if (s[0][0] == '#' && s[h - 1][w - 1] == '#') {
  //   init_cost++;
  //   rep(i, h) rep(j, w) s[i][j] = (s[i][j] == '.' ? '#' : '.');
  // }
  dp[0][0] = (int)(s[0][0] == '#');
  rep(i, h) rep(j, w) {
    if (ok(i, j - 1))
      dp[i][j] = min(dp[i][j], dp[i][j - 1] + (int)(s[i][j] != s[i][j - 1]));
    if (ok(i - 1, j))
      dp[i][j] = min(dp[i][j], dp[i - 1][j] + (int)(s[i][j] != s[i - 1][j]));
  }
  dp[h - 1][w - 1] += (int)(s[h - 1][w - 1] == '#');
  cout << dp[h - 1][w - 1] / 2 << endl;
  // cerr << dp[h - 1][w - 1] << endl;
  // rep(i, h) rep(j, w)
  //     fprintf(stderr, "%d%c", dp[i][j], (j == w - 1 ? '\n' : ' '));
  return 0;
}


Measured memory_bytes: 3688
import sys
def yutori():
    N, K, C = map(int,sys.stdin.readline().split())
    S = [i for i in sys.stdin.readline()]
    l = [i+1 for i in range(N) if S[i] == 'o']
    Left = []
    Right = []
    for u in l:
        if Left == []:
            Left.append(u)
        if u > Left[-1] + C:
            Left.append(u)
        if len(Right) == K:
            break
        
    if len(Left) <K:
        exit()

    for u in l[::-1]:
        if Right== []:
            Right.append(u)
        if u < Right[-1] - C:
            Right.append(u)
        if len(Right) == K:
            break

    if len(Right) <K:
            exit()
    
    for i in range(K):
        if Left[i] == Right[-i-1]:
            print(Left[i])

yutori()


Measured memory_bytes: 17508
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
bool cmp(pii x, pii y){
	return x.f<y.f; 
}
signed main(){  
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);  
	int n; cin>>n;
	vector<pii> vc(n);
	REP(i,n){
		cin>>vc[i].f;
		vc[i].s=i;
	} 
	sort(ALL(vc));
	REP(i,n){
		cout<<vc[i].s+1<<' '; 
	} 
	cout<<endl;
	
}

Measured memory_bytes: 1664
x,y,a,b,c=map(int, input().split())
p = sorted(list(map(int, input().split())),reverse=True)
q = sorted(list(map(int, input().split())),reverse=True)
r = sorted(list(map(int, input().split())),reverse=True)

total=sorted(p[:x]+q[:y]+r, reverse=True)

print(sum(total[:x+y]))

Measured memory_bytes: 23200
#include <iostream>
#include <stdio.h>
#include <cmath>

#define MAX(a,b) (a > b ? a : b)
int main(void){
	int c;
	scanf("%d",&c);
	for(;c;c--){
		int x,y,z;
		bool f;
		scanf("%d%d%d",&x,&y,&z);
		if(MAX(z,MAX(x,y))==x)
			f = (pow(y,2) + pow(z,2) == pow(x,2));
		else{
			if(MAX(z,MAX(x,y))==y)
				f = (pow(x,2) + pow(z,2) == pow(y,2));
			else
				f= (pow(x,2)+pow(y,2)==pow(z,2));
		}
		std::cout << (f?"YES":"NO") << std::endl;
	}
	return 0;
}
		

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int gcd(int A, int B) {
	if (B == 0) return A;
	return gcd(B, A % B);
}

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


	int N;
	//N = 8;
	//for (int i = 2; i <= 10; i++) {
	//	rep1(j, 8) {
	//		ll kari = 1;
	//		rep1(k, 8) {
	//			kari *= j;
	//			cesp(kari % i);
	//		}
	//		ce("");
	//	}
	//	ce("");
	//}

	cin >> N;
	int A[10001];
	rep(i, N + 1) cin >> A[N - i];

	set<int> kotae;
	int saidai = 10001;
	for (int i = 2; i <= saidai; i++) {
		int sosuu = 1;
		for (int j = 2; j < i; j++) {
			if (i % j == 0) {
				sosuu = 0;
				break;
			}
		}
		if (sosuu) {
			vector<int> V(i);
			rep1(j, N) {
				V[j % (i - 1)] += A[j];
			}
			int OK = 1;
			rep(j, i) {
				if (V[j] % i) OK = 0;
			}
			if (A[0] % i) OK = 0;
			if (OK) kotae.insert(i);
		}
	}

	int GCD = abs(A[N]);
	rep(i, N) if (A[i]) GCD = gcd(abs(A[i]), GCD);

	if (GCD > 1) {
		int saidai2 = sqrt(GCD) + 1;
		for (int i = 2; i <= saidai; i++) {
			if (GCD % i == 0) {
				while (GCD % i == 0) GCD /= i;
				kotae.insert(i);
			}
		}
		if (GCD > 1) kotae.insert(GCD);
	}

	for (int i : kotae) co(i);

	Would you please return 0;
}

Measured memory_bytes: 384
package main

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

func main() {
    var fp *os.File
    fp = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)
    N, _ := strconv.Atoi(readLine(reader))
    T_arr := readLine(reader)
    t_arr := strings.Split(T_arr, " ")
    M, _ := strconv.Atoi(readLine(reader))

    var line string
    var arr []string
    var sum int = 0
    var key int
    var t, t2 int

    for i := 0; i < N; i++ {
        t, _ = strconv.Atoi(t_arr[i])
        sum += t
    }

    for j := 0; j < M; j++ {
        line = readLine(reader)
        arr = strings.Split(line, " ")
        key, _ = strconv.Atoi(arr[0])
        t,  _ = strconv.Atoi(t_arr[key-1])
        t2, _ = strconv.Atoi(arr[1])
        fmt.Println(sum - t + t2)
    }
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int n;
    cin >> n;
    int a[n], b[n], c[n-1];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];
    int ans = 0;
    int before = -1000;
    rep(i, n){
        ans += b[a[i]-1];
    }

    rep(i, n)
        if(a[i+1]-1==a[i]) ans += c[a[i]-1];

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 37

typedef struct card{
 char mark;
 int num;
}card;


void swap(card C[],int x,int y){
card temp;
temp=C[x];
C[x]=C[y];
C[y]=temp;

return;
}



void bubble(card C[],int n){
 for(int i=0;i<n-1;i++){
  for(int j=n-1;j>=i+1;j--){
   if(C[j].num<C[j-1].num){swap(C,j,j-1);}
  }
 }
}


void selesort(card C[],int n){
 for(int i=0;i<n;i++){int minid=i;
  for(int j=i;j<n;j++){
   if(C[j].num<C[minid].num){minid=j;}
  }
  swap(C,i,minid);
 }
return;
}




int main(){
int n,i;
card C[MAX];
card D[MAX];


scanf("%d",&n);

for(i=0;i<n;i++){scanf(" %c%d",&C[i].mark,&C[i].num);D[i]=C[i];}


bubble(C,n);
selesort(D,n);


for(i=0;i<n-1;i++)printf("%c%d ",C[i].mark,C[i].num);printf("%c%d\n",C[n-1].mark,C[n-1].num);
printf("Stable\n");
for(i=0;i<n-1;i++)printf("%c%d ",D[i].mark,D[i].num);printf("%c%d\n",D[n-1].mark,D[n-1].num);


for(i=0;i<n;i++){
 if(C[i].num!=D[i].num||C[i].mark!=D[i].mark){printf("Not stable\n");break;}
 if(i==n-1){printf("Stable\n");}
}




return 0;
}


Measured memory_bytes: 2072
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
using namespace std;

int N, K;
vector<int>a;
vector<vector<int>>invtree;
int answer = 0;

int dfs(int index) {
	int height = 0;
	EACH(i, invtree[index])height = max(height, dfs(i));
	if (K - 1 <= height && a[index] != 0) {
		answer++;
		return 0;
	}
	return height + 1;
}

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

	cin >> N >> K;
	a.resize(N);
	rep(i, N)cin >> a[i];
	rep(i, N)a[i]--;

	if (K == 1) {
		int answer = 0;
		rep(i, N)if (a[i])answer++;
		cout << answer << endl;
		return 0;
	}

	answer = a[0] == 0 ? 0 : 1;
	a[0] = 0;

	invtree.clear(); invtree.resize(N);
	REP(i, 1, N) invtree[a[i]].push_back(i);

	dfs(0);

	cout << answer << endl;
}



Measured memory_bytes: 11264
import math
a,b,C = map(float,input().split())
C_rad=math.pi*C/180
print("{0:.8f}".format(math.sin(C_rad)*a*b/2))
print("{0:.8f}".format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(C_rad))))
print("{0:.8f}".format(b*math.sin(C_rad)))


Measured memory_bytes: 5696
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a,b,c,d=MAP()

while True:
    c-=b
    if c<=0:
        print("Yes")
        exit()
    a-=d
    if a<=0:
        print("No")
        exit()

Measured memory_bytes: 61704
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)
            r=(r*a)%m;
        b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

int main(){
    string s; cin>>s;
    if(s=="Sunny")cout<<"Cloudy\n";
    else if(s=="Cloudy")cout<<"Rainy\n";
    else cout<<"Sunny\n";
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m;
const int mod=1e9+7;
const int maxn=500005;
int a[maxn+3];
int b[maxn+3];
inline int aa(int n,int m){
	return b[n]*a[n-m]%mod;
}
inline int c(int n,int m){
	return aa(n,m)*a[m]%mod;
}
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n>>m;
	b[0]=b[1]=1;
	for(int i=2;i<maxn;i++){
		b[i]=i*b[i-1];
		b[i]%=mod;
	}
	a[0]=a[1]=1;
	for(int i=2;i<=maxn;i++){
		a[i]=(mod-mod/i)*a[mod%i]%mod;
	}
	for(int i=2;i<=maxn;i++){
		a[i]=(a[i]*a[i-1])%mod;
	}
	int sum=0;
	for(int i=0;i<=n;i++){
		int ans=c(n,i)*aa(m-i,n-i);
		ans%=mod;
		if(i%2==0){
			sum+=ans;
		}else{
			sum-=ans;
		}
		sum+=mod;
		sum%=mod;
	}
	sum*=aa(m,n);
	sum+=mod;
	sum%=mod;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 11444
#include <iostream>
using namespace std;
int constexpr y = 753;
int main() {
    string x;
    cin >> x;
    

    int ans = stoi(x.substr(0, 3));
    int sa = abs(ans - y);
    for (int i = 1; i < x.length() - 2; i++) {

        int temp = stoi(x.substr(i, 3));
        int temp_sa = abs(temp - y);

        if (temp_sa < sa) {
            ans = temp;
            sa = temp_sa;
        }
     }
    cout << sa << endl;

    return 0;
}


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

typedef long long ll;
ll n, mx, a[105];
void f(ll p) {
	ll i, k, t[105];
	if (p > n) {
		k = 0;
		for (i =1; i <= n; i++) k += a[i];
		mx = max(mx, k);
		return;
	}
	f(p + 1);
	if (a[p] < 0) {
		for (i = 1; i <= n; i++) t[i] = a[i];
		for (i = p; i <= n; i += p) a[i] = 0;
		f(p + 1);
		for (i = 1; i <= n; i++) a[i] = t[i];
	}
}
int main()
{
	ll i, j, k;
	cin >> n;
	for (i = 1; i <= n; i++) scanf ("%lld", &a[i]);
	for (i = n; i > n / 4; i--) {
		k = 0;
		for (j = i; j <= n; j += i) k += a[j];
		if (k < 0) for (j = i; j <= n; j += i) a[j] = 0;
	}
	f(1);
	cout << mx;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    LL N;
    cin >> N;

    LL ans = 0;
    for (LL x = 1; x <= N; ++x) {
        LL n = N/x;
        ans += x * (n*(n+1)/2);
    }

    cout << ans << endl;

    return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

    int x[3], cnt = 0;
    arep(i, x) cin >> i;
    sort(x, x + 3);
    int a = x[2] - x[0];
    int b = x[2] - x[1];

    cnt += a / 2 + b / 2;
    if ((a % 2 + b % 2) % 2 == 0)
        cnt += (a % 2 + b % 2) / 2;
    else
        cnt += 2;

    cout << cnt << '\n';
}

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

using namespace std;

int main(void) {
  int N, M; cin >> N >> M;
  int WAn[N+1];
  bool ACd[N+1];
  memset(ACd, false, sizeof(ACd));
  memset(WAn, 0, sizeof(WAn));

  int a_num = 0;
  for (int i = 0; i < M; i++) {
    int n; string d;
    cin >> n >> d;
    if (!ACd[n]) {
      if (d == "AC") {
        ACd[n] = true;
        a_num++;
      } else {
        WAn[n]++;
      }
    }
  }
  
  int p_num = 0;
  for (int i = 1; i <= N; i++) {
    if (ACd[i]) {
      p_num += WAn[i];
    }
  }

  cout << a_num << " " << p_num << endl;

  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,P;
vector<ll> A;

class Combination{
    public:
        int N;
        vector<vector<long long>> cmb;
        Combination(int n):N(n),cmb(n,vector<long long>(n,0)){
            for(int i=0;i<N;i++){
                cmb[i][0]=1;
                for(int j=1;j<=i;j++) cmb[i][j]=cmb[i-1][j-1]+cmb[i-1][j];
            }
        }

        long long operator()(int i,int j) const{
            return cmb[i][j];
        }
};

ll h_pow(ll x,ll n){
    ll ret=1;
    while(n>0){
        if(n&1) ret = ret * x;
        x = x * x;
        n>>=1;
    }
    return ret;
}

int main(){
    cin >> N >> P;
    A.resize(N);

    int cnt0=0,cnt1=0;
    rep(i,N){
        cin >> A[i];
        if(A[i]%2==0) cnt0++;
        else cnt1++;
    }

    if(P==0){
        ll t = h_pow(2,cnt0);
        ll t2 = 0;

        Combination cmb(100);
        for(int i=0;i<=cnt1;i+=2){
            t2 += cmb(cnt1,i);
        }
        cout << t * t2 << endl;
    }else{
        ll t = h_pow(2,cnt0);
        ll t2 = 0;

        Combination cmb(100);
        for(int i=1;i<N;i+=2){
            t2 += cmb(cnt1,i);
        }
        cout << t * t2 << endl;
    }

}


Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

ll dp[110000];

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    rep(i, 110000) dp[i] = INF;
    dp[0] = 0;
    rep(i, n) {
        Rep(j, i+1, i+k+1) {
            chmin(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1536
import java.util.*;

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

        for(int i=1; i<=9; i++){
            for(int j=1; j<=9; j++){
                a[i][j] = 0;
            }
        }

        for(int i=1; i<=N; i++){
            String s = String.valueOf(i);
            int l = s.length();
            int x = Integer.parseInt(String.valueOf(s.charAt(0)));
            int y = Integer.parseInt(String.valueOf(s.charAt(l - 1)));
            a[x][y]++;
        }

        long ans = 0;
        for(int i=1; i<=9; i++){
            for(int j=1; j<=9; j++){
                ans += a[i][j] * a[j][i];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 41948
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 2; i < (int)(n); i++)

int main() {
  std::string s;
  int n, m;
  char a, b, c;
  
  std::cin >> n >> s;
  
  rep(i, n) {
    a = s.at(i-2);
    b = s.at(i-1);
    c = s.at(i);
    if (a == 'A' && b == 'B' && c == 'C') {
      m++;
    }
  }
  std::cout << m << std::endl;
}


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

int main(){

    int N;
    cin >> N;
    int A, B;
    cin >> A >> B;
    vector<int> P(N);
    for(int i = 0; i < N; i++) cin >> P[i];
    sort(P.begin(), P.end());

    int Q1 = -1, Q2 = -1;
    for(int i = 0; i < N; i++){
        if(Q1 == -1 && P[i] > A) Q1 = i;
        if(Q2 == -1 && P[i] > B) Q2 = N - i;
    }

    if(Q1 == -1 || Q2 == -1) cout << 0 << endl;
    else cout << min(min(Q1, N - Q1 - Q2), Q2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
inline long long read()
{
	long long x=0;
	char ch=getchar();
	while(ch>='0'&&ch<='9')
	{x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x;
}
long long a,b,c;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b>>c;
	a=a-b;
	a=a%c;
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    S = 1
    for i in range(N):
        S *= A[i]
        if S > 10 ** 18:
            print(-1)
            return

    print(S)

main()

Measured memory_bytes: 21580
S = input()
hms = int(S)
#print(hms/3600, (hms-((hms/3600)*3600)) / 60, hms - (h*3600)-(m*60) / 60)
h = int(hms/3600)
m = int((hms-(h*3600))/60)
s = int((hms-(h*3600)-(m*60)))
print(str(h)+":"+str(m)+":"+str(s))


Measured memory_bytes: 5588
#include <stdio.h>
int main (void) {

  int s[20000], t[900];
  int n, a, i, j, key;
  int c = 0;

  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ) { 
    scanf("%d", &s[i]);
    }
    
  scanf("%d", &a);

  for ( i = 0; i < a; i++ ) { 
    scanf("%d", &t[i]);
    }

  for ( j = 0; j < a; j++ ) {
    i = 0;
    key = t[j];
    s[n] = key;
  
      while ( s[i] != key ) {
         i++;
        }

        if ( i != n ) {
            c++;
        }
    }
    
    printf("%d\n", c);

    return 0;
}


Measured memory_bytes: 1992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,D;
  cin >> N >> D;
  int tree = D*2+1;
  if(N%tree==0){
    int ans = N/tree;
    cout << ans << endl;
  } else{
    int ans = N/tree+1;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max({a * c, a * d, b * c, b * d}) << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define roop(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) { x = max(x, y); }

int a[3005][3005];
ll dp[3005][3005][4];

int main() {
    int R, C, K;
    cin >> R >> C >> K;
    roop(i, K){
        int r, c, v;
        cin >> r >> c >> v;
        a[r - 1][c - 1] = v; //各マスのアイテム
    }
    roop(i, R){
        roop(j, C){
            for(int k = 2; k >= 0; k--){
                chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
            }
            roop(k, 4){
                chmax(dp[i + 1][j][0], dp[i][j][k]);
                chmax(dp[i][j + 1][k], dp[i][j][k]);
            }
        }
    }
    ll ans = 0;
    roop(k, 4){
        chmax(ans, dp[R - 1][C - 1][k]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int maxn = 2*1e5+10;

long long hist[maxn];

int main(){

	int n;
	long long tot;
	cin >> n;
	
	vector<int> v(n);
	vector<long long> cant_remove(n),can_remove(n);
	set<int> st;

	for(int i=0;i<n;++i){
		cin >> v[i];
		hist[v[i]]++;
		st.insert(v[i]);
	}

	for(auto &s:st){
		can_remove[s] =  hist[s] > 1 ? ((hist[s]-1)*(hist[s]-2))/2 : 0;
		cant_remove[s] = (hist[s]*(hist[s]-1))/2;
		tot += cant_remove[s];	
	}

	for(int i=0;i<n;++i){
		//cout << "tot = " << tot << " can = " << can_remove[v[i]] << " cant = " << cant_remove[v[i]] << '\n';
		cout << tot - cant_remove[v[i]] + can_remove[v[i]] << '\n';
	}

	return 0;
}

Measured memory_bytes: 13056
# -*- coding utf-8 -*-
S = input()
ans = [0] * len(S)

onum = 0
enum = 0
j = 0

even = True
for i in range(len(S)):
    if S[i] == 'R':
        if even:
            enum += 1
        else:
            onum += 1
        if S[i + 1] == 'L':
            if even:
                ans[i] += enum
                ans[i + 1] += onum
            else:
                ans[i] += onum
                ans[i + 1] += enum
            onum = 0
            enum = 0
            j = i
    else:
        if (i - j) % 2 == 0:
            ans[j] += 1
        else:
            ans[j + 1] += 1

    even = not even

print(' '.join(map(str, ans)))


Measured memory_bytes: 10484
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvin;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpin;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef queue<int> qin;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
const int maxn = 1e5;
vin adj[maxn];
int dp[maxn];
int vis[maxn];
void addEdge (int a, int b) {
  adj[a].pb(b);
}
void dfs (int a) {
  vis[a]=1;
  for (auto v:adj[a]) {
    if (vis[v]==0) dfs(v);
    dp[a]=max(dp[a],1+dp[v]);
  }

}
int main()
{
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
int n ,m ;
cin>>n>>m;
F (i,0,m,1) {
  int a, b;
  cin>>a>>b; --a; --b;
  addEdge (a,b);
}
F (i,0,n,1) {
  if (!vis[i]) dfs(i);
}
int mxn = -1;
F (i,0,n,1) {
  mxn = max (mxn,dp[i]);
}
cout<<mxn;
return 0;
}



Measured memory_bytes: 12556
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
using namespace std;
int main()
{
    string s ;
    cin>>s ;
    if (s=="SAT")
        cout<<1 ;
    else if (s=="SUN")
        cout<<7 ;
    else if (s=="MON")
        cout<<6 ;
    else if (s=="TUE")
        cout<<5 ;
    else if (s=="WED")
        cout<<4 ;
    else if(s=="THU")
    cout<<3 ;
    else if (s=="FRI")
        cout<<2 ;
}




Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        if (d == 25) {
        	System.out.println("Christmas");
        } else if (d == 24) {
        	System.out.println("Christmas Eve");
        } else if (d == 23) {
        	System.out.println("Christmas Eve Eve");
        } else if (d == 22) {
        	System.out.println("Christmas Eve Eve Eve");
        }
    }
}

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

using namespace std;
using ll = long long;

bool isP(string s){
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main()
{
    string s;
    cin >> s;
    cout << (isP(s) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3612
S = input()
a = []
b = []
for i, s in enumerate(S):
  if i%2==0:
    a.append(s)
  else:
    b.append(s)
a0 = a.count('0')
a1 = a.count('1')
b0 = b.count('0')
b1 = b.count('1')
if a0+b1>=a1+b0:
  print(a1+b0)
else:
  print(a0+b1)

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    int h,n;cin>>h>>n;
    int a[n], sum=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum<h) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 3984
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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

int main() {
	int N;
	string A,B,C;
	cin >> N >> A >> B >> C;
	int ret=0;
	for(int i=0;i<N;i++){
		if(A[i]==B[i]||A[i]==C[i]||B[i]==C[i]){
			if(A[i]==B[i]&&B[i]==C[i]){
			}
			else{
				ret++;
			}
		}
		else{
			ret+=2;
		}
	}
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dist[1100][1100],visited[1100][1100];
P vec[4] = {P(0,1),P(1,0),P(-1,0),P(0,-1)};
vector<string> f;
int h,w;
int bfs(queue<P> q){
    while(!q.empty()){
        P now = q.front();q.pop();
        int x = now.first,y = now.second;
        for(P t:vec){
            int nx = x+t.first,ny = y+t.second;
            if(nx<0 || ny<0 || nx > h-1 || ny > w-1)continue;
            if(f[nx][ny] == '#')continue;
            if(visited[nx][ny])continue;
            visited[nx][ny] = 1;
            dist[nx][ny] = dist[x][y] +1;
            q.push(P(nx,ny));


        }
    }
    int res = 0;
    rep(i,h)rep(j,w){
        res = max(res,dist[i][j]);

    }
    return res;
    
}
int main()
{ 
    cin >> h >> w;
    f.resize(h);
    queue<P> q;
    rep(i,h)cin >> f[i];
    rep(i,h)rep(j,w){
        if(f[i][j] == '#')q.push(P(i,j));
    }
    int ans = bfs(q);
    cout << ans << endl;


    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
// ここに処理を記述

    int A, B;

    cin >> A >> B;

    int ans = A - 2 * B;

    if(ans < 0){
        cout << 0 << "\n";
    }
    else{
        cout << ans << "\n";
    }

return 0;
}

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

int main(){
  int K;
  cin >> K;
  int C = 1;
  int M = 7;
  if (M % K == 0){ cout << 1;}
  else if (K % 2 == 0 || K % 5 == 0){ cout <<-1;}
  else{
    M = 77%K;
    C = 2;
  	while (M!= 0 && M!=(7%K)){ C+=1; M=(M*10+7)%K;}
  	if (M==0){cout << C;} else {cout << -1;}
  }
}

Measured memory_bytes: 3172