akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long double
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
int main()
{
    fast;
  
    ll a,b,i;
    cin>>a>>b;
    for(i=1;i<=1000;i++)
    {
    	ll aa = floor(i * ((ll)0.08));
    	ll bb = floor(i * ((ll)0.1));
    	if(a==aa and b==bb) 
    	{
    		cout<<i;
    		return 0;
    	}
    }
    cout<<"-1";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long gcd(long long x,long long y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}
int main(){
  long long n,ans,i,a;cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    if(i==0) ans = a;
    else ans = gcd(ans,a);
  }
  cout << ans << endl;
}
  

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if ( A == B ) {
    cout << "Draw" << endl;
  }
  else if ( A == 1 ) {
    cout << "Alice" << endl;
  }
  else if ( B == 1 ) {
    cout << "Bob" << endl;
  }
  else if ( A > B ) {
    cout << "Alice" << endl;
  }
  else { 
    cout << "Bob" << endl;
  }
    
  
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,c,ans;
    scanf("%lld",&n);
    long long a[n+2];
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    c=n-2;
    ans=a[n-1];
    i=n-2;
    while(c>0){
        if(c==1){
           ans+=a[i];
           c=0;
           break;
        }
        else{
            ans+=2*a[i];
            i--;
            c-=2;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5380
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

using namespace std;

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

int main() {
	
	unsigned long long int n, k, key = 0;
	cin >> n >> k;

	vector<pair<unsigned long long int, unsigned long long int>>num(n);
	
	rep(i, 0, n) {
		cin >> num[i].first;
		cin >> num[i].second;
	}

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

	rep(i, 1, n) {
		num[i].second +=num[i - 1].second;
	}


	if (k <= num[0].second) {
		cout << num[0].first << endl;
		return 0;
	}

	rep(i, 1, n) {
		if (num[i-1].second< k && k<=num[i].second)key = i;
	}

	cout << num[key].first << endl;


	return 0;
}

 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
#define MAX_N 100005
  
ull B=5575777;
ull mem[MAX_N];
  
ull pow(int x){
  if(x==0)return 1;
  if(mem[x]>0)return mem[x];
  if(x&1)return mem[x]=pow(x-1)*B;
  mem[x]=pow(x/2);
  mem[x]*=mem[x];
  return mem[x];
}
  
int n,q,l,r,t;
char s[MAX_N];
ull p[MAX_N];
  
ull get(int l,int r){
  return p[r]-p[l]*pow(r-l);
}
  
ull get(int l,int r,int x,char ch){
  ull res=p[r]-p[l]*pow(r-l);
  if(l<=x&&x<r){
    int dist=r-x-1;
    res-=pow(dist)*s[x];
    res+=pow(dist)*ch;
  }
  return res;
}
  
bool eq(int a,int b,int l,int r){
  return ( get(a,b) == get(l,r) );
}
  
bool eq(int a,int b,int l,int r, int x,char ch){
  return ( get(a,b,x,ch) == get(l,r,x,ch) );
}
  
bool calc(int a,int b,int l,int r){
  if(b-a!=r-l)return false;
  int L=0,R=b-a+1,M;
  while(R-L>1){
    M=(L+R)/2;
    if( eq(a,a+M,l,l+M) ){
      L=M;
    }else{
      R=M;
    }
  }
  if(L==b-a)return true;
  return ( eq(a,b,l,r, l+L, s[a+L]) || eq(a,b,l,r, a+L, s[l+L] )  );
}
  
  
bool solve(){
  int len=r-l;
  if(t==len)return true;
  if(t*2>=len){
    return calc(l,l+(len-t),r-(len-t),r);
  }
  if( calc(l,r-t,l+t,r) )return true;  
  return false;
}
  
int main(){
  scanf("%s",s);
  n=strlen(s);
  
  p[0]=0;
  for(int i=1;i<=n;i++){
    p[i]=p[i-1]*B+s[i-1];
  }
  
  scanf("%d",&q);
  while(q--){
    scanf("%d %d %d",&l,&r,&t);
  
    l--;
  
    if(solve())printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

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

//union-find
//グループ分けを木構造で管理する

//強み(高速)
//・xとyが同じグループかを判定する
//・xとyが同じグループでない場合にこの2グループを併合する

//小さい方を大きい方にくっつける(長さの情報が必要)
//経路縮約

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int root(int x){
        if(d[x]<0)return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y){
        x = root(x); y = root(y);
        if(x==y) return false;
        if(d[x]>d[y]) swap(x,y);
        d[x] += d[y]; d[y] = x;
        return true;
    }
    bool same(int x, int y){return root(x) == root(y);}
    int size(int x){return -d[root(x)];}
};


int main(){
    int n,m;cin>>n>>m;//n人m関係
    UnionFind uf(n);
    
    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a; --b;
        uf.unite(a,b);
    }
    int ans = 0;
    rep(i,n){
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4040
use proconio::{fastout, input};
use std::collections::BTreeMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        k: i64,
        q: usize,
        a: [i64; q]
    };

    let a: Vec<i64> = a.iter().map(|x| x - 1).collect();
    let mut map = BTreeMap::new();

    for i in a.iter() {
        let count = map.entry(i.to_string()).or_insert(0);
        *count += 1;
    }

    for i in 0..n {
        let x = map.get(&i.to_string());
        match x {
            None => {
                if k - q as i64 > 0 {
                    println!("Yes")
                } else {
                    println!("No")
                }
            }
            Some(value) => {
                if k - (q as i64 - value) > 0 {
                    println!("Yes")
                } else {
                    println!("No")
                }
            }
        }
    }
}


Measured memory_bytes: 9224
using System;
using System.Collections.Generic;

namespace atcoder
{
    class Program
    {
        static bool checkPal(string s)
        {
            char[] arr = s.ToCharArray();
            Array.Reverse(arr);
            return s == new string(arr);
        }


        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string str = s.Substring(0, s.Length / 2);
            Console.WriteLine(checkPal(s) && checkPal(str) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
int main() {
    int N;
    cin >> N;
    map<int, int>mp;
    rep(i, 0, N){
        int Anum;
        cin >> Anum;
        mp[Anum] = i+1;
    }
    for (auto& s : mp){
        cout << s.second << " ";
    }
    return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main() {
  vector<int>a(1000001);
  REP(i,1000001){
         a[i]=100000000;
       }
  int x, ans=0;
  cin >> x;
  a[x]=x;
  REP(i,1000001){   
  if(x%2==0){
         x/=2;
         if(a[x]==x){
         cout <<i+2;
         return 0;
         }
          a[x]=x;    
     }else{
        x=x*3+1;
         if(a[x]==x){
         cout <<i+2;
           return 0;
         }
       a[x]=x;
       }
     }
}

Measured memory_bytes: 10980
from itertools import combinations
L,R = (int(x) for x in input().split())
ans = 2018
if (R-L) // 2018 > 1:
    print('0')
else:
    for x in combinations(range(L,R+1),2):
        ans = min(ans,x[0]*x[1]%2019)
    print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
	int i, j, key;
	for(i = 1; i <= 9; i++){
		for(j = 1;j <= 9; j++){
			key = i * j;
			printf("%dx%d=%d\n", i, j, key);
		}
	}
	return 0;
}

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

int main(){
	int n, m;
	int c[201], ans[201];
	
	scanf(" %d", &n);
	for(int i=1; i<=2*n; ++i) c[i]=i; //初期化
	scanf(" %d", &m);
	
	for(int i=0; i<m; ++i){
		int com;
		scanf(" %d", &com);
		
		if(com==0){
			for(int i=1; i<=2*n; ++i){
				ans[i]=(i%2==0) ? c[n+i/2] : c[i/2+1];
			}
		}
		else{
			int i;
			for(i=1; com+i<=2*n; ++i)
				ans[i]=c[com+i];
			//printf("i=%d\n", i);
			for(int j=i; j<=2*n; ++j)
				ans[j]=c[j-i+1];
		}
		
		for(int i=1; i<=2*n; ++i) c[i]=ans[i];
	}

	for(int i=1; i<=2*n; ++i)
		printf("%d\n", ans[i]);

	return 0;
}

Measured memory_bytes: 1188
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;

    long ans = 0;
    int [int[300]] cnt;
    while (n--) {
        auto s = readln.chomp;
        int[300] c = new int[300];
        foreach (e; s) { ++c[e]; }
        
        ans += cnt.get(c, 0);
        cnt[c] += 1;
    }
    
    ans.writeln;
}

Measured memory_bytes: 260988
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define S second
#define ld long double
#define eps 0.00000000001
#define MAX 1000000007
#define vll vector <ll> 
#define pll pair <ll,ll> 

using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ll powc(ll a, ll b){
    if(b<0){
        return -1;
    }
    ll res=1;
    while(b>0){
        if(b&1){
            res*=a;
        }
        a*=a;
        res%=m9, a%=m9;
        b>>=1;
    }
    return res;
}



int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    ll n; cin>>n;
    string s; cin>>s;
    ll r=0, w=0;
    REP(i,0,n){
        if(s[i]=='R'){
            r++;
        }
        else{
            w++;
        }
    }
    ll xr=r, xw=w;
    string temp="";
    while(r--){
        temp+="R";
    }
    while(w--){
        temp+="W";
    }
    ll fh=0; ll sh=0;
    REP(i,0,xr){
        if(s[i]!=temp[i] ){
            fh++;
        }
    }
    REP(i,xr+1,n){
        if(s[i]!=temp[i]){
            sh++;
        }
    }
    cout<<max(sh,fh);

}       

Measured memory_bytes: 3868
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<bitset>
#define d double
#define ll long long
#define ull unsigned long long
using namespace std;
const int maxn=302333;
int a[maxn];
int i,j,k,n,m;

int ra;char rx;
inline int read(){
	rx=getchar(),ra=0;
	while(rx<48)rx=getchar();
	while(rx>47)ra=ra*10+rx-48,rx=getchar();return ra;
}



int main(){
	n=read();m=3*n;
	for(i=1;i<=m;i++)a[i]=read();
	sort(a+1,a+1+m);ll ans=0;
	for(i=m;i>n;i-=2)ans+=a[i-1];
	printf("%lld\n",ans);
}

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


int main() {
  int a,b;
  cin >>a>>b;
  bool f = false ;
  for(int i=0;i<1009;i++){
	if(floor(i*0.08)== a&& floor(i*0.1)==b) {
cout <<i <<endl;
      f = true;
      break;
    }
  }
  if(f == false) cout <<-1<<endl;
}

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

int main()
{
  unsigned long long A;
  std::string B;
  unsigned long long C;

  std::cin >> A >> B;

  B.erase(B.begin()+1);   // 2文字目(コンマ)削除

  C = (unsigned long long)atoi(B.c_str());

  //std::cout << C << std::endl;
  //std::cout << (unsigned long long)(A * C) << std::endl;
  std::cout << (unsigned long long)(A * C / 100) << std::endl;

  return 0;

}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;
 
unordered_map<int,int> um;
unordered_set<int> us;
set<int> s;
// v.front() gives the first element of vector 
// v.back()  gives the last element of vector
// insert erase substr
//g++ -o Legendary-Grandmaster Legendary-Grandmaster.cpp&Legendary-Grandmaster.exe 
//cd C:\Users\158si\Desktop\Algorithim\codeForces\elite
// for-bash cd C:/Users/158si/Desktop/Algorithim/codeForces/elite
//typedef ll long long;

int health[1000],cost[1000];
int dp[10001];
int main(){
	int h,n;
	cin >> h >> n;
	memset(dp,1000000,sizeof(dp));
	dp[0] = 0;
	for(int k=0;k<n;++k){
		cin >> health[k] >> cost[k];
		for(int i=0;i<=h;++i){
			dp[min(i+health[k],h)] = min(dp[min(i+health[k],h)],dp[i]+cost[k]);
		}
	} 
	//dp[min(j+a[i], h)]=min(dp[min(j+a[i], h)], dp[j]+b[i]);
	//Arr(dp,sizeof(dp)/sizeof(dp[0]));
	cout << dp[h];
	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++)

int main() {
  string s;
  cin >> s;
  int n = s.length();
  string t;
  for(char c : s) {
    if(c != 'x') t += c;
  }
  int len = t.length();
  bool f = true;
  rep(i,len/2) {
    if(t[i] != t[len-1-i]) f = false;
  }
  if(!f) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  int l = 0, r = n-1;
  while(r > l) {
    if(s[l] == 'x' and s[r] == 'x') {
      l++; r--;
    } else if(s[l] == 'x') {
      ans++; l++;
    } else if(s[r] == 'x') {
      ans++; r--;
    } else {
      l++; r--;
    }
  } 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3760
use proconio::{input, marker::Bytes};

fn main() {
    input!(n: Bytes);

    let dsum = n.iter().map(|&d| (d - b'0') as u64).sum::<u64>();
    let ans = if dsum % 9 == 0 { "Yes" } else { "No" };

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


Measured memory_bytes: 2300
package main

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

func main() {
	H := readInt()
	N := readInt()

	dp := make([]int, H+1)
	fill(dp, math.MaxInt64)

	dp[0] = 0
	for i := 0; i < N; i++ {
		A := readInt()
		B := readInt()
		for j := 0; j < H; j++ {
			if dp[j] == math.MaxInt64 {
				continue
			}
			t := min(j+A, H)
			dp[t] = min(dp[t], dp[j]+B)
		}
	}

	fmt.Println(dp[H])
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func fill(a []int, x int) {
	for i := 0; i < len(a); i++ {
		a[i] = x
	}
}

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


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int N; cin >> N;
  vector<int> s(N);
  rep(i,N) cin >> s[i];
  
  sort(all(s));
  int ans = 0;
  rep(i,N) ans += s[i];

  if (ans % 10 == 0) {
    rep(i,N) {
      if (s[i] % 10 != 0) {
        ans -= s[i];
        break;
      }
    }
  }
  if (ans % 10 == 0) ans = 0;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int x,y;
    int i,j;
    for(;;){
        scanf("%d %d",&y,&x);
        if(x+y==0) break;
        for(i=0;i<y;i++){
            for(j=0;j<x;j++)
                if((i+j)%2==0)
                    printf("#");
                else 
                    printf(".");
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  string S; cin >> S;
  if (S[0] == 'S') {
    cout << "Cloudy" << endl;
  } else if (S[0] == 'R') {
    cout << "Sunny" << endl;
  } else {
    cout << "Rainy" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char s[4];
  scanf("%s",&s);
  int count=0;
  
  for(int i=0;i<4;i++){
    for(int j=i;j<4;j++){
      if(s[i]==s[j]){
        count++;
      }
    }
  }
  if(count==6){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <cstdlib> // rand
#include <cfloat> // DBL_MAX
#include <map>
#include <vector>
#include <algorithm> // sort
#include <utility> // pair

typedef long long ll;
using namespace std;

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

  // vector<bool> sieve(32-2, true); // 32**2 = 1024 > 10**3
  vector<bool> sieve(1000-2, true);
  vector<int> ps;
  for(int i=0; i<sieve.size(); i++){
    if(!sieve[i]){ continue; }
    ps.push_back(i+2);
    for(int j=2*i+2; j<sieve.size(); j+=(i+2)){
      sieve[j] = false;
    }
  }

  map<int,int> pfs; // prime factorization
  for(int i=2; i<=N; i++){
    int v = i;
    for(int j=0; j<ps.size(); j++){
      if(v==1){ break; }
      while(v%ps[j] == 0){
        if(pfs.find(ps[j]) != pfs.end()){
          pfs[ps[j]] += 1;
        } else {
          pfs[ps[j]] = 1;
        }
        v /= ps[j];
      }
    }
  }

  ll ans = 1;
  for(auto itr=pfs.begin(); itr!=pfs.end(); itr++){
    ans = (ans*(itr->second+1)) % 1000000007;
    // cout << itr->first << " " << itr->second << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
//list($N,$K) =  explode(" ",trim(fgets(STDIN)));
//$X = explode(" ",trim(fgets(STDIN)));

list($a[],$a[]) =  explode(" ",trim(fgets(STDIN)));
list($a[],$a[]) =  explode(" ",trim(fgets(STDIN)));
list($a[],$a[]) =  explode(" ",trim(fgets(STDIN)));

$r = array_count_values($a);
$odd = 0;
foreach($r as $v) {
  if (($v % 2) == 1)
    $odd++;
}
if ($odd == 2) {
  printf("YES\n");
}
else {
  printf("NO\n");
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  long long N;
  cin >> N;
  vector<long long> ABC(3);
  for(int i = 0; i < 3; i++) cin >> ABC[i];
  vector<char> ans(N);
  int i = 0;
  string sa;
  bool check = false;
  while(i < N){
    string s;
    if(check){  
      s = sa; 
    } else{  
      cin >> s;
    }
    int t1 = s[0] - 'A';
    int t2 = s[1] - 'A';
    if(ABC[t1] == 0 && ABC[t2] == 0){  
      cout << "No" <<endl; 
      return 0;
    }
    if(ABC[t1] == 1 && ABC[t2] == 1 && i != N - 1){  
      cin >> sa;
      int ta1 = sa[0] - 'A';
      int ta2 = sa[1] - 'A';
      if(ta1 == t1 && ta2 == t2){  
        ABC[t1]++;
        ABC[t2]--;
        ans[i] = s[0];
      } else if(ta1 == t1){  
        ABC[t1]++;
        ABC[t2]--;
        ans[i] = s[0];
      } else if(ta2 == t2){  
        ABC[t2]++;
        ABC[t1]--;
        ans[i] = s[1];
      } else{  
        if(t1 == 0){  
          ABC[t2]++;
          ABC[t1]--;
          ans[i] = s[1];
        } else{  
          ABC[t1]++;
          ABC[t2]--;
          ans[i] = s[0];
        }
      }
      check = true;
    }
    else if(ABC[t1] < ABC[t2]){  
      ABC[t1]++;
      ABC[t2]--;
      ans[i] = s[0];
      check = false;
    } else {  
      ABC[t2]++;
      ABC[t1]--;
      ans[i] = s[1];
      check = false;
    }
    //cout << ABC[0] << " " << ABC[1] << " " << ABC[2] <<endl;
    i++;
  }
  cout << "Yes" <<endl;
  for(int i = 0; i < N; i++){  
    cout << ans[i] <<endl;
  }
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 21, mod = 1e9 + 7;
int dp[1 << 21][21];
int n;
int a[N][N];

int dynamic(int bitmask, int pos, int count)
{
    if (pos == n)
    {
        if (count == n)
            return 1;
        else
            return 0;
    }
    if (dp[bitmask][pos] != -1)
        return dp[bitmask][pos];
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if ((1 << i)&bitmask)continue;
        if (a[i][pos] == 1)
        {
            ans += dynamic(bitmask | 1 << i, pos + 1, count + 1) ;
            ans %= mod;
        }
    }
    dp[bitmask][pos] = ans;
    return ans;
}

void solve()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    }
    mem1(dp);
    cout << dynamic(0, 0, 0);
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//main code

int main(int argc, char const* argv[])
{
	int n,d;
	cin >> n >> d;
	VVL x(n,VL(d));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			LL d2 = 0;
			for (int z = 0; z < d; z++) {
				d2 += (x[i][z] - x[j][z])*(x[i][z] - x[j][z]);
			}
			for (LL m = 0; m < 200; m++) {
				if (m*m == d2) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
two=0
four=0
other=0
for i in range(n):
    if a[i]%4==0:
        four+=1
    elif a[i]%2==0:
        two+=1
    else:
        other+=1
if four>=two+other-1:
    print("Yes")
elif four>=two%2+other-1:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 19996
/************************************************
 # @Author:      miniLCT
 # @DateTime:    2019-12-22 20:03:32
 # @Description: You build it.You run it
 # @More: If lots of AC,try BF,dfs,DP
 ***********************************************/
#include <bits/stdc++.h>

using namespace std;
#define eps 1e-8
#define close ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long ll;
const int maxn = 1e6;
const int INF = 1e9;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int main()
{
	ll a , c;
	cin >> a >> c;
	cout << a*c/__gcd(a,c) << endl;

}

/******************************************************
 stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?), set tle
  * do smth instead of nothing and stay organized
*******************************************************/

Measured memory_bytes: 256
s = input()
i = len(s)
while i > 0:
    if s[i - 5:i] in ('dream', 'erase'):
        i -= 5
    elif s[i - 6:i] == 'eraser':
        i -= 6
    elif s[i - 7:i] == 'dreamer':
        i -= 7
    else:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 3188
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))

first = 0
second = 0
third = 0

for i in p:
    if i<=a:
        first += 1
    elif i<=b:
        second += 1
    else:
        third += 1

print(min(first, second, third))

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

int main(){
	int n;
	long long a;
	long long minValue = 10000000;
	long long maxValue = -10000000;
	long long sum = 0;

	cin >>n;

	for (int i = 0; i < n; i++){
		cin >> a;
		if (a < minValue) minValue = a;
		if (a > maxValue) maxValue = a;
		sum += a;
	}

	cout << minValue << " " << maxValue << " " << sum << endl;

	return 0;
}

Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#include <cstring>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	string s;
	cin >> s;

	s[3] = '8';
	cout << s << endl;

	return ( 0 );
}


Measured memory_bytes: 256
NA, NB, NM = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
M = [[int(x) for x in input().split()] for i in range(NM)]
res = min(A) + min(B)
for i in range(NM):
  x, y, c = M[i]
  res = min(res, A[x-1] + B[y-1] - c)
print(res)

Measured memory_bytes: 32500
#include <bits/stdc++.h>
    using namespace std;
    #define int long long
    #define N 100010
    struct node{
    	int x,id;
    	bool operator<(const node &a) const{
    		return x<a.x;
    	}
    	node(int x=0,int id=0):x(x),id(id){}
    }P[N<<1];
    bool vis[N];
    int n,x,y,M1=0,M2=0,tot=0;
    signed main(){
    	scanf("%lld",&n);
    	for (int i=1;i<=n;i++){
    		scanf("%lld%lld",&x,&y);
    		M1+=x; M2+=y;
    		P[++tot]=node(x,i);
    		P[++tot]=node(y,i);
    	}
    	sort(P+1,P+1+tot);
    	bool flag=0; int Mn=0;
    	for (int i=1;i<=n;i++){
    		Mn+=P[i].x;
    		if (vis[P[i].id]) flag=1;
    		vis[P[i].id]=1;
    	}
    	if (!flag) {
    		if (P[n+1].id==P[n].id) Mn=min(Mn-P[n].x+P[n+2].x,Mn-P[n-1].x+P[n+1].x);
    		else Mn=Mn-P[n].x+P[n+1].x;
    	}
    	printf("%lld\n",min(min(Mn,M1),M2));
    	return 0;
    }

Measured memory_bytes: 3456
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
D = collections.Counter(iln())
M = iin()
T = collections.Counter(iln())

isOK = False
for key, value in T.items():
    if value > D[key]:
        break
else:
    isOK = True
print('YES' if isOK else 'NO')



Measured memory_bytes: 57376
import java.util.Scanner;
import java.math.BigDecimal;

class Main{
        public static void main(String[] args){
                Scanner scanner=new Scanner(System.in);
                int n=scanner.nextInt();
                int p=scanner.nextInt();

                int even=0;
                for(int i=0;i<n;i++){
                        if(scanner.nextInt()%2==0){
                                even++;
                        }
                }
                int odd=n-even;

                BigDecimal e=new BigDecimal(0);
                for(int i=0;i<new BigDecimal(even).add(new BigDecimal(1)).intValue();i++){
                        e=e.add(combi(even,i));
                }

                BigDecimal o=new BigDecimal(0);
                if(p==0){
                        for(int i=0;i<odd+1;i+=2){
                                o=o.add(combi(odd,i));
                        }
                }else{
                        for(int i=1;i<odd+1;i+=2){
                                o=o.add(combi(odd,i));
                        }
                }
                System.out.println(e.multiply(o));
        }

        private static BigDecimal factorial(int i){
                BigDecimal j=new BigDecimal(1);
                while(i>1){
                        j=j.multiply(new BigDecimal(i--));
                }
                return j;
        }

        private static BigDecimal combi(int i,int j){
                return factorial(i).divide(factorial(i-j).multiply(factorial(j)));
        }
}

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

int map[200][200];

int gcd(int x, int y){  
  int tmp;
  int ret;
  if (x < y){
    tmp = x;
    x = y;
    y = tmp;
  }
  if(map[x-1][y-1] != -1) return map[x-1][y-1];
  if (x % y == 0){
    ret =  y;
    //cout << "anko:" << x << " " << y << " " <<  ret << endl;
  }
  else{
    ret = gcd(y, x % y);
    //cout << "kinako:" << x << " " << y << " " <<  ret << endl;
  }
  map[x-1][y-1] = ret;
  return ret;
}

int main(){
  int K;
  long sum=0;
  cin >> K;

  for(int i=0;i<K;i++)
    for(int j=0;j<K;j++)
      map[i][j] = -1;
  
  for(int i=1;i<=K;i++)
    for(int j=1;j<=K;j++)
      for(int k=1;k<=K;k++){
	//cout << i << " " << j << " " << k << endl;
	//cout << gcd(i,gcd(j,k)) << endl;
	sum += gcd(i,gcd(j,k));
      }

  cout << sum << endl;
}


Measured memory_bytes: 3344
H1, M1, H2, M2, K = gets.split.map(&:to_i)

min = 0

if H1 == H2
  min += M2 - M1
else
  min += 60 * ((H2 - 1) - H1)
  min += (M2 + 60) - M1
end

puts min - K


Measured memory_bytes: 14392
#include<bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define ll         	long long int
#define pb          push_back
#define ar 			array
#define mp 			make_pair
#define f(i,n)   	for(ll i =0;i<n;i++)
#define inf 		INT_MAX
#define pll 		pair<ll, pair<ll,ll>>
const ll INF = 1e18;
void init(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE 
		freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
}
void solve(){
	
	
	
	string s;
	cin>>s;
	for(int i = 0;i<s.length() ;i++){
		if(s[i] == '?'){
			s[i] = 'D';
		}
	}
	cout<<s<<endl;

}
int main(){
	init();
	ll t = 1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int D,T,S;
    cin>>D>>T>>S;
    if(T*S>=D) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}

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

const int MAX_N = 200000;

int main() {
	int N, K, total = 0, Amax = 0;
	static int cnt[MAX_N + 1];

	std::cin >> N >> K;
	for(int i = 0; i < N; ++i) {
		int A;
		std::cin >> A;
		Amax = std::max(Amax, A);
		if(cnt[A] == 0) ++total;
		++cnt[A];
	}
	std::sort(cnt, cnt + Amax + 1);

	int ans = 0;
	size_t c = std::upper_bound(cnt, cnt + Amax + 1, 0) - std::begin(cnt);
	while(total > K) {
		ans += cnt[c];
		--total;
		++c;
	}

	std::cout << ans << std::endl;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
# 整数の入力
N = int(input())
#配列の入力
data = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if data[i] != data[j] and data[j] != data[k] and data[k] != data[i]:
                l = [data[i],data[j],data[k]]
                ld = sorted(l, reverse = True)
                if ld[0] < ld[1]+ld[2]:
                    ans += 1

print(ans)


Measured memory_bytes: 9196
def solve():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))

    l = [int(i) for i in range(105, -105, -1)]
    for i in range(n):
        l.remove(p[i])
    ans = 105
    for i in range(len(l)):
        if ans >= abs(l[i]-x):
            ans = abs(l[i]-x)
        else:
            return l[i-1]
    



print(solve())


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);

int expr(string& s, int& i) {
	int val = term(s, i);
	while (s[i] == '+' || s[i] == '-') {
		char op = s[i++];
		int val2 = term(s, i);
		if (op == '+') val += val2;
		else val -= val2;
	}
	return val;
}

int term(string& s, int& i) {
	int val = factor(s, i);
	while (s[i] == '*' || s[i] == '/') {
		char op = s[i++];
		int val2 = factor(s, i);
		if (op == '*') val *= val2;
		else val /= val2;
	}
	return val;
}

int factor(string& s, int& i) {
	if (isdigit(s[i])) return number(s, i);
	
	i++;
	int res = expr(s, i);
	i++;
	return res;
}

int number(string& s, int& i) {
	int num = s[i++] - '0';
	while (isdigit(s[i])) num = num*10 + s[i++] - '0';
	return num;
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		string str;
		cin >> str;
		str.erase(str.end() - 1);
		int i = 0;
		cout << expr(str, i) << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
import math

a,b,h,m = input().split()
a,b,h,m = int(a),int(b),int(h),int(m)
asin = a * math.sin(math.radians(90-30*h-0.5*m))
acos = a * math.cos(math.radians(90-30*h-0.5*m))
bsin = b * math.sin(math.radians(90-6*m))
bcos = b * math.cos(math.radians(90-6*m))
d = math.sqrt((asin - bsin)**2 + (acos - bcos)**2)
print(d)

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

int main()
{
    int A;
    bool ret = false;
    cin >> A;

    for(int i = 1; i < 10; ++i){
        if(A%i == 0){
            if( (A/i) < 10 ){
                ret = true;
            }        
        }
    }

    if(ret == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

bool compare(const pair<int, int>& f, const pair<int, int> s)
{
  return f.first > s.first;
}

int main(){
  int n, m;
  cin >> n >> m;
  int a[100000] = {};
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a+n, greater<int>() );
  vector< pair<int, int> > bc;
  for(int i = 0; i < m ; i++){
    int b, c;
    cin >> b >> c;
    bc.push_back(make_pair(c, b));
  }
  sort(bc.begin(), bc.end(), compare);
  int count = 0;
  long long ans = 0;
  int soe = 0;
  int asoe = 0;
  for(int i = 0; i < n ; i++){
    if(bc[soe].first > a[asoe]){
      ans += bc[soe].first;
      count++;
      if(count == bc[soe].second){
        count = 0;
        soe++;
      }
    }
    else{
      ans += a[asoe];
      asoe++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1784
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main(void){
    int s,count=1;
    cin >> s;
    vector<int> used(1000007,0);
    while(used[s]==0){
        used[s]++;
        if(s%2==0)s=s/2;
        else s=3*s+1;
        count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int i, j, k, n, a, b, ans=0, po=0;
    scanf("%lld %lld", &a, &b);
    for(i=1; i<=10000; i++){
        if(i*8/100 == a && i*10/100 == b){
            ans = i;
            po++;
            break;
        }
    }
    if(po == 0) printf("-1");
    else printf("%lld", ans);

    
}

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

int main() {
    char grid[2][3];
    int i,j;
    
    for(i=0;i<2;i++)
        for(j=0;j<3;j++)
            cin>>grid[i][j];
            
    if(grid[0][0]==grid[1][2] && grid[0][1]==grid[1][1] && grid[0][2]==grid[1][0])
        cout<<"YES";
    else
        cout<<"NO";
            
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> n;
    if(a >= b) {
        ans = 0;
        rep(i, min(n + 1, b)) { ans = max(ans, a * i / b - a * (i / b)); }
    } else {
        t = min(n, b - 1);
        ans = a * t / b - a * (t / b);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

int n, MOD;

ll bp(ll a, ll p, ll m = MOD) {
    ll r = 1;
    while (p > 0) {
        if (p & 1)
            r = r * a % m;
        a = a * a % m;
        p >>= 1;
    }
    return r;
}

const int N = 3005;
ll c[N][N], w[N][N], two[N][N];

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

    cin >> n >> MOD;

    for (int i = 0; i <= n; i++) {
        ll x = bp(2, n - i), y = 1;
        for (int j = 0; j <= n; j++) {
            two[i][j] = y;
            y = y * x % MOD;
        }
    }

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

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
        }
    }

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

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            w[i][j] = (w[i][j - 1] * (i + 1) + w[i - 1][j - 1]) % MOD;
        }
    }

    ll ans = 0;

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

        for (int k = 0; k <= i; k++) {
            cur = (cur + w[k][i] * two[i][k]) % MOD;
        }

        cur = cur * c[n][i] % MOD * bp(2, bp(2, n - i, MOD - 1)) % MOD;

        if (i % 2)
            ans = (ans - cur + MOD) % MOD;
        else
            ans = (ans + cur) % MOD;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 211840
n,m = map(int,input().split())
PY = [list(map(int,input().split()))+[0] for i in range(m)]
X = sorted(PY,key = lambda x:x[1])
city = {}
for x in X:
    p = x[0]
    y = x[1]
    if p in city:
        city[p] += 1
    else:
        city[p] = 1
    x[2] = city[p]
for p,y,z in PY:
    print(str(p).zfill(6)+str(z).zfill(6))


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

int main(){

    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    for(int i = 0; i < N; i++) cin >> x[i];
    x.push_back(X);
    for(int i = 0; i < M; i++) cin >> y[i];
    y.push_back(Y);

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    if(x.back() < y.front()) cout << "No War" << endl;
    else cout << "War" << endl;

    return 0;
}

Measured memory_bytes: 256