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

using namespace std;

typedef long long int LL;
typedef LL ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll M=2e5+5,LG=26,SM=2000+5,inf=1e18+1;
ll mod=1e9+7;

deque<ll> hf[26];
ordered_set<ll> se;
ll n;

ll befo(ll i)
{
    return i-se.order_of_key(i);
}

ll afte(ll i)
{
    return n-SZ(se)-befo(i)-1;
}

int main()
{
	ios::sync_with_stdio(0);
    str s;
    cin >> s;
    n=SZ(s);
    For(i,0,n)
    {
        hf[s[i]-'a'].PB(i);   
    }   
    ll cnt=0;
    while (SZ(se)<n-n%2)
    {
        ll haz=inf;
        ll hazi=-1;
        For(i,0,26)
        {
            if (SZ(hf[i])>1)
            {
                ll phaz=befo(hf[i].front())+afte(hf[i].back());
                if (phaz<haz)
                {
                    haz=phaz;
                    hazi=i;
                }
            }
        }
        if (hazi==-1)
        {
            cout << -1;
            return 0;
        }
        cnt+=haz;
        se.insert(hf[hazi].front());
        se.insert(hf[hazi].back());
        hf[hazi].pop_front();
        hf[hazi].pop_back();
    }   
    cout << cnt;
}

Measured memory_bytes: 13204
<?php

$n = (int) trim(fgets(STDIN));

$a = $b = [];
for ($i = 1; $i <= $n; $i++) {
    $target = (string)$i;

    $last = $target[strlen($target) - 1];
    if ($last === '0') {
        continue;
    }

    $a[] = "$target[0]$last";
    $b[] = "$last$target[0]";
}

$valuesA = array_count_values($a);
$valuesB = array_count_values($b);

$ans = 0;

foreach ($valuesA as $k => $v) {
    if (isset($valuesB[$k])) {
        $ans += $v * $valuesB[$k];
    }
}

echo $ans;


Measured memory_bytes: 29168
class PriorityQueue
  def initialize
    @q = []
    @h = {}
  end

  # push obj unless already contained
  def push_ex(obj, cost)
    return if @h.key?(obj)
    i = (0...@q.size).bsearch{|i| @q[i][1] > cost} || @q.size
    @q.insert(i, [obj, cost])
    @h[obj] = true
  end

  def pop
    return nil if @q.empty?
    obj = @q.shift[0]
    @h.delete(obj)
    return obj
  end

  # - Node number starts from 1
  def self.dijkstra(edges, start)
    best = Array.new(edges.size+1){ [Float::INFINITY, nil] }
    best[start] = [0, [start]]
    q = PriorityQueue.new
    q.push_ex([start, [start]], 0)
    while (item = q.pop)
      a, route = *item
      edges[a].each do |b, cost|
        new_cost = best[a][0] + cost
        #p a: a, route: route, b: b, cost: cost, best: best[b][0], new_cost: new_cost
        if new_cost < best[b][0]
          best[b] = [new_cost, route+[b]]
          q.push_ex([b, route+[b]], new_cost)
        end
      end
    end
    return best
  end
end

N, M, *rest = $stdin.read.split.map(&:to_i)
EDGES = rest.each_slice(3).to_a
edges = Array.new(N+1){ [] }
EDGES.each do |a, b, cost|
  edges[a] << [b, cost]
  edges[b] << [a, cost]
end

used = Array.new(N+1){ Array.new(N+1) }
for i in 1..N
  best = PriorityQueue.dijkstra(edges, i)
  best.each do |_, route|
    next unless route
    route.each_cons(2) do |j, k|
      if j < k
        used[j][k] = true
      else
        used[k][j] = true
      end
    end
  end
end

p EDGES.count{|a, b| 
  a < b ? !used[a][b] : !used[b][a]
}


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

int main() {
  int N ,X ;
  bool a=false;
  cin >> N;
  for (int i = 1; i <= N; i++)
  {
    if (i*108/100 == N)
    {
     a=true;
     cout << i <<endl;
     break;
    }
     
  }
  if (a == false)
  {
    cout << ":(" << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    string s;cin>>s;
    string t;cin>>t;
    t.pop_back();
    if(s==t) cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n, m;
  cin >> n >> m;
  
  ll sum = 0;
  for (int i = 0; i < m; i++){
    ll a;
    cin >> a;
    
    sum += a;
  }


  cout << max(-1LL, n - sum) << endl;
  

  return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int sum=0;
		int max=0;
		int a[] =new int[N];
		int b[]=new int[N-1];
		for(int i=0;i<N-1;i++) {
			b[i]=sc.nextInt();
			if(i==0) {
				a[i]=b[i];
			}else {
				if(b[i]<b[i-1]) {
					a[i]=b[i];
				}else {
					a[i]=b[i-1];
				}
			}
			sum+=a[i];
		}
		sum+=b[N-2];
		System.out.println(sum);

	}

}


