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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<int> ans(N + 1, 0);
    for (int i = N; i > 0; --i) {
        int cnt = 0;
        for (int j = 2; i * j <= N; ++j) {
            cnt += ans[i*j];
        }
        cnt %= 2;
        ans[i] = A[i-1] ^ cnt;
    }

    int M = 0;
    for (auto &i : ans) M += i;
    cout << M << endl;
    rep(i, N+1) {
        if (ans[i]) cout << i << " ";
    }
    if (M) cout << endl;
}

Measured memory_bytes: 2432
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] arr = new int[n];
    int ans = 0;
    int max = 0;
    for(int i = 0; i < n; i++){
      arr[i] = scan.nextInt();
    }
    for(int i = 0; i < n-1; i++){
      if(arr[i] >= arr[i+1]){
        ans++;
        if(max < ans){max = ans;}
      }else{
        ans = 0;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 49404
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <time.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,m,L;
vl a,s;

ll f(int l,int r){
	return (s[r]-s[l-1])/L;
}

int main(){
	cin>>n>>m>>L;
	a=vl(n);
	s=vl(m+1);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<=m;i++){
		cin>>s[i];
		s[i]+=s[i-1];
	}
	sort(a.begin(),a.end());
	vvl dp(n,vl(n));
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(i!=j){
		if(abs(i-j)==1){
			ll tmp=INF;
			if(i>j){
				for(int k=0;k<i-(i==1?0:1);k++) tmp=min(tmp,dp[k][j]+f(a[k],a[i]));
			}
			else{
				for(int k=0;k<j-(j==1?0:1);k++) tmp=min(tmp,dp[i][k]+f(a[k],a[j]));
			}
			dp[i][j]=tmp;
		}
		else{
			if(i>j) dp[i][j]=dp[i-1][j]+f(a[i-1],a[i]);
			else dp[i][j]=dp[i][j-1]+f(a[j-1],a[j]);
		}
	}
	ll res=INF;
	for(int i=0;i<n-1;i++) res=min(res,dp[n-1][i]+f(a[i],a[n-1]));
	cout<<res<<endl;
}

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

using namespace std;

typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef pair<LL,LL> P;
int main(){
    int N;
    cin>>N;
    vector<LL> A(N),cnt(N,0);
    cin>>A;
    map<LL,P> num;
    REP(i,N){
        if(num.count(A[i])==0)num[A[i]]=P(i,1);
        else num[A[i]].se++;
    }
    auto it=num.rbegin();
    auto nxt=it;nxt++;
    for(;nxt!=num.rend();it++,nxt++){
        //        cout<<it->fi<<it->se.fi<<it->se.se<<endl;
        cnt[it->se.fi]+=(it->fi-nxt->fi)*it->se.se;
        nxt->se.se+=it->se.se;
        chmin(nxt->se.fi,it->se.fi);    
    }
    cnt[it->se.fi]+=(it->fi)*it->se.se;
    REP(i,N)cout<<cnt[i]<<fin;
    return 0;
}


Measured memory_bytes: 9984
#include<iostream>
#include<algorithm>

using namespace std;
int a[3], total, les, righ, more;
int main(){
    while(cin){
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if(a[2] >= a[0] + a[1] || a[2] <= a[1] - a[0]){
	    cout << total << " " << righ << " " << more << " " << les << endl;
	    return 0;
	}
	int p = a[2] * a[2];
	int q = a[1] * a[1] + a[0] * a[0];
	if(p > q)les++;
	if(p == q)righ++;
	if(p < q)more++;
	total++;
    }
}

Measured memory_bytes: 1180
#include <stdio.h>

int pita(int a,int b,int c){
	if(a*a+b*b==c*c)return 1;
	return 0;
}

int main(){
	int tyou=0,hishi=0;
	int hen1,hen2,tai;
	int a,b;
	while(scanf("%d,%d,%d",&hen1,&hen2,&tai)!=EOF){
		a=pita(hen1,hen2,tai);
		b=(hen1==hen2);
		if(a&&b)continue;
		if(a)tyou++;
		if(b)hishi++;
	}
	printf("%d\n%d\n",tyou,hishi);

	return 0;
}

Measured memory_bytes: 596
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==c||(a<c&&a+b>=c)){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    
}




Measured memory_bytes: 256
import math

n = int(input())
i = 1
ans = 100000000000
while i <= math.sqrt(n):
    if n%i == 0:
        a = n//i
        b = i
        temp = max(len(str(a)), len(str(b)))
        ans = min(ans, temp)
    i+=1
print(ans)
        



Measured memory_bytes: 9128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int mod = 1000000007;
long long fact[100020],ny[100020];
int n,m;

long long qpow (long long base, long long tms) {
	long long tmp = 1;
	while (tms) {
		if (tms & 1) 
			tmp *= base,tmp %= mod;
		base *= base,base %= mod;
		tms >>= 1;
	}
	return tmp;
}

long long C (int a, int b)
{
	return (long long)fact[a] * ny[b] % mod * ny[a - b] % mod;
}

