akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	var H, W int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &H, &W)

	var matrix [][]string
	matrix = make([][]string, H+1)
	for i := 1; i <= H; i++ {
		matrix[i] = make([]string, W+1)

		var str string
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%s", &str)
		chars := strings.Split(str, "")
		for j := 1; j <= W; j++ {
			matrix[i][j] = chars[j-1]
		}
	}

	removedi := make(map[int]struct{})
	removedj := make(map[int]struct{})

	// check i
	for i := 1; i <= H; i++ {
		isTarget := true
		for j := 1; j <= W; j++ {
			if matrix[i][j] == "#" {
				isTarget = false
				break
			}
		}
		if isTarget {
			removedi[i] = struct{}{}
		}
	}

	// check j
	for j := 1; j <= W; j++ {
		isTarget := true
		for i := 1; i <= H; i++ {
			if matrix[i][j] == "#" {
				isTarget = false
				break
			}
		}
		if isTarget {
			removedj[j] = struct{}{}
		}
	}

	// print
	for i := 1; i <= H; i++ {
		if _, e := removedi[i]; e {
			continue
		}
		for j := 1; j <= W; j++ {
			if _, e := removedj[j]; e {
				continue
			}
			fmt.Print(matrix[i][j])
		}
		fmt.Println()
	}
}


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

int main(){
    char ch[4] = {'L','R','U','D'};
    string s;
    cin >> s;

    bool f = true;

    for(int i = 0; i < s.size(); ++i){
        if(i % 2 == 1){
            if(s[i] == 'R') f= false;
        }else{
            if(s[i] == 'L') f= false;
        }
    }

    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main{

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

		
		while(true){
			int max  = -1;
			int maxi;
			int min  = 1001;
			int mini;
			int sum = 0;
			
			num = scan.nextInt();
			if(num == 0)break;
			
			int[] scr = new int[num];
			
			for(int i = 0; i < num; i++){
				scr[i] = scan.nextInt();
				if(max < scr[i]){
					max = scr[i];
					maxi = i;
				} 
				if(min > scr[i]){
					min = scr[i];
					mini = i;
				}
				sum += scr[i];
			}
			
			sum -= (max + min);
			sum /= (num-2);
			
			System.out.println(sum);
		
		}
	}

}

Measured memory_bytes: 29404
#include <stdio.h>
#include <math.h>

int main()
{
    int a,b,C;
    double PI = acos(-1);
    scanf("%d%d%d",&a,&b,&C);
    printf("%lf\n",a*b*sin(C*PI/180)/2);
    
    double c=pow(a*a+b*b-2*a*b*cos(C*PI/180),0.5);
    
    printf("%lf\n",a+b+c);
    printf("%lf\n",b*sin(C*PI/180));
}



Measured memory_bytes: 2140
#include<stdio.h>
using namespace std;
int a[1000000],n;
int bin(int q){
    int left=0,righ=n,mid;
    while(left<righ){
        mid=(left+righ)/2;
        if(a[mid]==q){
            return 1;
        }
        else{
            if(q<a[mid]){
                righ=mid;
            }else{
                if(q>a[mid]){
                    left=mid+1;
                }
            }
        }
    }
    return 0;
}
int main(){
    int q,sum=0,b;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d",&b);
        if(bin(b))sum++;
    }
    printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 2944
s = input()
ans = 'Yes'
n = 0
w = 0
sow = 0
e = 0
#print(s)
for i in range(len(s)):
    if s[i] == 'N':
        n += 1
    elif s[i] == 'W':
        w += 1
    elif s[i] == 'S':
        sow += 1
    else:
        e += 1



if (n == 0 and sow != 0) or (n != 0 and sow == 0):
    ans = 'No'
if (w == 0 and e != 0) or (w != 0 and e == 0):
    ans = 'No'
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
const int mod=1e9+7;
using LL=long long;
using namespace std;
namespace ndifix{

}//end of namespace ndifix