Measured memory_bytes: 21844
program answer
  implicit none
  character(len=4) :: S
  read(*,*) S

  if(S(2:2)==S(1:1)) then
     if(S(3:3)==S(4:4).and.S(1:1)/=S(3:3)) then
	write(*,*) 'Yes'
        stop
     end if
  else if(S(3:3)==S(1:1).and.S(2:2)==S(4:4)) then
     write(*,*) 'Yes'
     stop
  else if(S(4:4)==S(1:1).and.S(2:2)==S(3:3)) then
     write(*,*) 'Yes'
     stop
  end if


  write(*,*) 'No'
  stop
end program answer

Measured memory_bytes: 2748
#include <iostream>
using namespace std;
typedef long long int LLI;
int main()
{
	int n, ans = 0;
	cin >> n;
	int l, r;
	for(int i = 0; i < n; i++)
	{
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans;
}

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			String[] nml = input.readLine().split(" ");
			int n = Integer.parseInt(nml[0]);
			int m = Integer.parseInt(nml[1]);
			int l = Integer.parseInt(nml[2]);
			String[][] matrix1 = new String[n][m];
			String[][] matrix2 = new String[m][l];
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			for (int i = 0; i < n; i++) {
				matrix1[i] = input.readLine().split(" ");
			}
			for (int i = 0; i < m; i++) {
				matrix2[i] = input.readLine().split(" ");
			}
			long sum;
			int s = l - 1;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < l; j++) {
					sum = 0;
					for (int k = 0; k < m; k++) {
						sum += Integer.parseInt(matrix1[i][k]) * Integer.parseInt(matrix2[k][j]);
					}
					answer.append(String.valueOf(sum)).append(j != s ? " "  : lb);
				}
			}
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}

Measured memory_bytes: 33220
#include <iostream>

using namespace std;

int main(){
    int N, Z, W;
    cin >> N >> Z >> W;
    int X[2000];
    for(int i = 0; i < N; i++){
        cin >> X[i];
    }
    int ans = abs(X[N-1]-W);
    if(N >= 2) ans = max(ans, abs(X[N-1]-X[N-2]));
    cout << ans << endl;
}

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

//問題文
//英大文字からなる文字列 S が与えられます。
//S の部分文字列 (注記を参照) であるような最も長い ACGT 文字列 の長さを求めてください。

int main(void)
{
    char s[10];
    char acgt[4] = { 'A','C','G','T' };
    int len;
    int count = 0;
    int count2 = 0;

    scanf("%s", &s);
    
    len = strlen(s);
    if(len > 10)
    {
        len = 10;
    }
	for( int i = 0; i < len; i++ )
	{
        //printf("c=%c\n", s[i]);
		int bFind = 0;
		char input = s[i];
		for( int j = 0; j < 4; j++ )
		{
			char comp = acgt[j];
			if( input == comp )
			{
				bFind = 1;
			}
		}
		if( bFind )
		{
			count++;
		}
		else
		{
			if( count > count2 )
			{
				count2 = count;
				count = 0;
			}
		}
	}
	if( count2 == 0 || count > count2)
	{
		count2 = count;
	}
    // Sの部分文字列であるような最も長い ACGT 文字列の長さを出力せよ。
    // ATCODER　3 ATCODER の部分文字列であるような ACGT 文字列のうち、最も長いものは ATC です。
    // HATAGAYA 5 HATAGAYA の部分文字列であるような ACGT 文字列のうち、最も長いものは ATAGA です。
    // SHINJUKU 0 SHINJUKU の部分文字列であるような ACGT 文字列のうち、最も長いものは  (空文字列) です。
    printf("%d", count2);
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N; cin >> N;

	vi arr;
	arr.push_back(0);
	for (int i = 0; i < N; ++i) {
		int c; cin >> c;
		arr.push_back(c);
	}
	arr.push_back(0);

	int AC = 0;
	for (int i = 0; i < N + 1; ++i) {
		AC += abs(arr[i] - arr[i + 1]);
	}

	for (int i = 1; i < N + 1; ++i) {
		print(AC - abs(arr[i - 1] - arr[i]) - abs(arr[i] - arr[i + 1]) + abs(arr[i - 1] - arr[i + 1]));
	}
}

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

