akhauriyash/Code-Regression huggingface dataset:
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  int n;
    cin >> n;
    cout << (n+1)/2;
    return 0;
}

Measured memory_bytes: 256
char buf[1800000],f[5];
sz,osz;
rd(){
	int k,x=0;
	for(;;)
	{
		k=buf[sz++];
		if(k<'0')break;
		x=x*10+k-'0';
	}
	return x;
}
N,M,L,Q;
D[301][301];
i,j,k;
a,b,c;
main()
{
	read(0,buf,1800000);
	N=rd();M=rd();L=rd();
	for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=1000000001;
	for(i=0;i<M;i++)
	{
		a=rd();b=rd();c=rd();
		--a;
		--b;
		D[a][b]=D[b][a]=c;
	}
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];
	for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=D[i][j]>L?1000000000:1;
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];
	Q=rd();
	for(i=0;i<Q;i++)
	{
		a=rd();b=rd();
		--a;
		--b;
		if(D[a][b]<1000000000)
		{
			c=D[a][b]-1;
			k=0;
			do{
				f[k++]=c%10+'0';
				c/=10;
			}while(c);
			for(;k--;)buf[osz++]=f[k];
		}
		else buf[osz++]='-',buf[osz++]='1';
		buf[osz++]='\n';
	}
	write(1,buf,osz);
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

string dp[10010];

void chmax(string &a, const string &b)
{
    if (a.size() < b.size() || (a.size() == b.size() && a < b))
        a = b;
}

void Main()
{
    // arrayFill(dp, "");
    int n = in(), m = in();
    vint a = in(m);

    vint v{0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    vpint match(m);
    rep(i, m)
    {
        match[i].fi = a[i];
        match[i].se = v[a[i]];
    }

    rep(i, n + 2)
    {
        for (auto e : match)
        {
            if (dp[i].empty() && i != 0)
                continue;
            chmax(dp[i + e.se], dp[i] + string(1, '0' + e.fi));
        }
    }

    cout << dp[n] << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 33024
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=1<<21;
	int n,K,tr[N][2],f[21][N],count[N];
	inline void print(int A){
		for(int i=count[A];~i;i--) cout<<(A>>i&1);
		cout<<endl;
	}
	int main(){
		n=read<int>(),K=read<int>();
		count[0]=-1;
		for(int i=1;i<2<<n;i++) count[i]=count[i>>1]+1;
		for(int i=0;i<=n;i++)
			for(int j=0;j<1<<i;j++) scanf("%1d",&f[i][1<<i^j]);
		tr[0][0]=tr[0][1]=tr[1][0]=tr[1][1]=0;
		for(int i=2;i<2<<n;i++){
			if(i>>(count[i]-1)&1){
				tr[i][1]=i^1<<count[i];
				tr[i][0]=tr[tr[i][1]][0];
			}else{
				tr[i][0]=i^3<<(count[i]-1);
				tr[i][1]=tr[tr[i][0]][1];
			}
		}

		for(int j=n;j;j--)
			for(int i=2;i<2<<n;i++) if(f[j][i]){
				int A=i>>j,B=(i&((1<<j)-1))^(1<<j);
				if(tr[B][0]){
					int tmp=tr[B][0],len=count[tmp];
					f[len][A<<(len+1)^(tmp^(1<<len))]+=f[j][i];
				}
				if(tr[B][1]){
					int tmp=tr[B][1],len=count[tmp];
					f[len][((A<<1)+1)<<len^(tmp^(1<<len))]+=f[j][i];
				}
				f[0][A]+=f[j][i];
			}
		int ans=1;
		for(int i=2;i<2<<n;i++) if(f[0][i]>=K && count[i]>count[ans]) ans=i;
		if(ans>1)
			for(int j=count[ans]-1;~j;j--) printf("%d",ans>>j&1);
		return 0;
	}
}
int main(){
#ifdef my
	freopen("subsequence.in","r",stdin);
	freopen("subsequence.out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 192296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		int x = 100;
		if (D == 2) {
			x *= 100;
		}
		if (N <= 99) {
			System.out.println(D > 0 ? x * N : N);
		} else {
			System.out.println(D > 0 ? x * 101 : 101);
		}
		sc.close();
	}
}

Measured memory_bytes: 23636
package main

import "fmt"

func main() {
  var s string
  fmt.Scan(&s)
  list := []string{
    "dream",
    "dreamer",
    "erase",
    "eraser",
  }
  for len(s) > 0 {
    flag := false
    for _, w := range list {
      if len(s)-len(w) >= 0 && s[len(s)-len(w):] == w {
        flag = true
        s = s[:len(s)-len(w)]
      }
    }
    if flag == false {
      fmt.Println("NO")
      return
    }
  }
  fmt.Println("YES")
}

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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn =new Scanner(System.in);
		int  n =scn.nextInt();
		int m =scn.nextInt();
		long k =scn.nextLong();
		long [] arr =new long[n];
		long [] arr2 =new long[m];
		
		long count=0;
		
		for(int i=0;i<arr.length;i++){
			
			arr[i]=scn.nextLong();
			
			
		}
	
		for(int i=0;i<arr2.length;i++){
			arr2[i]=scn.nextLong();
			
		}
		long sum=0;
		
		int idx1=-1;
		int idx2=-1;
		for(int i=0;i<arr.length;i++){
			if(sum+arr[i]<=k){
				sum+=arr[i];
				idx1=i;
			}else{
				break;
			}
		}
		for(int i=0;i<arr2.length;i++){
			if(sum+arr2[i]<=k){
				sum+=arr2[i];
				idx2=i;
			}else{
				break;
			}
		}
		
		
		count=idx1+1+idx2+1;
		idx2++;
		while(idx2<arr2.length ){
			if(idx1>=0){
				sum-=arr[idx1];
				idx1--;
			}
		     while(idx2<arr2.length && sum+arr2[idx2]<=k){
		    	
		    	 sum+=arr2[idx2];
		    	 count=Math.max(count, (idx1+1)+idx2+1);
		    	 idx2++;
		    	 
		     }
		   
		     if(idx1<0){
		    	 break;
		     }
		     
		}
	
    
     
		System.out.println(count);

	}

}