int main(){
  int n;
  cin>>n;
  vector<int> a(n);for(int i=0;i<n;i++)cin>>a[i];
  vector<int> c;
  c.push_back(a[0]);
  for(int i=1;i<n;i++){
    int locate=distance(c.begin(),lower_bound(c.begin(),c.end(),a[i]));
    if(locate==0)c.insert(c.begin(),a[i]);
    else c[locate-1]=a[i];
  }
  cout<<c.size()<<endl;
  return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mk make_pair
#define all(c) (c).begin(),(c).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define debug2(x,y) cerr<<"("<<#x<<","<<#y<<") = ("<<x<<","<<y<<")\n";
#define debugM(x,n,m) rep(i,0,n){ rep(j,0,m) cerr<<x[i][j]<<" ";cerr<<endl;}
#define debugV(x,n) rep(i,0,n){cerr<<x[i]<<" ";}cerr<<endl; 
#define pi 3.14159265358979323846264338
typedef pair<int,int> ii;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const int MOD = 1e9+7;
   
ll n,h[100100],m[100100];
int main(){
	
	cin>>n;
	rep(i,0,n+1){
		cin>>m[i];
	}
	rep(i,0,n){
		cin>>h[i];
	}
	
	ll ans=0;
	rep(i,0,n){
		debug(i)
		cerr<<"Before: ";
		debug2(m[i],h[i])
		if(m[i]>0){
			ll aux=min(h[i],m[i]);
			h[i]-=aux;
			ans+=aux;
			m[i]-=aux;
			
		}
		ll aux=min(h[i],m[i+1]);
		h[i]-=aux;
		ans+=aux;
		m[i+1]-=aux;
			
		
		cerr<<"After: ";
		debug2(m[i],h[i])
		debug(ans)
		cerr<<endl;
	}
	
	cout << ans<<endl;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> vec(n, 0);
	//vector<long long> presum(n, 0);
	long long vsum, lhlf, dis, tmp;
	//dis = LLONG_MAX;
	dis = 1e17;
	vsum = 0;
	for(int i=0; i<n; i++) {
		cin >> vec[i];
		vsum += vec[i];
	}
	lhlf = 0;
	for(int i=0; i<n-1; i++) {
		lhlf += vec[i];
		tmp = abs(vsum - (lhlf << 1));
		if(dis > tmp)
			dis = tmp;
	}
	cout << dis << endl;
	return 0;
}

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

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

  ll s = 7;
  ll digit = 1;
  ll cnt = 1;
  for (int i = 0; i < 100000000; i++) {
    if (s % K == 0) {
      cout << cnt << endl;
      return 0;
    }
    s %= K;
    digit *= 10;
    digit %= K;
    s += digit * 7;
    cnt++;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

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

int main()
{
  int a, b;
  cin>>a>>b;
  cout << a*b << endl;
}


Measured memory_bytes: 3564
N = input()
K = int(input())

def solve(N, K):
    l = len(N)
    dp = [[[0] * (10) for i in range(2)] for _ in range(l+1)]
    dp[0][0][0] = 1
    for i in range(l):
        D = int(N[i])
        for j in range(2):
            for k in range(K+1):
                for d in range(10):
                    if j == 0 and d > D: break
                    dp[i+1][j or (d < D)][k if d == 0 else k+1] += dp[i][j][k]
    
    return dp[l][0][K] + dp[l][1][K]

print(solve(N,K))



Measured memory_bytes: 39792
#include <stdio.h>
#define MXSZ 200002
int N,Q,A[MXSZ],M[MXSZ],E[MXSZ],id = 0;
typedef struct Node{
    int u;
    struct Node *next;
}node;
node *edge[MXSZ];
node *New(int a){
    node *t = (node*)malloc(sizeof(node));
    t->u = a;
    t->next = NULL;
    return t;
}
node *add(node* root, int a){
    node *t = New(a);
    if(root==NULL) return t;
    t->next = root;
    return t;
}
void init(){
    id = 0;
    for(int i = 0;i<MXSZ;i++) {
        edge[i]=NULL;
        M[i] = 0;
    }
}
void dfs(int u,int p){
    node *t = edge[u];
    M[u]=++id;
    while (t!=NULL)
    {
        int v = t->u;
        if(v!=p) dfs(v,u);
        t = t->next;
    }
    E[u] = id;
}
void MRoy(){
    init();
    scanf("%d%d",&N,&Q);
    for(int i = 1;i<N;i++){
        int a,b; scanf("%d %d",&a,&b);
        edge[a] = add(edge[a],b);
        edge[b] = add(edge[b],a);
    }
    dfs(1,-1);
    while (Q--){
        int p,x; scanf("%d%d",&p,&x);
        A[M[p]]+=x;
        A[E[p]+1]-=x;

    }
    for(int i = 1;i<=N;i++){
        A[i]+=A[i-1];
    }
    for(int i = 1;i<=N;i++){
        if(i!=1) printf(" ");
        printf("%d",A[M[i]]);
    }
    printf("\n");
    return;
}
int main(){
    MRoy();
    return 0;
}

Measured memory_bytes: 28032
#include<bits/stdc++.h>
		#include <ext/pb_ds/assoc_container.hpp>
		#include <ext/pb_ds/tree_policy.hpp>
		using namespace __gnu_pbds;
		using namespace std;
		typedef long long ll;
		typedef unsigned long long int ull;
		// PB-DS
		#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
		#define ff first
		#define ss second
		#define pb push_back
		#define Inf  1000000000000000000
		#define inf -1000000000000000000
		#define mod 1000000007
 
		ll mulmod(ll x,ll y){
			  return (x%mod*y%mod)%mod;
		}
 
		ll addmod(ll x,ll y){
			  return (x%mod+y%mod)%mod;
		}
 
		long long  power(long long  x,long long  y) {
				long long  res = 1;
				x = x%mod;
				while (y > 0)
				{
					if (y & 1)
						res = (res*x)%mod;
					y = y>>1;
					x = (x*x)%mod;
				}
				return res;
		}
	
 
void testcases(int cases){
		int c;
		cin >> c;
		if(c>=30)
			cout << "Yes" << "\n";
		else
			cout << "No" << "\n";
}
	
		 
int main()
{
		
	//sieve();
		ios_base::sync_with_stdio(false);
		cin.tie(0);
		cout.tie(0);
		ll t;
		t = 1;
				//cin >> t;
		ll Case =1 ;
		while(t--)
		{
		 testcases(Case++);
		}
}


Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int n,a[100005];
bool pd=true;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i-1]-a[i]>=2)
			pd=false;
		else if(a[i-1]<=a[i])
			continue;
		else for(int j=i-2;j>=1;j--){
			if(a[j]-a[j+1]==1)
				pd=false;
			if(a[j]!=a[j+1])
				break;
		}
	}
	if(pd)
		cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int s1 = sc.nextInt();
   int s2 = sc.nextInt();
   int s3 = sc.nextInt();
   
   if(s2-s1==s3-s2)System.out.println("YES");
   else System.out.println("NO");
 }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define ldb long double