int n;
int dp[maxn][3];
int atv[maxn][3];

signed main(){
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> atv[i][0];
		cin >> atv[i][1];
		cin >> atv[i][2];
	}

	dp[n-1][0] = max(atv[n-1][1],atv[n-1][2]);
	dp[n-1][1] = max(atv[n-1][0],atv[n-1][2]);
	dp[n-1][2] = max(atv[n-1][0],atv[n-1][1]);

	for (int i = n-1; i >= 0; --i){
		int a = atv[i][0] + dp[i+1][0];
		int b = atv[i][1] + dp[i+1][1];
		int c = atv[i][2] + dp[i+1][2];

		dp[i][0] = max(b,c);
		dp[i][1] = max(a,c);
		dp[i][2] = max(a,b);				
	}

	cout << max(max(dp[0][0],dp[0][1]),dp[0][2]) << endl;

	return 0;
}

Measured memory_bytes: 5248
N = int(input())
T_arr = []
S_arr = []
count = 0
while N > 0:
    S,T = (input().split())
    T_arr.append(int(T))
    S_arr.append(S)
    N -= 1
LS = input()
print (sum(T_arr[S_arr.index(LS) + 1:]))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000
using ll = long long;

int main(){
  ll k;
  int n,q;
  cin >> n >> k >> q;
  map<int,int> m;
  rep(i,q){
    int a;
    cin >> a;
    if(m.count(a))m[a]++;
    else m[a]=1;
  }
  rep1(i,n+1){
    ll ans = k-q+m[i];
    if(ans>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    ll a;
    string b;
    cin >> a >> b;
    string c = "";
    c += b[0];
    c += b[2];
    c += b[3];
    ll x = stol(c);
    cout << a * x / 100 << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
int main()
{
    char N[3];
    int i;
    scanf("%s",&N);
    for(i=0;i<3;i++)
    {
    if(N[i]=='7')
    {
        printf("Yes\n");

    return 0;
    }
    }
    printf("No\n");

}

Measured memory_bytes: 1660
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    BGoToJail solver = new BGoToJail();
    solver.solve(1, in, out);
    out.close();
  }

  static class BGoToJail {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int row = 0;
      int mx = 0;
      for (int i = 0; i < n; ++i) {
        int a = in.nextInt(), b = in.nextInt();
        if (a == b) {
          row++;
        } else {
          row = 0;
        }
        mx = Math.max(mx, row);
      }
      out.println(mx >= 3 ? "Yes" : "No");
    }

  }

  static class InputReader {

    private InputStream stream;
    private static final int DEFAULT_BUFFER_SIZE = 1 << 16;
    private static final int EOF = -1;
    private byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (this.numChars == EOF) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return EOF;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == EOF;
    }

  }
}



Measured memory_bytes: 32484
N, M = gets.split.map(&:to_i)
L = Hash.new {|h, x| h[x] = []}
M.times do
  a, b = gets.split.map(&:to_i)
  L[a] << b
  L[b] << a
end

(1..N).each do |k|
  puts L[k].size
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int N = 200005;
int n;
vector<pair<int, int> > v;
ll memo[2000][2000];
ll solve(int *arr, int i, int l, int r) {
if (i==n) {
return 0LL;
}
if (memo[l][r] != -1) {
return memo[l][r];
}
ll ans1 = solve(arr, i + 1, l + 1, r) + (1LL * v[i].first * abs(v[i].second - l));
ll ans2 = solve(arr, i + 1, l, r - 1) + (1LL * v[i].first * abs(v[i].second - r));
return memo[l][r] = max(ans1, ans2);
 
}
 
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n;
int arr[2005];
for (int i = 0; i < n; i++)
cin >> arr[i];
for (int i = 0; i < n; i++) {
v.push_back({arr[i], i});
}
memset(memo, -1, sizeof memo);
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
// for (int i = 0; i < n; i++) {
// cout << v[i].first << " " << v[i].second << endl;
// }
cout<<solve(arr, 0, 0, n - 1);
//cout<<ans<<endl;
return 0;
 
}

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

using namespace std;

