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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

auto maxx(auto& a, auto b){a = max(a, b);}

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

  int N, W;
  cin >> N >> W;

  vi w(N), b(N);
  rep(i, 0, N) {
    cin >> w[i] >> b[i];
  }

  auto dp = vector<ll>(W + 1, 0);
  dp[0] = 0;
  rep(i, 0, N) {
    for (int weight = W; weight >= 0; weight--) {
      if (weight >= w[i])
	maxx(dp[weight], dp[weight - w[i]] + b[i]);
    }
  }
  cout << dp[W] << '\n';
  
}


Measured memory_bytes: 1024
#include <stdio.h>
const int MAX_V = 10000;
int prime[10000];
int main(){
int i, k, v ,n;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }
  while(scanf("%d", &n)){
    if(n==0)break;
    int fir=0 , sec=0;
    for(i=n ;i>3 ;i--){
      if(prime[i] && prime[i-2]){
        fir=i-2;
        sec=i;
        break;
      }
    }
    printf("%d %d\n" ,fir ,sec);
  }
  return 0;
}

Measured memory_bytes: 1764
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end() , greater<ll>());

  int ans = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0) ans += a[i];
    else ans -= a[i];
  }
  cout << ans << endl;
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

typedef long long llong;

const int INF = 2e9;
const llong LINF = 2e18;

void inv(bool e);
template<typename T> T sign(T a);
template<typename T> void die(T &a);
template<typename T> void umax(T &a, T b);
template<typename T> void umin(T &a, T b);

bool brute, alter;
int cnt_tests = 1;

// Improving atcoter rating

// Code below

int n, w, h;

vector<int> arr;

void inp() {
    cin >> h >> w >> n;
    arr.resize(n);
    for (auto &x: arr) {
        cin >> x;
    }
}

const int N = 200;

int ans[N][N];

void solve() {
    int p = 0;
    for (int i = 0; i < h; i++) {
        for (int j = (i % 2 ? w - 1 : 0); ; j += (i % 2 ? -1 : 1)) {
            if (j < 0 || j >= w) {
                break;
            }
            if (arr[p] == 0) {
                p++;
            }
            ans[i][j] = p + 1;
            arr[p]--;
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ans[i][j] << ' ';
        }
        cout << endl;
    }
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("palindrome.in", "r", stdin);
            freopen("palindrome.out", "w", stdout);
        }
    #endif
    srand(time(0));
    #ifdef STRESS
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
    cout << endl;
}

template<typename T>
void die(T &a) {
    cout << a;
    exit(0);
}

template<typename T>
T sign(T a) {
    if (a == 0)
        return 0;
    if (a < 0)
        return -1;
    return 1;
}

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

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

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(114514)

from collections import Counter

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

g=[i for i in range(N+1)]

def find(x):
	if g[x] == x:
		return x
	g[x] = find(g[x])
	return g[x]

def union(x, y):
	x = find(x)
	y = find(y)
	if x != y:
		g[x] = y

for _ in range(M):
	x,y,_=map(int,input().split())
	union(x, y)

print(len(Counter([find(i) for i in range(1, N+1)])))


Measured memory_bytes: 30496
#include <iostream>
#include <vector>
#include <regex>

using namespace std;