int main()
{
	fact[0] = ny[0] = fact[1] = ny[1] = 1;
	for (int i = 1;i <= 100000; ++ i) {
		fact[i] = fact[i - 1] * i, fact[i] %= mod;
		ny[i] = qpow(fact[i], mod - 2);
	}
	scanf("%d%d", &n, &m);
	long long ans = n + 1;
	for (int i = 1;i < m; ++ i) {
		if (m - i > n) continue;
		for (int j = 1;j <= m - i; ++ j) {
			if ((m - i) + (m - i - j) > n) continue;
			ans += C(m - 1, i - 1) * C(m - i - 1, j - 1) % mod 
				* C(n - m + i - m + i + j + 2, 2) % mod;
			ans %= mod; 
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define INF 1LL<<62

int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	cout << min(n*a,b);
	// your code goes here
	return 0;
}

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

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

int gcd(int a, int b)
{
    if (a < b)
        return gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    int n = gcd(A, B);
    if (C % n == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second

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

ll h,w;
char s[100][100];
bool used[100][100];



int main(){
	cin >> h >> w;
	REP(i,h) {
		cin >> s[i];
	}

	ll cou = 0;
	REP(i,h) {
		REP(j,w) {
			if(s[i][j] == '#') {
				cou++;
			}
		}
	}

	queue<Pp> que;

	que.push(Pp(P(0,0),0));

	bool f = true;
	while(!que.empty()) {
		Pp p = que.front();
		que.pop();
		if(used[p.fi.fi][p.fi.sc]) {
			continue;
		}
		used[p.fi.fi][p.fi.sc] = true;
		if(p.fi == P(h - 1,w - 1)) {
			f = false;
			cout << h * w - cou - p.sc - 1 << endl;
			break;
		}
		REP(i,4) {
			ll x = p.fi.fi + dx[i],y = p.fi.sc + dy[i];
			if((0 <= x && x < h && 0 <= y && y < w) && s[x][y] == '.' && !used[x][y]){
				que.push(Pp(P(x,y),p.sc + 1));
			}
		}
	}
	if(f) {
		cout << -1 << endl;
	}
	return 0;
}


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

int main() {
    int n, t; cin >> n >> t;
    double a = 0;
    for(int i = 0; i < n; ++i) {
        double x, h; cin >> x >> h;
        a = max(a, h / x);
    }
    cout << fixed << setprecision(10) << t * a << endl;
}



Measured memory_bytes: 3284
package main

import (
	"fmt"
)

func main() {
	var A, B int
	fmt.Scan(&A)
	fmt.Scan(&B)
	list := []int{1, 2, 3}
	list = remove(list, A)
	list = remove(list, B)
	fmt.Println(list[0])
}

// スライスの中身削除
func remove(ints []int, search int) []int {
	result := []int{}
	for _, v := range ints {
		if v != search {
			result = append(result, v)
		}
	}
	return result
}


Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
    double a, b, c, S, L, h;
    scanf("%lf %lf %lf", &a, &b, &c);
    L = a + b + sqrt((a*a)+(b*b)-(2*a*b*cos(M_PI*c/180)));
    h = sin(M_PI*c/180)*b;
    S = h*a*0.5;
    printf("%f %f %f\n", S, L, h);
}


Measured memory_bytes: 3024
#include<stdio.h>
int main () {
	int a, b;
	while (~scanf("%d%d", &a, &b)) {
		int count = 0, sum = a + b;
		while (sum) {
			sum /= 10;
			count++;
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 1028
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

pub trait BITOperator {
    fn unit() -> Self;
    fn apply(a: &Self, b: &Self) -> Self;
}

pub struct BIT<T: BITOperator> {
    buffer: Vec<T>,
}

impl<T: BITOperator> BIT<T> {
    pub fn new(n: usize) -> BIT<T> {
        let mut buffer = vec![];
        for _ in 0..n {
            buffer.push(T::unit());
        }
        BIT { buffer }
    }

    pub fn update(&mut self, i: usize, v: T) {
        let mut x = i + 1;
        let mut base = 1;
        while x <= self.buffer.len() {
            self.buffer[x - 1] = T::apply(&v, &self.buffer[x - 1]);
            while x & base == 0 {
                base *= 2;
            }
            x += base;
        }
    }

    pub fn query(&self, i: usize) -> T {
        let mut v = T::unit();
        let mut x = i + 1;
        let mut base = 1;
        while x > 0 {
            v = T::apply(&v, &self.buffer[x - 1]);
            while x & base == 0 {
                base *= 2;
            }
            x -= base;
        }
        v
    }
}

impl BITOperator for isize {
    fn unit() -> isize {
        0
    }

    fn apply(a: &isize, b: &isize) -> isize {
        a + b
    }
}

fn main() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        mut lr: [(usize, usize); q],
    }

    let mut indices = (0..q).collect::<Vec<_>>();
    indices.sort_by_key(|&i| lr[i].1);

    let mut last_index = vec![INF; n];
    let mut prev = vec![INF; n];
    for i in 0..n {
        prev[i] = last_index[c[i]];
        last_index[c[i]] = i;
    }

    let mut result = vec![0; q];
    let mut bit = BIT::new(n + 1);
    let mut k = 1;
    for &i in &indices {
        let (li, ri) = lr[i];
        while k <= ri {
            bit.update(k, 1);
            if prev[k - 1] != INF {
                bit.update(prev[k - 1] + 1, -1);
            }
            k += 1;
        }
        result[i] = bit.query(ri) - bit.query(li - 1);
    }
    for i in 0..q {
        println!("{}", result[i]);
    }
}


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

int main(){
	ll n;
	cin >> n;
	ll a=1;
	ll b=1;

	for(ll i=2; i*i<=n;i++){
		if(n%i == 0){
			a = i;
		}
	}
	b = n/a;
	ll ans;
	ans = a + b -2;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

N, K = geta(int)
h = geta(int)

INF = 1 << 60
dp = [INF] * N
dp[0], dp[1] = 0, abs(h[0] - h[1])

for i in range(2, N):
    lb = i - K if i > K else 0
    for j in range(lb, i):
        tmp = dp[j] + abs(h[j] - h[i])
        if tmp < dp[i]:
            dp[i] = tmp

print(dp[N - 1])


Measured memory_bytes: 52448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int ans=INT_MAX;
    int n=s.size(),m=t.size();
    for(int i=0;i<n-m+1;i++)
    {
        int p=0;
        for(int j=0;j<m;j++)
        {
            if(s[i+j]!=t[j])
            {
                p++;
            }
        }
       ans=min(p,ans);
    }
    cout<<ans;
}




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

int main() {
  char a;
  cin>>a;
  char x[5]={'a', 'i', 'u', 'e', 'o'};
  bool frag = false;
  rep(i, 5) if (x[i]==a) frag = true;
  if (frag) cout<<"vowel"<<endl;
  else cout<<"consonant"<<endl;
}


Measured memory_bytes: 256
function main(input) {
    var n = input.split(/\n/)[0] / 1;
    var a = input.split(/\n/)[1];
    var as = a.split(/\s/);
    for (var i = 0; i <= n - 1; i++) {
        as[i] /= 1;
    }
    var result = 0;
    for (var j = 0; j <= n - 1; j++) {
        result += 1 / as[j];
    }
    result = 1 / result;
    console.log(result);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> //std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> // std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N; std::cin >> N;
  std::vector<int> A(N); for(int i=0; i<N; i++) std::cin >> A[i];

  double up = 1.;
  for(int i=0; i<N; i++) up *= (double)A[i];

  double down = 0.;
  for(int i=0; i<N; i++){
    double tmp = 1.;
    for(int j=0; j<N; j++){
      if ( i == j ) continue;
      tmp *= A[j];
    }
    down += tmp;
  }
  std::cout << std::setprecision(15);
  std::cout << up / down << std::endl;
  return 0;
}


Measured memory_bytes: 256
def gcd(x,y):
    if y==0:
        return x
    else:
        return(gcd(y,x%y))
    
a,b,c,d = map(int,input().split())
g = gcd(c,d)
l = c*d//g

ans =(b-a+1)-( (b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//l-(a-1)//l)  )
print(ans)

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

int main(){
    string str;
    while(1){
        cin >> str;
        int sum=0;
        if(str == "0") break;
        for(int x : str){
            sum+=x-'0';
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;

vector<int> cost(1000000);
vector<vector<int>> data(1000000);

ll minLL(ll a, ll b){
    if(a < b) return a;
    else return b;
}


int main(){
    ll n, answer = 0;
    cin >> n;
    vector<ll> a(n);
    queue<ll> right;
    queue<ll> left;
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<>());
    for(ll i = 1; i < n; i++){
        answer += a.at((i/2));
    }
    cout << answer << endl;
}

Measured memory_bytes: 32172
#include <atcoder/all>
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

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 main(){
    int N, Q;
    cin >> N >> Q;
    atcoder::fenwick_tree<ll> fw(N);
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        fw.add(i, a);
    }
    for (int i = 0; i < Q; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        if(a) cout << fw.sum(b, c) << endl;
        else fw.add(b, c);
    }
}

Measured memory_bytes: 8220
import math

n = int(input())
x = list(int(x) for x in input().split())
y = list(int(x) for x in input().split())

d = []
d2 = []
d3 = []
for i in range(n):
  d.append(abs(x[i] - y[i]))
  d2.append(abs(x[i] - y[i]) ** 2)
  d3.append(abs(x[i] - y[i]) ** 3)
  
print(sum(d))
print(sum(d2) ** (1/2))
print(sum(d3) ** (1/3))
print(max(d))


Measured memory_bytes: 5700
n,k = map(int,input().split())
d = [0] * k
a = [0] * k
arr = []
for i in range(k):
    d[i] = int(input())
    a[i] = [int(j) for j in input().split()]
    arr = arr + a[i]

ans = 0
for i in range(n):
    if i+1 in arr:
        continue
    else:
        ans += 1

print(ans)


Measured memory_bytes: 9232
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;

	int _max = max({ a, b, c }) * (int)pow(2, k);

	vector<int> v{ a, b, c };

	sort(v.begin(), v.end());

	v[2] = _max;

	cout << accumulate(v.begin(), v.end(), 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N;
    string s1, s2;
    cin >> N;
    vector<pair<int, int>> A(N);
    rep(i, N){
        int a;
        cin >> a;
        A[i] = make_pair(-1 * a, i);
    }
    sort(all(A));
    // cout << A[0].first << endl;
    rep(i, N){
        if(i == A[0].second) cout << A[1].first * -1 << endl;
        else cout << A[0].first * -1 << endl;
    }
}

Measured memory_bytes: 4744
#include <stdio.h>

long long gcd(long long a, long long b)
{
	if (a > b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{
	int i, N;
	char A[200001][20];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%s", A[i]);
	
	int j, k;
	long long g, a[200001][2] = {}, tmp;
	for (i = 1; i <= N; i++) {
		for (j = 0; A[i][j] != 0; j++);
		for (j--, tmp = 1, a[i][1] = 1; j >= 0; j--, tmp *= 10) {
			if (A[i][j] != '.')	a[i][0] += (A[i][j] - '0') * tmp;
			else {
				a[i][1] = tmp;
				tmp /= 10;
			}
		}
		g = gcd(a[i][0], a[i][1]);
		a[i][0] /= g;
		a[i][1] /= g;
	}
	
	int count[4][11][11] = {}, sum = 0;
	long long two[11], five[11];
	for (i = 1, two[0] = 1, five[0] = 1; i < 10; i++) {
		two[i] = two[i-1] * 2;
		five[i] = five[i-1] * 5;
	}
	for (i = 1; i <= N; i++) {
		if (a[i][1] == 1) {
			for (j = 0; j < 10 && a[i][0] % two[j] == 0; j++);
			for (k = 0; k < 10 && a[i][0] % five[k] == 0; k++);
			count[0][j-1][k-1]++;
			sum++;
		} else if (a[i][1] % 5 != 0) {
			for (j = 0; j < 10 && a[i][1] % two[j] == 0; j++);
			for (k = 0; k < 10 && a[i][0] % five[k] == 0; k++);
			count[1][j-1][k-1]++;
		} else if (a[i][1] % 2 != 0) {
			for (j = 0; j < 10 && a[i][0] % two[j] == 0; j++);
			for (k = 0; k < 10 && a[i][1] % five[k] == 0; k++);
			count[2][j-1][k-1]++;
		} else {
			for (j = 0; j < 10 && a[i][1] % two[j] == 0; j++);
			for (k = 0; k < 10 && a[i][1] % five[k] == 0; k++);
			count[3][j-1][k-1]++;
		}
	}
	
	int m, n;
	long long ans = (long long)sum * (sum - 1) / 2;
	for (j = 0; j < 10; j++) {
		for (k = 0; k < 10; k++) {
			for (m = 0; m <= j; m++) {
				for (n = 0; n < 10; n++) ans += (long long)count[0][j][k] * count[1][m][n];
			}
			for (m = 0; m < 10; m++) {
				for (n = 0; n <= k; n++) ans += (long long)count[0][j][k] * count[2][m][n];
			}
			for (m = 0; m <= j; m++) {
				for (n = 0; n <= k; n++) ans += (long long)count[0][j][k] * count[3][m][n];
			}
		}
	}
	for (j = 0; j < 10; j++) {
		for (k = 0; k < 10; k++) {
			for (m = j; m < 10; m++) {
				for (n = 0; n <= k; n++) ans += (long long)count[1][j][k] * count[2][m][n];
			}
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 8760
import networkx as nx

N=int(input())
ab=[list(map(int,input().split())) for _ in range(N)]
ab=sorted(ab)
cd=[list(map(int,input().split())) for _ in range(N)]
cd=sorted(cd,reverse=True)

G = nx.DiGraph()
for i in range(N):
  G.add_edge('x',i, capacity=1)
  for j in range(N):
    if i == 0:
      G.add_edge(N+j,'y', capacity=1)
    a,b=ab[i]
    c,d=cd[j]
    if a<c and b<d:
      G.add_edge(i,N+j, capacity=1)
    elif a>=c:break

flow_value, flow_dict = nx.maximum_flow(G, 'x', 'y')
print(flow_value)

Measured memory_bytes: 55784
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin>>s;
	if(s.substr(0,1)=="9" || s.substr(1,1)=="9" ){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int N=100009;
int n,a[N],ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);

	for(int i=1;i<=n;i++)
		if(i+1>a[i+1])
		{
			for(int j=i+1;a[j]==i;j++)
				ans^=1;
			ans|=(a[i]-i)&1;
			return puts(ans? "First":"Second"),0;
		}

	return 0;
} 



Measured memory_bytes: 640
//途中から違う問題解いてたｗ
//隣り合う点に辺を張って、各連結成分で座圧やって数えるだけですね。はい。
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int x[100000], y[100000];
vector<int> xid[100001];
vector<int> yid[100001];
vector<int> et[100001];
int label[100000];
vector<vector<int>> ids;

int calc(vector<int> &ids) {
	vector<int> xs;
	vector<int> ys;
	int i;
	
	rep(i, ids.size()) {
		xs.push_back(x[ids[i]]);
		ys.push_back(y[ids[i]]);
	}
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	ys.erase(unique(ys.begin(), ys.end()), ys.end());
	
	return (int)xs.size() * ys.size();
}

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> x[i] >> y[i];
	rep(i, n) {
		xid[x[i]].push_back(i);
		yid[y[i]].push_back(i);
	}
	
	rep(i, 100001) {
		rep(j, (int)xid[i].size() - 1) {
			int u = xid[i][j];
			int v = xid[i][j + 1];
			et[u].push_back(v);
			et[v].push_back(u);
		}
		rep(j, (int)yid[i].size() - 1) {
			int u = yid[i][j];
			int v = yid[i][j + 1];
			et[u].push_back(v);
			et[v].push_back(u);
		}
	}
	
	rep(i, n) { label[i] = -1; }
	
	int lcnt = 0;
	rep(i, n) {
		if (label[i] != -1) continue;
		label[i] = lcnt;
		
		queue<int> que;
		que.push(i);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			rep(j, et[v].size()) {
				int nv = et[v][j];
				if (label[nv] == -1) {
					label[nv] = lcnt;
					que.push(nv);
				}
			}
		}
		lcnt++;
	}
	
	ids.resize(lcnt);
	rep(i, n) {
		ids[label[i]].push_back(i);
	}
	
	int sumCnt = 0;
	rep(i, ids.size()) {
		sumCnt += calc(ids[i]);
	}
	cout << sumCnt - n << endl;
	return 0;
}

Measured memory_bytes: 19956
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

const int MAX = 5;

int len;
char num[6];
char field1[MAX][MAX], field2[2][MAX];
void change(int i) {
  
  if(num[i] % 5 == 1) { field1[1][i] = ' '; field1[0][i] = '*'; }
  if(num[i] % 5 == 2) { field1[2][i] = ' '; field1[0][i] = '*'; }
  if(num[i] % 5 == 3) { field1[3][i] = ' '; field1[0][i] = '*'; }
  if(num[i] % 5 == 4) { field1[4][i] = ' '; field1[0][i] = '*'; }
  if(num[i] >= 5) { field2[0][i] = ' '; field2[1][i] = '*'; }
}
  
int main() {
  char dumy[6];
  bool flag = 0;
  while(1/*scanf("%s", dumy) != EOF*/) {
    if(scanf("%s", dumy) == EOF) { break; flag = true; }
    if(flag == true) cout << endl;
    flag = 1;
    memset(num, '#', sizeof(num));
    for(int i = 1 ; i < MAX ; i++)
      for(int j = 0 ; j < MAX ; j++) field1[i][j] = '*';
    
    for(int i = 0 ; i < MAX ; i++) field1[0][i] = ' ';

    for(int i = 0 ; i < MAX ; i++) {
      field2[0][i] = '*'; 
      field2[1][i] = ' ';
    }
    // cout << "OK" << endl;
    len = strlen(dumy);
    //cout << len << endl;
    len = MAX - len;
    //cout << len << endl;
    num[len] = dumy[0];
    if(len+1 < 5) num[len+1] = dumy[1];
    if(len+2 < 5) num[len+2] = dumy[2];
    if(len+3 < 5) num[len+3] = dumy[3];
    if(len+4 < 5) num[len+4] = dumy[4];
    //cout << "OK" << endl;
    for(int i = 4 ; i >= 0 ; i--) {
      if(num[i] != '#') {
	num[i] = num[i] - '0';
	change(i);
      }
    }
    
    for(int i = 0 ; i < 2 ; i++) {
      for(int j = 0 ; j < 5 ; j++) {
	cout << field2[i][j];
      }
      cout << endl;
    }
  
    cout << "=====" << endl;
    
    for(int i = 0 ; i < 5 ; i++) {
      for(int j = 0 ; j < 5 ; j++) {
	cout << field1[i][j];
      }
      cout << endl;
    }
    memset(num, '#', sizeof(num));
  }
  return 0;
}

Measured memory_bytes: 876
/*
 *      ┌─┐       ┌─┐ + +
 *   ┌──┘ ┴───────┘ ┴──┐++
 *   │                 │
 *   │       ───       │++ + + +
 *   ███████───███████ │+
 *   │                 │+
 *   │       ─┴─       │
 *   │                 │
 *   └───┐         ┌───┘
 *       │         │
 *       │         │   + +
 *       │         │       Code is far away from bug with the animal protecting
 *       │         └──────────────┐
 *       │                        │
 *       │                        ├─┐
 *       │                        ┌─┘
 *       │                        │
 *       └─┐  ┐  ┌───────┬──┐  ┌──┘  + + + +
 *         │ ─┤ ─┤       │ ─┤ ─┤
 *         └──┴──┘       └──┴──┘  + + + +
 *                神兽保佑
 *               代码无BUG!
 */

#include<bits/stdc++.h>
using namespace std;
class IN{
public:
    template<typename T>
    IN& operator >>(T &x){read(x);return *this;}
    IN& operator >>(double &x){scanf("%lf",&x);return *this;}
    IN& operator >>(char *s){scanf("%s",s);return *this;}
    IN& operator >>(char &c){c=getchar();return *this;}
private:
    template<typename T>
    void read(T &x){
        T f=1;int c=getchar();x=0;
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
        while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
        x*=f;
    }
}in;
class NL{}nl;
class BK{}bk;
class OUT{
public:
    template<typename T>
    OUT& operator <<(T x){write(x);return *this;}
    OUT& operator <<(const char *s){printf("%s",s);return *this;}
    OUT& operator <<(char c){putchar(c);return *this;}
    OUT& operator <<(BK x){putchar(' ');return *this;}
    OUT& operator <<(NL x){putchar('\n');return *this;}
private:
    template<typename T>
    void write(T x){
        if(x<0)putchar('-'),x=-x;
        if(x>=10)write(x/10);
        putchar(x%10+48);
    }
}out;

#define pb(x) push_back(x)
#define fi first
#define se second
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define mem(a,x) memset(a,x,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;
/*****************************************************************************************************/
ll Pow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)(res*=a)%=mod;(a*=a)%=mod;b>>=1;}return res%mod;}
ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}//p为素数,a<p
//ll C(ll n,ll m){ll res=1;for(ll i=1,j=n-m+1;i<=m;++i,++j){res=res*inv(i,p)%p*j%p;}return res;}
/*****************************************************************************************************/
/*ll ask(int x){ll res=0;while(x)res+=c[x],x-=x&-x;return res;}
void add(ll v,int x){while(x<=n)c[x]+=v,x+=x&-x;}*/
const int p=1e9+7;
const int N=2e5+10;

int main(){
    int n,m;
    in>>n>>m;
    int ans=0;
    if(n>=2)
        ans+=n*(n-1)/2;
    if(m>=2)
        ans+=m*(m-1)/2;
    out<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

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

namespace Q3
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] words = line.Split(' ');

            int N = int.Parse(words[0]);
            int M = int.Parse(words[1]);

            //[電球,スイッチ番号]
            int[] switches = new int [M];
            for(int i = 0; i < M; i++)
            {
                switches[i] = 0;
            }
            for(int i = 0; i < M; i++)
            {
                line = Console.ReadLine();
                words = line.Split(' ');
                for(int j = 0; j < int.Parse(words[0]); j++)
                {
                    switches[i] += (int)Math.Pow(2, int.Parse(words[j + 1]) - 1);
                }
            }
            int[] p = new int[M];
            line = Console.ReadLine();
            words = line.Split(' ');
            for(int i = 0; i < M; i++)
            {
                p[i] = int.Parse(words[i]);
            }
            int MAX = (int)Math.Pow(2, N);
            int switch_on = 0;
            int count = 0;
            bool OK;
            for(int i = 0; i < MAX; i++)
            {
                switch_on = 0;
                OK = true;
                for(int j = 0; j < M; j++)
                {
                    switch_on = i & switches[j];
                    if (bit_pop_count(switch_on)%2 != p[j])
                    {
                        OK = false;
                        break;
                    }
                }
                if (OK) count++;
            }

            Console.WriteLine(count);
        }

        public static int bit_pop_count(int n)
        {
            int count = 0;

            for(; n > 0; n>>=1)
            {
                count += n & 1;
            }

            return count;
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
using namespace std;
using pii = pair<int, int>;

int N;
vector<int> v;

void dfs(int lev, int sum) {
  if (lev == 10) {
    return;
  }
  int tmp = sum * 10;
  v.emplace_back(tmp+3);
  dfs(lev+1, tmp+3);
  v.emplace_back(tmp+5);
  dfs(lev+1, tmp+5);
  v.emplace_back(tmp+7);
  dfs(lev+1, tmp+7);
}

bool check(int x) {
  int a = 0, b = 0, c = 0;
  while (x) {
    int y = x % 10;
    a |= (y == 3);
    b |= (y == 5);
    c |= (y == 7);
    x /= 10;
  }
  return a && b && c;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  dfs(0, 0);
  vector<int> w;
  for (int i = 0; i < v.size(); i++) {
    if (check(v[i])) w.emplace_back(v[i]);
  }
  sort(w.begin(), w.end());
  cout << upper_bound(w.begin(), w.end(), N) - w.begin() << endl;

  return 0;
}

Measured memory_bytes: 2548
#include <cstdio>

int P, A[3000], C[3000], R[3000];

int main()
{
	scanf ("%d", &P);
	for (int i = 0; i < P; i++) scanf ("%d", &A[i]);

	C[0] = 1;
	for (int i = 1; i < P; i++){
		for (int j = i; j > 0; j--) C[j] = (C[j] + C[j - 1]) % P;
	}

	for (int i = 0; i < P; i++) if (A[i]){
		R[0] = (R[0] + 1) % P;
		for (int j = 0, x = 1; j < P; j++){
			R[P - j - 1] = (R[P - j - 1] + P - x * C[j] % P) % P;
			x = x * (P - i) % P;
		}
	}

	for (int i = 0; i < P; i++) printf ("%d ", R[i]); puts("");

	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt, ans = {}, 0

for i in a:
    if i in cnt:
        cnt[i] += 1
    else:
        cnt[i] = 1

item = cnt.items()
item_srt = sorted(item, key=lambda x: x[1])
l = len(item_srt)
for j in item_srt:
    if l <= k:
        break
    ans += j[1]
    l -= 1
print(ans)

Measured memory_bytes: 38964
#include <cstdio>
#include <cstdlib>

int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int a[n],b[n];
    for(int i = 0; i < n; i++){
        scanf("%d %d",&a[i],&b[i]);
    }
    int c[m],d[m];
    for(int i = 0; i < m; i++){
        scanf("%d %d",&c[i],&d[i]);
    }
    int min;
    int Hd;
    int p[n];
    for(int i = 0; i < n; i++){
        min = abs(a[i] - c[0]) + abs(b[i] - d[0]);
        p[i] = 0;
        for(int j = 0; j < m; j++){
            Hd = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(Hd < min){
                min = Hd;
                p[i] = j;
            }
        }
        printf("%d\n",p[i] + 1);
    }

    return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll a,b;
  cin>>a>>b;
  if(a==1&&b==1){
    cout<<1<<endl;
  }
  else if(a!=1&&b!=1){
    cout<<(a-2)*(b-2)<<endl;
  }
  else cout<<a*b-2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i,a,b) for(int i=a; i<=b; i++)
#define MOD 1000000007
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int x,n,p[101],a[102]={0};
	cin>>x>>n;
	forn(i,1,n) cin>>p[i],a[p[i]]=1;
	if(n==0) cout<<x<<"\n";
	else {
		int min=INT_MAX,ans;
		forn(i,0,101){
			if(a[i]==0){
				if(min>abs(x-i)){
					min=abs(x-i);
					ans=i;
				}
			}
		}
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 3696
fn main() {
    let s: String = read_line_as_value();
    match s.as_str() {
        "Sunny" => println!("Cloudy"),
        "Cloudy" => println!("Rainy"),
        "Rainy" => println!("Sunny"),
        _ => println!("should not be called"),
    };
}

fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

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

int main()
{
	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	long long ret = -2000000000000000000;
	ret = max(ret, a*c);
	ret = max(ret, a*d);
	ret = max(ret, b*c);
	ret = max(ret, b*d);

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 3620
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;

void solve()
{
	string s;cin>>s;
	if(s[0]=='7' or s[1]=='7' or s[2]=='7')cout<<"Yes\n";
	else cout<<"No\n";
}

int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
//cin>>t;
while(t--)
{
	solve();
}
}

Measured memory_bytes: 3612
import itertools

n = int(input())

alpha_list = ['a','b','c','d','e','f','g','h','i','j']
string_list = []
count = 0

def extend(string,count,n):
    if len(string) >= n:
        string_list.append(string)
        return True
    else:
        for i in range(count+1):
            sc = string
            sc += alpha_list[i]
            if i == count:
                count += 1
            extend(sc,count,n)
    
extend('',count,n)

string_list.sort()
for s in string_list:
    print(s)

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String st = sc.nextLine();
		StringBuilder sb = new StringBuilder(st);
		for(int i = 0 ; i < sb.length(); i++){
			int appleindex = sb.indexOf("apple",i);
			int peachindex = sb.indexOf("peach",i);
			if(appleindex == -1 && peachindex == -1){
				break;
			}else if(peachindex == -1){
				sb.replace(appleindex, appleindex+5, "peach");
				i = appleindex+4;
			}else if(appleindex == -1){
				sb.replace(peachindex, peachindex+5, "apple");
				i = peachindex+4;
			}else{
				if(peachindex < appleindex){
					sb.replace(peachindex, peachindex+5, "apple");
					i = peachindex+4;
				}else{
					sb.replace(appleindex, appleindex+5, "peach");
					i = appleindex+4;
				}
			}
		}
		System.out.println(sb);
		sc.close();
	}
}

Measured memory_bytes: 17128
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b
  | b = putStrLn "YES"
  | otherwise = putStrLn "NO"

yesNo b
  | b = putStrLn "Yes"
  | otherwise = putStrLn "No"

main = do
  n <- getLine
  yesNo $ n == reverse n


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

bool compare_by_a(tuple<ll, ll, ll, string> a, tuple<ll, ll, ll, string>  b) {
    if(get<1>(a) != get<1>(b)){
        return get<1>(a) < get<1>(b);
    }else{
        return get<2>(a) < get<2>(b);
    }
}

bool compare_by_b(tuple<ll, ll, ll, string> a, tuple<ll, ll, ll, string>  b) {
    return get<0>(a) < get<0>(b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    vector<tuple<ll, ll, ll, string> > t(M);

    REP(i ,M){
        ll p, y;
        cin >> p;
        cin >> y;
        get<0>(t[i]) = i;
        get<1>(t[i]) = p;
        get<2>(t[i]) = y;
    }

    sort(t.begin(), t.end(), compare_by_a);

    ll counter = 0;
    REP(i, M){
        string s1 = to_string(get<1>(t[i]));

        counter++;
        // 前の市と県が違うとき
        if(i !=0 && get<1>(t[i]) != get<1>(t[i-1])){
            counter = 1;
        }
        string s2 = to_string(counter);
        string ans = "";
        REP(j, 6 - s1.length()){
            ans += "0";
        }
        ans += s1;
        REP(j, 6 - s2.length()){
            ans += "0";
        }
        ans += s2;
        get<3>(t[i]) = ans;
    }

    sort(t.begin(), t.end(), compare_by_b);

    REP(i, M){
        cout << get<3>(t[i]) << endl;
    }

    return 0;
}

Measured memory_bytes: 10880
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    unsigned long long sum = 0;
    int N, M;
    cin >> N >> M;
    using veci = vector<int>;
    vector<veci> V(N, vector<int>(2));
    for (auto& v : V) cin >> v[0] >> v[1];
    sort(V.begin(), V.end(), [](const veci& a, const veci& b){return a[0] < b[0];});
    for (const auto& v : V){
        bool brk = false;
        for (int i = 0; i < v[1]; i++){
            sum += v[0];
            if (--M <= 0){
                brk = true;
                break;
            }
        }
        if (brk) break;
    }
    cout << sum << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int k;
  cin>>k;
  int count=0;
   while(b<=a)
  {
    b*=2;
    count++;
  }
  while(c<=b)
  {
    c*=2;
    count++;
  }
 
  if(count<=k)
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
  
}

Measured memory_bytes: 3640
# coding: utf-8
# Your code here!
dic = set()
def insert(s):
    dic.add(s)
def find(s):
    if s in dic:
        print("yes")
    else:
        print("no")
i = int(input())
for c in range(i):
    op,s = map(str,input().split())
    if op == "insert":
        insert(s)
    elif op == "find":
        find(s)


Measured memory_bytes: 30992
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

ll dp[100001][13]={};

int main(){
    string S;
    cin >> S;
    
    int n=S.length();
    
    ll dix[100001];
    dix[0]=1;
    for(int i=1; i<=100000; i++){
        dix[i]=(dix[i-1]*10)%13;
    }
    

    dp[0][0]=1;
    for(int i=n-1; i>=0; i--){
        int k=n-1-i+1;
        // 10^(k-1)の位
        if(S[i]=='?'){
            for(int s=0; s<10; s++){
                for(int d=0; d<13; d++){
                    dp[k][(dix[k-1]*s+d)%13] += dp[k-1][d];
                }
            }
        }else{
            int s=S[i]-'0';
            for(int d=0; d<13; d++){
                dp[k][(dix[k-1]*s+d)%13] += dp[k-1][d];
            }
        }
        
        for(int x=0; x<13; x++){
            dp[k][x]%=MOD;
        }
    }

    cout<<dp[n][5]<<endl;
    return 0;
}



Measured memory_bytes: 11392
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        a: i64, b: i64
    }
    println!("{}", a*b);
}


Measured memory_bytes: 2164
# 高速版input
import sys
input = sys.stdin.readline

n,m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
bc = [[int(i) for i in input().split()] for i in range(m)]

x = []
for b,c in sorted(bc, key=lambda x: x[1], reverse=True):
    x.extend([c]*b)
    if len(x) > n:
        break
        
a.extend(x)
print(sum(sorted(a,reverse=True)[:n]))


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

int main()
{
    long long int a,b,c,d;
    cin >> a >> b >> c >> d;

    cout << fixed << setprecision(18) << max(max(a*c, a*d),max(b*c, b*d)) << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
 
int main(){
  int n,x=0,max=0;
  char s;
  scanf("%d\n",&n);
  for (int i=0;i<n;i++){
      scanf("%c",&s);
      if (s=='I'){
        x+=1;
        if(x>max){max=x;}
      }else{x-=1;}
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline

n = int(input())
d = list(map(int,input().split()))

mod = 998244353
ans = 1

if d[0] != 0 or d.count(0) > 1:
    print(0)
    exit()

d.sort()

for i in range(n-1):
    if d[i+1] - d[i] > 1:
        print(0)
        exit()

count = 1
count2 = 0
li = [1]

for i in range(1,n):
    if count == d[i]:
        count2 += 1
    else:
        li.append(count2)
        count += 1
        count2 = 1

if count2 != 1:
    li.append(count2)
else:
    if count == d[-1]:
        li.append(1)
    else:
        print(0)
        exit()

for i in range(len(li)-1):
    ans *= li[i] ** li[i+1]
    ans %= mod

print(ans)


Measured memory_bytes: 13876