int main(){
 long n,m;
  cin >> n >> m;
  
  vector<pair<long,long>> p(m);
  for(int i=0;i<m;i++) cin >> p[i].second >> p[i].first;
  
  sort(p.begin(),p.end());
  
  long b=p[0].first;
  long res=1;
  for(int i=1;i<m;i++){
    if(p[i].second>=b){ 
     res++;
     b=p[i].first;
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 1792
INF = 1e9

n = int(input())
a = [[-1 for i in range(n)]for i in range(n)]
for i in range(n):
    b = list(map(int, input().split()))
    index = b[0]
    k = b[1]
    for j in range(k):
        a[index][b[2+j*2]] = b[3+j*2]


def dijkstra(s):
    flag = [0] * n
    d = [INF] * n
    d[s] = 0
    p = [-1] * n

    while True:
        min_cost = INF

        for i in range(n):
            if flag[i] != 1 and d[i] < min_cost:
                min_cost = d[i]
                u = i
        if min_cost == INF:
            break
        flag[u] = 1

        for v in range(n):
            if flag[v] != 1 and a[u][v] != -1:
                if a[u][v] + d[u] < d[v]:
                    d[v] = d[u] + a[u][v]
                    p[v] = u
    return d
d = dijkstra(0)
for i in range(n):
    print(i, d[i])


Measured memory_bytes: 5792
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	return i
}
func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()

	for a != 0 {
		//fmt.Println(a, b, c, d)
		c = c - b
		if c <= 0 {
			fmt.Println("Yes")
			return
		}
		a = a - d
		if a <= 0 {
			fmt.Println("No")
			return
		}

	}

}


Measured memory_bytes: 1760
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	string s;
	int k;
	cin >> s >> k;
	set<string>st;
	if (s.size() == 1) {
		print(s);
		return 0;
	}
	rep(i, s.size()) {
		rep1(j, k+1) {
			string sub = s.substr(i, j);
			st.insert(sub);
		}
	}
	auto itr = st.begin();
	for (int i = 0; i < k - 1; i++) {
		itr++;
	}
	print(*itr);
}

Measured memory_bytes: 4744
import glob


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\143\\B'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]
        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class B(Common):

    def resolve(self):

        n = int(self.input_data())
        tako = [int(i) for i in self.input_data().split()]
        result = 0

        for i in range(len(tako)):
            for j in range(len(tako)):
                if i < j:
                    result += tako[i] * tako[j]
                else:
                    continue

        print(str(result))

solver = B(REL_PATH)
solver.exec_resolve()

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n;

	cin >> n;

	int ans_p = 0, ans_q = 0;

	vector<int> p(n);
	vector<int> q(n);
	vector<int> v(n);

	for(int i = 0; i < n; ++i)
	{
		v[i] = i + 1;
	}

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

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

	int loop_cnt = 0;
	do{
		loop_cnt++;
		if (v == p) { ans_p = loop_cnt; }
		if (v == q) { ans_q = loop_cnt; }
	} while(next_permutation(v.begin(), v.end()));

	cout << abs(ans_p - ans_q);
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