#define clr(x) memset(x,0,sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
const int size1 = 1e6+7;
const int size2 = 1e4;

//ll fact[size1];
 
ll pw(ll x,ll y,ll mod)
{
    if(y==0)return 1;
    ll p =pw(x,y/2,mod);
    p = (p*p)%mod;
    if(y%2==1)p = (p*x)%mod;
    return p;
}
ll gcd(ll a,ll b)
{
	if(b==0)return a;
	a = a%b;
	return gcd(b,a);
}
// ll inverse(ll x,ll mod)
// {
//     return pw(x,mod-2,mod);
// }
// ll ncr(ll n,ll r,ll mod)
// {
//     ll num = fact[n];
//     ll den = (fact[r] * fact[n-r])%mod;
//     den = inverse(den,mod);
 
//     ll ans = (num*den)%mod;
//     return ans;
// }
// vector<ll> adj1[size1];
// vector<ll> adj[size1];
// ll d[size1];
// ll n,m;
// void dikstra(ll s)
// {
//     for(ll i=1;i<=n;i++)d[i]=1e9;
//     d[s] = 0;
//     priority_queue<pll, vector<pll>, greater<pll>> q;
//     q.push({0, s});
//     while(!q.empty())
//     {
//         ll v = q.top().ss;
//         ll d_v = q.top().ff;
//         q.pop();
//         if(d_v!=d[v])continue;
//         for(auto to:adj1[v])
//         {
//             ll len = 1;
//             if(d[v] + len < d[to])
//             {
//                 d[to] = d[v]+len;
//                 q.push({d[to],to});
//             }
//         }
//     }
// }

ll smallestPrimeFactor[size1];

void seive(){
    clr(smallestPrimeFactor);

    for(ll i=2;i<size1;i++){
        if(smallestPrimeFactor[i]!=0)continue;
        smallestPrimeFactor[i] = i;
        for(ll j=2*i;j<size1;j+=i){
            smallestPrimeFactor[j]=i;
        }
    }    
}
const ll mod = 1e9+7;
int main()
{
    //cout<<setprecision(12)<<fixed;
    #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 	
 	
    ll T;
    //cin>>T;
    T = 1;
    ll cas=1;
    while(T--)
    {
        //cout<<"Case #"<<cas<<": ";cas++;
       seive();

       ll n;cin>>n;
       ll cnt[size1];
       clr(cnt);
       ll g = 0;
       ll fl = 0;

       for(ll i=0;i<n;i++){
            ll x;cin>>x;
            if(i==0)g=x;
            else g=gcd(g,x);
            while(x!=1 and fl==0){
                ll p =smallestPrimeFactor[x];
                while(x%p==0){x=x/p;}
                if(cnt[p]==0)cnt[p]=1;
                else {fl=1;break;}
            }
       }

       if(fl==0){
        cout<<"pairwise coprime";
       }
       else if(g==1){
        cout<<"setwise coprime";
       }
       else{
        cout<<"not coprime";
       }
       cout<<endl;

    }
}


Measured memory_bytes: 19288
mod = 1000000007

N, M = [int(i) for i in input().split()]
A = [int(input()) for _ in range(M)] + [N + 1]

for i in range(len(A) - 1):
    if A[i] + 1 == A[i + 1]:
        print(0)
        quit()

fib = [-1] * (N + 1)
fib[0] = 1
fib[1] = 1
for i in range(2, len(fib)):
    fib[i] = fib[i - 1] + fib[i - 2]