int main(){
  string n;
  cin >> n;
  for (int i=2; i<n.size(); i++) {
    if (n[i]==n[i-1] && n[i]==n[i-2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

using namespace std;
#define taskname ""
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 1e5 + 5;
ll n , x[maxn] , k , res = 0;
ll pos[maxn] , neg[maxn];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen(taskname".INP", "r",stdin);
	//freopen(taskname".OUT", "w",stdout);
    cin >> n  >> k;
    int cnt1 = 0, cnt0 = 0;
    for(int i = 1 ; i <= n ; ++i)
    {
        cin >> x[i];
        if(x[i] >= 0)pos[cnt0 + 1] = x[i] , cnt0++;
    }
    for(int i = 1 ; i <= n + 1; ++i)
    {
        if(x[i] >= 0)
        {
            for(int j = i - 1 ; j >= 1 ; --j)neg[cnt1 + 1] = -x[j] , ++cnt1;
            break;
        }
    }
    res = LLONG_MAX;
    //cout << pos[2] + neg[1] * 2;
    for(int i = 0 ; i <= cnt0 ; ++i)
    {
        ll d = k - i;
        if(cnt1 >= d && d >= 0){
            ll d1 = pos[i] * 2ll + neg[d];
            res = min(d1 , res);
            d1 = pos[i] + neg[d] * 2ll;
            res = min(d1 ,res);
        }
    }
    cout << res;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;

int main()
{
	int n,check=0;
	cin >> n;
	while (n>0)
	{
		int k=n%10;
		if (k == 7) check=1;
		n/=10;
	}
	if (check) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3636
def exchange(cookies)
  a, b, c = cookies
  [b / 2 + c / 2, a / 2 + c / 2, a / 2 + b / 2]
end

cookies = gets.split.map(&:to_i)

ans = 0
until cookies.any? { |cookie| cookie.odd? }
  exchanged_cookies = exchange(cookies)
  if cookies.sort == exchanged_cookies.sort
    puts -1
    exit
  else
    cookies = exchanged_cookies
    ans += 1
  end
end
puts ans


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

int main() {
  int A, B, C, ans = 0; cin >> A >> B >> C;
  if(3*max({A, B, C})%2 == (A+B+C)%2) ans = (3*max({A, B, C})-(A+B+C))/2;
  else ans = (3*max({A, B, C})+3-(A+B+C))/2;
  cout << ans << "\n";
}

  
                                            


Measured memory_bytes: 256
attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

N, M = attrs[0].map{|a| a.to_i}
A = attrs[1].map{|a| a.to_i}

total_bin = A.inject(:+)
condition = 1.0/ (4*M)
a = attrs[1].select{|a| (a.to_f/total_bin) >= condition}
puts a.size >= M ? "Yes" : "No"

Measured memory_bytes: 14364
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int a,b;
    char c;
    cin>>a>>c>>b;
    if(c=='+'){
        cout<<a+b;
    }else{
        cout<<a-b;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque
h,w=map(int,input().split())
l=['@'*(w+2)]
for i in range(h):
    l.append('@'+input()+'@')
l.append('@'*(w+2))
s=[[-1 for i in j] for j in l]
s[1][1]=l[1][1]=='#'
q=deque([[1,1]])
while len(q)>0:
    x,y=q.popleft()
    for i,j in [[1,0],[0,1]]:
        if l[i+x][j+y]!='@' and s[i+x][j+y]==-1:
            if l[x][y]==l[i+x][j+y]:
                q.appendleft([i+x,j+y])
                s[i+x][j+y]=s[x][y]
            else:
                q.append([i+x,j+y])
                s[i+x][j+y]=s[x][y]+1
print(-s[h][w]//2*-1)
#print(*l,*s,sep='\n')

Measured memory_bytes: 9584
package main

import "fmt"
import "os"
import "bufio"
import "bytes"
import "strconv"

const NEW_LINE byte = 10
const SPACE string = " "

type long int64
type float float32
type double float64

var reader *bufio.Reader
var buffer[][]byte
var pointer int

func InitReader() {
    reader = bufio.NewReaderSize(os.Stdin,4096)
}

func ReadLine() []byte {
    retBytes,_ := reader.ReadBytes(NEW_LINE)
    return retBytes
}

func Next() string {
    if pointer < len(buffer) {
        ret := buffer[pointer]
        pointer++
        return string(ret)
    }

    bs := ReadLine()
    bs = bs[0:len(bs)-1]
    buffer = bytes.Split(bs,[]byte(SPACE))
    pointer = 0
    return Next()
}

func NextLine() string {
    b := ReadLine()
    return string(bytes.TrimSpace(b))
}

func NextInt() int {
    s := Next()
    i,_ := strconv.ParseInt(s,10,32)
    return int(i)
}

func NextLong() long {
    s := Next()
    l,_ := strconv.ParseInt(s,10,64)
    return long(l)
}

func NextFloat() float {
    s := Next()
    f,_ := strconv.ParseFloat(s,32)
    return float(f)
}

func NextDouble() double {
    s := Next()
    d,_ := strconv.ParseFloat(s,64)
    return double(d)
}
func Max(x int,y int) int {
    if x < y {
        return y
    }
    return x
}

func Min(x int,y int) int {
    if x < y {
        return x
    }
    return y
}

func main() {
    InitReader()

    N := NextInt()
    min := 1 << 30
    max := 0
    for i := 0;i < N;i++ {
        a := NextInt()
        min = Min(min,a)
        max = Max(max,a)
    }
    fmt.Println(max-min)
}

Measured memory_bytes: 640
#include<stdio.h>

int main()

{
    int N, remainder;

    scanf("%d", &N);

    remainder = N%10;

    if(remainder==2 || remainder==4 || remainder==5 || remainder==7 || remainder==9)
        printf("hon\n");
    else if(remainder==0 || remainder==1 || remainder==6 || remainder==8)
        printf("pon\n");
    else if(remainder==3)
        printf("bon\n");

    return 0;

}


Measured memory_bytes: 1652
import numpy as np
N = int(input())
Hi = np.array(list(map(int,input().split())))
if N==1:
  print(0)
else:
  idou = 0
  idou_max = 0
  mae = Hi[0]
  for H in Hi[1:]:
    if mae>=H:
      idou += 1
      if idou_max < idou:
      	idou_max = idou
    else:
      idou = 0
    mae = H
  print(int(idou_max))

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

int main() {
  int N, M; cin >> N >> M;
  vector<vector<long long>> A(N, vector<long long>(3));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) cin >> A.at(i).at(j);
  }
  long long ans = -(1LL << 60);
  for (int i = 0; i < 8; i++) {
    vector<long long> v;
    for (int j = 0; j < N; j++) {
      long long S = 0;
      for (int k = 0; k < 3; k++) {
        if ((i / (1 << k)) % 2 == 0) S += A.at(j).at(k);
        else S -= A.at(j).at(k);
      }
      v.push_back(S);
    }
    sort(v.begin(), v.end(), greater<long long>());
    long long tmp = 0;
    for (int j = 0; j < M; j++) tmp += v.at(j);
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

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

int main(){
    int N,M,X,sum=0,MIN=1001;
    cin>>N>>X;
    for(int i=0;i<N;i++){
        cin>>M;
        sum+=M;
        if(MIN>M){
            MIN=M;
        }
    }
    X=floor((X-sum)/MIN);
    cout <<N+X<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#define INF 0x3f3f3f3f
#define ll long long
const int N=1005;
const double c=1e-7;
using namespace std;
int main(){
	long long a;
	double b;
	cin>>a>>b;
	b+=c;
	long long d=b*100;
	long long e=a*d;
	long long f=e/100;
	cout<<f;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int n, k;
  cin >> n >> k;
  int tmp = k, ans = 1;

  while(tmp<=n){
    tmp *= k;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 101;
int f[N][N][N][N] , col[N][N] , row[N][N] , H , W , ex , ey;
char s[N][N];
inline void Update(int &a,int d){
    if(d > a) a = d;
}
inline int Row(int x,int a,int b){
    return row[x][b] - row[x][a-1];
}
inline int Col(int y,int a,int b){
    return col[b][y] - col[a-1][y];
}

int main(){
    scanf("%d%d",&H,&W);
    rep(i,1,H+1) scanf("%s",s[i] + 1);
    rep(i,1,H+1) rep(j,1,W+1){
        col[i][j] = col[i-1][j] + (s[i][j] == 'o');
        row[i][j] = row[i][j-1] + (s[i][j] == 'o');
        if(s[i][j] == 'E') ex = i , ey = j;
    }
    int _L = ey , _R = W-ey+1 , _U = ex , _D = H-ex+1;
    rep(l,0,_L) rep(r,0,_R) rep(u,0,_U) rep(d,0,_D){
        int t = f[l][r][u][d];
        //cout << l << " " << r << " " << u << " " << d << endl;
        int U = max(ex-u,1+d) , D = min(ex+d,H-u);
        Update(f[l+1][r][u][d] , t + (U<=D && 1+r<=ey-l-1 ? Col(ey-l-1,U,D) : 0));
        Update(f[l][r+1][u][d] , t + (U<=D && ey+r+1<=W-l ? Col(ey+r+1,U,D) : 0));
        int L = max(ey-l,1+r) , R = min(ey+r,W-l);
        Update(f[l][r][u+1][d] , t + (L<=R && 1+d<=ex-u-1 ? Row(ex-u-1,L,R) : 0));
        Update(f[l][r][u][d+1] , t + (L<=R && ex+d+1<=H-u ? Row(ex+d+1,L,R) : 0));
    }
    printf("%d\n",f[_L-1][_R-1][_U-1][_D-1]);
    return 0;
}


Measured memory_bytes: 97920
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a;
     cin >> a;
    if(a==7){
         cout  << "YES\n " << endl;
        return 0;
    }else if(a==5){
         cout  << "YES\n " << endl;
        return 0;
    }else if(a==3){
         cout  << "YES\n " << endl;
        return 0;
    }
    // 出力
    cout  << "NO\n " << endl;
    return 0;
}

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

int main() {
	char x[3];
	int i, sum = 0;

	for (i = 0; i < 3; i++) {
		cin >> x[i];
		if (x[i] == '1') {
			sum += 1;
		}
	}

	cout << sum;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	static ArrayList<Integer> list = new ArrayList<Integer>();

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		for (;;) {
			int a = Integer.parseInt(br.readLine());
			if (a == 0) {
				break;
			} else {
				list.add(a);
			}
		}
		for (int i = 0; i < list.size(); i++) {
			System.out.println("Case " + (i + 1) + ": " + list.get(i));
		}
	}
}


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

int main() {
  int i=0,j,k;
  long long N;
  long long ans;
  
  cin >> N;

  double a = sqrt(N);
  int b = a;


  for ( i = b; i > 0; i--)
  {
      if (N%i==0)
      {
          ans=i+N/i-2;
          break;
      }
      
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  int H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  int ans = 0;
  int v = 0;
  for (int i = 0; i < N - 1; i++) {
    if (H[i] >= H[i + 1]) v++;
    else v = 0;
    ans = max(ans, v);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 640
n, x = input().split(" ")
a = input().split(" ")

n, x = int(n), int(x)
a = sorted([int(i) for i in a])

s = x
ret = 0
for i in a:
    if s >= i:
        ret += 1
        s -= i
        n -= 1

if s and not n:
    ret -= 1

print(ret)


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef map<int, int> mii;

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

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

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    int sum = 0;
    int x;
    while (m--){
      cin >> x;
      sum += x;
    }

    cout << max(-1, n - sum) << '\n';

    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 5

int main(){
    int d1, d2, d3, d4 , i, flag;
    char S[5];

    scanf("%s", S);
    flag = 0;

    d4 = atoi(S) / 1000;
    d3 = atoi(S) % 1000 / 100;
    d2 = atoi(S) % 100 / 10;
    d1 = atoi(S) % 10;
    
    if(d4 == d3)flag=1;
    if(d3 == d2)flag=1;
    if(d2 == d1)flag=1;

    if(flag == 1)printf("Bad\n");
    else printf("Good\n");

    return 0;
}

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

typedef long long ll;
const int N = 2003;

int n,m;
vector<int> adj[N];
vector<int> ans;

int vstd[N];
vector<int> sol;

bool check(){
	set<int> st;
	int cnt = 0;
	for(int x:ans){
		st.insert(x);
	}
	for(int x:ans){
		for(int y:adj[x]){
			if(st.count(y))cnt++;
		}
	}
	return cnt == (int)st.size();
}

void dfs(int x){
	vstd[x] = 1;
	sol.push_back(x);
	for(int y:adj[x]){
		if((int)ans.size() > 0)return ;
		if(vstd[y] == 2)continue;
		if(vstd[y] == 1){
			int sz = (int)sol.size();
			for(int i=sz-1;i>=0;i--){
				ans.push_back(sol[i]);
				if(sol[i] == y)break;
			}
			if(check()) return;
			else ans.clear();
			/*
			while(sol.back() != y){
				ans.push_back(sol.back());
				sol.pop_back();
			}
			ans.push_back(y);
			return ;
			*/
		}
		else dfs(y);
	}
	if((int)ans.size() > 0)return;
	sol.pop_back();
	vstd[x] = 2;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
	}
	
	for(int i=1;i<=n;i++){
		if(!vstd[i]){
			dfs(i);
			if((int)ans.size() > 0){
				break;
			}
		}
	}

	if((int)ans.size() > 0){
		cout<<(int)ans.size()<<endl;
		for(int x:ans) cout<<x<<endl;
	}
	else{
		cout<<-1;
	}
	
	return 0;
}


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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    ll N;
    cin >> N;

    ll ans;
    if (N%2 == 0) ans = (N/2) - 1;
    else ans = (N-1) / 2;

    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,k,x[100010],y=1e10;
  bool f=1;
  cin>>n>>k;
  fr(i,n) cin>>x[i];
  fr(i,n-k+1){
    int j=i+k-1;
    if(x[j]<0) y=min(y,-x[i]);
    else if(x[i]>0) y=min(y,x[j]);
    else y=min(y,2*min(-x[i],x[j])+max(-x[i],x[j]));
  }
  cout<<y<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,pl,g;
ll qz[SZ],hz[SZ];
char s[SZ]; ll l,r;
struct arr {ll c[26];}clr;
arr operator + (arr a,arr b)
{for(int i=0;i<26;++i) a.c[i]+=b.c[i]; return a;}
arr operator - (arr a,arr b)
{for(int i=0;i<26;++i) a.c[i]-=b.c[i]; return a;}
arr ps[SZ]; ll len[SZ];
arr calc(char*l,char*r)
{
	arr g=clr;
	while(l!=r) ++g.c[*(l++)-'a'];
	return g;
}
arr qry(int r,ll p)
{
	if(!p) return clr;
	if(r<=1) return calc(s+1,s+p+1);
	if(p<=len[r-1]) return qry(r-1,p);
	return ps[r-1]+qry(r-2,p-len[r-1]);
}
arr qry(ll p)
{return qry(g,p);}
int main()
{
	memset(&clr,0,sizeof clr);
	scanf("%s%lld%lld",s+1,&l,&r);
	n=strlen(s+1); n/=2; s[n+1]=0;
	for(int i=1;i<=n;++i)
		qz[i]=qz[i-1]*233+s[i];
	{
	ll po=1;
	for(int i=n;i>=1;--i)
		hz[i]=hz[i+1]+ll(s[i])*po,po*=233;
	}
	for(int i=1;i<=n;++i)
		if(qz[n-i]==hz[i+1])
		{pl=i; break;}
	len[0]=pl; len[1]=n;
	ps[0]=calc(s+1,s+pl+1);
	ps[1]=calc(s+1,s+n+1);
	for(int i=2;;++i)
	{
		len[i]=len[i-1]+len[i-2];
		ps[i]=ps[i-1]+ps[i-2];
		if(len[i]>1e18) {g=i; break;}
	}
	arr ans=qry(r)-qry(l-1);
	for(int i=0;i<26;++i)
		printf("%lld ",ans.c[i]);
}


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

using namespace std;

int main()
{
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  double ret = -1.0;
  int x, y;

  vector< int > latte, malta;
  for(int i = 0; i <= 30; i++) {
    for(int j = 0; j <= 30; j++) {
      latte.emplace_back(100 * A * i + 100 * B * j);
      if(latte.back() > F || latte.back() == 0) latte.pop_back();
    }
  }
  for(int i = 0; i <= 3000; i++) {
    for(int j = 0; j <= 3000; j++) {
      malta.emplace_back(i * C + j * D);
      if(malta.back() > F) malta.pop_back();
    }
  }

  sort(begin(latte), end(latte));
  latte.erase(unique(begin(latte), end(latte)), end(latte));
  sort(begin(malta), end(malta));
  malta.erase(unique(begin(malta), end(malta)), end(malta));


  for(auto &i : latte) {
    for(auto &j : malta) {
      if(i + j > F) continue;
      if(i * E < j * 100) continue;
      double beet = (double) j / (i + j);
      if(ret < beet) {
        ret = beet;
        x = i;
        y = j;
      }
    }
  }

  cout << x + y << " " << y << endl;
}

Measured memory_bytes: 1400
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000000
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
 
void solve()
{
    ll n,k;cin>>n>>k;
    ll a[n];ll dis[maxn];memset(dis,0,sizeof dis);
    for(ll j=0;j<k;j++)
    {
    for(ll i=0;i<n;i++)
    {
       if(!j) cin>>a[i];
        
        ll l = max(0LL,i-a[i]);
        ll r =min(n-1,i+a[i]);
        
        dis[l]++;dis[r+1]--;
    }
        for(ll i=0;i<n;i++)
        {
            a[i] = dis[i];
            if(i){a[i]+=dis[i-1];dis[i]+=dis[i-1];}
        }
        ll cnt =0;
        for(ll i=0;i<n;i++){if(a[i]==n)cnt++;dis[i]=0;}
        if(cnt==n)
        {
            for(ll i=0;i<n;i++)cout<<n<<" ";
            cout<<Endl;return;
        }
    }
    for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
}

signed main()
{
   Need_for_speed(activated);
//
//satisfy
//    {
//  solve();
//   }

    solve();
    
    return 0;
}


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

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXT 20
#define MAXS 65600

int n;
LL tab[MAXT][MAXT];
LL dp[MAXS];

LL przejdz(int mask){
	
	if(dp[mask]==-1){
		LL sum=0;
		FOR(i,1,n){
			FOR(j,1,n){
				if(((1<<(i-1)&mask)!=0)&&((1<<(j-1)&mask)!=0))
					sum+=tab[i][j];
			}
		}
		dp[mask]=max(0LL,sum);
	}
	else
		return dp[mask];
	
	for(int sub1=(mask-1)&mask;sub1;sub1=(sub1-1)&mask){
		
		int sub2=sub1^mask;
		dp[mask]=max(dp[mask],przejdz(sub1)+przejdz(sub2));		
		
	}
		
	return dp[mask];
}

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	
	FOR(i,1,n){
		FOR(j,1,n)
			cin>>tab[i][j];
	}
	
	FOR(i,0,1<<n)
		dp[i]=-1;
	
	cout<<przejdz((1<<n)-1)/2LL;
	
	
	return 0;
}


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

int main() {
  int n; cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    int p; cin >> p;
    if (!(p == i)) cnt++;
  }
  cout << (cnt <= 2 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const array = input.split(" ").map(Number);
const a = array[0];
const b = array[1];
const c = array[2];
let count = 0;

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

console.log(count);



Measured memory_bytes: 17180
#include <iostream>
using namespace std;
int main(){
	int n,a[100001],b[100001],ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		ans+=b[i]-a[i]+1;
	}
	cout<<ans<<endl;
	return 0;	
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



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


  ll x = h[0];
  ll cnt = 0;
  ll maxx = 0;
  rep1(i, n-1){
    if(h[i] <= x) cnt++;
    else          cnt = 0;
    maxx = max(maxx, cnt);
    x = h[i];
  }

  cout << maxx << endl;


  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
#define INF	1e18
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int x, y, z, n, q[MAXN];
int a[MAXN], b[MAXN], c[MAXN];
long long pre[MAXN], succ[MAXN];
priority_queue <int> Heap;
bool cmp(int x, int y) {
	return a[x] - b[x] < a[y] - b[y];
}
long long solve() {
	sort(q + 1, q + n + 1, cmp);
	long long now = 0;
	for (int i = 1; i <= n; i++) {
		if (i <= y) {
			Heap.push(-b[q[i]]);
			now += b[q[i]];
		} else {
			Heap.push(-b[q[i]]);
			now += b[q[i]];
			now += Heap.top();
			Heap.pop();
		}
		if (i >= y) pre[i] = now;
		else pre[i] = -INF;
	}
	now = 0;
	while (!Heap.empty())
		Heap.pop();
	for (int i = n; i >= 1; i--) {
		int j = n - i + 1;
		if (j <= x) {
			Heap.push(-a[q[i]]);
			now += a[q[i]];
		} else {
			Heap.push(-a[q[i]]);
			now += a[q[i]];
			now += Heap.top();
			Heap.pop();
		}
		if (j >= x) succ[i] = now;
		else succ[i] = -INF;
	}
	long long ans = -INF;
	for (int i = 1; i < n; i++)
		ans = max(ans, pre[i] + succ[i + 1]);
	return ans;
}
int main() {
	read(x), read(y), read(z);
	n = x + y + z;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		read(a[i]), read(b[i]), read(c[i]);
		a[i] -= c[i]; b[i] -= c[i];
		ans += c[i]; q[i] = i;
	}
	cout << ans + solve() << endl;
	return 0;
}

Measured memory_bytes: 3832
N = int(input())
W = list(map(int, input().split()))

minimum = max(W)

for i in range(N-1):
  S_1 = sum(W[:i+1])
  S_2 = sum(W[i+1:])
  minimum = min(minimum, abs(S_2 - S_1))
print(minimum)

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

int main() {
	int N, T, c[120], t[150];
	cin >> N >> T;
	
	for(int i=0; i<N; i++){
		cin >> c[i] >> t[i];
	}
	
	int ans = 9999;
	
	for(int i=0;i<N;i++){
		if(t[i] <=T){
			if(c[i] < ans){
				ans = c[i];
				
			}
		}
	}
	if(ans < 9999){
		cout << ans << endl;
	}
	else{
		cout << "TLE" << endl;
		
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let m: usize = read();
    let mut d: Vec<usize> = vec![0; m];
    let mut c: Vec<usize> = vec![0; m];

    for i in 0..m {
        d[i] = read();
        c[i] = read();
    }

    let mut sum = 0;
    let po = [(10, 10), (10, 11), (4, 4), (10, 13), (10, 14), (4, 5), (28, 48), (64, 119), (2, 2)];

    for i in 0..m {
        if d[i] == 0 {
            sum += c[i];
            c[i] = 0;
            continue;
        }
        let (p, o) = po[d[i]-1];
        while c[i] >= p {
            sum += (c[i] / p) * o;
            c[i] = c[i] / p + c[i] % p;
        }
    }/*
    for i in 0..m {
        println!("{}:{}", d[i], c[i]);
    }*/
    let mut now = 0;
    for i in 0..m {
        while c[i] > 0 {
            now += d[i];
            c[i] -= 1;
            sum += 1;

            while now > 9 {
                now = now % 10 + now / 10;
                sum += 1;
            }
        }
    }
    //println!("{}", now);
    println!("{}", sum-1);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<bool> isAC(n, false);
  vector<int> countWA(n, 0);
  
  int p;
  string s;
  for (int i = 0; i < m; ++i)
  {
    cin >> p >> s;
    if (s == "AC") isAC[p-1] = true;
    else if (!isAC[p-1]) ++countWA[p-1];
  }
  
  int numAC = 0, numP = 0;
  for (int i = 0; i < n; ++i)
  {
    if (isAC[i])
    {
      ++numAC;
      numP += countWA[i];
    }
  }
  
  cout << numAC << " " << numP << endl;
}


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

int main(){
	ll n;
	cin >> n;
	vector<ll> x(5);
	rep(snip_i, 5) cin >> x.at(snip_i);
	ll mn;
	rep(i, 5){
		if(i == 0) mn = x.at(i);
		else mn = min(mn, x.at(i));
	}
	ll ans = (n+mn-1)/mn;
	ans += 4;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func joinInts(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func divUp(x, y int64) int64 {
	return (x + y - 1) / y
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	s := strings.Split(nextLine(), "")
	g, p, ans := 0, 0, 0
	for _, c := range s {
		if c == "g" {
			if p < g {
				p++
				ans++
			} else {
				g++
			}
		} else {
			if p < g {
				p++
			} else {
				g++
				ans--
			}
		}
	}
	out(ans)
}


Measured memory_bytes: 2816
h,w,k = gets.split.map &:to_i

ks = []

h.times{ 
	ks << (gets.chomp.split(""))
}

mark = 1

result = []

ks.each_with_index{ |k, i|
	line = []
	mark_flag = false
	last_dot_len = 0

	k.each{ |dot|
		line << mark
		if dot == "#" then
			mark += 1
			mark_flag = true
			last_dot_len = 0
		else
			last_dot_len += 1
		end
	}

	if mark_flag then
		last_dot_len.times{ |i|
			line[- (i + 1)] -= 1
		}
	else
		line = result[i - 1]
	end
	
	result << line
}

index = result.index{ |r| r != nil }

if index > 0 then
	(0..index - 1).each{ |i|
		result[i] = result[index]
	}
end

puts result.map{ |r|
	r.join(" ")
}.join("\n")


Measured memory_bytes: 12668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());

int main() {
  int K, A, B;
  cin >> K >> A >> B;

  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3596
an1, at1, an2, at2 = 0, 1000, 0, 1000
for i in range(3):
    n1, t1, n2, t2 = 0, 1000, 0, 1000
    for j in range(8):
        n, t = map(float, raw_input().split())
        if t < t1:
            if t2 < at1:
                an1 = n2; at1 = t2
            elif t2 < at2:
                an2 = n2; at2 = t2
            n2 = n1; t2 = t1
            n1 = n ; t1 = t
        elif t < t2:
            if t2 < at1:
                an1 = n2; at1 = t2
            elif t2 < at2:
                an2 = n2; at2 = t2
            n2 = n ; t2 = t
        else:
            if t < at1:
                an1 = n; at1 = t
            elif t < at2:
                an2 = n; at2 = t
    print "%d %4.2f"%(int(n1), t1)
    print "%d %4.2f"%(int(n2), t2)
print "%d %4.2f"%(int(an1), at1)
print "%d %4.2f"%(int(an2), at2)

Measured memory_bytes: 4292
#include <iostream>
using namespace std;
long long n,ans,co;

int main(){
	cin>>n;
	int f=0;
	bool ft=true;
	while(n>=10){
		f=1;
		if(n%10!=9){
			ft=false;
		}
		n/=10;
		ans+=9;
		co++;
	}
	if(f==0){
		cout<<n<<endl;
	}else{
		if(ft){
			cout<<ans+n<<endl;
		}else{
			cout<<ans+n-1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll n, m; cin >> n >> m;
    VL div;

    for (ll i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            div.push_back(i);
            if (i * i != m)div.push_back(m / i);
        }
    }

    rSORT(div, greater<ll>());
    each(i, div)if (i * n <= m) {
        cout << i << "\n";
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int mod=1e9+7;
int main()
{
    fast
    int n;  cin>>n;
    ll z;
   ll sum=0;
    cin>>sum;
    ll res=0;
    for(int i=1;i<n;i++)
    {
        cin>>z;
        res+=((sum%mod)*(z%mod));
        res%=mod;
        sum+=z;
        sum%=mod;
      //  cout<<res<<endl;
    }
    cout<<res;



    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 1000;

int BubbleSort(int a[], int n)
{
	int i = 0, ans = 0;
	bool flag = 1;
	while (flag)
	{
		flag = 0;
		for (int j = n - 1; j >= i+1; j--)
		{
			if (a[j] < a[j - 1])
			{
				swap(a[j], a[j - 1]);
				ans++;
				flag = 1;
			}
		}
		i++;
	}
	return ans;
}

int main() {
	int n, i,ans;
	int A[N + 1];
	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &A[i]);
	ans=BubbleSort(A, n);
	for (i = 0; i < n; i++)
	{
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n%d\n", ans);
	return 0;
}

Measured memory_bytes: 3204
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
ll N,M,ans;
string S,T;
bool found = true;
int main(){
    cin >> S >> T;
    for(int i=0;i<S.size();i++){
        if(S[i] != T[i]){
            found = false;
        }
    }
    if(T.size() - S.size() != 1){
        found = false;
    }
    if(found){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}



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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> f(n + 1, 1);
    ll ans = 1;
    for(ll i = 2; i <= n; i++) {
        for(ll j = 1; j * i <= n; j++) {
            f[j * i]++;
        }
        ans += i * f[i];
    }
    cout << ans << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

// dp[k][sum] := w[k] まで使ったときに合計が sum になるかどうか
bool dp[1001][1001];

int main(){
	int N, r[1001], w[1001];
	while( cin >> N , N ){
		for(int i = 0 ; i < 1001 ; i++ ) fill(dp[i], dp[i] + 1001, false);
	
		int sum_r = 0, sum_w = 0, max_r = 0, k;
		for(int i = 0 ; i < N ; i++ ){
			cin >> r[i] >> w[i];
			sum_r += r[i];
			sum_w += w[i];
			if( max_r < r[i] ){
				k = i;
			}
			max_r = max(max_r, r[i]);
		}

		if( max_r <= sum_r - max_r ){
			cout << sum_r + sum_w << endl;
		}else{
			// wt := 待ち時間
			int wt = 2 * max_r - sum_r, res = 0;
			
			// w[0..N-1] の部分和で wt 以下の最大値を DP で求める
			// r[k] の本はまだ読んでいないので感想は書けない
			w[k] = 0;
			dp[0][0] = true;
			for(int i = 0 ; i < N ; i++ ){
				for(int j = 0 ; j <= wt ; j++ ){
					if( dp[i][j] ){
						dp[i + 1][j] = dp[i][j];
						if( j + w[i] <= wt ){
							dp[i + 1][j + w[i]] = dp[i][j];
						}
					}
				}
			}
			for(int j = 0 ; j <= wt ; j++ ){
				if( dp[N][j] ) res = j;
			}
			int ans = 2 * max_r + sum_w - res;
			cout << ans << endl;
		}
	}
}

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

int main() {
 int N;
 cin >> N;
  
 long long sum = 0;
  
  for(int i=1;i<N+1;i++){
    if(i%3!=0 && i%5!=0){
      sum += i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3584
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

template<unsigned long N>
struct precalc{
    unsigned long sz, val[N + 1];
    constexpr precalc() : sz(N), val() {
        for(unsigned long i{1}; i <= N; ++i)val[i] = i;
        for(unsigned long i{2}; i <= N; ++i)if(val[i] == i)for(unsigned long j{i}; j <= N; j += i)(val[j] /= i) *= (i - 1);
        for(unsigned long i{1}; i <= N; ++i)val[i] = (val[i] + val[i - 1]) % 1000000007;
    }
};

constexpr auto v = precalc<100000>{};

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    unsigned long ans{0};
    for(unsigned long i{K}, p{0}; i; ){
        auto t = K / i;
        auto r{1UL}, n{N}, a{t};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        ans += (r + p) * v.val[i];
        i = K / (t + 1);
        p = MOD - r;
    }
    cout << ans % MOD << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int MAX = 405;
const ll INF = 1e18 + 5;

ll v[MAX], dp[MAX][MAX];

ll sum(int L, int R)
{
    return v[R] - v[L - 1];
}

int main()
{
    int n;

    cin >> n;

    for(int i = 1; i <= n; ++i)
    {
        cin >> v[i];

        v[i] += v[i - 1];
    }

    for(int L = n; L > 0; --L)
        for(int R = L; R <= n; ++R)
            if(L != R)
            {
                dp[L][R] = INF;
                for(int i = L; i < R; ++i)
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i + 1][R] + sum(L, R));
            }

    cout << dp[1][n];

    return 0;
}


Measured memory_bytes: 4852