int main() {
  int N,A;
  cin >> N;
  vector<int> vec(N);
  for(int i;i < N;i++){
    cin >> vec.at(i);
  }
  A = vec.at(0);
  for(int i;i < N;i++){
    if (A == 2){
      cout << i + 1 << endl;
      break;
    }
    
    A = vec.at(A - 1);
    
    if (i == N - 1){
      cout << -1 << endl;
    }
  }
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	int a[3],cnt = 0;
	
	rep(i,0,3){
		cin >> a[i];
		if(a[i] % 2) cnt++;
	}
	
	sort(a,a+3);
	
	if(cnt == 0 || cnt == 3){
		cout << (a[2]-a[0]) / 2 + (a[2]-a[1])/2 << endl;
	}
	else {
		if(a[2] % 2){
			if(a[0] % 2){
				cout << (a[2]-a[0]) / 2 + (a[2]+1-a[1])/2 + 1 << endl;
			}
			else if(a[1] % 2){
				cout << (a[2]+1-a[0]) / 2 + (a[2]-a[1])/2 + 1 << endl;
			}
			else{
				cout << (a[2]-a[0]-1) / 2 + (a[2]-a[1]-1)/2 + 1 << endl;
			}
		}
		else{
			if(a[0] % 2){
				cout << (a[2]+1-a[0]) / 2 + (a[2]-a[1])/2 + 1<< endl;
			}
			else if(a[1] % 2){
				cout << (a[2]-a[0]) / 2 + (a[2]+1-a[1])/2 + 1 << endl;
			}
			else{
				cout << (a[2]-a[0]-1) / 2 + (a[2]-a[1]-1)/2 + 1 << endl;
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    ls = list(map(int, input().split(' ')))
    diff, rst = -1, 0
    for i in range(101, -1, -1):
        if i not in ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
    print(rst)

Measured memory_bytes: 9108
import java.util.*;

public class Main{

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

        int x = sc.nextInt();
        int y = sc.nextInt();
        sc.close();

        long count = 0;

        if(x < y){
            if(x >= 0 || y <= 0)
                count = y-x;
            else{
                if(Math.abs(x) > y)
                    count = Math.abs(x) - y + 1;
                else
                    count = y + x + 1;
            }
        } else {
            if(y >= 0) {
                count = 2+(x-y);
                if(y == 0)
                    count--;
            }
            else if(x <= 0){
                count = x-y+2;
                if(x == 0)
                    count--;
            }
            else
                count = Math.abs(x+y)+1;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int k;
    cin >> k;
    int ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                ans+=__gcd(i,__gcd(j,l));
            }
        }
    }
    cout << ans << endl;
}

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

int tax(int x,int p){
    return p*(100+x)/100;
}

int main(){
    while(1){
        int x,y,s;
        cin >> x >> y >> s;
        if(x*y*s==0) break;
        int ans=0;
        for(int a=1;a<s;a++){
            for(int b=1;b<s;b++){
                if(tax(x,a)+tax(x,b)==s && tax(y,a)+tax(y,b)>ans) ans=tax(y,a)+tax(y,b);
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n),b(m);
    For(i,0,n) cin >> a[i];
    For(i,0,m) cin >> b[i];
    vector<ll> dpa(n+1,0),dpb(m+1,0);
    For(i,0,n) dpa[i+1]=dpa[i]+a[i];
    For(i,0,m) dpb[i+1]=dpb[i]+b[i];
    For(i,0,m+1){
        if(dpb[i]>k) break;
        auto itr=upper_bound(ALL(dpa),k-dpb[i])-1;
        ans=max(ans,i+(itr-dpa.begin()));
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

vector<ll> h(100010);
vector<ll> dp(100010);

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

  for(int i = 0; i < N; i++){
    cin >> h.at(i);
  }

  for(int i = 0; i < 100010; i++){
    dp.at(i) = INF;
  }

  dp.at(0) = 0;

  for(int i = 1; i < N; i++){
    for(int j = i - K; j < i; j++){
      if(j < 0) continue;
      chmin(dp.at(i), dp.at(j) + abs(h.at(i) - h.at(j)));
    }
  }
  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    N *= 2;
    for(int n = 1; n <= 1000; n++)
    {
        if(N == n * (n+1))
        {
            cout << "Yes" << endl;
            cout << n+1 << endl;
            vector<vector<int>> v(n+1);
            int count = 0;
            for(int j = n; j >= 1; j--)
            {
                for(int k = 1; k <= j; k++)
                {
                    v[n-j].push_back(count+k);
                    v[n-j+k].push_back(count+k);
                }
                count += j;
            }
            for(int j = 0; j <= n; j++)
            {
                cout << n << " ";
                for(int k = 0; k < n; k++)
                {
                    cout << v[j][k] << " ";
                }
                cout << endl;
            }
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <memory.h>
#include <algorithm>
using namespace std;

#define CIDX(cchar)		((cchar == 'W') ? 0 : 1)

char org_c[4003];
int d[2002][2002], org_n[4003], idx[2][2003], cum[4003][2003][2];

int main()
{
	int N; scanf("%d", &N);
	for(int i = 1; i <= 2 * N; i++){
		scanf(" %c %d", &org_c[i], &org_n[i]);
		idx[CIDX(org_c[i])][org_n[i]] = i;
	}

	for(int i = 1; i <= 2 * N; i++)
		for(int j = 1; j <= N; j++){
			cum[i][j][0] += cum[i - 1][j][0] + cum[i][j - 1][0] - cum[i - 1][j - 1][0];
			cum[i][j][1] += cum[i - 1][j][1] + cum[i][j - 1][1] - cum[i - 1][j - 1][1];
			if(org_n[i] == j) cum[i][j][CIDX(org_c[i])]++;
		}

	memset(d, 0x3f, sizeof(d));
	d[0][0] = 0;
	for(int i = 1; i <= N; i++){
		d[i][0] = d[i - 1][0] + idx[0][i] - cum[idx[0][i]][i][0];
		d[0][i] = d[0][i - 1] + idx[1][i] - cum[idx[1][i]][i][1];
	}
	for(int i = 0; i <= N; i++)
		for(int j = 0; j <= N; j++){
			d[i + 1][j] = min(d[i + 1][j], d[i][j] + idx[0][i + 1] - cum[idx[0][i + 1]][i + 1][0] - cum[idx[0][i + 1]][j][1]);
			d[i][j + 1] = min(d[i][j + 1], d[i][j] + idx[1][j + 1] - cum[idx[1][j + 1]][i][0] - cum[idx[1][j + 1]][j + 1][1]);
		}

	printf("%d\n", d[N][N]);
	return 0;
}

Measured memory_bytes: 78464
import sys
h, w = map(int, input().split())
s = [input() for _ in range(h)]
if h == 1 and w == 1:
    if s[0] == '#':
        print('#')
    else:
        print(0)
    sys.exit()
for i, m in enumerate(s):
    for j in range(w):
        if m[j] != '#':
            if w == 1:
                if i == 0:
                    count = s[1][0].count('#')
                elif i == h-1:
                    count = s[-2][0].count('#')
                else:
                    count = s[i-1][0].count('#') + s[i+1][0].count('#')
            elif h == 1:
                if j == 0:
                    count = m[1].count('#')
                elif j == w-1:
                    count = m[-2].count('#')
                else:
                    count = m[j-1].count('#') + m[j+1].count('#')
            else:
                if i == 0:
                    if j == 0:
                        count = s[i+1][:2].count('#') + m[1].count('#')
                    elif j == w-1:
                        count = s[i+1][-2:].count('#') + m[-2].count('#')
                    else:
                        count = s[i+1][j-1:j+2].count('#') + m[j-1:j+2].count('#')
                elif i == h-1:
                    if j == 0:
                        count = s[-2][:2].count('#') + m[1].count('#')
                    elif j == w-1:
                        count = s[-2][-2:].count('#') + m[-2].count('#')
                    else:
                        count = s[i-1][j-1:j+2].count('#') + m[j-1:j+2].count('#')
                else:
                    if j == 0:
                        count = s[i-1][:2].count('#') + s[i+1][:2].count('#') + m[1].count('#')
                    elif j == w-1:
                        count = s[i-1][-2:].count('#') + s[i+1][-2:].count('#') + m[-2].count('#')
                    else:
                        count = s[i-1][j-1:j+2].count('#') + s[i+1][j-1:j+2].count('#') + m[j-1:j+2].count('#')
            m = m.replace(m[j], str(count), 1)
    print(m)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
using ll = long long;
using namespace std;

int a, b;
int main() {
    scanf("%d%d", &a, &b);
    printf("%d\n", (a < 10 && b < 10 ? a*b : -1));
    return 0;
}




Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, x;
    cin >> n;
    vi a;
    vi b;
    FOR(i, 0, n){
        cin >> x;
        a.pb(x);
        b.pb(x);
    }
    sort(all(b));
    int max, max2;
    max = b[n-1];
    max2 = b[n-2];
    FOR(i, 0, n){
        if(a[i]!=max){
            cout << max << endl;
        }
        else{
            cout << max2 << endl;
        }
    }
}

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

using namespace std;

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

        if (n == 1) return cout << 1, 0;

        vector<vector<int>> adj(n, vector<int>());
        for (int i = 0, u, v; i < n - 1; i++) {
                cin >> u >> v;
                --u, --v;
                adj[u].push_back(v);
                adj[v].push_back(u);
        }
        vector<int> vec[2];
        function<void(int, int, int)> dfs = [&](int u, int p, int cur) {
                vec[cur].push_back(u);
                for (int v : adj[u])
                        if (v != p)
                                dfs(v, u, cur ^ 1);
        };
        dfs(0, -1, 0);

        if (vec[0].size() > vec[1].size()) {
                swap(vec[0], vec[1]);
        }
        int m = n % 3, c[] = { n / 3, n / 3 + (m > 0), n / 3 + (m > 1) };

        vector<int> col(n);
        if (vec[0].size() <= c[0]) {
                for (int u : vec[0]) {
                        col[u] = 0;
                        --c[0];
                }
                for (int u : vec[1]) {
                        for (int t = 0; t < 3; t++) {
                                if (c[t]) {
                                        col[u] = t;
                                        --c[t];
                                        break;
                                }
                        }
                }
        } else {
                for (int u : vec[0]) {
                        if (c[1]) {
                                col[u] = 1;
                                --c[1];
                        } else {
                                col[u] = 0;
                                --c[0];
                        }
                }
                for (int u : vec[1]) {
                        if (c[2]) {
                                col[u] = 2;
                                --c[2];
                        } else {
                                col[u] = 0;
                                --c[0];
                        }
                }
        }

        int p[] = { 0, -2, -1 };
        for (int i = 0; i < n; i++) {
                cout << (p[col[i]] += 3) << ' ';
        }

        return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n, m;
  cin >> n >> m;
  vector<int>ar(n, 0);
  for (int i = 0; i < m; i++){
    int x, y;
    cin >> x >> y; x--; y--;
    ar[x]++;
    ar[y]++;
  }
  for (int i = 0; i < n; i++){
    cout << ar[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
#include<cassert>
using namespace std;
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fil(a,b) memset((a),(b),sizeof(a))
#define cl(a) fil(a,0)
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b) for (int i=(a),_ed=(b);i<_ed;i++)
#define per(i,a,b) for (int i=(b)-1,_ed=(a);i>=_ed;i--)
#define forg(i,gu) for (int i=gu;~i;i=e[i].next)
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
void getre(){int x=0;printf("%d\n",1/x);}
void gettle(){int res=1;while(1)res<<=1;printf("%d\n",res);}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}
template<typename N,typename PN>inline N flo(N a,PN b){return a>=0?a/b:-((-a-1)/b)-1;}
template<typename N,typename PN>inline N cei(N a,PN b){return a>0?(a-1)/b+1:-(-a/b);}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
template<typename N>inline int sgn(N a){return a>0?1:(a<0?-1:0);}
#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld "%I64d"
#else
#define lld "%lld"
#endif
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
#ifdef JCVB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
typedef long long ll;
typedef double db;
inline ll sqr(ll a){return a*a;}
inline db sqrf(db a){return a*a;}
const int inf=0x3f3f3f3f;
//const ll inf=0x3f3f3f3f3f3f3f3fll;
const db pi=3.14159265358979323846264338327950288L;
const db eps=1e-6;
//const int mo=0;
//int qp(int a,ll b){int n=1;do{if(b&1)n=1ll*n*a%mo;a=1ll*a*a%mo;}while(b>>=1);return n;}

int main()
{
#ifdef JCVB
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	int _time_jc=clock();
#endif
	char s[100];
	gs(s);
	int n=strlen(s);
	n-=8;
	s[n]=0;
	puts(s);
	


#ifdef JCVB
	debug("time: %d\n",int(clock()-_time_jc));
#endif
	return 0;
}




Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int itemCount = int.Parse(Reader.ReadLine());
        long[] items = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

        long[] sorted = items.OrderBy(a => a).ToArray();

        long mid1 = sorted[itemCount / 2 - 1];
        long mid2 = sorted[itemCount / 2];
        StringBuilder ans = new StringBuilder();

        for (int i = 0; i < itemCount; i++) {
            if(items[i]<=mid1) {
                ans.AppendLine(mid2.ToString());
            } else {
                ans.AppendLine(mid1.ToString());
            }
        }

        Console.Write(ans.ToString());

    }



    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


4
2 4 4 3



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 48256
#include <bits/stdc++.h>
using namespace std;
int main()
 
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	unsigned long long int n,power=1,i,mod=1e9+7;
     cin>> n;
     for(i=1;i<=n;i++)

     {
     	power=(power*i);
     	power=power%(mod);
     }
     cout<< power;
 }

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 100100;
const ll MOD = 1e9+7;

int main()
{
    FAST_IO;

    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c-(a-b), 0) << endl;

    return 0;
}


Measured memory_bytes: 256
// B - AtCoder Beginner Contest 111
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vi d{111,222,333,444,555,666,777,888,999};
	rp(i, 0, d.size())
		if(d[i] >= N){ cout<< d[i] <<endl; return 0; }
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int angka;
	scanf ("%d", &angka);
	int x = (angka/100);
	int y = (angka - (x*100))/10;
	int z = (angka - ((angka/10)*10));
	if (x == 7 | y == 7 | z == 7) {
		puts ("Yes");
	} else puts ("No");
	
	return 0;
}

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

long long n, m;
vector<long long> vec[100001];
priority_queue<long long> Q;


int main(){
    cin>>n>>m;
    long long a, b;
    
    for(int i=0; i<n; i++){
        cin>>a>>b;
        vec[a].push_back(b);
    }

    long long ans = 0;
    for(int i=1; i<=m; i++){
        for(int j=0; j<vec[i].size(); j++){
            Q.push(vec[i][j]);
        }
        if(Q.size()){
            ans += Q.top();
            Q.pop();
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;
int n,v[1009],w[1009],c;
long long dp[1009][100009];
int main()
{
    cin>>n>>c;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=c;j++)
        {
            if(dp[i-1][j]==-1)continue;
            if(j+w[i]<=c)
                dp[i][j+w[i]]=max(dp[i][j+w[i]],dp[i-1][j]+v[i]);
            dp[i][j]=max(dp[i-1][j],dp[i][j]);
        }
    }
    long long ans=-3;
    /*for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=c;j++)
        {
            cout<<dp[i][j]<<"\t";
        }
        cout<<"\n";
    }*/
    for(int i=1;i<=c;i++)
    {
        ans=max(ans,dp[n][i]);
    }
    cout<<ans;
}


Measured memory_bytes: 788736
import Data.Array (Array, listArray, (!))
import Data.Int (Int64)

b :: Array Int64 Int64
b = listArray (0,50) $ iterate (\x->2*x+3) 1
p = listArray (0,50) $ iterate (\x->2*x+1) 1

f 0 0 = 0
f 0 n = 1
f n 0 = 0
f n 1 = 0
f n x
  | x<=1+(b!(n-1))   = f (n-1) (x-1)
  | otherwise = (p!(n-1)) + f (n-1) (x-2-(b!(n-1))) + 1

main = do
  [n,x] <- map read . words <$> getLine
  print $ f n x


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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}

int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    ll a[3][3];
    cin >> a[0][0] >> a[0][1] >> a[0][2];
    cin >> a[1][0] >> a[1][1] >> a[1][2];
    cin >> a[2][0] >> a[2][1] >> a[2][2];
    ll n;
    cin >> n;
    //ll b[n];
    for(ll i=0; i<n ;i++){
        ll b;
        cin >> b;
        for(ll j=0; j<3; j++){
            for(ll k=0; k<3; k++){
                if(a[j][k]==b)
                    a[j][k]=0;
            }
        }
    }
    
    //縦
    for(ll i=0; i<3; i++){
        ll raw=0;
        for(ll j=0; j<3; j++){
            raw+=a[i][j];
        }
        if(raw==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    //横
    for(ll j=0; j<3; j++){
        ll raw=0;
        for(ll i=0; i<3; i++){
            raw+=a[i][j];
        }
        if(raw==0){
            cout << "Yes" << endl;
            return 0;
        }
    }

    //斜め
    ll raw=0;
    for(ll i=0; i<3; i++){
        raw+=a[i][i];
    }
    if(raw==0){
        cout << "Yes" << endl;
        return 0;
    }


    ll raw2=0;
    for(ll i=0; i<3; i++){
        raw2+=a[i][2-i];
    }
    if(raw2==0){
        cout << "Yes" << endl;
        return 0;
    }

    
    cout << "No" << endl;    
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;cin >> N;

    REP(i,3500){
        REP(j,3500){
            ll a = 4 * i * j - (i + j) * N;
            ll b = N * i * j;

            if(a > 0 && !(b%a)){
                cout << i << ' ' << j << ' ' << b/a << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M; cin>>N>>M;
  vector<int>A(M,200001);
  vector<int>B(M,-1);
  for(int i=0;i<M;i++){
    int a,b; cin>>a>>b;
    if(a==1)A[i]=b;
    if(b==N)B[i]=a;
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  for(int i=0;i<M;i++){
    if(A[i]==200001)break;
    if(binary_search(B.begin(),B.end(),A[i])){cout<<"POSSIBLE"<<endl;return 0;}
  }
  cout<<"IMPOSSIBLE"<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int>  p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p.at(i);
  }

  int ans = 0;
  for (int i = 1; i < n - 1; ++i) {
    if (p.at(i - 1) < p.at(i) && p.at(i) < p.at(i + 1)) {
      ans++;
    }
    else if (p.at(i + 1) < p.at(i) && p.at(i) < p.at(i - 1)) {
      ans++;
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

int main(){
  int n, m;cin>>n>>m;
  vector<vector<ll>> value(3, vector<ll>(n)), cost(8,vector<ll>(n));
  rep(i, n){
  	cin>>value[0][i]>>value[1][i]>>value[2][i];
  }
  rep(i, 2)rep(j, 2)rep(k, 2){
  	rep(l, n){
      cost[i*4+j*2+k*1][l]=(i*2-1)*value[0][l]+(j*2-1)*value[1][l]+(k*2-1)*value[2][l];
    }
  }
  ll ans=0LL;
  rep(i, 8){
  	sort(cost[i].begin(), cost[i].end(), greater<ll>());
    ll tmp=0LL;
    rep(j, m)tmp+=cost[i][j];
    ans=max(ans, tmp);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 384