akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
bool seive[100005];
void SieveOfEratosthenes(ll n)
{ memset(seive, true, sizeof(seive)); for (ll p=2; p*p<=n; p++) if (seive[p] == true) for (ll i=p*p; i<=n; i += p) seive[i] = false; }
// ll a[11*LIM]={0},b[11*LIM]={0};
// vp64 v[LIM];
typedef struct 
{
	ll one,two,three;
}data;






int main()
{
	fast;
	ll a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for a in range(j+1,n):
      if l[i]+l[j]>l[a] and l[i]!=l[j] and l[j]!=l[a]:
        ans+=1
print(ans)        
 

Measured memory_bytes: 9184
from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

N, K = map(int, input().split())
A =list(map(int, input().split()))

#if K <= max(A) and K % reduce(gcd, A) == 0:
if K <= max(A) and K % gcd_list(A) == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 16280
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int n;
vector<vector<int> > a;
map<pair<int,int>,int> mp;
struct DAG{
  int node;
  vector<vector<int> > edge;
  vector<bool> visited,visiting;
  vector<int> dp;
  
  DAG(int N)
  {
    node = N;
    edge.resize(N);
  }
  
  void add_edge(int from,int to)
  {
    edge[from].push_back(to);
  }
  
  bool dfs_find_loop(int v)
  {
    bool f = true;
    visiting[v] = true;
    rep(i,edge[v].size()){
      int w = edge[v][i];
      if(visited[w]) continue;
      if(visiting[w]) return false;
      f = f&&dfs_find_loop(w);
    }
    visited[v] = true;
    return f;
  }  
  bool find_loop()
  {
    bool f = true;
    visited.assign(node,0);
    visiting.assign(node,0);
    rep(i,node){
      if(!visited[i]) f = f&&dfs_find_loop(i);
    }
    return f;
  }

  int dfs_longest_pass(int v)
  {
    if(dp[v]>=0) return dp[v];
    int res = 0;
    rep(i,edge[v].size()){
      int w = edge[v][i];
      res = max(res,dfs_longest_pass(w)+1);
    }
    return dp[v] = res;
  }
  
  int longest_pass()
  {
    int res = 0;
    dp.assign(node,-1);
    rep(i,node){
      dfs_longest_pass(i);
    }
    rep(i,node){
      res = max(res,dp[i]);
    }
    
    return res+1;
  }
};


pair<int,int> pair_make(int x,int y){
  if(x<y) return make_pair(x,y);
  else return make_pair(y,x);
}

int main()
{
  cin >> n;
  a.resize(n);
  rep(i,n) a[i].resize(n-1);
  rep(i,n){
    rep(j,n-1){
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  
  {
    int k = 0;
    rep(i,n){
      for(int j=i+1;j<n;++j){
	mp[make_pair(i,j)] = k++;
      }
    }
  }

  int nn = n*(n-1)/2;
  DAG dag(nn);

  rep(i,n){
    rep(j,n-2){
      dag.add_edge(mp[pair_make(i,a[i][j])],mp[pair_make(i,a[i][j+1])]);
    }
  }
  
  if(dag.find_loop()){
    cout << dag.longest_pass() << "\n";
  }
  else{
    cout << -1 << "\n";
  }
  
  return 0;
}


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

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

    vector<string> x(N), u(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> u[i];
    }

    double ans = 0.0;
    for (int i = 0; i < N; i++)
    {
        if (u[i] == "JPY")
        {
            ans += stod(x[i]);
        }
        else
        {
            ans += 380000.0 * stod(x[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    int n;
    cin>>n;
    int d[100][2];
    rep(i,n){
        cin>>d[i][0]>>d[i][1];
    }
    bool a=false;
    rep(i,n-2){
        if(d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] && d[i+2][0]==d[i+2][1]){
            a=true;
        }
    }
    if(a){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


    return 0;
}



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

int main()
{
  string s1, s2;
  cin >> s1;
  int ans = 0;
  while(cin >> s2) {
    if(s2 == "END_OF_TEXT") break;
    transform(s2.begin(), s2.end(), s2.begin(), ::tolower);
    if(s1 == s2) {
      ans ++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string c;
  cin >> c;
 
  if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o") {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
const int MOD = 1000000007;
int main() {
    // long long a = 201;
    // long long b = 200;
    // cout << 1LL * a * a * a * a * a << endl;
    // cout << 1LL * b * b * b * b * b << endl;
    // cout << (1LL * a * a * a * a * a) - (b * b * b * b * b) << endl;

    long long x;
    cin >> x;
    rep(i, -200, 200) {
        rep(j, -200, 200) {
            long long a = 1LL * i;
            long long b = 1LL * j;
            if((1LL * a * a * a * a * a) - (b * b * b * b * b) == x) {
                cout << a << " " << b << endl;
             return 0;
            }
        }
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (s, t): (String, String);
    input!(s, t);
    println!("{}{}", t, s);
}


Measured memory_bytes: 4352
using System;

public class Program
{
    public static long loop;

    static long a;
    static long b;

    static string output;

    public static void Main(string[] args)
    {
        loop = 0;

        Input();
        Proc();
        Output();
    }

    static void Input()
    {
        string[] input = null;

        // スペース区切りの整数の入力(横、個別)
        input = Console.ReadLine().Split(' ');

        a = long.Parse(input[0]);
        b = long.Parse(input[1]);
    }

    static void Proc()
    {
        long result = Math.Max(a - (b * 2), 0);
        output = result.ToString();
    }

    static void Output()
    {
        // 出力
        Console.WriteLine(output);
        output = string.Empty;
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
 
int main() {
	ios::sync_with_stdio(0); 
	cin.tie(0);
 
ll n;
cin>>n;

ll a[n];

for(auto &e:a)cin>>e;

sort(a,a+n);
ll ans=0;
ll cnt=1;
for(ll i=n-1;i>0&&cnt<n;i--)
{
	ans+=a[i];
	cnt++;
	if(cnt>=n)break;
	if(i!=n-1)
	{
		ans+=a[i];
		//index=i;
		cnt++;
	}
	
}


cout<<ans;
	
}
 

Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


// ユークリッドの互除法
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

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


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

    int N; cin >> N;
    ll a, b;
    cin >> a >> b;
    if(N == 1) {
        COUT(a);
        return 0;
    }
    ll ans = lcm(a, b);
    for(int i = 2; i < N; i++) {
        ll t; cin >> t;
        ans = lcm(ans, t);
    }
    COUT(ans);
}

Measured memory_bytes: 256
import heapq
from sys import stdin
input = stdin.readline

#入力
# s = list(input()[0:-1])
# n = int(input())
# A,B,M = map(int, input().split())
# a = list(map(int,input().split()))
# b = list(map(int,input().split()))
# w = [int(input()) for i in range(n)]

# xyc=[]
# for i in range(M):
#     x,y,c = map(int, input().split())
#     xyc.append((x,y,c))
def main():
    n = int(input())
    ans = 0
    while n >0:
        if n %10 == 2:
            ans += 1
        n= n//10
    print(ans)
if __name__ == '__main__':
    main()

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

using namespace std;

const int INF = 1e9 + 5;
const int N = 2e5 + 5;
const int MOD = 998244353;
const double EPS = 1e-9;

const double PI = acos(-1);



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    set<string> st;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size();
}

Measured memory_bytes: 19244
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	          ll a,b,c;
	          cin >> a >> b >> c;

	          ll ans=0,A=a,B=b,C=c;
	          while(1){

	        	 if(a%2==1 || b%2==1 || c%2==1) break;
	        	 ll xa=b/2+c/2;
	        	 ll xb=a/2+c/2;
	        	 ll xc=a/2+b/2;
	        	 if(xa==A && xb==B && xc==C){
	        		 cout << -1 << endl;
	        		 return 0;
	        	 }

	        		 ans++;
	        		 a=xa; b=xb; c=xc;

	          }

	          cout << ans << endl;

	          return 0;
}


Measured memory_bytes: 256
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    y, m, d = map(int, input().split("/"))

    if 2018 >= y:
        print("Heisei")
    elif 2019 == y and m <= 3:
        print("Heisei")
    elif 2019 == y and m == 4 and d <= 30:
        print("Heisei")
    else:
        print("TBD")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
num = gets.to_i
ary = gets.split.map(&:to_i)
 
count = 0
index_last = num - 2
 
while index_last >= 0
 
  for i in 0 .. index_last
 
    if ary[i] > ary[i + 1]
      ary[i], ary[i + 1] = ary[i + 1], ary[i]
      count += 1
    end
  end
 
  index_last -= 1
end
 
(num-1).times{ |j| print "#{ary[j]} "}
print "#{ary[-1]}\n"
puts count


Measured memory_bytes: 6872
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

const int N = (int) 1e6 + 10;
int n, m;
char s[N], t[N];

int gcd(int a, int b) {
	return (b == 0) ? a : gcd(b, a % b);
}

int main() {
	scanf("%d%d%s%s", &n, &m, s, t);
	long long l = n * (long long) m / gcd(n, m);
	map<long long, char> data;
	for (int i = 0; i < n; ++i) {
		data[i * (l / n)] = s[i];
	}
	for (int i = 0; i < m; ++i) {
		char c = data[i * (l / m)];
		if ((c != 0) && (c != t[i])) {
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", l);
	return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

ll n;
vector<vl> g, e;
vb seen;

ll dfs(ll i) {
  ll res = 1;
  for(auto v : g[i]) {
    if(seen[v]) continue;
    seen[v] = true;
    ll now = dfs(v);
    e[i].push_back(now);
    res += now;
  }
  if(i != 0) e[i].push_back(n - res);
  return res;
}

int main() {
  cin >> n;
  g.resize(n);
  e.resize(n);
  seen.resize(n, false);
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  seen[0] = true;
  dfs(0);
  mint ans = 0;
  rep(i, n) {
    ll m = e[i].size();
    if(m <= 1) continue;
    mint cnt = 1;
    ll sum = 0;
    for(auto v : e[i]) {
      cnt += mint(2).pow(v) - 1;
      sum += v;
    }
    ans += mint(2).pow(sum) - cnt;
  }
  ans /= mint(2).pow(n);
  cout << ans << endl;
}

Measured memory_bytes: 36512
import java.io.*;

class Main
{
   public static void main(String[] args) throws IOException
   {
	BufferedReader br =
	 new BufferedReader(new InputStreamReader(System.in));

	String str = br.readLine();
	int x = Integer.parseInt(str);

	//System.out.println( x^3 );  //^???java??§???????????§?????????XOR??????????¨????
	System.out.println( x*x*x );
	//System.out.println( Math.pow(x, 3) );
	//System.out.println((int)Math.pow(x, 3));
   }
}

Measured memory_bytes: 24272
#include<bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){
    string s;
    cin >> s;
    vector<int> alp(26, 0);
    for(int i = 0;i < s.size();i++) alp[s[i]-'a']++;
    if(s.size() < 26){
        for(int i = 0;i < 26;i++){
            if(!alp[i]){
                cout << s+(char)('a'+i) << endl;
                return 0;
            }
        }
    }else{
        int M = s[25]-'a';
        for(int i = s.size()-2;i >= 0;i--){
            int x = s[i]-'a';
            if(x < M){
                int c = 100;
                for(int j = i+1;j < s.size();j++)   if(s[j]-'a' > x)    c = min(c, s[j]-'a');
                cout << s.substr(0, i)+(char)('a'+c) << endl;
                return 0;
            }else{
                M = x;
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);


int main()
{
    fastio;
    int n,i=0,j=0;
    int dp[10][10]={0};
    cin>>n;
    for(i=1;i<=n;i++)
    {
        int x=i;
        while(x>9)
            x=x/10;
        dp[x][i%10]++;
    }
    int ans=0;
    for(i=1;i<=n;i++)
    {
        int x=i;
        while(x>9)
            x=x/10;
        ans+=dp[i%10][x];
    }

    cout<<ans<<"\n";
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int min =100000;
  for(int i=1;i<N;i++){
    int A = i;
    int B = N-i;
    int count=0;
    for(int j=0;j<6;j++){
      count+= A%10;
      count+= B%10;
      A/=10;
      B/=10;
    }
    if(min > count){
      min = count;
    }
  }
  cout << min <<endl;
}


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

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

using namespace std;

int main(){
  int a, b;
  char op;
  cin>>a;
  cin>>op;
  cin>>b;

  if(op=='+'){
    cout<<a+b;
  }else{
    cout<<a-b;
  }


  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
        
        while (scan.hasNext()){
      int n=scan.nextInt();
      int r =scan.nextInt();
      if((n|r)==0)break;
      Stack <Integer> stack =new Stack<Integer>();
      for(int i=1;i<=n;i++)stack.push(i);
      
      for(int i=0;i<r;i++){
    	  int p=scan.nextInt();
    	  int c=scan.nextInt();
    	  Stack<Integer> tmp1 =new Stack<Integer>();
    	  Stack<Integer> tmp2 =new Stack<Integer>();
    	  for(int j=0;j<p-1;j++)tmp1.push(stack.pop());
    	  for(int k=0;k<c;k++)tmp2.push(stack.pop());
    	  
    	  for(int j=0;j<p-1;j++)stack.push(tmp1.pop());
    	  for(int k=0;k<c;k++)stack.push(tmp2.pop());
      }
      System.out.println(stack.peek());
    			  
      }
        }
      

}

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

int main()
{
	long long n;
	
	cin >> n;
	
	long long mini = 10000000000000000;
	
	for(int i = 1 ; i<=5 ; i++)
	{
		long long x;
		
		cin >> x;
		
		mini = min(mini , x);
	}
	
	mini = (n+mini-1)/mini;
	
	cout << mini + 4;
	return 0;
}

Measured memory_bytes: 256
ABCD = input()
for i in range(8):
    tmp = bin(i)[2:].zfill(3)
    tmp_num = int(ABCD[0])
    result = ABCD[0]
    for op in range(3):
        if tmp[op] == '1':
            tmp_num += int(ABCD[op+1])
            result = result + '+' + ABCD[op+1]
        else:
            tmp_num -= int(ABCD[op+1])
            result = result + '-' + ABCD[op+1]
    if tmp_num == 7:
        break
print(result+'=7')

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(void){
  for(;;){
    int N, M, P;
    cin >> N >> M >> P;
    if(N == 0 && M == 0 && P == 0){
      return 0;
    }
    int X[N];
    for(int i = 0 ; i < N ; i++){
      cin >> X[i];
    }
    int sum = 0;
    for(int i = 0 ; i < N ; i++){
      sum += 100 * X[i];
    }
    sum = sum * (100 - P) / 100;
    if(X[M-1] > 0){ cout << sum / X[M-1] << endl;}else{ cout << 0 << endl;}
  }
}



Measured memory_bytes: 2980
package main

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

var inputs []int
var inputLen int

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var inputStr string
	fmt.Fscan(r, &inputStr)

	inputLen = len(inputStr)
	inputs = make([]int, inputLen)
	for i := 0; i < inputLen; i++ {
		tmp, _ := strconv.Atoi(string(inputStr[i]))
		inputs[i] = tmp
	}

	result, _ := calc(0)
	fmt.Fprintln(w, result)
}

func calc(index int) (tmpSum int, count int) {
	if index == inputLen {
		return 0, 1
	}

	var tmp int
	for i := index; i < inputLen; i++ {
		tmp = tmp*10 + inputs[i]
		others, othersCount := calc(i + 1)
		tmpSum += tmp*othersCount + others
		count += othersCount
	}

	return tmpSum, count
}


Measured memory_bytes: 1848
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	int in,ans=0,hi=0;
	cin>>n;
	rep(i,n){
		cin>>in;
		if(hi<=in)ans++;
		chmax(hi,in);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
"use strict"
function main(arg) {
    var data = arg.trim().split("\n")[0].split(" ").map(Number)
    var N = data[0]
    var K = data[1]
    if (N < 10) {
        console.log(K + 100 * (10 - N))
    } else {
        console.log(K)
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main()
{   
    int k,a,b;
    cin>>k>>a>>b;
    int s=0;
    for(int i=a; i<b+1; i++){
        if(i%k==0){
            s++;
        }
        
    }

    if(s!=0){
        cout<<"OK"<<endl;
    }
    else{
        cout<<"NG"<<endl;
    }


}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    string S, T; cin >> S >> T;
    rep(i, N){cout << S.at(i) << T.at(i);}
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

int main()
{
    solve();
}

void solve()
{
    int a[3][3];
    rep(i, 3)
    {
        rep(j, 3)
        {
            in(a[i][j]);
        }
    }
    int n;
    in(n);
    int b[n];
    rep(i, n) in(b[i]);
    rep(i, n)
    {
        rep(j, 3)
        {
            rep(k, 3)
            {
                if (b[i] == a[j][k])
                {
                    a[j][k] = 0;
                }
            }
        }
    }
    int flag = 0;

    rep(j, 3)
    {
        int sum = 0;
        rep(i, 3)
        {
            sum += a[i][j];
        }
        if (sum == 0)
        {
            flag = 1;
        }
    }
    rep(i, 3)
    {
        int sum = 0;
        rep(j, 3)
        {
            sum += a[i][j];
        }
        if (sum == 0)
        {
            flag = 1;
        }
    }
    if (a[0][0] + a[1][1] + a[2][2] == 0)
    {
        flag = 1;
    }
    if (a[0][2] + a[1][1] + a[2][0] == 0)
    {
        flag = 1;
    }
    if (flag)
    {
        out("Yes");
    }
    else
    {
        out("No");
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define pii pair<int,int>
using namespace std;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



int main() {

	int a,b,c;

	cin >> a >> b >> c;
	if (a == b)cout << c << endl;
	if (b == c)cout << a << endl;
	if (c == a)cout << b << endl;


	return 0;
}

Measured memory_bytes: 256
from math import sqrt,floor
def comb(n,m):
  if m == 0:
    return 1
  return comb(n-1,m-1)*n // m
n,m=map(int,input().split())
mod=10**9+7
def factorization(x):
  ans=[]
  for i in range(2,floor(sqrt(x))+1):
    if x%i==0:
      cnt=0
      while x%i==0:
        x//=i
        cnt+=1
      ans.append([i,cnt])
      if x==1:
        break
  if x!=1:
    ans.append([x,1])
  return ans
g=factorization(m)
ans=1
for i in g:
  ans=(ans*(comb(i[1]+n-1,i[1])%mod))%mod
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int find(string str)
{
int num=0;
for(int i=0;i<str.length();i++)
{
if(str[i]=='+')
num++;
else if(str[i]=='-')
num--;
}
return num;
}
int main()
{
string str;
cin >> str;
cout << find(str);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
int main() {
    long long N;
    cin >> N;
    vector<long long>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    long long ans = 1;
    for(int i = 0; i < N; i++) {
        if(INF/A[i] < ans) {
            cout << -1 << endl;
            return 0;
        }
        ans*=A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  C *= 2;
  int XY;
  if(X > Y) {
    cout << min(C * X, min(C * Y + A * (X - Y), A * X + B * Y)) << endl;
  }  else {
    cout << min(C * Y, min(C * X + B * (Y - X), A * X + B * Y)) << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
// const int mod=998244353;
const int INF=4e18+10;
const int MOD=mod;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


bool no(string s)
{
    return !(s=="0011" || s=="0101"|| s=="1110" || s=="1111");
}

int pow(int a, int b)
{
    int prod=1;
    int mult=a%mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod;
        }
        mult*=mult;
        mult%=mod;
        b/=2;
    }
    return prod;
}
int inverse(int q)
{
   return pow(q, mod-2);
}

signed main()

{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
       cout.tie(NULL);
     #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        }
     #endif
    auto clk=clock(); 
    // -------------------------------------Code starts here---------------------------------------------------------------------     
    int n, m;
    cin>>n>>m;
    vector<int> a(n);
    for(auto&i:a)
        cin>>i;
    int sum=0;
    for(auto i:a)
        sum+=i;
    int cnt=0;
    double offset =(1.0 * sum)/(4*m);
    for(int i=0;i<n;i++)
    {
        if(a[i]>=offset)
            cnt++;
    }
    if(cnt>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    // -------------------------------------Code ends here------------------------------------------------------------------

 
 
    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll A, B, C, D, ans=0;
    in(A); in3(B, C, D);
    rep(i, 101) if(A<=i && i<=B && C<=i && i<=D) ans++;
    put(max(0, ans-1));
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll n;
    cin>>n;
    vector<bool> prime(1e6+1, true);
    for(ll i=2; i<=(ll)1e6; i++)
    {
    	if(prime[i]==true)
    	{
    		for(ll j=2*i; j<=(ll)1e6; j+=i)
    			prime[j]=false;
    	}
    }
    for(ll i=2; ; i++)
    {
    	if(prime[i]&&i>=n)
    	{
    		cout<<i<<endl;
    		return;
    	}
    }
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3920
from itertools import groupby

n = int(input())
a = [i for i, _ in groupby(map(int, input().split()))]
n = len(a)

money = 1000
stock = 0
if n > 1 and a[0] < a[1]:
    stock, money = divmod(money, a[0])
for i in range(1, n-1):
    if a[i-1] < a[i] > a[i+1]:
        money += stock * a[i]
        stock = 0
    elif a[i-1] > a[i] < a[i+1]:
        stock, money = divmod(money, a[i])
if n > 1 and a[-2] < a[-1]:
    money += stock * a[-1]
    stock = 0
print(money)


Measured memory_bytes: 9220
#include <iostream>

using namespace std;

long long input1;
long long input2;

int main(){
    cin >> input1 >> input2;
    int result;
    if(input1>input2){
        result = result + input1;
        input1 = input1 - 1;
        if (input1>=input2){
            result = result + input1;
            cout << result << "\n";
        }
        else{
            result = result + input2;
            cout << result << "\n";
        }
    }
    else{
        result = result + input2;
        input2 = input2 - 1;
        if (input1>=input2){
            result = result + input1;
            cout << result << "\n"; 
        }
        else{
            result = result + input2;
            cout << result << "\n";
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 20000; i++) {
		if (i * 8 / 100 == a && i * 10 / 100 == b) {
			cout << i;
			return 0;
		}
		if (i == 20000) {
			cout << -1;
			return 0;
		}
	}
}


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

using namespace std;

typedef long long int llint;

int N, M;

int main() {
	cin >> N >> M;
	vector<pair<llint, int> > shop(N);
	for (int i = 0; i < N; i++) {
		cin >> shop[i].first >> shop[i].second;
	}
	sort(shop.begin(), shop.end());

	llint ans = 0;
	int now = 0;
	for (int i = 0; i < N; i++) {
		if (now + shop[i].second <= M) {
			now += shop[i].second;
			ans += shop[i].first * shop[i].second;
		}
		else {
			ans += shop[i].first * (M - now);
			break;
		}
	}
	cout << ans << endl;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 3;
    if(a == b) ans--;
    if(a == c) ans--;
    if(b == c) ans--;
    if(a == b && b == c) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.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<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int f(ll x){
	int t=0;
	while(x){
		t+=x%10;
		x/=10;
	}
	return t;
}

ll n;

int main(){
	cin>>n;
	ll res=f(n);
	string s=to_string(n);
	ll t=(s[0]-'0')+(s.size()-1)*9-1;
	res=max(res,t);
	cout<<res<<endl;
}

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

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i] -= (1+i);
    }
    sort(a.begin(), a.end());
    ll ans;
    

    rep(j,n){
       ans += abs(a[j] - a[n/2]);
    }

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


Measured memory_bytes: 1024
#include "bits/stdc++.h"

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

using namespace std;

void BFS(vector<vector<pair<int, int>>> &G, int &max) {
	queue<pair<int, int>> que;
	que.push(make_pair(1, -1)); // チェックするノード番号, 直前の色

	while (!que.empty()) {
		int num = que.front().first;
		int color = que.front().second;
		que.pop();
		int edge = G[num - 1].size();
		if (color != -1)edge++;
		if (edge > max)max = edge;

		rep(i, G[num - 1].size()) {
			if (G[num - 1][i].second == color)G[num - 1][i].second = G[num - 1].size() + 1;
			que.push(make_pair(G[num - 1][i].first, G[num-1][i].second));
		}
	}
}

int main() {
	int N;
	cin >> N;
	vector<vector<pair<int, int>>> G(N);
	vector<pair<int, int>> input(N - 1);

	int a, b;
	rep(i, N-1) {
		cin >> a >> b;
		G[a - 1].push_back(make_pair(b, G[a - 1].size() + 1));
		input[i] = make_pair(a, b);
	}

	//cout << "aaa" << endl;
	int K = 0;
	BFS(G, K);
	cout << K<< endl;
	rep(i, N - 1) {
		rep(j, G[input[i].first - 1].size()) {
			if (input[i].second == G[input[i].first - 1][j].first) {
				cout << G[input[i].first - 1][j].second << endl;
				break;
			}
		}
	}



}

Measured memory_bytes: 5504
use std::io;
use std::str::FromStr;

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, m) = input_tuple();
    let mut counts = vec![0; n];
    for _ in 0..m {
        let (a, b) = input_tuple();
        counts[a - 1] += 1;
        counts[b - 1] += 1;
    }
    for c in counts {
        if c % 2 != 0 {
            println!("NO");
            return;
        }
    }
    println!("YES");
}


Measured memory_bytes: 4352
class BIT:
    def __init__(self,n):
        self.size=n
        self.tree=[0]*-~n
    def sum(self,i):
        s=0
        while i:
            s+=self.tree[i]
            i-=i&-i
        return s
    def add(self,i,x):
        while i<=self.size:
            self.tree[i]+=x
            i+=i&-i
n,k,*a=map(int,open(0).read().split())
a=[t-k for t in a]
for i in range(1,n):
    a[i]+=a[i-1]
d={}
for i,v in enumerate(sorted(set(a+[0])),1):
    d[v]=i
for i in range(n):
    a[i]=d[a[i]]
b=BIT(max(a))
b.add(d[0],1)
c=0
for i,p in enumerate(a):
    c+=b.sum(p)
    b.add(p,1)
print(c)

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

using namespace std;

int main()
{

	string s;
	cin>>s;

	int k;
	cin>>k;

	int len = s.size();
	
	vector<string> v;


	for(int i=0;i<len;i++)
	{
		for(int j=i;j<len && (j-i+1)<=k;j++)
		{
			string a = s.substr(i,j-i+1);
			v.push_back(a); 
		}
	}

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

	cout<<v[k-1]<<'\n';
	return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N, D, X; cin >> N >> D >> X;
  int A[N];
  rep(i,N) cin >> A[i];

  int cnt = X;
  rep(i,N){
    cnt += (D-1)/A[i] + 1;
  }

  cout << cnt << endl;




  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int w = sc.nextInt();
      int n = sc.nextInt();
      int[] values = new int[w];

      for (int i = 0; i < values.length; i++) {
        values[i] = i + 1;
      }
      for (int i = 0; i < n; i++) {
        String str = sc.next();
        String[] ab = str.split(",");
        int a = Integer.parseInt(ab[0]) - 1;
        int b = Integer.parseInt(ab[1]) - 1;
        int tmp = values[a];
        values[a] = values[b];
        values[b] = tmp;
      }
      for (int i = 0; i < values.length; i++) {
        System.out.println(values[i]);
      }
    }
  }
}



Measured memory_bytes: 26212