akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, L; cin >> N >> L;
	vector<string> S(N);
	rep (i, N) cin >> S[i];

	sort(ALL(S));
	
	string res = "";
	rep (i, N) res += S[i];
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int t;
	cin >> t;
	if (t %= 1000){
		cout << 1000 - t;
	}
	else cout << t % 1000;
	return 0;
}

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

int n;
char s[10005];

int main() {
    scanf("%d%s", &n, s);
    n %= 26;
    for (int i = 0; i < strlen(s); ++i) {
        s[i] += n;
        if (s[i] > 'Z') s[i] -= 26;
        putchar(s[i]);
    }
    putchar('\n');
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {s: String, t: String};
    let ans = t.to_string() + &s;
    println!("{}", ans);
}


Measured memory_bytes: 4352
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.append((s,int(p),i+1))
l.sort(key = lambda x : x[1],reverse=True)
l.sort(key = lambda x : x[0])
for i in range(n):
    print(l[i][2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()


int main()
{
    string S,T,U;
    ll A,B;
    cin>>S>>T>>A>>B>>U;
    if(U==S)A--;
    if(U==T)B--;
    cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect

Mod=10**9+7
M=10**6*2 #書き換え
fac=[0]*M
finv=[0]*M
inv=[0]*M

#finvに逆元、facに階乗のmod
def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return (fac[n]*(finv[k]*finv[n-k]%Mod)%Mod)%Mod

COMinit()

k=int(input())
s=input()
n=len(s)
ans=0
for i in range(k+1):
    ans+=COM(n+k-i-1,n-1)*pow(26,i,Mod)*pow(25,k-i,Mod)
    ans=ans%Mod
print(ans)

Measured memory_bytes: 137752
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		List<Double> list = new ArrayList<Double>();
		for (int i = 0; i < N; i++) {
			list.add(Double.parseDouble(sc.next()));
		}
		
		Collections.sort(list);
		
		double ans = list.get(0);
		list.remove(0);
		
		for (double v : list) {
			ans = ans/2 + v/2;
		}

		PrintWriter out = new PrintWriter(System.out);
		out.println(ans);
		out.flush();

	}

}


Measured memory_bytes: 21844
#n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

a,b,m = map(int,input().split())
a_L = list(map(int,input().split()))
b_L = list(map(int,input().split()))

ans = min(a_L) + min(b_L)

for _ in range(m):
    x,y,c = map(int,input().split())
    price = a_L[x-1] + b_L[y-1] - c
    ans = min(ans,price)

print(ans)

Measured memory_bytes: 18740
"""
P
1
B|P|P|P|B
0|1|1|1|0 3
B|BPPPB|P|BPPPB|B
0|3|1|3|0 7
a_1 = 1
a_n+1 = 2 * a_n + 3
b = 2b + 3 => b = -3
a_n + 3 = 4*2^(n-1)
a_n = 2^(n+2) - 3

b_1 = 1
b_n+1 = b_n * 2 + 1
c = 2c + 1 => c = -1
b_n + 1 = 2^n
b_n = 2^(n+1) - 1
"""


def check(n, x):
    if n == 0:
        return 0
    
    lower_n = 2 ** (n+1) - 3
    lower_pat = 2 ** n - 1
    if x == 1:
        return 0
    elif x == 1 + lower_n:
        return lower_pat
    elif x == 1 + lower_n + 1:
        return lower_pat + 1
    elif x == 1 + lower_n + 1 + lower_n:
        return lower_pat + 1 + lower_pat
    elif x == 1 + lower_n + 1 + lower_n + 1:
        return lower_pat + 1 + lower_pat
    elif 1 < x < 1 + lower_n:
        return check(n-1, x-1)
    elif 1 + lower_n + 1 <x< 1 + lower_n + 1 + lower_n:
        return lower_pat + 1 + check(n-1, x-1-lower_n-1)

N, X = [int(s) for s in input().split()]
print(check(N, X))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>
#include "math.h"
using namespace std;

int main() {
    
    int H, W, h, w;
    
    cin >> H >> W >> h >> w;
    
    cout << (H-h) * (W-w) << endl;
    
    
    return 0;
}

Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        long[] s = new long[N+1];
        s[0] = 0;
        for (int i = 0; i< N; i++) {
            s[i+1] = s[i] + a[i];
        }
        // 正、負、正
        long answer1 = solve(N, s, 1);
        // 負、正、負
        long answer2 = solve(N, s, 0);
        System.out.println(Math.min(answer1, answer2));
    }
    public static long solve(int N, long[] s, int pattern) {
        long answer = 0;
        long diff = 0;
        for (int i = 1; i <= N; i++) {
            if (i % 2 == pattern) {
                if (0 < s[i]+diff) {
                    continue;
                } else {
                    answer += Math.abs(1-(s[i]+diff));
                    diff += (1 - (s[i]+diff));
                }
            } else {
                if (s[i]+diff < 0) {
                    continue;
                } else {
                    answer += Math.abs(s[i]+diff+1);
                    diff -= (s[i]+diff+1);
                }
            }
        }
        return answer;
    }
}