Measured memory_bytes: 62164
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
 
 
 
class Program
{
    public const int INF = 1 << 25;
 
    static void Main()
    {
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                Console.WriteLine("{0}x{1}={2}", i, j, i * j);
            }
        }
    }
}

Measured memory_bytes: 5544
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n,m;
    std::cout.precision(10);
    int yes=0;
  cin>>n>>m;
  if(m%2==0 && (2*n<=m && 4*n>=m))
     {
      cout<<"Yes"; 
     }
     else
     {
      	cout<<"No" ;
     }
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3652
import java.util.*;


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

    int five = 0;
    int seven = 0;

    for(int i = 0; i < 3; i++) {
      int n = sc.nextInt();
      if(n == 5) five++;
      if(n == 7) seven++;
    }

    if(five == 2 && seven == 1) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 8916
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            List<Integer> list = Arrays.stream(br.readLine().split(" "))
                    .map(Integer::parseInt)
                    .collect(Collectors.toList());

            int m = list.get(0);
            int f = list.get(1);
            int r = list.get(2);

            if (m == -1 && f == -1 && r == -1) {
                break;
            }

            if (m == -1 || f == -1) {
                System.out.println("F");
                continue;
            }

            if (m + f >= 80) {
                System.out.println("A");
                continue;
            }

            if (m + f >= 65) {
                System.out.println("B");
                continue;
            }

            if (m + f >= 50) {
                System.out.println("C");
                continue;
            }

            if (m + f >= 30) {
                if (r >= 50) {
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
                continue;
            }

            System.out.println("F");
        }
    }
}

Measured memory_bytes: 31344
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
main(){
  int d,n;
  bool dp[101][101],table[101][101],b[101];
  while(cin>>d>>n,d){
    int a[n],e[n],r[n];
    memset(dp,0,sizeof(dp));
    memset(b,0,sizeof(b));
    dp[0][0]=1;b[0]=1;
    r(i,n)cin>>a[i]>>e[i]>>r[i];
    for(int o=1;o<203;o++){
      r(i,101)r(j,d+1)table[i][j]=dp[i][j];
      r(i,n){
        r(j,101){
          if(j<r[i])continue;
          if(!b[j])continue;
          r(k,d+1){
            if(dp[j][k]){
              int y=j+e[i];
              int x=k+a[i];
              if(x>=d){
                cout<<o<<endl;
                goto L;
              }
              if(y>100)y=100;
              b[y]=1;
              table[y][x]=1;
            }
          }
        }
      }
      r(i,101)r(j,d+1)dp[i][j]=table[i][j];
    }
    cout<<"NA"<<endl;
    L:;
  }
}

Measured memory_bytes: 3088
#include <stdio.h>
int main()
{
  int input,a,b,c,d=0;
  scanf("%d",&input);
  a=input/3600;
  b=input%3600;
  c=b/60;
  d=b%60;
  printf("%d:%d:%d\n",a,c,d);

 return 0;
}

Measured memory_bytes: 592
n = gets.to_i
$l = 0

catch(:break_loop) do
    10.times do |uhen|
        $i = uhen
        10.times do |sahen|
            puts "Yes" if $i * sahen == n
            throw :break_loop if $i * sahen == n
        end
        $l = $l + 1
    end
end

puts "No" if $l == 10

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

using graph = vector<vector<int>>;