ans = 1
pre = -1
lo = 0
for a in A:
    f = fib[a - 1 - lo]
    ans = (ans * f) % mod

    lo = a + 1
    pre = a

print(ans)

Measured memory_bytes: 461984
#include <iostream>
#include <bits/stdc++.h>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>
#include <unistd.h>

using namespace std;

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

long long int INF = 1e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define line cout << "----------" << endl;


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}


//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q;
ll x[300005],y[300005],z[100005];
char s[300005],t[300005];

int main(){
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> x[i];
	}
	for(i=n;i>=1;i--){
		//iの倍数を見ます
		ll sum = 0;
		for(j=i;j<=n;j+=i){
			sum += y[j];
		}
		if(sum % 2 != x[i]){
			y[i] ++;
		}
	}
	for(i=1;i<=n;i++){
		if(y[i])num++;
	}
	p(num);
	for(i=1;i<=n;i++){
		if(y[i])pe(i);
	}
	el;



	return 0;
}



Measured memory_bytes: 17280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define cps(x) sort(all(x)), (x).erase(unique(all(x)), end(x))
#define cps2(x, y) sort(all(x), y), (x).erase(unique(all(x)), end(x))
#define mem(x, y) memset(& x, y, sizeof(x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[103], b[103];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if (i >= 2 && a[i] == b[i] && a[i - 1] == b[i - 1] && a[i - 2] == b[i - 2])
			return cout << "Yes", 0;
	}
	cout << "No";
}


Measured memory_bytes: 3648
A, B, C, X = 4.times.map{ gets.to_i }

count = 0

(0..A).each do |a|
  (0..B).each do |b|
    (0..C).each do |c|
      count += 1 if 500 * a + 100 * b + 50 * c == X
    end
  end
end

puts count

Measured memory_bytes: 1788
import java.util.*;
public class Main {
  public static void main(String args[]) {
  	Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(x >= 30) {
    	System.out.println("Yes");
    }
    else {
    	System.out.println("No");
    }
  }
}


Measured memory_bytes: 35608
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int A = cin.nextint;
        int B = cin.nextint;
        int C = cin.nextint;

        int max = Math.Max(A, B);
        max = Math.Max(max, C);
        int ans = 0;
        while (max - A > 1)
        {
            A += 2;
            ans++;
        }
        while (max - B > 1)
        {
            B += 2;
            ans++;
        }
        while (max - C > 1)
        {
            C += 2;
            ans++;
        }

        int cnt = 0;
        if (max == A) cnt++;
        if (max == B) cnt++;
        if (max == C) cnt++;

        if (cnt == 3)
        {
            WriteLine(ans);
        }
        else if (cnt == 2)
        {
            WriteLine(ans + 2);
        }
        else
        {
            WriteLine(ans + 1);
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K, H[220000];
signed main() {
    cin >> N >> K;
    rep(i, N) { cin >> H[i]; }
    sort(H, H + N);
    reverse(H, H + N);
    int ans = 0;
    for (int i = K; i < N; i++) { ans += H[i]; }
    cout << ans << endl;
}

Measured memory_bytes: 1792
c = [list(map(int, input().split())) for i in range(3)]

b0 = c[0][0]
b1 = c[0][1]
b2 = c[0][2]

for i in range(1, 3):
    if not ((c[i][0] - b0) == (c[i][1] - b1) and (c[i][1] - b1) == (c[i][2] - b2)):
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

int x,a;

int main(){
    scanf("%d %d",&x,&a);
    cout<<(x*a%2 ? "Odd":"Even")<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math

s = sys.stdin.readline().rstrip()
mins = [
    [len(s)*2 for _ in range(len(s))]
    for _ in range(26)
]

for i in range(len(s)):
    code = ord(s[i]) - ord("a")
    for j in range(i, -1, -1):
        mins[code][j] = min( mins[code][j], i-j)

#print(mins)
print(min(max(max(tries[:len(s)-i]), i) for i in range(len(s)) for tries in mins))

exit(0)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String data = sc.nextLine();
        
        String[] array = data.split(" ");
        long n = Long.parseLong(array[0]);
        long a = Long.parseLong(array[1]);
        long b = Long.parseLong(array[2]);
        
        long count = n / (a + b);
        long amari = n % (a + b);
        
        long blue = count * a;
        if(amari <= a)
        {
            blue += amari;
        }
        else
        {
            blue += a;
        }
        
        System.out.println(blue);
    }
}


Measured memory_bytes: 21844
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = lc()
k = ni()

not1first_idx = len(s)
not1first = '1'

for i in range(len(s)):
    if s[i] != '1':
        not1first_idx = i
        not1first = s[i]
        break
        
        
if k >= not1first_idx+1:
    print(not1first)
    