Measured memory_bytes: 51724
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int k = sc.nextInt();
  if(k==111){
     System.out.println(999);
    }else if(k==119){
       System.out.println(991);
    }else if(k==199){
       System.out.println(911);
    }else if(k==999){
       System.out.println(111);
    }else if(k==911){
     System.out.println(199);
    }else if(k==991){
     System.out.println(119);
    }else if(k==919){
     System.out.println(191);
    }else if(k==191){
     System.out.println(919);
  }}}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	
	bool yes = false;
	double ans = (double)(w * h) / 2.0;
	
	if( x * 2 == w && y * 2 == h ) yes = true;

	printf("%.12f %d\n", ans, yes);
	
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{	
		
		 Scanner cthanh = new Scanner(System.in);
        int x;
        int y;
        x= cthanh.nextInt(); y= cthanh.nextInt();
        System.out.println(x * y + " " + (2*x + 2*y));		
	}
}
		
    
    
   

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a , n) for(int i = (a); i < (n); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  vector<int> hoge(n);
  rep(i,n)cin>>hoge[i];
  int num=1,cnt=0;
  rep(i,n){
    if(hoge[i]==num){
      num++;
    }else{
      cnt++;
    }
  }
  cout<<(cnt==n?-1:cnt)<<endl;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}

int main() {
  ll N,A,B;
  cin >> N >> A >> B;
  if((B - A)% 2 == 1)cout << "Borys" << endl;
  else cout << "Alice" << endl;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	int sum = 0;
	int arr[n];
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		sum += arr[i];
	}
	vector<int> div;
	for(int i = 1; i * i <= sum; i++) {
		if(sum % i == 0) {
			div.push_back(i);
			if(sum / i != i)
				div.push_back(sum / i);
		}
	}
	int ans = 1;
	for(int d : div) {
		int rem = 0;
		int q[n];
		for(int i = 0; i < n; i++) {
			q[i] = arr[i] % d;
		}
		sort(q, q + n);
		int l = 0, r = n - 1;
		while(l < r) {
			if(q[l] == 0) {
				l++;
				continue;
			}
			if(q[r] == d) {
				r--;
				continue;
			}
			int toRemove = min(d - q[r], q[l]);
			q[r] += toRemove;
			rem += toRemove;
			q[l] -= toRemove;
			if(q[l] == 0) l++;
			if(q[r] == d) r--;
		}
		if(q[l] != 0 && q[l] != d)
			rem += q[l];
		if(rem <= k)
			ans = max(ans, d);
	}
	cout << ans << '\n';
	return 0;
}


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

const ll N = 10;

bool query(ll n) {
    cout << "? " << n << endl;
    char c; cin >> c;
    return c == 'Y';
}