int f(graph& g, vector<int>& dp, int i){
    if (dp[i] != -1)
        return dp[i];
    auto& dest = g[i];
    int path = 0;
    for (auto to : dest) {
        updatemax(path, f(g, dp, to) + 1);
    }
    dp[i] = path;
    return path;
}

int main() {
    ll N; //vertex
    ll M; //edge
    cin >> N >> M;
    graph g(N+1);
    vector<int> dp(N+1, -1);
    rep(i,M) {
        int x,y;
        cin >> x >> y;
        g[x].push_back(y);
    }
    int path = 0;
    for (int i=1; i<N+1; ++i) {
        updatemax(path, f(g, dp, i));
    }

    cout << path << endl;
    return 0;
}


Measured memory_bytes: 11132
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

ll inf = 1e18;
ll memo[410][410];

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> sum(n+1);
    sum[0] = 0;
    rep(i,n) sum[i+1] += sum[i]+a[i];

    vector<vector<int>> visited(410, vector<int>(410));

    auto dp = [&](auto &&dp, int l, int r) -> ll {
        if (l == r) return 0;
        if (visited[l][r]) return memo[l][r];
        visited[l][r] = 1;

        ll res = inf;
        repf(i,l,r) {
            chmin(res, dp(dp, l, i) + dp(dp, i+1, r) + (sum[r+1]-sum[l]));
        }
        return memo[l][r] = res;
    };

    cout << dp(dp, 0, n-1) << endl;

    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(void){
    int num,sum,pass,ticket,base=4280;
    for(;ticket=1,sum=0,scanf("%d",&num),num != -1;){
        pass=num/10;
        if(num%10 != 0 || num == 0)
            pass++;
        while(pass+1 != ticket){
            switch(ticket){
                case 1:
                    sum+=1150;
                    num-=10;
                    break;
                case 2:
                    if(num > 9){
                        sum+=1250;
                        num-=10;
                    }
                    else{
                        sum+=125*(num%10);
                        num-=num%10;
                    }break;
                 case 3:
                    if(num > 9){
                        sum+=1400;
                        num-=10;
                    }
                    else{
                        sum+=140*(num%10);
                        num-=num%10;
                    }break;
                 case 4:
                    sum+=num*160;
                    break;
            }ticket++;
        }
        printf("%d\n",base-sum);
    }
    return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String args[])
  {
    Scanner sc =new Scanner(System.in);
    int d = sc.nextInt();
    int t = sc.nextInt();
    int s = sc.nextInt();
    double div = (double)((double)d/(double)s);
    if(div<=(double)t)
    {
      System.out.println("Yes");
    }
    else
    {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35512
from collections import defaultdict

N = int(input())
s = []
for i in range(N):
    s.append(input())

d = defaultdict(lambda: 0)
ans = 0

for i in s:
    d[ str(sorted(i)) ] += 1

for i in d.keys():
    count = int(d[i])
    if count > 1:
        ans += (count * (count - 1)//2)

print(ans)

Measured memory_bytes: 29516
//sieu nhan
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inp "test.inp"
#define out "test.out"
#define oo 100005
#define inf 1e15
#define mod 1000000007
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define y1 hungdzno1
int h,w;
main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //freopen(inp,"r",stdin);
  //freopen(out,"w",stdout);
  cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;++i) cin>>s[i];
  vector<int> a((h+1)*(w+1));
  a[w+1]=1;
  for(int i=1;i<h+1;++i) for(int j=1;j<w+1;++j) if(s[i-1][j-1]!='#') a[i*(w+1)+j]=(a[(i-1)*(w+1)+j]+a[i*(w+1)+j-1])%mod;
  cout<<a[(h+1)*(w+1)-1];
}


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

int main(){
  vector<char> s(3);
  int count=0;
  for(int i=0;i<3;i++){
    cin >> s.at(i);
    if(s.at(i)=='o'){
      count++;
    }
  }
  cout << 700+100*count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,A=0;
  cin>>N>>M;
  vector<int>k(M),p(M);
  vector<vector<int>>s(M,vector<int>(N));
  for(int i=0;i<M;i++){
    cin>>k.at(i);
    for(int j=0;j<k.at(i);j++)cin>>s.at(i).at(j);
  }
  for(int i=0;i<M;i++)cin>>p.at(i);
  for(int i=0;i<(1<<10);i++){
    bitset<10>x(i);
    if(N<10&&x.test(N))break;
    int T=0;
    for(int j=0;j<M;j++){
      int S=0;
      for(int a=0;a<k.at(j);a++)if(x.test(s.at(j).at(a)-1))S++;
      if(S%2==p.at(j))T++;
    }
    if(T==M)A++;
  }
  cout<<A<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,mo=998244353,inv=499122177;
struct Edge{
	int next,to;
}edge[N*2];
int fi[N],se,rt,mx,fa[N],f[N][3][3],tmp[3][3];
//f[i][j][k]±íÊ¾i×ÓÊ÷ÖÐÓÐ´ïµ½d==-m/2ºÍm/2Éî¶ÈµÄ½Úµã¸öÊý(2´ú±í¶à¸ö
//it's easy to prove f[i][j][k]=f[i][k][j]
inline void add_edge(int u,int v){edge[++se].next=fi[u],fi[u]=se,edge[se].to=v;}
inline void add(int u,int v){add_edge(u,v),add_edge(v,u);}
void dfs(int x,int d){
	if(d>mx)mx=d,rt=x;
	for(int i=fi[x];i;i=edge[i].next){
		int v=edge[i].to;if(v==fa[x])continue;
		fa[v]=x,dfs(v,d+1);
	}
}
void dp(int x,int d,int fa){
	if(d==mx/2)f[x][1][1]=1;
	else f[x][0][0]=1;
	for(int i=fi[x];i;i=edge[i].next){
		int v=edge[i].to;if(v==fa)continue;
		dp(v,d+1,x);
		memset(tmp,0,sizeof(tmp));
		for(int t1:{0,1,2})for(int t2:{0,1,2})for(int s1:{0,1,2})for(int s2:{0,1,2}){
			for(int k:{0,1,2}){//0 indicate d[u]==d[v],1 indicate d[v]==d[u]-1,2 indicate d[v]==d[u]+1
				int w1=min(2,t1+s1*(k==1)),w2=min(2,t2+s2*(k==2));
				(tmp[w1][w2]+=1ll*f[x][t1][t2]*f[v][s1][s2]%mo)%=mo;
			}
		}
		memcpy(f[x],tmp,sizeof(tmp));
	}
}
int main(){
	int n,u,v;scanf("%d",&n);
	for(int i=1;i<n;i++)scanf("%d%d",&u,&v),add(u,v);
	dfs(1,0);
	mx=fa[rt]=0,dfs(rt,0);
	for(int i=0;i<mx/2;i++)rt=fa[rt];
	if(mx&1){
		u=rt,v=fa[rt];
		dp(u,0,v),dp(v,0,u);
		printf("%d\n",(1ll*f[u][1][0]+f[u][1][1]+f[u][1][2])*(1ll*f[v][1][0]+f[v][1][1]+f[v][1][2])%mo);
	}
	else{
		dp(rt,0,0);
		printf("%d\n",1ll*f[rt][1][1]*inv%mo);
	}
	return 0;
}

Measured memory_bytes: 19712
MAX = int(1e9)
n, k, s = map(int, input().split())
if s != MAX:
    for _ in range(k):
        print(s, end=" ")
    for _ in range(n - k):
        print(MAX, end=" ")
else:
    for _ in range(k):
        print(s, end=" ")
    for _ in range(n - k):
        print(1, end=" ")


Measured memory_bytes: 4340
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    LL n;
    cin >> n;
    vector<double> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    double sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
    }

    double ave = sum/(double)n;

    int idx = 0;
    double dist = abs(a[0]-ave);
    for(int i = 1; i < n; i++){
        if(dist > abs(a[i]-ave)){
            dist = abs(a[i]-ave);
            idx = i;
        }
    }

    cout << idx << endl;
    
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.conv, std.string;

void main() {
  string[] input = split(readln());
  int a = to!int(input[0]), b = to!int(input[1]), c = to!int(input[2]);

  int ans = 0;
  for (int i = a; i <= b; ++i) {
    if (c % i == 0) ans++;
  }

  writeln(ans);
}

Measured memory_bytes: 2488
#include<iostream>    //I
#include<cstdio>
#include<map>
#include<string>
#include<list>
#include<vector>
#include<cstring>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<set>
#include<functional>
using namespace std; 
typedef long long  ll;
const ll maxn=1e5+5;
struct node{
	int mon;
	int a[15];
}book[15];
int m,n,x;
int b[15];
int main(){
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>book[i].mon;
		for(int j=0;j<m;j++){
			cin>>book[i].a[j];
		}
	}
	int ans=2e9;
	for(int i=0;i<(1<<n);i++){
		memset(b,0,sizeof(b));
		int sum=0;
		for(int j=0;j<n;j++){
			if(i>>j&1){
				sum+=book[j].mon;
				for(int k=0;k<m;k++) b[k]+=book[j].a[k];
			}
		}
		bool flag=1;
		for(int j=0;j<m;j++) if(b[j]<x) flag=0;
		if(flag) ans=min(ans,sum);
	}
	if(ans==2e9) cout<<"-1\n";
	else cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 3616
// #include <bits/stdc++.h>
// using namespace std;
// #define rep(i, c) for (int i = 0; i < (int)c; i++)
// int main()
// {
//   int N;
//   cin >> N;
//   if (N = 0)
//   {
//     cout << 2 << endl;
//   }
//   if (N = 1)
//   {
//     cout << 1 << endl;
//   }
//   int ans = 0;
//   vector<int> L;
//   for (int i = 2; i <= N; i++)
//   {
//     ans = ans + L.at(i)
//   }
// }

#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //long long型に別名を付けてる
int N;
ll L[87]; //long long型のL。最大87要素。
int main()
{
  scanf("%d", &N);
  L[0] = 2LL, L[1] = 1LL; //int64_t型として扱うためにはLLと書く
  for (int i = 2; i <= N; i++)
    L[i] = L[i - 2] + L[i - 1]; //L.at(i)の数列
  printf("%lld \n", L[N]);   //L.at(N)をlong long型の数字＋改行で出力
}


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

int main () {
  int i,l,N,K,x;
  l=0;
  cin>>N>>K;
  for (i=0;i<N;i++) {
    cin >> x;
    if (x<(K-x)) {
      l+=x+x;
    }
    else {
      l+=(K-x)*2;
    }
  }
  cout<<l<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n,k;cin>>n>>k;
    vector<int> f(n+10);
    priority_queue<P> q;
    priority_queue<P,vector<P>,greater<P>> q2;
    for(int i=0;i<n;i++){
        int t,d;cin>>t>>d;
        q.push(P(d,t));
    }
    int co=0;
    ll x=0,s=0,ans=0;
    while(co<k){
        P p=q.top();q.pop();
        q2.push(p);
        s+=p.first;
        if(f[p.second]==0)x++;
        f[p.second]++;
        co++;
    }
    ans=s+x*x;
    while(!q.empty()){
        P p=q.top();q.pop();
        if(f[p.second])continue;
        ll m=-1;
        while(!q2.empty()){
            P p2=q2.top();q2.pop();
            if(f[p2.second]>1){
                f[p2.second]--;
                m=p2.first;
                break;
            }
        }
        if(m==-1)break;
        x++;
        f[p.second]++;
        s+=p.first;
        s-=m;
        ans=max(ans,s+x*x);
    }
    cout<<ans<<endl;
}


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

int main() {
	int n, y;
	cin >> n >> y;
	y /= 1000;
	//10a+5b+1c=y (n=a+b+c)となるa,b,cがあるか？
	//9a+4b = y-n (a+b<=n)となるa,bはあるか？→全探索可能
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n-i; j++) {
			if ((9 * i) + (4 * j) == (y - n)) {
				cout << i << " " << j << " " << n - i - j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <string>
using namespace std;
#include<chrono>
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define foo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(a,min(b,min(c,d)))
#define max4(a,b,c,d)       max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
int gcd(int a,int b);
void rstgraph(int n);

const int mod = pow(10,9)+7;
const int N = 3e5, M = N;

//=======================================================================================
vi g[N];
int vis[N];
int nodes=0;
// ll ans=0;
void iluzn() {
 string s,t;
 cin>>s>>t;
 int min=t.length();
 int i,j;
 
 fo(i,s.length()-t.length()+1){
  int count=0;
  int k=i;
  string w;
  fo(j,t.length()){
     // w+=s[k];
     if(s[k]!=t[j]){
      ++count;
     }
       ++k;
  }
  // deb(w);
  if(count<min) min=count;
 }
 cout<<min;
}

 
int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t=1,i;
    // cin>>t;
     while(t--) iluzn();
    return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    // g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

Measured memory_bytes: 10648
import java.io.BufferedReader
import java.io.PrintWriter

class MainKt

var out: PrintWriter = PrintWriter(System.out)  // これを使って出力すると早い

fun main(args: Array<String>) {
    val ab = MyScanner.readAsIntArray()
    out.println(if (ab[0] <= 8 && ab[1] <= 8) "Yay!" else ":(")

    out.flush() // 消さない
}

/**
 * 読み取り
 */
class MyScanner {
    companion object {
        private var reader : BufferedReader = System.`in`.bufferedReader()

        fun reset(){
            reader = System.`in`.bufferedReader()
        }

        fun readAsInt(): Int {
            return Integer.parseInt(reader.readLine())
        }

        // Int
        fun readAsIntArray(delimiters: String = " "): IntArray {
            return reader
                .readLine()
                .split(delimiters)
                .map { s -> Integer.parseInt(s) }
                .toIntArray()
        }

        fun readNTimesAsInt(n: Int): IntArray {
            return (1..n).map { readAsInt() }.toIntArray()
        }

        fun readNTimesAsIntArray(n: Int): Array<IntArray> {
            return (1..n).map { readAsIntArray() }.toTypedArray()
        }

        // long
        // TODO 別の方法を考える
        fun readAsLong(): Long {
            return reader.readLine().toLong()
        }

        fun readAsLongArray(delimiters: String = " "): LongArray {
            return reader.readLine()
                .split(delimiters)
                .map { s -> s.toLong() }
                .toLongArray()
        }

        fun readNTimesAsLong(n: Int): LongArray {
            return (1..n).map { readAsLong() }.toLongArray()
        }

        fun readAsString(): String {
            return reader.readLine()
        }

        fun readAsStringArray(delimiters: String = " "): Array<String> {
            return readAsString().split(delimiters).toTypedArray()
        }

    }
}

/**
 * 要素とその個数を出力
 */
fun <T> Array<T>.ofCountMap(): Map<T, Int> {
    return this.groupBy { it }.mapValues { it.value.count() }
}

/**
 * 文字とその個数を出力
 */
fun String.ofCountMap(): Map<Char, Int> {
    return this.toCharArray().ofCountMap()
}

/**
 * 文字とその個数を出力
 */
fun CharArray.ofCountMap(): Map<Char, Int> {
    return this.groupBy { it }.mapValues { it.value.count() }
}

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

using namespace std;

int n, c, k;
char s[200010];
int dp[200010];
int l[200010], r[200010];

int main(){
    scanf("%d%d%d", &n, &k, &c);
    scanf(" %s", s + 1);

    for(int i = 1; i <= n; i++) dp[i] = -1;

    for(int i = 1; i <= n; i++){
        dp[i] = dp[i - 1];

        if(s[i] == 'o'){
            dp[i] = (i - c - 1 >= 0) ? dp[i - c - 1] + 1 : 1;
        }
    }

    if(dp[n] > k) exit(0);

    for(int i = 1; i <= n; i++){
        if(s[i] == 'o'){
            l[dp[i]] = i;

            i += c;
        }
    }

    for(int i = n; i >= 1; i--){
        if(s[i] == 'o'){
            r[dp[i]] = i;

            i -= c;
        }
    }

    for(int i = 1; i <= k; i++){
        if(l[i] == r[i]) printf("%d\n", l[i]);
    }
    
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define vstroku() to_string()
#define vchislo() to_ulong()
#define numberof1(x) __builtin_popcount(x)
#define povsemelementam(i,mnozh) for(auto i: mnozh)
#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back 
#define pii pair <int, int>
#define F first
#define S second
#define mipletsplay ios_base::sync_with_stdio(0); cin.tie(0); 


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 3e5;
const ll INF = 1e9;
const ll kek = 998244353;

int main() {
	mipletsplay;
int n;
cin>>n;
int k;
cin>>k;
if (k>((n-1)*(n-2)/2))
cout<<-1;
else
{
if (k>=n-2){
int sum=n-2,j=0;
int f=n-1;
while (sum<k)
{
sum+=j+1;
j++;
}
//cout<<j<<endl;
cout<<f+sum-k<<endl;
for (int i=1;i<n-j;i++)
cout<<i<<" "<<i+1<<endl;
for (int i=n-j+1;i<=n;i++)
cout<<2 <<" "<<i<<endl;
int t=n-j+1;
while (sum-k>0)
{
cout<<n<<" "<<t<<endl;
t++;
sum--;
}}
else
{
cout<<n*(n-1)/2 - k<<endl;
for (int i=1;i<=n-1;i++)
{
for (int j=i+1;j<=n-1;j++)
{
cout<<i<<" "<<j<<endl;}
}
for (int i=1;i<=n-1-k;i++)
cout<<n<<" "<<i<<endl;


}





}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#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);
    int a, b; cin >> a >> b;
    int ans = a - 1;
    if(a <= b) ans++;
    cout << ans;
    cout << endl;
    return 0;
}





Measured memory_bytes: 256
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize(4)
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <bits/extc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define mt make_tuple
//#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 998244353
#define ld long double
//#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define bpc __builtin_popcount
#define base 1000000000000000000ll
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mr mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
template<typename T>inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
template<typename T>inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=mul(ans,a,c);a=mul(a,a,c),b>>=1;}return ans;}

using namespace std;
//using namespace __gnu_pbds;

const ld pi = acos(-1);
const ull ba=233;
const db eps=1e-5;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=300000+10,maxn=2000000+10,inf=0x3f3f3f3f;

char s[N];
int a[3],b[3];
int main()
{
    auto ch = [] (char c)
    {
        if(c=='R')return 0;
        if(c=='G')return 1;
        return 2;
    };
    int n;
    scanf("%d%s",&n,s+1);
    ll ans=1;
    for(int i=1;i<=3*n;i++)
    {
        int x=ch(s[i]);
        if(b[x])ans=ans*b[x]%mod,b[x]--;
        else
        {
            if(a[(x+1)%3])ans=ans*a[(x+1)%3]%mod,b[(x+2)%3]++,a[(x+1)%3]--;
            else if(a[(x+2)%3])ans=ans*a[(x+2)%3]%mod,b[(x+1)%3]++,a[(x+2)%3]--;
            else a[x]++;
        }
    }
    for(int i=1;i<=n;i++)ans=ans*i%mod;
    printf("%lld\n",ans);
    return 0;
}
/********************

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


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int H, W;
    while (cin >> H >> W, H) {
        for (int i=0; i<H; ++i) {
            for (int j=0; j<W; ++j) {
                if ((i + j) % 2 == 0) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MAXN 100010
int a[MAXN],n,cnt;
inline int read(){
    int f(1),x(0);
    char ch(getchar());
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
int main(){
    int a(read()),b(read()),n;
    double ret(0),tmp;
    for(register int i(1);i<=a;++i){
        tmp=1.0/a;
        n=i;
        while(n<b) n*=2,tmp/=2;
        ret+=tmp;
    }
    printf("%.12f",ret);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	char a[101],b[101];
	int n;
	cin>>n;
	for(int t=0;t<n;t++)
	cin>>a[t];
	for(int t=0;t<n;t++)
	cin>>b[t];
	for(int t=0;t<n;t++)
	cout<<a[t]<<b[t];
}

Measured memory_bytes: 384
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<H(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define pll				pair <ll,ll>
#define vii				vector <pll>
#define PI				double PPPPPP = 3.14159265358979323846;
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
void solve(){
	ll n;
	cin>>n;
	cout<<"ABC"<<n;
}
int main() {
	run();
	int t=1;
	///cin>>t;
	while(t--)solve();

}


Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))
assert len(D) == N

# i個目のたこ焼のうまさDi
# おいしさがx,yのたこやき2個を食べると体力がxy回復
total = 0
for i,x in enumerate(D[:-1]):
  for y in D[i+1:]:
    total += x * y
print(total)

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

int main()
{
    int n;
    std::cin >> n;
    std::vector<std::pair<std::string,int>> s(n);
    for(int i = 0; i < n; i++)std::cin >> s[i].first >> s[i].second;
    int cnt = 0;
    bool res = false;
    std::string k;
    std::cin >> k;
    for(int i = 0; i < n; i++){
        if(res)cnt += s[i].second;
        if(k == s[i].first)res = true;
    }
    std::cout << cnt <<std::endl;
}

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

using namespace std;

int main() {
  int R;
  scanf("%d", &R);
  if (R < 2800) {
    if (R < 1200) {
      printf("ABC");
    } else {
      printf("ARC");
    }
  } else {
    printf("AGC");
  }
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input()) 
    d, x = (int(i) for i in input().split())
    a = [int(input()) for i in range(n)]
    tot = x
    for i in a:
        m = d % i
        if (m==0):
            tot+=int(((d-m)/i))
        else:    
            tot+=int(((d-m)/i)+1)
    print(tot)
    
main()

Measured memory_bytes: 3060
import math
n = int(input())
div = math.floor(math.sqrt(n))
def sosu(n):
    if n <= 1:
        return False
    for i in range(2,div+1):
        if n%i==0:
            return False
    return True
while True:
    if sosu(n):
        print(n)
        break
    else:
        n+=1

Measured memory_bytes: 3060
import std.stdio, std.array, std.conv, std.algorithm, std.string, std.numeric, std.range;
void main() {
        auto a = readln.strip.to!int;
        auto b = readln.strip.to!int;
        auto c = readln.strip.to!int;
        auto d = readln.strip.to!int;
        auto e = readln.strip.to!int;
        min(a*e, max(b,b+(e-c)*d)).writeln;
}

Measured memory_bytes: 2476
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,q = map(int, readline().split())
#*a, = map(int, readline().split())

n = int(input())

ans = 0
for a in range(1,n):
    ans += (n-1)//a



print(ans)

Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

ll n;
double dp[301][301][301];

double dfs(ll i, ll j, ll k) {
  if(dp[i][j][k]>-1) return dp[i][j][k];
  double res=n;
  if(i) res+=dfs(i-1,j,k)*i;
  if(j) res+=dfs(i+1,j-1,k)*j;
  if(k) res+=dfs(i,j+1,k-1)*k;
  res*=1.0/(i+j+k);
  return dp[i][j][k]=res;
}

int main() {
  cin >> n;
  ll one=0,two=0,three=0;
  for(ll i=0;i<n;i++) {
    ll a;
    cin >> a;
    if(a==1) one++;
    else if(a==2) two++;
    else three++;
  }
  memset(dp,-1,sizeof(dp));
  dp[0][0][0]=0;
  cout << fixed << setprecision(10) << dfs(one,two,three) << endl;
}

Measured memory_bytes: 213376
/**
 * 降参。
 * 解説の方法を試す
 */
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <unordered_set>
#include <cmath>

using namespace std;

struct point {
  int x;
  int y;
};

int main() {
  int n;
  cin >> n;
  vector<point> points(n);

  for (int i = 0; i < n; i++) {
    int x,y;
    cin >> x >> y;
    points[i] = {x,y};
  }

  // 偏角ソート
  // 浮動小数点の精度について考慮必要？
  sort(points.begin(), points.end(), [](const auto& a, const auto& b) {
      return atan2l(a.y, a.x) > atan2l(b.y, b.x); }); // atan2は、座標から偏角を計算する関数。(atanはtanから計算)。lは精度(long double)

  long long int result = 0ll;

  // iを端点として、結果計算
  // O(N**2)かかるけど、Nが小さいので問題なし
  // Nが大きい場合は尺取法とか使うといいらしいが面倒くさそう
  for (int i = 0; i < n; i++) {
    long long int x = 0;
    long long int y = 0;

    for (int j = 0; j < n; j++) {
      int k = (i+j) % n;
      int k_x = points[k].x;
      int k_y = points[k].y;

      x += k_x;
      y += k_y;

      result = max(result, x*x+y*y);
    }
  }

  cout << fixed << setprecision(15) << sqrtl(result) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if(a<1||9<a||b<1||9<b)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    else
    {
        cout<<a*b<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mp[15][15];
int main(){
  int n,d;cin>>n>>d;
  for(int i=0;i<n;++i){
    for(int j=0;j<d;++j){
      cin>>mp[i][j];
    }
  }
  int result = 0;
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      float tmp = 0.0;
      for(int k=0;k<d;++k){
        tmp += (mp[i][k]-mp[j][k]) * (mp[i][k]-mp[j][k]);
      }
      tmp = sqrt(tmp);
      if( tmp-int(tmp) == 0.0){
        result ++;
      }
    }
  }
  cout<<result<<endl;
  return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Main
 */
public class Main {

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

        int K = sc.nextInt();
        String S = sc.next();

        if(S.length() <= K){
            System.out.println(S);
        }else{
            System.out.println(S.substring(0,K) + "...");
        }
    }
}

Measured memory_bytes: 27016
A, B = map(int, input().split())

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

def coprime(a, b):
    return gcd(a, b) == 1
 
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

cmlist = sorted(list(set(divisor(A)) & set(divisor(B))))
res = []
for cm1 in cmlist:
  can_append = True
  for cm2 in res:
    if not coprime(cm1, cm2):
      can_append = False
      continue
  if can_append:
    res.append(cm1)
print(len(res))

Measured memory_bytes: 41580
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N, K;
  int ans = 0;
  cin>>N>>K;
  vector<int> p(N);
  REP(i,N) cin>>p[i];
  sort(p.begin(), p.end());
  REP(i,K) ans += p[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3172
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int n3 = n%10;
		int n2 = n/10%10;
		int n1 = n/100;
		
		switch (n1) {
			case 1:
			 n1 = 9;
			break;
			case 9:
			 n1 = 1;
			break;
		}
			
		switch (n2) {
			case 1:
			 n2 = 9;
			break;
			case 9:
			 n2 = 1;
			break;
		}
		
		switch (n3) {
			case 1:
			 n3 = 9;
			break;
			case 9:
			 n3 = 1;
			break;
			
		}
		
		System.out.println(100*n1 + 10*n2 + n3);
		
	}
	
}

Measured memory_bytes: 23764
def max_profit(num, time1, time2, pro, idx):
    if idx == 10:
        if time1 == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]:
            return -1000000000

        prof = 0
        for i in range(num):
            cnt = 0
            for j, k in zip(time1, time2[i]):
                if j == 1 and j == k:
                    cnt += 1
            prof += pro[i][cnt]

        return prof

    time3 = time1.copy()
    p1 = max_profit(num, time3, time2, pro, idx+1)
    time3[idx] = 1
    p2 = max_profit(num, time3, time2, pro, idx+1)

    return max(p1, p2)


n = int(input())
t = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for j in range(n)]
t1 = [0 for k in range(10)]
print(max_profit(n, t1, t, p, 0))


Measured memory_bytes: 3064
N, A, B, C = map(int, input().split())
Goals = [A, B, C]
bamboos = []
for _ in range(N):
    bamboos.append(int(input()))
INF = 10 ** 9

def dfs(cur, bs):
    if cur == N:
        return sum(abs(x - y) for x, y in zip(bs, Goals)) - 30 if min(bs) > 0 else INF
    ret = dfs(cur + 1, bs)
    for i in range(len(bs)):
        bs0 = bs.copy()
        bs0[i] += bamboos[cur]
        ret = min(ret, dfs(cur + 1, bs0) + 10)
    return ret

ans = dfs(0, [0, 0, 0])

print(ans)


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

int main()
{
    int n;
    cin>>n;
    
    string s[n],str;
    for(int i=0;i<n;i++) cin>>s[i];
    
    int ans=1;
    sort(s,s+n);
    str = s[0];
    for(int i=1;i<n;i++)
    {
        if(s[i]!=str) ans++;
        str = s[i];
    }
    cout<<ans;
}

Measured memory_bytes: 9880