else:
    print('1')

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

void tranverse_to_vector(string S, vector<char> &s) {
	for (char e : S) {
		s.push_back(e);
	}
}

bool is_equal(vector<char>& s, vector<char>& t) {
	bool flag = true;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			flag = false;
			break;
		}
	}
	return flag;
}

int main() {
	vector<char> s, t;
	string S, T;
	cin >> S;
	cin >> T;
	tranverse_to_vector(S, s);
	tranverse_to_vector(T, t);
	// s.erase(s.begin());
	bool flag = false;
	if (s.size() == t.size()) {
		char tmp;
		for (int i = 0; i < s.size(); i++) {
			tmp = s[0];
			s.erase(s.begin());
			s.push_back(tmp);
			if (is_equal(s, t)) {
				flag = true;
				break;
			}
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, x;
	cin >> n >> x;
	vector <int> l(n);
	for (int i = 0; i < n; i++)cin >> l[i];

	int count = 1,a=0;

	for (int i = 0; i < n;i++)
	{
		a += l[i];
		if (a <= x)
		{
			count++;
		}
		else
		{
			break;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 256
import fractions
a,b = list(map(int, input().split()))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
res = dict(factorization(fractions.gcd(a,b)))
res[1] = 1
print(len(res))


Measured memory_bytes: 65004
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

int check_k(string &s1, string &s2, int i, int j) {
    if (i == 0 && j == 0) return 3;
    if (i == 0) {
        if (s1[0] == s2[0]) return 1;
        else return 2;
    }
    if (j == 0) {
        if (s1[i] == s1[i - 1]) return 1;
        else if (s1[i - 1] == s2[i - 1]) return 2;
        else {
            if (s1[i] == s2[i]) return 1;
            else return 3;
        }
    }
    return 1;
}


int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;

    mint ans = 1;
    rep(i, n) {
        rep(j, 2) {
            int k = check_k(s, t, i, j);
            ans *= k;
        }
    }

    cout << ans << endl;

}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
typedef long long LL;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 2e5 + 5;

int a[ N ];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1, greater <int>());
  LL tot = 0;
  for (int i = k + 1; i <= n; i++) tot += a[i];
  cout << tot << endl;
  return 0;
}



Measured memory_bytes: 1024
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

ans = ['A'] * N
for i, (si, ci) in enumerate(sc):
    if ans[si - 1] != 'A' and ans[si - 1] != str(ci):
        ans = -1
        break
    #
    ans[si - 1] = str(ci)

if ans == -1:
    print(ans)
else:
    for i in range(N):
        if ans[i] == 'A':
            if N == 1:
                ans[i] = '0'
            else:
                ans[i] = '1' if i == 0 else '0'
    #
    if ans[0] == '0':
        if N == 1:
            print(0)
        else:
            print(-1)
    else:
        print(''.join(ans))

Measured memory_bytes: 3064
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N,K = map(int, input().split())

ans = 0
if N >= K:
    ans += (N-K+1)/N
    M = K-1
else:
    M = N
cnt = 1

while K>1:
    K = math.ceil(K/2)
    if K <= M:
        ans += (M-K+1)/((2**cnt)*N)
        M = K-1
        cnt += 1
    else:
        cnt += 1

print(ans)

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

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main() {
	sp;

	////////////////To Remove//////////////
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	///////////////////////////////////////

	int n, w;

	cin>>n>>w;

	vector<long long> dp_prev(w+1, 0), dp(w+1, 0);
	vector<int> wi(n), vi(n);

	for(int i = 0; i < n; ++i){
		cin>>wi[i]>>vi[i];
	}

	for(int i = 0; i < n; ++i){
		for(int j = wi[i]; j <= w; ++j){
			dp[j] = max(dp_prev[j], vi[i] + dp_prev[j - wi[i]]);
		}
		dp_prev = dp;
	}

	cout<<dp_prev[w];

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    int H,W,N;
    cin >> H >> W >> N;
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    string S,T;
    cin >> S >> T;
    bool ret = true;
    int left = 0;
    int right = W;
    if(S.at(N - 1) == 'L') {
        left++;
    }
    else if(S.at(N - 1) == 'R') {
        right--;
    }
    for(int i = N - 2;i >= 0;i--) {
        if(T.at(i) == 'L') {
            right = min(W,right + 1);
        }
        else if(T.at(i) == 'R') {
            left = max(0,left - 1);
        }
        if(S.at(i) == 'L') {
            left++;
        }
        else if(S.at(i) == 'R') {
            right--;
        }
        if(left >= right) {
            ret = false;
        }
    }
    if(b < left || right <= b) {
        ret = false;
    }
    left = 0;
    right = H;
    if(S.at(N - 1) == 'U') {
        left++;
    }
    else if(S.at(N - 1) == 'D') {
        right--;
    }
    for(int i = N - 2;i >= 0;i--) {
        if(T.at(i) == 'U') {
            right = min(H,right + 1);
        }
        else if(T.at(i) == 'D') {
            left = max(0,left - 1);
        }
        if(S.at(i) == 'U') {
            left++;
        }
        else if(S.at(i) == 'D') {
            right--;
        }
        if(left >= right) {
            ret = false;
        }
    }
    if(a < left || right <= a) {
        ret = false;
    }

    if(ret == true) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 776
#include<iostream>
#include<cstring>
#include<map>
using namespace std;
int main()
{
    int N,M,s,c,a[10];
    map<int,int>m;
    cin>>N>>M;
    int flag=1;
    memset(a,-1,sizeof(a));
    while(M--)
    {
        cin>>s>>c;
        if(m.count(s)==0)
        {
            m[s]=c;
            a[s]=c;
        }
        else
        {
            if(m[s]!=c)
                flag=0;
        }
    }
    if(a[1]==0&&N>1)
        flag=0;
    if(flag==0)
    {
        cout<<-1<<endl;
        return 0;
    }
    else
    {
        if(N>1)
        {
            for(int i=1; i<=N; i++)
            {
                if(a[i]==-1 && i==1)
                    cout<<1;
                else if(a[i]==-1 && i>1)
                    cout<<0;
                else
                    cout<<a[i];
            }
        }
        else
        {
            if(a[1]==-1)
                cout<<0;
            else
                cout<<a[1];
        }
        cout<<endl;
    }
    return 0;
}

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

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



Measured memory_bytes: 3084
using System;
using System.Linq;

namespace ABC152
{
    class B
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = input[0];
            int b = input[1];

            if (a <= b)
            {
                for (int i = 0; i < (int)b; i++)
                {
                    Console.Write(a);
                }
            }
            else
            {
                for (int i = 0; i < (int)a; i++)
                {
                    Console.Write(b);
                }
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  vector<string> A(h); rep(i, h) cin >> A[i];
  auto bfs = [&]() {
               int dx[] = {-1, 0, 1, 0};
               int dy[] = {0, 1, 0, -1};
               queue<int> q;
               vector<vector<int>> D(h, vector<int>(w, inf));
               vector<vector<bool>> vis(h, vector<bool>(w));
               rep(i, h) rep(j, w) {
                 if(A[i][j] == '#') {
                   q.push(i*w+j);
                   D[i][j] = 0;
                 }
               }
               while(!q.empty()) {
                 auto tmp = q.front(); q.pop();
                 int x = tmp/w;
                 int y = tmp%w;
                 if(vis[x][y]) continue;
                 vis[x][y] = true;
                 rep(k, 4) {
                   int nx = x+dx[k];
                   int ny = y+dy[k];
                   if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                   if(!vis[nx][ny] && D[nx][ny] > D[x][y]+1) {
                     D[nx][ny] = D[x][y]+1;
                     q.push(nx*w+ny);
                   }
                 }
               }
               int ret = 0;
               rep(i, h) ret = max(*max_element(all(D[i])), ret);
               return ret;
             };
  cout << bfs() << endk;
  return 0;
}


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

int main(){
  const int Nbit= 12;
  int Nbook,Nalg,X;
  cin >> Nbook >> Nalg >> X;

  vector<vector<int>> contents(Nbook, vector<int>(Nalg));
  vector<int> prices(Nbook);
  for(int i=0; i<Nbook; i++){
    cin >> prices.at(i);
    for(int j=0; j<Nalg; j++){
      cin >> contents.at(i).at(j);
    }
  }

  int ans= INT_MAX;
  for(int tmp=0; tmp<(1<<Nbook); tmp++){
    bitset<Nbit> bs(tmp);
    int payment= 0;
    vector<int> learn(Nalg);
    for(int i=0; i<Nbook; i++){
      if(bs.test(i)){
        payment+= prices.at(i);
        for(int j=0; j<Nalg; j++){
          learn.at(j)+= contents.at(i).at(j);
        }
      }      
    }

    bool is_satisfied= true;
    for(int j=0; j<Nalg; j++){
      if(learn.at(j) < X){
        is_satisfied= false;
        break;
      }
    }
    if(is_satisfied){
      ans= min(ans, payment);
    }
  }
  if(ans==INT_MAX){ ans= -1; }

  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#define re(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector <int>a(n);
	re(i, n) cin >> a[i];
	int  p = -100;
	re(i, n)
	{
		if (p < a[i])
			p = a[i] - 1;
		else if (p == a[i])
			p = a[i];
		else 
		{
			cout << "No";
			return 0;
		}
			
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 640
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC172E
//ABC172D
//ABC172C
int main(void) {
  long long n, m, k, i, p=0, q, cou=0, tmp;
  scanf("%lld %lld %lld", &n, &m, &k);
  long long a[n+1], b[m+1];
  a[0]=0, b[0]=0;
  for(i=1; i<n+1; i++){
    scanf("%lld", &a[i]);
    if(i!=1) a[i]+=a[i-1];
  }
  for(i=1; i<m+1; i++){
    scanf("%lld", &b[i]);
    if(i!=1) b[i]+=b[i-1];
  }
  i=0;
  while(a[i]<=k && i<=n)
    i++, cou=i-1;
  //printf("%lld, %lld, %lld\n", i, p, cou);


  for(i=n; i>=0; i--){
    while(a[i]+b[p]<=k&&p<=m){
      cou=cou>=i+p ? cou : i+p;
      p++;
    }
    //printf("%lld, %lld, %lld\n", i, p, cou);
  }
  printf("%lld", cou);
}


Measured memory_bytes: 4852
///Atcoder
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000

#define ll long long
#define sc scanf
#define pf printf
//#define pi 2*acos(0.0)

#define ft first
#define se second
#define Max 10001000
#define st(s) s.size();
#define r(input) freopen("input.txt","r",stdin)
#define w(output) freopen("output.txt","w",stdout)
#define maxall(v) *max_element(v.begin(),v.end())
#define minall(v) *min_element(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define un(v) Sort(v), v.erase(unique(v.begin(),v.end()),v.end())
#define cover(a,d) memset(a,d,sizeof(a))

using namespace std;


int main()
{
    ll a,b=0,n;
    cin>>n;
    ll arr[n+1];
    ll cpy[n+1];
    for(ll i=0; i<n; i++)
    {
        cin>>arr[i];
        cpy[i]=arr[i];
    }
    sort(arr,arr+n);
//    cout<<arr[0]<<endl;
//    cout<<arr[n-1]<<endl;
    for(ll i=0; i<n; i++)
    {
        if(cpy[i]!=arr[i])
            b++;
    }
    if(b<=2)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}





Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}
#[allow(unused_imports)]
use std::io::{stdout, Write};
fn main() {
    let mut s: i32 = read();
    let mut count = 1;
    use std::collections::HashSet;
    let mut set = HashSet::new();
    while set.insert(s) {
        count += 1;
        if s % 2 == 0 {
            s = s / 2;
        } else {
            s = 3 * s + 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
long long int n, k;
long long int a[200001];
long long int flag[200001];
/*int n, m, x;
int c[12];
int a[12][12];
int un[12];
*/
//int dfs(int u[], int k, int money);
int main() {

	/*string s, t;
	cin >> s;
	cin >> t;
	int i;
	for (i = 0; i < s.length(); i++) {
		if (s[i] == t[i]) {

		}
		else {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";
	return 0;*/

	/*int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a) {
		cout << k << endl;
	}
	else if (k <= a + b) {
		cout << a << endl;
	}else{
		cout << a - (k - a - b) << endl;
	}
	return 0;*/


	/*cin >> n >> m >> x;
	int i,j;
	
	for (i = 0; i < n; i++) {
		cin >> c[i];
		for (j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (i = 0; i < m; i++) {
		un[i] = 0;
	}
	cout << dfs(un, 0, 0) << endl;
	return 0;*/

	cin >> n >> k;
	int i;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		flag[i] = 0;
	}
	long long int c = 1;
	flag[1] = 1;
	i = 1;
	long long int preloop;
	long long int looplength;
	while (1) {
		i = a[i];
		if (flag[i] > 0) {
			preloop = flag[i] - 1;
			looplength = c + 1 - flag[i];
			break;
		}
		else {
			c++;
			flag[i] = c;
		}
	}
	if (k > preloop) {
		k = ((k - preloop) % (looplength)) + preloop;
	}
	int j = 1;
	for (i = 0; i < k; i++) {
		j = a[j];
	}
	cout << j << endl;
	return 0;
}
/*int dfs(int u[], int k, int money) {
	//kを加えるのと加えないの．
	//cout << 'a\n';
	int i;
	int mmoney;
	int unn[12];
	int flag = 0;
	int money1, money2;
	mmoney = money + c[k];//kを買った場合のお金
	for (i = 0; i < m; i++) {
		unn[i] = u[i] + a[k][i];//理解度の追加
		if (unn[i] < x) {//理解が足りない
			flag = 1;
		}
	}
	if (k == n-1) {
		if (flag > 0) {
			return -1;
		}
		else {
			return mmoney;
		}
	}
	if (flag == 0) {
		money1 = mmoney;//そろったなら次から調べない．
	}
	else {
		money1 = dfs(unn, k + 1, mmoney);
	}
	money2 = dfs(u, k + 1, money);//kを買わない場合．
	if ((money1 == -1) && (money2 == -1)) {
		return -1;
	}
	else if (money1 == -1) {
		return money2;
	}
	else if (money2 == -1) {
		return money1;
	}
	else if (money2 < money1) {
		return money2;
	}
	else{
		return money1;
	}
}*/

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

int main(){
    int n;cin>>n;
    int d[n];
    for(int i=0;i<n;i++) cin>>d[i];
    int s=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            s+=d[i]*d[j];
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stack>
#include<string>
#define NIL -1

using namespace std;

const int white=0;
const int gray=1;
const int black=2;
const int maxn=1110;
int G[maxn][maxn];
int color[maxn];
int ne[maxn],d[maxn],f[maxn];
int n,tt; 

int next(int u)
{
	for(int v=ne[u];v<n;v++){
		ne[u]=v+1;
		if(G[u][v])return v;
	}
	return NIL;
}

void dfs(int r)
{
	if(r>=n||color[r]!=white)return;
	stack<int> st;
	memset(ne,0,sizeof(ne));
	st.push(r);
	color[r]=gray;
	d[r]=++tt;
	while(!st.empty()){
		int u=st.top();
		int v=next(u);
		if(v!=NIL){
			if(color[v]==white){
				color[v]=gray;
				d[v]=++tt;
				st.push(v);
			}
		}else{
			color[u]=black;
			st.pop();
			f[u]=++tt;
		}
	}
	while(color[r+1]!=white)r++;
	dfs(r+1);
}

int main()
{
	memset(color,white,sizeof(white));
	memset(G,0,sizeof(G));
	memset(f,0,sizeof(f));
	memset(d,0,sizeof(d));
	int u,k,v;
	cin>>n;
	//邻接矩阵存图 
	for(int i=0;i<n;i++){
		cin>>u>>k;
		u--;
		for(int j=0;j<k;j++){
			cin>>v;
			v--;
			G[u][v]=1;
		}
	}
	tt=0;
	dfs(0);
	for(int i=0;i<n;i++){
		cout<<i+1<<' '<<d[i]<<' '<<f[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 7928
#include <iostream>
#include <string>
using namespace std;
int main(){
string a[3];
cin >> a[0]>>a[1]>>a[2];
cout << (char)(a[0].front() & 95) << (char)(a[1].front() & 95)<< (char)(a[2].front() & 95);
return 0;
}

Measured memory_bytes: 256
N = int(input())
digit = len(str(N))
list753 = ["3", "5", "7"]  # string

for i in range(digit):
    for n in list753:
        if len(n) == i:
            list753.append(n + "7")
            list753.append(n + "5")
            list753.append(n + "3")

# print(list753)
counter = 0
for num in list753:
    if int(num) <= N and 0 not in [num.count("3"), num.count("5"), num.count("7")]:
        counter += 1
print(counter)

Measured memory_bytes: 5156
#include<stdio.h>
int IN(void)
{
  int x=0;short f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
signed main(void)
{
  int N=IN(),a=0,i=0,j,max=0,DP[1000001]={0};
  while(i<N){a=IN();DP[a]++;max=a>max?a:max;i++;}a=0;
  for(i=1;i<=max;i++)
  {
    if(!DP[i])continue;
    else
    {
      if(DP[i]==1){a++;}else{DP[i]=0;}
      for(j=2*i;j<=max;j+=i)DP[j]=0;
    }
  }
  return printf("%d\n",a),0;
}

Measured memory_bytes: 5508
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>

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

using namespace std;

vector<int> ans(100);
vector<int> table(17);

struct K
{
	int id;
	int startT;
	int eatingT;
	int endT;
	int num;
};

queue<K> wait;

int getNum(int n)
{
	rep(i,17)
	{
		if(table[i] > 0) continue;

		REP(j,i+1,17)
		{
			if(table[j] > 0) break;;

			if(j-i+1 == n)
			{
				return i;
			}
		}
	}

	return -1;
}

void task()
{
	int t = 0;
	while(!wait.empty())
	{
		while(!wait.empty() && wait.front().id * 5 <= t)
		{
			K temp = wait.front();
			int start = getNum(temp.num);
			if(start != -1)
			{
				REP(k,start,start + temp.num)
				{
					table[k] = temp.eatingT;
				}
				ans[temp.id] = abs(t - temp.startT);
				wait.pop();
			}
			else break;
		}

		rep(i,17)
		{
			if(table[i] > 0) table[i]--;
		}
		t++;
	}
}

int main()
{
	rep(i,100)
	{
		K k;
		k.id = i;

		if(i%5 == 1) k.num = 5;
		else k.num = 2;

		k.eatingT = 17*(i%2) + 3*(i%3) + 19;
		k.startT = 5*i;
		wait.push(k);
	}

	rep(i,17) table[i] = 0;

	task();

	int n;
	while(cin >> n)
	{
		cout << ans[n] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200