int main() {
    ll ans = 0, T = 9, last = 0, cnt = 0;
    if (query(999999999) == false) {
        cout << "! " << (int)1e9 << endl;
        return 0;
    }
    while (T--) {
        ll ng = -1, ok = 9;
        if (ans == 0) ng = 0;
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            ll x = ans * pow10(10) + mid * pow10(9);
            rep(i,9) x += 9 * pow10(i);
            if (query(x)) ok = mid;
            else ng = mid;
        }
        if (ok) { last = ok; cnt++; }
        ans *= 10;
        ans += ok;
    }
    if (last == 1 and cnt == 1) {
        while (ans > 1 and query(ans - 1)) ans /= 10;
        cout << "! " << ans << endl;
        return 0;
    }
    while (query(ans - 1) == false) ans /= 10;
    cout << "! " << ans << endl;
    return 0;
}


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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,w,a,b,ans=0,w1,dp[4][101]={0};
    vector<ll> v[4];
    cin>>n>>w;
    for(ll i=0;i<n;i++){
        cin>>a>>b;
        if(i==0){
            w1=a;
            v[0].pb(b);
        }
        else if(a==w1){
            v[0].pb(b);
        }
        else if(a==w1+1){
            v[1].pb(b);
        }
        else if(a==w1+2){
            v[2].pb(b);
        }
        else{
            v[3].pb(b);
        }
    }
    for(int i=0;i<4;i++){
        sort(be(v[i]));
        reverse(be(v[i]));
    }
    for(int i=0;i<4;i++){
        for(ll j=0;j<v[i].size();j++){
            dp[i][j+1]=dp[i][j]+v[i][j];
        }
    }
    for(ll i=0;i<=v[0].size();i++){
        for(ll j=0;j<=v[1].size();j++){
            for(ll k=0;k<=v[2].size();k++){
                for(ll m=0;m<=v[3].size();m++){
                    a=w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*m;
                    b=dp[0][i]+dp[1][j]+dp[2][k]+dp[3][m];
                    if(w>=a){
                        ans=max(ans,b);
                    }
                }
            }
        }
    }
    cout <<ans<<endl;
    return 0;
}



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

struct TPoint{
    double x;
    double y;
};

void Cal(TPoint P1, TPoint P2, int Num);

void Cal(TPoint P1, TPoint P2, int Num)
{
    if(Num == 0)    return;
    
    TPoint Temp1, Temp2, Temp3;

    Temp1.x = (2 * P1.x + P2.x) / 3;
    Temp1.y = (2 * P1.y + P2.y) / 3;
    Temp3.x = (P1.x + 2 * P2.x) / 3;
    Temp3.y = (P1.y + 2 * P2.y) / 3;
    Temp2.x = (Temp3.x - Temp1.x) * cos(60 * M_PI / 180) - (Temp3.y - Temp1.y) * sin(60 * M_PI / 180) + Temp1.x;
    Temp2.y = (Temp3.x - Temp1.x) * sin(60 * M_PI / 180) + (Temp3.y - Temp1.y) * cos(60 * M_PI / 180) + Temp1.y;
    
    Cal(P1, Temp1, Num - 1);
    cout << Temp1.x << " " << Temp1.y << endl;
    Cal(Temp1, Temp2, Num - 1);
    cout << Temp2.x << " " << Temp2.y << endl;
    Cal(Temp2, Temp3, Num - 1);
    cout << Temp3.x << " " << Temp3.y << endl;
    Cal(Temp3, P2, Num - 1);
}

int main(void){
    int Number;
    std::cin >> Number;
    
    TPoint P1, P2;
    
    P1.x = 0; 
    P1.y = 0;
    P2.x = 100;
    P2.y = 0;
    
    cout << P1.x << " " << P1.y << endl;
    Cal(P1, P2, Number);
    cout << P2.x << " " << P2.y << endl;
}

Measured memory_bytes: 1252
#include<iostream>
#include <string>
#include<vector>

using namespace std;

int main(){

	int a, b;
	char op;
	cin >> a >> op >> b;
	if(op == '+'){
		cout << a+b << endl;
	}
	else{
		cout << a-b << endl;
	}

	return 0;

}

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

using namespace std;
int main()
{
	int N,M,X,Y,x[110],y[110];
	cin >> N >> M >> X >> Y;
	for(int i=0; i<N; i++){
		cin >>x[i];
	}
	for(int i=0; i<M; i++){
		cin >> y[i];
	}
	sort(x,x+N);
	sort(y,y+M);
	if(x[N-1] < y[0] && X < y[0] && x[N-1] < Y && X < Y){
		cout << "No War" << endl;
	}else{
		cout << "War" << endl;
	}
	
	return 0;
}




