akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a /g* b ;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
int  GetDigit(T num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};


int main()
{
    string S;
    cin >> S;
    if((S[0]==S[1])||S[1]==S[2]||S[2]==S[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

a, b, c, x, y = map(int, input().split())

if 2 * c >= a + b:
    print(a * x + b * y)
    sys.exit(0)

ans = 0
_min = min(x, y)
ans += (2 * c) * _min
x -= _min
y -= _min
if x != 0:
    ans += x * min(a, 2 * c)
    pass
if y != 0:
    ans += y * min(b, 2 * c)
print(ans)


Measured memory_bytes: 61924
import java.util.Scanner;
  
public class Main {
	
  public static void main(String[] args) {
	  Scanner sc=new Scanner(System.in);
	  int a=Integer.parseInt(sc.next());
	  int b=Integer.parseInt(sc.next());
	  int c=Integer.parseInt(sc.next());
	  if(a<b){
		  if(b<c){
		  System.out.println("Yes");
	  }
		  else{
System.out.println("No");
		  }
	  }
	  else{
		  System.out.println("No");
	  }
	  
    
  }
}

Measured memory_bytes: 17120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()


int main(){
    int X, Y, min, ans, j;
    cin >> X >> Y;
    vector<int> box(1000,10000);
    rep(i, Y){
        cin >> box.at(i);
    }
    sort(box.begin(), box.begin()+Y);
    min = 10000;
    j = 0;
    for(int i = -1*X; i <= 2*X; i++){
        if(box.at(j) == i){
            j++;
            continue;
        }

        if(min > abs(X-i)){
            min = abs(X-i);
            ans = i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		List<Integer> cards = new ArrayList<>();

		int alice = 0;
		int bob = 0;

		for (int i = 0; i < n; i++) {
			int x = Integer.parseInt(sc.next());
			cards.add(x);
		}

		 Collections.sort(cards, Comparator.reverseOrder());

		 for (int i = 0; i < n; i++) {

			 if (i % 2 == 0) {
				 alice += cards.get(i);
			 } else {
				 bob += cards.get(i);
			 }
		 }
		 
		 System.out.println(alice - bob);

	}
}


Measured memory_bytes: 23380
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn print_array<T: std::string::ToString>(array: &Vec<T>) {
    println!(
        "{}",
        array
            .iter()
            .map(|ref x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

fn query(a: &BTreeSet<usize>) -> char {
    let a = a.into_iter().map(|x| x + 1).collect::<Vec<_>>();
    print!("? ");
    print_array(&a);
    read::<String>().chars().collect::<Vec<_>>()[0]
}

fn inv(c: char) -> char {
    if c == 'R' {
        'B'
    } else {
        'R'
    }
}

fn main() {
    let n = read::<usize>();
    let ret0 = query(&(0..n).collect::<BTreeSet<_>>());
    let criterion = |x| query(&(x..x + n).collect::<BTreeSet<_>>()) == ret0;
    let (ok, _) = binary_search(0, n, criterion);
    let mut colors = vec!['U'; 2 * n]; // 0: unknown, 1: red: 2: blue
    colors[ok] = ret0;
    colors[ok + n] = inv(ret0);
    let mut query_base = BTreeSet::new();
    for i in ok + 1..ok + n {
        query_base.insert(i);
    }

    // coloring 0..ok
    for i in 0..ok {
        query_base.insert(i);
        colors[i] = query(&query_base);
        query_base.remove(&i);
    }
    // coloring ok + n + 1..2 * n
    for i in ok + n + 1..2 * n {
        query_base.insert(i);
        colors[i] = query(&query_base);
        query_base.remove(&i);
    }
    // coloring ok + 1..ok + n
    let mut query_base = BTreeSet::new();
    let mut r_count = 0;
    let mut b_count = 0;
    for i in 0..2 * n {
        if colors[i] == 'R' && r_count < n / 2 {
            query_base.insert(i);
            r_count += 1;
        } else if colors[i] == 'B' && b_count < n / 2 {
            query_base.insert(i);
            b_count += 1;
        }
    }
    assert!(query_base.len() == n - 1);

    for i in 0..2 * n {
        if colors[i] == 'U' {
            query_base.insert(i);
            colors[i] = query(&query_base);
            query_base.remove(&i);
        }
    }
    print!("! ");
    for ch in colors {
        print!("{}", ch);
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn binary_search<F>(lb: usize, ub: usize, criterion: F) -> (usize, usize)
where
    F: Fn(usize) -> bool,
{
    let mut ok = lb;
    let mut ng = ub;
    while ng - ok > 1 {
        let mid = (ng + ok) / 2;
        if criterion(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    (ok, ng)
}


Measured memory_bytes: 4816
process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  
  var num = parseInt(lines[0],10);

  var card = lines[1].split(' ');
  
  var hairetu = [];
  for(var i=0;i<card.length;i++){
  	hairetu.push(parseInt(card[i],10));
  }
  

  
  function compareFunc(a, b) {
  return b - a;
}
 

　hairetu.sort(compareFunc);
 var alice =0;
 var bob = 0;
  
 for(var i=0;i<hairetu.length;i++){
 	if(i%2 ===0){
    	alice += hairetu[i];
    }else{
    	bob += hairetu[i];
    }
 } 
  
  console.log(alice-bob);

  
  
});

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

int main() {
  int n; cin >> n;
  int ans = 0;
  if (n >= 105) ++ans;
  if (n >= 135) ++ans;
  if (n >= 165) ++ans;
  if (n >= 189) ++ans;
  if (n >= 195) ++ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
lis = list(map(int,input().split()))
sum = 0
for i in range(n-1):
  if int(lis[i])>int(lis[i+1]):
    sum += lis[i]-lis[i+1]
    lis[i+1] = lis[i]
  else:
    continue
print(sum)

Measured memory_bytes: 32308
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;
const double EPS = 1e-9;

double cx = 1e9, cy = 1e9, cr = 1e9;

void calc(double x1, double y1, double x2, double y2, double x3, double y3){
	double d = 2.0 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3));
	if(fabs(d) < EPS){
		cr = -1e9;
		return;
	}
	cx = ((y1 - y3) * (y1 * y1 - y2 * y2 + x1 * x1 - x2 * x2)
		 - (y1 - y2) * (y1 * y1 - y3 * y3 + x1 * x1 - x3 * x3)) / d;
  cy = ((x1 - x3) * (x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2) 
		 - (x1 - x2) * (x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3)) / (-d);
  cr = sqrt((cx - x1) * (cx - x1) + (cy - y1) * (cy - y1));
}

double dist(double x1,double y1,double x2,double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

signed main(){
	int n;
	cin >> n;
	vector<int> x(n), y(n);
	rep(i, 0, n) cin >> x[i] >> y[i];
	double ans = 1e18;
	// if(n == 2){
	// 	ans = dist(x[0], y[0], x[1], y[1]) / 2.0;
	// 	printf("%.15f\n", ans);
	// 	return 0;
	// }
	rep(i, 0, n){
		rep(j, i + 1, n){
			cr = dist(x[i], y[i], x[j], y[j]) / 2.0;
			cx = (x[i] + x[j]) / 2.0;
			cy = (y[i] + y[j]) / 2.0;
			bool f = true;
			rep(l, 0, n){
				if(dist(cx, cy, x[l], y[l]) - cr > EPS){
					f = false;
					break;
				}
			}	
			if(f) ans = min(ans, cr);
		}
	}
	rep(i, 0, n){
		rep(j, i + 1, n){
			rep(k, j + 1, n){
				calc(x[i], y[i], x[j], y[j], x[k], y[k]);
				bool f = true;
				rep(l, 0, n){
					if(dist(cx, cy, x[l], y[l]) - cr > EPS){
						f = false;
						break;
					}
				}	
				if(f) ans = min(ans, cr);
			}
		}
	}
	printf("%.15f\n", ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int,int> pii;
typedef std::pair<int,double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;



void solve(){
    int n,c,k;
    cin >> n >> c >> k;
    int cur = -1;
    int ans = 0;
    int p = 0;
    vi a(n,0);
    rep(i,n) cin >> a[i];
    SORT(a);
    
    rep(i,n){
        int t = a[i];
        if (cur==-1) cur = t;
        p++;
        
        if (t-cur>k || p > c){
            p = 1;
            cur = t;
            ans++;
        }
    }
    if (p) ans++;
    
    cout << ans;
}


int main(){
    int T;
    //cin >> T;
    T = 1;
    while(T--){
        solve();
        cout << endl;
    }
}





































Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;

int main() {
    int n;
    int a, b, c;

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a >> b >> c;
        int d[3] = {a, b, c};
        sort(d, d+3);
        if (d[2] == sqrt(pow(d[0], 2) + pow(d[1], 2))) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2992
N, L = map(int, input().split())
out = 0
all_out = []
abs_out = []
for i in range(1, N + 1):
    out += L + i - 1
    all_out.append(L + i - 1)
    abs_out.append(abs(L + i - 1))

if min(abs_out) == 0:
    out = out
elif min(all_out) > 0:
    out = out - min(all_out)
elif max(all_out) < 0:
    out = out - max(all_out)

print(out)

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

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

using namespace std;
using lint=long long;

const lint INF=1LL<<61;

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

	vector<lint> sum(n+1);
	rep(i,n) sum[i+1]=sum[i]+a[i];

	lint ans=INF;
	rep(i,n-1) ans=min(ans,abs(sum[i+1]-(sum[n]-sum[i+1])));
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 2560
N = int(input())
Flists = [list(map(int, input().split())) for _ in range(N)]
Plists = [list(map(int, input().split())) for _ in range(N)]
ans = -10**9
for i in range(1, 2**10):
    open = []
    for j in range(10):
        if ((i >> j) & 1):
            open.append(1)
        else:
            open.append(0)
    money = 0
    for num in range(N):
        Flist = Flists[num]
        same = sum([int(open[_] and Flist[_]) for _ in range(10)])
        money += Plists[num][same]
    ans = max(ans, money)
print(ans)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=1e5+4;
vector<bool> prime(N,1);
vector<int> spec(N,0);
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif
	
	int n;
	cin>>n;
	vector<int>a(n),b(n),c(n);
	for(auto &i:a)cin>>i;
	for(auto &i:b)cin>>i;
	for (int &i:c)cin>>i;

	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());


	int ans=0;

	for(int i=0;i<n;i++)
	{

		int l=lower_bound(a.begin(),a.end(),b[i])-a.begin();
		int r=n-(upper_bound(c.begin(),c.end(),b[i])-c.begin());
		ans+=l*r;
	}

	cout<<ans;

	




	
}

Measured memory_bytes: 6428
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
const int MOD = 1000000007;
int main() {
    long long A, B, N;
    cin >> A >> B >> N;
    long long i = N;
    if(N >= B - 1) {
        i = B - 1;
    }
    long long res = 1LL * (A * i / B) - A * (i / B);
    cout << res << endl;
}


Measured memory_bytes: 3576
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
int main()
{
    queue<ll> q;
    for(ll i = 1; i <= 9; i++) q.push(i);
    ll k, n, x;
    cin >> k;
    for(int i = 1; i < k; i++){
        n = q.front(); q.pop();
        x = n % 10;
        if(x != 0)  q.push(10*n + x - 1);
                    q.push(10*n + x);
        if(x != 9)  q.push(10*n + x + 1);
    }
    cout << q.front() << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,t,a,b;
    string s;
    while(cin>>a>>b>>s)
    {
         int  ok=0,cnt=0;
        for(i=0;i<s.size();i++)
        {

            if(s[i]=='-')
            {
                cnt++;
                if(i==a)
                {
                    ok=1;

                }

            }
        }
        if(cnt==1&&ok==1)printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    n, time = map(int, input().split())
    ans = 1001
    for i in range(n):
        c, t = map(int, input().split())
        if t <= time:
            ans = min(ans, c)
    print(ans if ans != 1001 else 'TLE')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define caseout(i, x) cout << "Case #" << i << ": " << x << endl;


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

    int n;
    ll k;
    ll ans = 0;
    cin >> n >> k;
    vector<ll> a(n);
    vector<int> c(40);
    vector<ll> pwr(40,1);

    rep(i, 39) pwr[i + 1] = 2 * pwr[i];

    rep(i, n){
        cin >> a[i];
        rep(j, 40) if ((a[i] >> j) & 1 == 1) c[j]++;
    }

    for (int i = 39; i >= 0;i--)
        if(2*c[i]<n&&k>=pwr[i]){
            ans += pwr[i];
            k -= pwr[i];
        }

    ll s = 0;

    rep(i, n) s += (a[i] ^ ans);

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >>n;
    int l[110];
    int x = 0,y = 0;
    for(int i=1;i<=n;i++){
        cin >>l[i];
        if(x<=l[i]){
            x = l[i];
        }
        y = y+l[i];
    }
    y = y-x;
    if(x<y){
        cout <<"Yes"<<endl;
    }else{
        cout <<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1,n,a,b,m1,d1,m2,d2;
    //cin>>t;
    while(t--){
        cin>>m1>>d1>>m2>>d2;
        if(m1!=m2 && d2==01)
            cout<<1;
        else
            cout<<0;
   }
    return 0;
}



Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i] == L[j] or L[j] == L[k]:
        continue
      if L[i]+L[j]>L[k]:
        ans+=1
print(ans)
      

Measured memory_bytes: 9172
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef pair <int, int> pii;
typedef vector <int> vii;
typedef complex <double> Point;

#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mp make_pair
#define fst first
#define snd second

long long t, n, m, u, v, q, k;
const int N = 2e5 + 500;
const int LN = 21;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 61LL;
long long arr[N], diff[N];

int main() {
  csl;
  cin >> n;
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    sum += arr[i];
  }
  
  if (sum % (n * (n + 1) / 2) != 0) {
    cout << "NO\n";
    return 0;
  }
  
  sum = sum / ((n * (n + 1) / 2));
  arr[n + 1] = arr[1];
  for (int i = 1; i <= n; ++i) {
    diff[i] = arr[i + 1] - arr[i];
  }
  
  long long res = 0;
  for (int i = 1; i <= n; ++i) {
    long long dx = sum - diff[i];
    if (dx < 0 || dx % n != 0) {
      cout << "NO\n";
      return 0;
    }
    res += (dx / n);
  }
  
  if (res != sum) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  return 0;
}


















Measured memory_bytes: 1792
#include <stdio.h>
int main()
{
int a, b, p, n;
scanf("%d%d", &a, &b);
p = 2 * (a + b);
n = a * b;
if (a>=1 && b<=100)
{
printf("%d %d\n", n, p);
}

return 0;

}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
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;
}

int N, K;
int main() {
    
    cin >> N >> K;
    vector<ll> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    for (int i = K; i < N; i++)
    {
        if(a[i]>a[i-K])cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
}

Measured memory_bytes: 4772
from collections import defaultdict
def main():
	H, W, N = map(int, input().split())
	offset = [[i, j] for i in range(-1, 2) for j in range(-1, 2)]
	ans = [0]*10
	ans[0] = (H-2)*(W-2)
	memo = defaultdict(int)
	for i in range(N):
		a, b = map(int, input().split())
		for o in offset:
			if a+o[0] < 2 or H-1 < a+o[0]:
				continue
			if b+o[1] < 2 or W-1 < b+o[1]:
				continue
			memo[(a-1+o[0], b-1+o[1])] += 1
	for v in memo.values():
		ans[v] += 1
		ans[0] -= 1

	for i in range(10):
		print(ans[i])


if __name__ == '__main__':
	main()

Measured memory_bytes: 166892
import java.util.*;

public class Main {
    public static void main(String[] args){
   
      Scanner sc = new Scanner(System.in);
    	String S = sc.next();
      	
 		if(S. equals ("SUN")){
        System.out.println("7");
   		}else if(S. equals ("MON")){
		System.out.println("6");
		}else if(S. equals ("TUE")){
		System.out.println("5");
		}else if(S. equals ("WED")){
		System.out.println("4");
        }else if(S. equals ("THU")){
		System.out.println("3");
        }else if(S. equals ("FRI")){
		System.out.println("2");
        }else {
		System.out.println("1");
          }
}
}

Measured memory_bytes: 22868
N = int(input())
L = [0]*100
L[0] = 2
L[1] = 1
if N == 0 or N == 1:
    print(L[N])
    exit()
for i in range(2,N+1):
    L[i] = L[i-1] + L[i-2]
print(L[i])

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
   static long i,j,k,l;
   long n;
   long cnt = 0;
   static char cell[4][3][10];
   int b,f,r,v;

   cin >> n;
   for(i=0; i<n; i++) {
      cin >> b >> f >> r >> v;
      cell[b-1][f-1][r-1] += v;
   }

   for(i=0; i<3; i++) {
      for(j=0; j<3; j++) {
         for(k=0; k<10;k++) {
            printf(" %d",cell[i][j][k]);
         }
         cout << endl;
      }
      cout << "####################\n";
   }
   for(j=0; j<3; j++) {
      for(k=0; k<10;k++) {
         printf(" %d",cell[i][j][k]);
      }
      cout << endl;
   }


   return 0;
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;

  double t = abs(h / 6.0 + m / 360.0 - m / 30.0) * M_PI;
  // t = min(t, 2 * M_PI - t);

  double ans = sqrt(a * a + b * b - 2 * a * b * cos(t));
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 4208
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll SORT(int n, vector<pair<ll, ll>> &v, int start){
  sort(v.begin()+start, v.end());
  return v[n-1].first;
}


int main(void){
 
  string s;
  cin>>s;
  
  ll count = 2;
  while(1){
    vector<char> v;
    REP(i, s.size()-count){
      v.push_back(s[i]);
    }
    REP(i, v.size()/2){
      if(v[i] != v[i+v.size()/2]) break;
      if(i == v.size()/2 -1 && v[i] == v[i+v.size()/2]){
        cout<<s.size()-count<<endl;
        return 0;
      }
    }
    count += 2;
  }

  
  return 0;

}

Measured memory_bytes: 256
#include"iostream"

using namespace std;

int main()
{
	int n;
	int a[100000];
	cin >> n;
	int m;
	int atc=0;
	int end = 1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int min = 1000000000;
	while (end) {
		for (int i = 0; i < n; i++) {
			if ((min > a[i]) && (a[i] != 0)) {
				min = a[i];
				m = i;
			}
		}
		for (int i = 0; i < n; i++) {
			if (i != m) {
				a[i] = a[i] % min;
				
				if (a[i] == 0&&n>1) {
					n -= 1;

					if (n == 1) {
						atc = m;
						cout <<  a[atc] << endl;
						end = 0;
					}
				}
			}
		}

	}

}

Measured memory_bytes: 640
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	int n;
	cin>>n;
	cout<<(n+1)*n/2<<endl;

}

Measured memory_bytes: 764
#include <cstdio>

int dp[1005];
int main(){
    int N, K;
    scanf("%d%d", &N, &K);

    dp[0] = 1;
    dp[1] = 1;
    for (int i=2; i<=N; ++i) {
        dp[i] = (K-1)*(dp[i-1]);
    }

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


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  int n;
  int ans=0;
  int i;
  
  scanf("%d",&n);

  for(i=1;i<n+1;i++){
    if(i<10||(99<i&&i<1000)||(9999<i&&i<100000)){
      ans++;
    }
  }
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define eps 1e-8
#define pr pair<int,int>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxx = 1e5;

int main()
{
	int a, b, c;
	int d, e, f;
	while(cin >> a >> b >> c)
	{
		d = abs(a-b);
		e = abs(a-c);
		f = abs(b-c);
		int cnt = 0;
		if(d == 0)	cnt ++;
		if(e == 0) cnt ++;
		if(f == 0) cnt ++;
		if(cnt == 1) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	

	return 0;
}



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

const ll MAXN = 200001;

ll N;
vector<ll> A(MAXN, 0), ans;

signed main(){
    cin >> N;
    for(int i=1;i<=N;i++) {
        cin >> A[i];
    }
    for(int i=N;i>=1;i--) {
        ll tmp=0;
        for(int j=i+i;j<=N;j+=i){
            tmp += A[j];
            tmp %= 2;
        }
        if(tmp!=A[i]) {
            A[i]=1;
            ans.push_back(i);
        }
        else A[i]=0;
    }
    cout << ans.size() << endl;
    for(int i=ans.size()-1;i>=0;i--) {
        if(i!=ans.size()-1) cout << " ";
        cout << ans[i];
    }
    return 0;
}

Measured memory_bytes: 3828
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e3 + 5;
int n , m , all , a[N] , b[N];
int memo[N][1 << 13];
int solve(int i , int mask) {
    if(i == m)
        return (mask == (1 << n) - 1) ? 0 : 1e9;
    int &ans = memo[i][mask];
    if(~ans)
        return ans;
    return ans = min(solve(i + 1 , mask | b[i]) + a[i] , solve(i + 1 , mask));
}
int main() {
    abdelrahman010
    cin >> n >> m;
    for(int i = 0;i < m;i++) {
        int x , y;
        cin >> a[i] >> x;
        while(x--) {
            cin >> y;
            y--;
            b[i] |= (1 << y);
        }
        all |= b[i];
    }
    if(all != (1 << n) - 1)
        return cout << -1 , 0;
    memset(memo , -1 , sizeof memo);
    cout << solve(0 , 0);
    return 0;
}

Measured memory_bytes: 35808
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        int weight=512,weights=1,flags=0;
        bool flag[15]={0};
        for(int i=1;i<11;i++){
            if(n-weight>=0){
                flag[i]=1;
                n-=weight;
            }
            weight/=2;
        }
        for(int i=10;i>0;i--){
            if(flag[i]==1&&flags==1){
                cout<<" ";
                flags=0;
            }
            if(flag[i]==1){
                flags=1;
                cout<<weights;
            }
            weights*=2;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,pos;
    cin>>n;
    int a[n],i;
    double avg,sum=0,temp=100000000;
    for(i=0;i<n;i++) {cin>>a[i];sum+=a[i];}
    avg=sum/n;
    for(i=0;i<n;i++)
    {
        if(abs(avg-a[i])<temp) {temp =abs(avg-a[i]);pos=i;}
    }
    cout<<pos<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  if(n%2==0)cout<<n/2<<endl;
  else cout<<n/2+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int baseA,goalB,freezC,unzipD,notzipE,ans,ans2 ;
	scanf("%d",&baseA);
	scanf("%d",&goalB);
	scanf("%d",&freezC);
	scanf("%d",&unzipD);
	scanf("%d",&notzipE);
	if(baseA<=0)
	{
		ans2=baseA*(-1);
		ans=ans2*freezC+unzipD+notzipE*goalB;
		printf("%d\n",ans);
	}
	else if(baseA>=0)
	{
		ans=(goalB-baseA)*notzipE;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
 
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: 3636
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  string S;
  cin>>S;
  int N=S.size();
  int N2=(N-1)/2;
  int N3=(N+3)/2;
  
  string N2st="";
  rep(i,N2)N2st=N2st+S[i];
  string N3st="";
  rep(N3,N)N3st=N3st+S[N3];
  
  string Srev=S;
  reverse(S.begin(),S.end());
  string N2strev=N2st;
  reverse(N2st.begin(),N2st.end());
  string N3strev=N3st;
  reverse(N3st.begin(),N3st.end());
  
  string ans="No";
  if(S==Srev&&N2st==N2strev&&N3st==N3strev)ans="Yes";
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N;
vector<int> A, B, C;

int main() {
  cin >> N;

  A.resize(N);
  B.resize(N);
  C.resize(N);

  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < N; i++)
    cin >> B[i];
  for (int i = 0; i < N; i++)
    cin >> C[i];

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  long long int res = 0;
  for (int i = 0; i < N; i++) {
    auto A_low_iter = lower_bound(A.cbegin(), A.cend(), B[i]);
    auto C_low_iter = upper_bound(C.cbegin(), C.cend(), B[i]);

    res += static_cast<long long int>(distance(A.cbegin(), A_low_iter)) *
           static_cast<long long int>(distance(C_low_iter, C.cend()));
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 4496
import math
import random

A,B,N = map(int,input().split())

def quick(x):
  pri = (A * x // B)
  lat = A * (x // B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(8000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)


Measured memory_bytes: 83352
function main(input) {
    var a = input[0].split(" ")[0]-0;
    var b = input[0].split(" ")[1]-0;
    var c = input[0].split(" ")[2]-0;
    
    console.log(a+b>=c?"Yes":"No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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 solve(mut as_: Vec<i64>, bs: Vec<i64>) -> i64 {
    let mut count = 0;
    for i in 0..bs.len() {
        let mut b = bs[i];
        let a1 = as_[i];
        let a2 = as_[i+1];
        if a1 >= b {
            count += b;
        } else {
            b -= a1;
            count += a1;
            if a2 >= b {
                count += b;
                as_[i+1] -= b;
            } else {
                count += a2;
                as_[i+1] = 0;
            }
        }
    }
    count
}




fn main() {
    input!{
        n: usize,
        as_: [i64; n+1],
        bs: [i64; n],
    }
    println!("{}", solve(as_, bs));
}


Measured memory_bytes: 10232
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String find;
		String ring;
		int n;
		int count;
		boolean flag = true;
		
		find = sc.next();
		n = sc.nextInt();
		count = 0;
		for (int i = 0; i < n; i++) {
			ring = sc.next();
			if (ring.contains(find)) {
				count++;
			} else {
				for (int j = ring.length() - find.length() + 1; j < ring.length(); j++) {
					flag = true;
					for (int k = 0; k < find.length(); k++) {
						if (ring.charAt((j + k) % ring.length()) != find.charAt(k)) {
							flag = false;
						}
					}
					if (flag) {
						count++;
						break;
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    cout << c << " " << a << " " << b;
    cout << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
#define rll register ll
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: putc;
using io :: print;
const int N=55,M=N*N*N,inf=2e9; 
const ll INF=1e18;
ll f[M],sum[N];
int sz[N],fa[N];
struct node{
	int v;
	ll w;
	int id;
	inline bool operator <(const node &rhs)const{
		return v*rhs.w>rhs.v*w||v*rhs.w==rhs.v*w&&w<rhs.w;
	}
}a[N];
int m;
inline void insert(ri v,rll w,ri x){
	v*=x;w*=x;
	for(ri i=m;i>=v;--i)
		f[i]=min(f[i-v]+w,f[i]);
}
inline void work(ri v,rll w,ri k){
	for(ri i=0;1<<i<=k;i<<=1)
		insert(v,w,1<<i),
		k-=1<<i;
	if(k) insert(v,w,k);
}
int main(){
	ri n,x,d,i,j,ans,res,cnt,now;
	gi(n);gi(x);gi(d);
	gi(sum[1]);sz[1]=1;
	for(i=2;i<=n;++i)
		gi(sum[i]),gi(fa[i]),
		sz[i]=1;
	for(i=n;i>=2;--i)
		sum[fa[i]]+=sum[i],
		sz[fa[i]]+=sz[i];
	for(i=1;i<=n;++i) a[i]=(node){sz[i],sum[i],i};
	sort(a+1,a+1+n);
//	for(i=1;i<=n;++i) printf("a %d %lld\n",a[i].v,a[i].w);
	m=min(n,d)*n*n;
	for(i=1;i<=m;++i) f[i]=INF;
	for(i=1;i<=n;++i)
		work(a[i].v,a[i].w,min(n,d));
	ans=0;
	for(i=0;i<=m;++i){
		if(f[i]>x) continue;
	//	printf("f %d %lld\n",i,f[i]);
		res=x-f[i];now=i;
		for(j=1;j<=n;++j)
			cnt=min(a[j].id==1?inf:d-min(n,d),int(res/a[j].w)),
			now+=cnt*a[j].v,
			res-=cnt*a[j].w;
		ans=max(ans,now);
	}
	print(ans);putc('\n');
	return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	const int MOD = 2019;
	auto p = vector<int>(n + 1);
	auto a = vector<int>(n + 1);
	auto d = vector<int>(n + 1);
	auto m = map<int, long long int>();
	++m[0];
	p[0] = 1;
	for(int i = 1; i <= n; ++i){
		a[i] = ((s[n - i] - '0') * p[i - 1]) % MOD;
		d[i] = (a[i] + d[i - 1]) % MOD;
		p[i] = (p[i - 1] * 10) % MOD;
		++m[d[i]];
	}
	long long int ans = 0;
	for(auto mm : m){
		ans += (mm.second * (mm.second - 1) / 2);
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define mod 1000000007
#define inf 9223372036854775807
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define umap unordered_map<ll,ll>
#define lpq priority_queue<ll,vector<ll>,greater<ll>>
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define repr(i,a,n) for(ll i=n-1;i>=a;i--)
ll globe=0;

ll solve(ll day, ll op, vll &a, vll &b, vll &c, vector<vll> &dp){
    if(day<0) return 0;
    if(dp[day][op]!=-1) return dp[day][op];
    if(op==0) dp[day][op]=a[day]+max(solve(day-1,1,a,b,c,dp), solve(day-1,2,a,b,c,dp));
    else if(op==1) dp[day][op]=b[day]+max(solve(day-1,0,a,b,c,dp), solve(day-1,2,a,b,c,dp));
    else dp[day][op]=c[day]+max(solve(day-1,0,a,b,c,dp), solve(day-1,1,a,b,c,dp));
    return dp[day][op];
}

void solution(){
    ll n;
    cin>>n;
    vll a(n);
    vll b(n);
    vll c(n);
    for(ll i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
    vector<vll> dp(n,vll (3,-1));
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    ll ans=-inf;
    ans=max(ans, solve(n-1,0,a,b,c,dp));
    ans=max(ans, solve(n-1,1,a,b,c,dp));
    ans=max(ans, solve(n-1,2,a,b,c,dp));
    cout<<ans<<endl;
}

int main() {
    
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll T=1;
    //cin>>T;
    while(T--){
        solution();
    }

    return 0;
}

//BitMasking->setBit: n|(1<<i); unsetBit: n&!(1<<i); checkBit: n&(1<<i);
//ll idcharacter=upper_bound(v.begin(),v.end(),val)-v.begin();
//v.erase(unique(v.begin(),v.end()),v.end());
//ll cnt=count(v.begin(),v.end(),val);
//bool f=find(v.begin(),v.end(),val);

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

int main() {
    int N;
    cin >> N;
    map<string, int> mp;
    string S;
    for (int i = 0; i < N; i++) {
        cin >> S;
        mp[S]++;
    }

    int maxv = 0;
    for (auto x : mp) {
        maxv = max(maxv, x.second);
    }

    for (auto x : mp) {
        if (x.second == maxv) {
            cout << x.first << endl;
        }
    }
}

Measured memory_bytes: 25344
N = int(input())

number = [[0]*10 for i in range(10)]

for i in range(1, N+1):
    s = str(i)
    id1 = int(s[0])
    id2 = int(s[-1])
    number[id1][id2] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += number[i][j]*number[j][i]

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main()
{	
	int ans[10001]={0};
	int n;
	ans[1]=2;
	for(int i=2;i<=10001;i++){
		ans[i]=ans[i-1]+i;
	}
	while(cin>>n){
		cout<<ans[n]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
vector<long long> Z;
void all(long long N, long long a, int b){
  a*=10;
  a+=b;
  if(a>N) return;
  Z.push_back(a);
  all(N, a, 3);
  all(N, a, 5);
  all(N, a, 7);
}
int main(){
  long long N;
  cin >> N;
  Z.assign(0,0);
  for(int i=3; i<=7; i+=2){
    for(int j=3; j<=7; j+=2){
      all(N, i, j);
    }
  } 

  for(int i=0; i<Z.size(); i++){
    vector<bool> check(3,false);
    int k=Z[i];
    bool push=false;
    while(k>0){
      int a=k%10;
      k/=10;
      if(a==3) check[0]=true;
      if(a==5) check[1]=true;
      if(a==7) check[2]=true;      
      if(check[0] && check[1] && check[2]){
        push=true;
        break;
      }
    }
    if(push==false){
      Z.erase(Z.begin()+i);
      i--;
    }
  }
  cout << Z.size() << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  long long n = 0;
  cin >> n;
  long long ans = 1e16;
  for (long long i=1; i<=sqrt(n); i++) {
    if (n%i == 0) {
      ans = min(ans, i+n/i-2);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
k,t = map(int,input().split())
a = list(map(int,input().split()))
last = None

if t == 1:
    print(k-1)
    exit()

for i in range(k):#　i日目(i=0,1...k-1)
    [nex,ful] = sorted(a)[-2:]
    ful_index,nex_index = a.index(ful),a.index(nex)
    if nex == 0:
        ans = k-i-1
        break
    if last == ful_index:
        last = nex_index
        a[nex_index] -= 1
    else:
        last = ful_index
        a[ful_index] -= 1
        
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
	"strconv"
	"strings"
)

var permutations [][]int = make([][]int, 0, 10)

func main() {
	var maxDepth int
	var p, q []int
	fmt.Scan(&maxDepth)
	p = make([]int, maxDepth)
	q = make([]int, maxDepth)
	for i := 0; i < maxDepth; i++ {
		var x int
		fmt.Scan(&x)
		p[i] = x - 1
	}
	for i := 0; i < maxDepth; i++ {
		var x int
		fmt.Scan(&x)
		q[i] = x - 1
	}

	for i := 0; i < maxDepth; i++ {
		call(i, 0, initialize(maxDepth))
	}
	//なんかアレだけど一応順列は出た
	sorted := make([][]int, len(permutations))
	copy(sorted, permutations)
	/*sort.Slice was introdued Go v1.8 according to godoc*/
	// sort.Slice(sorted, func(i, j int) bool {
	// 	for x := 0; x < len(permutations[i]); x++ {
	// 		if sorted[i][x] != sorted[j][x] {
	// 			return sorted[i][x] < sorted[j][x]
	// 		}
	// 	}
	// 	return false
	// })
	perms := Perms(sorted)
	sort.Sort(perms)

	index := make(map[string]int)
	for i, v := range perms {
		index[toS(v)] = i
	}
	answer := absInt(index[toS(p)] - index[toS(q)])
	fmt.Println(answer)
}

type Perms [][]int

func (p Perms) Len() int {
	return len(p)
}
func (p Perms) Less(i, j int) bool {
	for x := 0; x < len(p[i]); x++ {
		if p[i][x] != p[j][x] {
			return p[i][x] < p[j][x]
		}
	}
	return false
}

func (p Perms) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func absInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func initialize(length int) (result []int) {
	result = make([]int, length)
	for i := 0; i < length; i++ {
		result[i] = -1
	}
	return
}

//DFSみたいなので順列を求めようとしています
func call(v int, depth int, path []int) {
	copiedPath := make([]int, len(path))
	maxDepth := len(path)
	copy(copiedPath, path)
	copiedPath[v] = depth
	// fmt.Println(copiedPath)
	if depth == maxDepth-1 {
		permutations = append(permutations, copiedPath)
	}
	for i, w := range copiedPath {
		if w != -1 {
			continue
		} else {
			call(i, depth+1, copiedPath)
		}
	}
}

func toS(perm []int) string {
	chars := make([]string, len(perm))
	for i, v := range perm {
		chars[i] = strconv.Itoa(v)
	}
	// fmt.Println(chars)
	return strings.Join(chars, "")
}


Measured memory_bytes: 13056
import numpy as np
N = int(input())
A = list(map(int,input().split()))
aa = sorted(A)
ans = [0 for i in range(aa[-1]+1)]
for i in aa:
  ans[i] += 1
  if ans[i] == 1:
    for j in range(i*2,aa[-1]+1,i):
      ans[j] += 2
print(ans.count(1))

Measured memory_bytes: 51496