Measured memory_bytes: 256
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        m: usize,
        a:[usize;n]
    }

    let mut pr_queue: BinaryHeap<usize> = BinaryHeap::new();

    for p in a {
        pr_queue.push(p);
    }

    for i in 0..m {
        match pr_queue.pop() {
            Some(x) => pr_queue.push(x / 2),
            None => panic!(),
        }
    }

    //println!("{:?}", pr_queue);

    let mut ans = 0;

    while pr_queue.len() > 0 {
        let num = pr_queue.pop().unwrap();
        ans += num;
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 10620
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_126A(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    s[k-1] += 32;
    cout << s << endl;
}

int main(void){
    solve_126A();
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(sc.nextInt());
        }
        int ans = 0;
        for (int i = 0; i <= 100; i++) {
            int l = x-i, r = x+i;
            if(!set.contains(l)){
                ans = l;break;
            }
            if(!set.contains(r)){
                ans = r; break;
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 35904
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
vector<vector<int>> graph;
int n, m;
int ans = 0;

void dfs(int stp, int cv, vector<int> &seen) {
  seen.at(cv) = 1;
  if (stp == n - 1) {
    if (count(ALL(seen), 1) == n) ans++;
    seen.at(cv) = 0;
    return;
  }
  for (int nv : graph.at(cv)) {
    if (seen.at(nv)) continue;

    dfs(stp+1, nv, seen);
  }
  seen.at(cv) = 0;
  return;
}

int main()
{
  cin >> n >> m;
  graph.resize(n, vector<int>());
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    graph.at(y).push_back(x);
    graph.at(x).push_back(y);
  }
  vector<int> seen(n, 0);
  dfs(0, 0, seen);
  cout << ans << endl;

  
  
  return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
        z[i]--;
    }
    map<ll,vector<ll>> mp;
    mp[0].push_back(0);
    ll now = 0;
    for (int i = 0; i < n; i++) {
        now += z[i];
        mp[now % k].push_back(i+1);
    }
    ll ans = 0;
    for (auto z:mp) {
        for (int i = 0; i < z.second.size(); i++) {
            ll ok = i;
            ll ng = z.second.size();
            while (ng - ok > 1) {
                ll mid = (ok + ng) / 2;
                if (z.second[i] + k > z.second[mid])ok = mid;
                else ng = mid;
            }
            ans += ok - i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 26760
n, m = map(int, raw_input().split())
dic = {}
for i in range(n):
  l = map(int, raw_input().split())[1:]
  for j in l:
    if j in dic:
      dic[j] += 1
    else:
      dic[j] = 1
ans = 0
for i in dic:
  if dic[i] == n:
    ans += 1
print ans

Measured memory_bytes: 2568
#include <stdio.h>
#include <math.h>
 
int main(void){
  int i, n, s[1000];
  double x, a;
 
  while(1){
    scanf("%d", &n);
    if(n == 0){
      break;
    }
    x = 0;
    a = 0;
    for(i = 0; i < n; i++){
      scanf("%d", &s[i]);
      x += s[i];
    }
    x /= n;
    for(i = 0; i < n; i++){
      a += (s[i]-x) * (s[i]-x);
    }
    a = sqrt(a/n);
    printf("%f\n", a);
  }
  return 0;
}
 

 

Measured memory_bytes: 636
program main
  integer(8) :: n, i, num
  integer(8), allocatable :: a(:)
  read(*,*) n
  allocate(a(n))
  read(*,*) a

  num = 1
  do i = 1, n
    if(a(i)==num) then
      num = num + 1
    end if
  end do
  num = num - 1
  if (num == 0) then
    write(6,*) -1
  else
    write(6,*) n-num
  end if
end program main

Measured memory_bytes: 2432
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<tuple>
#include<limits>//ex numeric_limits<int>::max()
#include<unordered_set>
#define lli long long int

using namespace std;

int main(void){
    unordered_set<string> wset;
    int N;
    cin >> N;
    string result="Yes";
    char a='0';
    for (int i = 0; i < N; ++i)
    {
        string w;
        cin >> w;
        if(wset.find(w)!=wset.end()){
            result="No";
        }
        if(a!='0' && w[0]!=a)result="No";
        a=w[w.length()-1];
        wset.insert(w);
    }
    cout << result<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <iostream>
#include <cstdio>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
 
#define ll long long
#define pb push_back
#define vi vector<int>
#define sz(a) (int((a).size()))
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>
 
using namespace std;
 
const int mod = 998244353;
const int inf = (int)2e9;
const ll INF = (ll)2e18;
const int N = 100100;

string s;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> s;
	for (int i = 1; i < sz(s); i++) {
		if (s[i] == s[i - 1]) {
			cout << i << " " << i + 1 << endl;
			return 0;
		}
		if (i > 1 && s[i] == s[i - 2]) {
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
	}
	cout << "-1 -1\n";

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){
 ll d ; cin>> d ;
 ll c[26] ; rep(i,26) cin>>c[i] ;
 ll s[d][26] ;
 vector<ll> t(d) ;
 vector<ll> ans(d) ;
 rep(i,d){
     rep(j,26){
        cin>> s[i][j] ;
        if(t[i]<s[i][j]){
            t[i]= s[i][j] ;
            ans[i]= j;
        }
     }
 }



 rep(i,d){
     cout<< ans[i]+1 <<endl ;
 }
 return 0 ; 
}



Measured memory_bytes: 3716
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll d; cin >> d; ll happy = 0;
  vl whatday(26);
  
  vector<bool> israted(26,false);
  
  vl human(26);
  rep(i,26) cin >> human[i];
  
  vvl userhappy(d,vl(26));  
  rep(i,d){
    rep(j,26){
      cin >> userhappy[i][j];
    }
  }
  
 
  rep(i,d){
    ll now = 0; ll nowhappy = 0;
    rep(j,26){
      if(userhappy[i][j] > nowhappy){
        now = j;
        nowhappy = userhappy[i][now];
      }
    }
    
    cout << now+1 << endl;
  }
  
  
}

Measured memory_bytes: 3732
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int N;
	long long ans = 1;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		ans = ans * i % (1000000007);
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 3768
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

int main() {
  cin >> N >> K;
  cout << min(N%K, (K - N%K));
} 



Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<string>
#include<algorithm>
#include<iostream>
#include<math.h>
using namespace std;
int a[300];
int main(void)
{
    int i,j,k,n,m,s;
    int x,y;
    s=0;
    scanf("%d",&n);
    scanf("%d%d",&m,&k);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
    {
        for(j=0;j*a[i]+1<=m;j++)
        {
            s++;
        }
    }
    s+=k;
    printf("%d\n",s);
    return 0;
}


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

#define int long long

const int N = 1e5 + 5, MOD = 1e9 + 7;

int32_t main(){

	int l,r,d; cin>>l>>r>>d;

	int ans=0;

	for(int i=l;i<=r;i++){
		ans+=(i%d==0);
	}	    

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


Measured memory_bytes: 3580
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    print(ST().replace("?","D"))
if __name__ == '__main__':
    main()

Measured memory_bytes: 79032
#include <stdio.h>

#define MAX 2000000

int H,A[MAX+1];

void maxHeap(int i){
  int l,r,s,largest;
  l=2*i;
  r=2*i+1;

  if(l<=H && A[l]>A[i]){
    largest=l;
  }
  else largest=i;
  if(r<=H && A[r]>A[largest]){
    largest=r;
  }
  if(largest!=i){
    s=A[i];
    A[i]=A[largest];
    A[largest]=s;
    maxHeap(largest);
  }
}

int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=H/2;i>=1;i--){
    maxHeap(i);
  }
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n, x1[2000], Y1[2000], x2[2000], y2[2000], X[4001][4001];
vector<int> x, y;

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

    cin >> n;
    rep(i, n) {
        cin >> x1[i] >> Y1[i] >> x2[i] >> y2[i];
        x.push_back(x1[i]);
        x.push_back(x2[i]);
        y.push_back(Y1[i]);
        y.push_back(y2[i]);
    }

    sort(ALL(x));
    x.erase(unique(ALL(x)), x.end());
    sort(ALL(y));
    y.erase(unique(ALL(y)), y.end());

    rep(i, n) {
        int a = lower_bound(ALL(x), x1[i]) - x.begin();
        int b = lower_bound(ALL(x), x2[i]) - x.begin();
        int c = lower_bound(ALL(y), Y1[i]) - y.begin();
        int d = lower_bound(ALL(y), y2[i]) - y.begin();

        X[a][c]++;
        X[a][d]--;
        X[b][c]--;
        X[b][d]++;
    }
    rep(i, x.size()) rep(j, y.size()) X[i + 1][j] += X[i][j];
    rep(i, x.size()) rep(j, y.size()) X[i][j + 1] += X[i][j];

    ll ans = 0;
    rep(i, x.size() - 1) rep(j, y.size() - 1) {
        if(X[i][j]) ans += (ll)(x[i + 1] - x[i]) * (y[j + 1] - y[j]);
    }

    cout << ans << endl;

    return 0;
}


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

int main() {

	int a, b, m;
	scanf("%d %d %d", &a, &b, &m);
	vector<int> fri(a);
	vector<int> mic(b);
	vector<int> x(m);
	vector<int> y(m);
	vector<int> c(m);
	int dismin = 1e9;
	for(int i = 0; i < a; i++) {
		scanf("%d", &fri[i]);
	}
	for(int i = 0; i < b; i++) {
		scanf("%d", &mic[i]);
	}
	for(int i = 0; i < m; i++) {
		scanf("%d %d %d", &x[i], &y[i], &c[i]);
	}
	for(int i = 0; i < m; i++) {
		int dis = 0;
		dis= fri[x[i] - 1] +  mic[y[i] - 1] - c[i];
		dismin = min(dismin, dis);
	}
	sort(fri.begin(), fri.end());
	sort(mic.begin(), mic.end());
	int ans;
	ans = min(dismin, fri[0] + mic[0]);
	printf("%d\n", ans);
}

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

using namespace std;

#define endl '\n'
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef unordered_set<int> usi;
typedef vector<pi> vpi;

#define cw(x) cout << (x) << endl
#define cww(x,y) cout << (x) << ' ' << y << endl
#define cwa(x) for(auto a:x) cout << a << ' ';cout << endl
#define all(v) (v).begin(),(v).end()
#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)

int b[3],a[3],i,j;

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

    F0R(i,3) cin >> b[i];
    F0R(i,2){
        F0R(j,3){
            cin >> a[j],a[j]-=b[j];
        }
        F0R(j,3) if(a[j]!=a[0]) return cw("No"), 0;
    }

    cw("Yes");
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <string.h>
#include <stdio.h>
int main(){
  	int W, N, wi, vi;
	std::cin >> N >> W;
	int w[N + 1];
	int v[N + 1];
	long dp[N + 1][W + 1];
    memset(dp, 0, sizeof(dp));
	w[0] = 0;
	v[0] = 0;
	dp[0][0] = 0;
	for(int i=1;i<N+1;i++){
    	std::cin >> wi >> vi;
    	w[i] = wi;
    	v[i] = vi;
	}
	for(int i=1;i<N+1;i++){
    	for(int j=0;j<W+1;j++){
        	if(w[i] > j){
            	dp[i][j] = dp[i - 1][j];
        	}else{
            	dp[i][j] = std::max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
        	}
    	}
	}
	std::cout << dp[N][W];
}

Measured memory_bytes: 79104
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*約数*/vector<ll>div(ll a){vector<ll>b;ll i;rep(i,1,a){if(!a%i)push(b,a);}return b;}
/*素因数分解*/
llfor;///////////////////////////////////////////////////////////
int main(){
 ll n;
 sc(n);

 bool jd=prime(n);
 if(jd==true){
  puts("1");return 0;
 }
 ll tmp=n;
 ll b=2;
 ll ans=0;
 ll cnt=0;
 ll sm=0;

 while(b*b<=n){
  if(tmp%b==0){
   tmp/=b;cnt++;
  }
  else{
   rep(j,0,cnt+5){ 
    if((j*(j+1))/2<=cnt){
     sm=j;
    }
   }
   ans+=sm;
   //cout<<b<<" "<<cnt<<" "<<ans<<" "<<tmp<<endl;
   b++;cnt=0;
  }
 if(tmp==1&&cnt==0)break;
 }
 if(tmp!=1)ans++;
 pr(ans);

return 0;}



Measured memory_bytes: 3544
use std::io;
use std::cmp;
use std::collections::*;


fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {

    let n = read_one::<isize>();
    let (d, x) = {
        let i = read::<isize>();
        (i[0], i[1])
    };
    let mut total = x;
    for i in 0..n {
        let a = read_one::<isize>();
        total += 1 + ((d - 1) / a);
    }


    println!("{}", total);
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
  ll a, b, c; cin >> a >> b >> c;
  ll d = c-a-b;
  if(d > 0 && 4*a*b < d*d)
    cout << "Yes";
  else
    cout << "No";
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<29;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    ll x,y; cin >> x >> y;
    ll ans = 0;
    while(x<=y){
        ans++;
        x *= 2;
    }
    cout << ans << endl;
    
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
	while (a) {
		b %= a;
		swap(a, b);
	}
	return b;
}

int main()
{
	ll N; cin >> N;
	ll Y = 4;
	ll X = gcd(Y,N);
	Y /= X;
	N /= X;

	for (ll h = 1; h <= 3500; h++) {
		for (ll n = 1; n <= 3500; n++) {
			if (Y*n*h <= N*(n + h))continue;
			if ((N*n*h) % (Y*n*h - N*(n + h)))continue;

			ll w = N*n*h / (Y*n*h - N*(n + h));

			ll a = n*w + h*w + h*n;
			ll b = h*n*w;
			ll c = gcd(a, b);
			a /= c;
			b /= c;

			if (a == Y && b == N) {
				cout << h << " " << n << " " << w << endl;
				return 0;
			}
		}
	}

    return 0;
}



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

int main(){
	ll L, R;
    cin >> L >> R;

    ll minimum = 2019;
  
   	for (ll i = L; i <= R-1; ++i){
        for (ll j = L+1; j <= R; ++j){
            ll mod = (i*j) % 2019;
            minimum = min(mod, minimum);
            
            if (minimum == 0){
                cout << minimum << endl;
                return 0;
            }
        }
    }
  
    cout << minimum << endl;
    return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()

	fmt.Fprintln(wtr, ceil(N, 2))
}


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

ll n,a[3010],dp[3010][3010]={};

int main(){
  cin>>n;
  fr(i,n) cin>>a[i];
  fr(i,n){
    fr(j,n-i){
      ll k=j+i;
      if(i==0){dp[j][k]=a[j];continue;}
      dp[j][k]=max(a[j]-dp[j+1][k],a[k]-dp[j][k-1]);
    }
  }
  cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 70016
abcd = input()
for i in range(2**3):
  s = ""
  for j in range(3):
    if (i >> j) & 1 == 1:
      s += abcd[j] + "+"
    else:
      s += abcd[j] + "-"
  s += abcd[3]
  if eval(s) == 7:
    print(s + "=7")
    break

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	string t;
	cin>>t;
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	if(s<t) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctime>
#include<string.h>
#include<algorithm>
#include<cmath>
using namespace std;
char a[100005],b[100005];
int main()
{
	scanf("%s",a);
	for(int i=0,j=0;i<strlen(a);i+=2,j++)
	{
		b[j]=a[i];
	}
	printf("%s",b);
}


Measured memory_bytes: 384
N = int(input())
X = list(map(int, input().split()))
X.sort()
ans = 0
data = []

for p in range(X[N-1] + 1):
    sum = 0
    for i in range(len(X)):
         sum += (X[i]-p)**2
         ans = sum
    p += 1
    data.append(ans)

print(min(data))


Measured memory_bytes: 9160
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int route_a=0,route_b=0,route_c=0;
  int a,b,c;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &a, &b, &c);
    if (route_b >= route_c) {
      a += route_b;
    } else {
      a += route_c;
    }
    if (route_a >= route_c) {
      b += route_a;
    } else {
      b += route_c;
    }
    if (route_a >= route_b) {
      c += route_a;
    } else {
      c += route_b;
    }
    route_a = a;
    route_b = b;
    route_c = c;
  }
  if (route_a >= route_b && route_a >= route_c) {
    printf("%d\n", route_a);
  } else if (route_b >= route_c) {
    printf("%d\n", route_b);
  } else {
    printf("%d\n", route_c);
  }
  return 0;
}


Measured memory_bytes: 1732
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
res = 1
for i in range(n):
    res *= i+1
    res %= mod
print(res)

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

const long long mod = 1e9 + 7;

#define pb push_back

typedef pair <int,int> pii;


int main() {
    //freopen("in.txt","r",stdin);
    long long n, ans=1;
	cin >> n;
	for (long long i = 1; i <= n; i++) ans = ans * i % mod;
    cout << ans;
	return 0;
}


Measured memory_bytes: 256