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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n,m,sum1,sum2,sum3,val1,val2,val3,val4,mn=1e18;
    cin>>n>>m;
    for(long long i=1;i<n;i++)
    {
        vector<long long> v;
        sum1=m*i;
        if(m%2==0)
        {
            val1=m/2;
            val2=m/2;
            val3=n-i;
            val4=n-i;
            sum2=val1*val3;
            sum3=val2*val4;
        }
        else
        {
            val1=m/2+1;
            val2=m/2;
            val3=n-i;
            val4=n-i;
            sum2=val1*val3;
            sum3=val2*val4;
        }
        v.push_back(sum1);
        v.push_back(sum2);
        v.push_back(sum3);
        sort(v.begin(),v.end());
        mn=min(mn,v[2]-v[0]);
    }
    for(long long i=1;i<n-1;i++)
    {
        vector<long long> v;
        sum1=m*i;
        if((n-i)%2==0)
        {
            val1=m;
            val2=m;
            val3=(n-i)/2;
            val4=(n-i)/2;
            sum2=val1*val3;
            sum3=val2*val4;
        }
        else
        {
            val1=m;
            val2=m;
            val3=((n-i)/2)+1;
            val4=(n-i)/2;
            sum2=val1*val3;
            sum3=val2*val4;
        }
        v.push_back(sum1);
        v.push_back(sum2);
        v.push_back(sum3);
        sort(v.begin(),v.end());
        mn=min(mn,v[2]-v[0]);
    }
    for(long long i=1;i<m;i++)
    {
        vector<long long> v;
        sum1=n*i;
        if(n%2==0)
        {
            val1=n/2;
            val2=n/2;
            val3=m-i;
            val4=m-i;
            sum2=val1*val3;
            sum3=val2*val4;
        }
        else
        {
            val1=n/2+1;
            val2=n/2;
            val3=m-i;
            val4=m-i;
            sum2=val1*val3;
            sum3=val2*val4;
        }
        v.push_back(sum1);
        v.push_back(sum2);
        v.push_back(sum3);
        sort(v.begin(),v.end());
        mn=min(mn,v[2]-v[0]);
    }
    for(long long i=1;i<m-1;i++)
    {
        vector<long long> v;
        sum1=n*i;
        if((m-i)%2==0)
        {
            val1=n;
            val2=n;
            val3=(m-i)/2;
            val4=(m-i)/2;
            sum2=val1*val3;
            sum3=val2*val4;
        }
        else
        {
            val1=n;
            val2=n;
            val3=(m-i)/2+1;
            val4=(m-i)/2;
            sum2=val1*val3;
            sum3=val2*val4;
        }
        v.push_back(sum1);
        v.push_back(sum2);
        v.push_back(sum3);
        sort(v.begin(),v.end());
        mn=min(mn,v[2]-v[0]);
    }
    cout<<mn;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N;
  cin >> N;
  vector<ll> A(N, 0);
  rep(i, N) cin >> A[i];
  ll sum = 0, ans = 0, MOD = 1e9+7;
  rep(i, N){
    sum += A[i];
    sum %= MOD;
  }
  rep(i, N){
    sum -= A[i];
    sum = (sum + MOD) % MOD;
    ans += (A[i] * sum) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4740
N=int(input())
A=[]
first=0
first_num=0
second=0
second_num=0
for i in range(N):
    a=int(input())
    A.append(a)
    if a>first:
        first=a
        first_num=i+1
    elif a>second:
        second=a
        second_num=i+1

for j in range(N):
    if A[j]==first:
        print(second)
    else:
        print(first)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/12/13  Problem: a / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

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

	int H, W; cin >> H >> W;
	FOR(i, 0, H) {
		string s; cin >> s;
		cout << s << endl << s << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    float N;
    cin>>N;
    cout<<ceil(N/2)/N<<endl;
    
    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i;
  int N,X,D = 0,flag = 0;
  scanf("%d %d",&N,&X);
  int L[N];
  for(i=0;i<N;i++){
    scanf("%d",&L[i]);
  }
  for(i=0;i<N;i++){
    D+=L[i];
    if(D>X){
      printf("%d",i+1);
      flag = 1;
      break;
    }
  }
  if(flag==0) printf("%d",i+1);
 
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	ll q ,h , s, d ,n ;
	cin >> q >>h >> s>> d >>n ;
	cout << ( n / 2) *min({8*q,4*h,2*s,d}) + (n % 2) *min({4*q ,2*h,s}) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        StringTokenizer st;
        try {
            char c;
            String line;
            line = br.readLine();
            for (int i = 0; i < line.length(); i++) {
                c = line.charAt(i);
                if(Character.isLowerCase(c)){
                    c = Character.toUpperCase(c);
                }
                sb.append(c);
            }
            System.out.println(sb.toString());

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

Measured memory_bytes: 24072
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]

seq = 0
for i in range(len(D)-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                print('Yes')
                exit()
print('No')


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

ll n, k;

int main(){
    cin >> n >> k;
    ll s = 0, e = 1000000000000000007, mid;
    while(e-s > 1){
        mid = (s+e)/2;
        ll mmid = mid;
        rep(i,n-1){
            mid--;
            mid -= mid/k;
        }
        if(mid <= 0){
            s = mmid;
        } else{
            e = mmid;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 3092
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import factorial

def main():
  s = list(map(int, input().strip()))
  k = int(input())
  dp = []
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp.append([[0]*(len(s)+1) for _ in range(k+1)])
  dp[0][0][0] = 1
  
  for i, c in enumerate(s):
    for j in range(k+1):
        for d in range(10):
          nj = j
          if d != 0:
            nj+=1
          if nj > k:
            continue
            
          if d < c:
            dp[1][nj][i+1] += dp[0][j][i]
          if d == c:
            dp[0][nj][i+1] += dp[0][j][i]
          dp[1][nj][i+1] += dp[1][j][i]
            
  print(dp[0][k][len(s)]+dp[1][k][len(s)])

if __name__=='__main__':
  main()





Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

int D[510][510];

signed main() {
	int N, C;
	cin >> N >> C;

	int c[31][31];
	rep(i, C) rep(j, C) cin >> c[i][j];

	rep(y, N) rep(x, N) cin >> D[y][x];
	rep(y, N) rep(x, N) D[y][x]--;

	int memo[3][31];
	memset(memo, 0, sizeof memo);

	rep(y, N) rep(x, N) rep(c1, C) {
		memo[(x + y) % 3][c1] += c[D[y][x]][c1];
	}

	int ret = LLONG_MAX;
	rep(c1, C) rep(c2, C) rep(c3, C) {
		if (c1 == c2) continue;
		if (c2 == c3) continue;
		if (c3 == c1) continue;
		int tmp = 0;
		tmp += memo[0][c1];
		tmp += memo[1][c2];
		tmp += memo[2][c3];
		ret = min(ret, tmp);
	}

	cout << ret << endl;
}


Measured memory_bytes: 2304
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String X = sc.next();
    String Y = sc.next();
    
    HashMap<String, Integer> A = new HashMap<>();
    A.put("A", 10);
    A.put("B", 11);
    A.put("C", 12);
    A.put("D", 13);
    A.put("E", 14);
    A.put("F", 15);
    
    if (A.get(X) > A.get(Y)){   
      System.out.println(">");
    }else if(A.get(X) < A.get(Y)){
      System.out.println("<");
    }else{
      System.out.println("=");
    }
  }
}

Measured memory_bytes: 35288
#include <stdio.h>
#include <stdlib.h>

#define N 100000
#define INF 0x3f3f3f3f

int main() {
	static int aa[N];
	int n, i, a, b, c, x;

	scanf("%d", &n);
	a = -1;
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		if (a < aa[i])
			a = aa[i];
	}
	b = INF;
	c = -1;
	for (i = 0; i < n; i++)
		if (aa[i] < a) {
			x = abs(a - aa[i] * 2);
			if (b > x) {
				b = x;
				c = i;
			}
		}
	printf("%d %d\n", a, aa[c]);
	return 0;
}


Measured memory_bytes: 512
const FACT_MAX: usize = 2000000;
const MOD: i64 = 1000000007;

#[allow(dead_code)]
fn pow_mod(base: i64, power: i64, modulo: i64) -> i64 {
    let mut base = base;
    let mut power = power;
    let mut ans = 1;
    while power > 0 {
        if power & 1 == 1 {
            ans = ans * base % modulo;
        }
        power >>= 1;
        base = base * base % modulo;
    }
    ans
}

thread_local! {
    #[allow(unused)]
    pub static FACT: Vec<i64> = {
        let mut fac: Vec<i64> = vec![1; FACT_MAX+1];

        for i in 1..FACT_MAX+1 {
            fac[i] = (fac[i-1] * i as i64) as i64 % MOD;
        }
        fac
    };

    #[allow(unused)]
    pub static RFACT: Vec<i64> = {
        let mut rfac = vec![1; FACT_MAX+1];
        rfac[FACT_MAX] = FACT.with(|fact| {
            pow_mod(fact[FACT_MAX], MOD-2, MOD)
        });

        for i in (1..FACT_MAX).rev() {
            rfac[i] = (rfac[i+1] * (i+1) as i64) % MOD;
        }
        rfac
    }
}

#[allow(dead_code)]
fn combi(n: usize, m: usize) -> i64 {
    FACT.with(|fact| RFACT.with(|rfact| fact[n] * rfact[n - m] % MOD * rfact[m] % MOD))
}

fn solve(x: usize, y: usize) -> i64 {
    if x < y {
        return solve(y, x);
    }

    if x < (y / 2) {
        return 0;
    }
    if y < (x / 2) {
        return 0;
    }

    if (x + y) % 3 != 0 {
        return 0;
    }

    let d = x - y;
    let r = (y - d) / 3;
    let q = r + d;

    combi(r + q, r)
}

#[test]
fn solve_test() {
    assert_eq!(solve(3, 3), 2);
    assert_eq!(solve(999999, 999999), 151840682);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (x, y) = parse_line!(usize, usize);
    println!("{}", solve(x, y));
}


Measured memory_bytes: 37244
#include <stdio.h>

int main(){
   int n,a,b;
 
   scanf("%d %d",&a,&b);
   for (n=1;n<10*(a+b);n++)
      if (n*8/100==a && n/10==b) {
         printf("%d\n",n);
         return 0;
      }
   puts("-1");
   return 0;
}


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

int main(void)
{
	int n;
	int cnt;
	string s;

	cnt = 0;
	cin >> n >> s;
	for (int i = 0; i <= n - 3; i++)
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') cnt++;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#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++)
int INF=1e9+7,MOD=998244353;

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  vvl dp1(C-A+1,vl(D-B+1)),dp2(C-A+1,vl(D-B+1));
  dp1[0][0]=1;
  rep(j,D-B) dp1[0][j+1]=dp1[0][j]*A%MOD;
  rep(i,C-A) {
    dp1[i+1][0]=dp1[i][0]*B%MOD;
    rep(j,D-B) {
      dp1[i+1][j+1]=(dp1[i][j+1]+dp2[i][j+1])*(B+j+1)%MOD;
      dp2[i+1][j+1]=(dp1[i+1][j]+dp2[i+1][j]*(A+i+1))%MOD;
    }
  }
  
  cout << (dp1[C-A][D-B]+dp2[C-A][D-B])%MOD << endl;
}

Measured memory_bytes: 144108
package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scanf("%d", &n)

	D := make([][]int, n)
	for i := 0; i < n; i++ {
		D[i] = make([]int, 2)
		fmt.Scanf("%d %d", &D[i][0], &D[i][1])
	}

	var count int = 0
	var result bool = false

	for i := 0; i < n ; i ++{
		if D[i][0] == D[i][1]{
			count = count+1 
		} else {
			count = 0
		}

		if count == 3{
			result = true
			break
		}
	}

	var msg string

	if result {
		msg = "Yes"
	} else {
		msg = "No"
	}

    fmt.Printf("%s\n", msg)
}


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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;

int main() {
	int N, K;
	cin >> N >> K;
	if (N < K)cout << 0 << endl;
	else cout << 10 << endl;
}



Measured memory_bytes: 256
n=input()
N=int(n)

if N<10:
    print(N)
elif N<100:
    print(9)
elif N<1000:
    print(10+N-100)
elif N<10000:
    print(909)
elif N<100000:
    print(910+N-10000)
else:
    print(90909)

Measured memory_bytes: 3060
import sys

n = int(input())
a,b = map(int, input().split())
ps = list(map(int, input().split()))

if all([a<p for p in ps]) or all([p<b for p in ps]):
  print(0)
  sys.exit()

small = list(filter(lambda x: x<=a, ps))
large = list(filter(lambda x: x>b, ps))
other = list(filter(lambda x: not x in small and not x in large, ps))

print(min(len(small), len(large), len(other)))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll up = 1e11;

set<ll> ans;

void lunlun(ll x)
{

    ans.insert(10 * x + x % 10);

    if (10 * x + x % 10 <= up)
    {
        lunlun(10 * x + x % 10);
    }

    if (x % 10 - 1 >= 0)
    {
        ans.insert(10 * x + x % 10 - 1);

        if (10 * x + x % 10 - 1 <= up)
        {
            lunlun(10 * x + x % 10 - 1);
        }
    }

    if (x % 10 + 1 < 10)
    {
        ans.insert(10 * x + x % 10 + 1);

        if (10 * x + x % 10 + 1 <= up)
        {
            lunlun(10 * x + x % 10 + 1);
        }
    }
}

int main(void)
{
    ll k;
    cin >> k;

    ll count = 1;

    for (int i = 1; i < 10; i++)
    {
        ans.insert(i);
        lunlun(i);
    }

    for (auto x : ans)
    {
        if (count == k)
        {
            cout << x << endl;
            break;
        }

        count++;
    }
}

Measured memory_bytes: 79616
#include<stdio.h>
using namespace std;

int main(void)
{
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	while (C > 0 && A > 0)
	{
		C = C - B;
		if(C<=0) break;
		A = A - D;
		if(A<=0) break;
	}
	if(C<=0) printf("Yes");
	else if(A<=0) printf("No");
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

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

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

  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ab(n);

  rep(i, n) {
    int a, b;
    cin >> a >> b;
    ab[i] = make_pair(a, b);
  }
  sortv(ab);

  priority_queue<int> pq;
  int res = 0;
  int cur = 0;
  rep(i, m+1) {
    while(ab[cur].first == i) {
      pq.push(ab[cur].second);
      cur++;
    }
    if(!pq.empty()) {
      res += pq.top();
      pq.pop();
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 1660
#include <iostream>

int
main(void)
{
	char input;
	std::cin >> input;
	
	char output;
	switch (input) {
	case 'A':
		output= 'T';
		break;
	case 'T':
		output= 'A';
		break;
	case 'C':
		output= 'G';
		break;
	case 'G':
		output= 'C';
		break;
	}

	std::cout << output << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll NumR=0,NumG=0,NumB=0;
   int n; cin >> n;
   string s; cin >> s;
   rep(i,n)
   {
      switch (s[i]){
      case 'R': NumR++; break;
      case 'G': NumG++; break;
      case 'B': NumB++; break;
      }
   }
   ll ans = NumR*NumG*NumB;
   for (int i = 0; i < n; i++){
      for (int j = 0; i+2*j+2 < n; j++)
      {
         char si=s[i], sj=s[i+j+1], sk=s[i+2*j+2];
         if (si!=sj&&si!=sk&&sj!=sk){
            ans--;
         }
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m,g[101][101],w[1<<15],dp[1<<15][101];
int main()
{
	scanf("%d%d",&n,&m);int sum=0;for(int i=1;i<=m;++i){int a,b,c;scanf("%d%d%d",&a,&b,&c);g[a][b]=g[b][a]=c;sum+=c;}
	for(int i=0;i<(1<<n);++i)for(int j=1;j<=n;++j)if(i&(1<<j-1))for(int k=j+1;k<=n;++k)if(i&(1<<k-1))w[i]+=g[j][k];
	memset(dp,-1,sizeof(dp));for(int i=1;i<(1<<n);i+=2)dp[i][1]=w[i];
	for(int i=0;i<(1<<n);++i)
	{
		for(int j=1;j<=n;++j)if((i&(1<<j-1))&&~dp[i][j])
		{
			int tmp=(~i)&((1<<n)-1);
			for(int k=tmp;k;k=(k-1)&tmp)
			{
				for(int l=1;l<=n;++l)if((k&(1<<l-1))&&g[l][j])dp[i|k][l]=max(dp[i|k][l],dp[i][j]+w[k]+g[l][j]);
			}
		}
	}
	printf("%d\n",sum-dp[(1<<n)-1][n]);return 0;
}

Measured memory_bytes: 13184
#include<stdio.h>

int main(void){


int a,b,c;


int d;


scanf("%d %d %d",&a,&b,&c);


if(a>c){


d=a;


a=c;


c=d;


}


if(a>b){


d=b;


b=a;


a=d;


}


if(b>c){


d=c;


c=b;


b=d;


}


printf("%d %d %d\n",a,b,c);


return 0;


}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,a=0,ans=0;
  cin>>n;
  for(int i=0; i<n; i++){
    int x,y;
    cin>>x>>y;
    if(x>a){
      a=x;
      ans=x+y;
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

// エラトステネスの篩
template <typename T>
std::vector<T> sieve_of_eratosthenes(T n) {
	std::vector<T> sieve(n, 0);

	for(int i = 2; i < n; i++) {
		sieve[i] = i;
	}

	T i = 2;
	while(i * i < n) {
		if(sieve[i]) {
			for(T j = i * i; j < n; j += i) {
				sieve[j] = 0;
			}
		}
		i++;
	}

	return sieve;
}

// 素数リスト
template <typename T>
std::vector<T> prime_list(T n) {
	std::vector<T> primes = sieve_of_eratosthenes(n);
	primes.erase(std::remove(primes.begin(), primes.end(), 0), primes.end());
	return primes;
}

int main() {
	int q;
	cin >> q;
	VI l(q);
	VI r(q);
	REP(i, q) { cin >> l[i] >> r[i]; }
	VI sieve = sieve_of_eratosthenes(100030);
	VI primes = prime_list(100030);
	VI count(100001, 0);
	for(int i = 1; i <= 100000; i += 2) {
		count[i] += (sieve[i] && sieve[(i + 1) / 2]) ? 1 : 0;
	}
	VI s(100002, 0);
	for(int i = 1; i <= 100001; i++) {
		s[i] = s[i - 1] + count[i - 1];
	}
	REP(i, q) { cout << s[r[i] + 1] - s[l[i]] << endl; }
	return 0;
}


Measured memory_bytes: 5608
#define __STDC_WANT_IEC_60559_DFP_EXT__
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int64_t a;
    _Decimal128 b;
#if 0
    scanf("%" SCNd64 " %DDf", &a, &b);
#else
    // 現行のGCCは _DecimalNN の入出力に対応していないので手動で読み込む
    {
        int d1, d2;
        scanf("%" SCNd64 " %d.%d", &a, &d1, &d2);
        int d = d1 * 100 + d2;
        b = (_Decimal128)d / 100.0DL;
    }
#endif
#if 0
    printf("%" PRIi64 "\n", (int64_t)floord128((_Decimal128)a * b));
#else
    int64_t bb = (int64_t)(b * 100.0DL);
    printf("%" PRIi64 "\n", a * bb / INT64_C(100));
#endif
}


Measured memory_bytes: 1864
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    if (s == "ARC")
    {
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ARC" << endl;
    }
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"

const int MAXN = 50 + 10;

int n, p;
int a[MAXN];

bool read() {
	if  (scanf("%d%d", &n, &p) < 2) {
		return 0;
	}
	forn(i, n) {
		scanf("%d", &a[i]);
	}
	return 1;
}

ll C[MAXN][MAXN];

void precalc() {
	C[0][0] = 1;
	for (int i = 1; i < MAXN; ++i) {
		C[i][0] = 1;
		for (int j = 1; j < MAXN; ++j) {
			C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
		}
	}
}

ll solve() {
	vi cnt(2, 0);
	forn(i, n) {
		++cnt[a[i] % 2];
	}

	ll ans = 0;
	forn(c0, cnt[0] + 1) {
		forn(c1, cnt[1] + 1) {
			if  (c1 % 2 == p) {
				ans += C[cnt[0]][c0] * C[cnt[1]][c1];
			}
		}
	}
	return ans;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	precalc();

	while (read()) {
		printf("%lld\n", solve());
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}
func NewConsole() Console {
	return Console{ bufio.NewWriter(os.Stdout) }
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

type Unique struct {
	arr []int
	existsMap map[int]struct{}
}

func (this *Unique) Push(i int) {
	if _, ok := this.existsMap[i]; !ok {
		this.arr = append(this.arr, i)
		this.existsMap[i] = struct{}{}
	}
}

func main() {
	con := NewConsole()
	defer con.Flush()

	// create list
	var n int
	fmt.Scanf("%d", &n)
	lines, _ := ReadLongLines(1)

	list := Unique{make([]int, 0, n), make(map[int]struct{})}
	elements := strings.Split(lines[0], " ")
	for _, v := range elements {
		i, _ := strconv.Atoi(v)
		list.Push(i)
	}


	// print
	for i := 0; i < len(list.arr); i++ {
		if i == 0 {
			con.Printf("%d", list.arr[i])
		} else {
			con.Printf(" %d", list.arr[i])
		}
	}
	con.Println("")
}


Measured memory_bytes: 8824
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
    	

	bool pairComparefirst(const p& firstElof, const p& secondElof)
{
    return firstElof.second < secondElof.second;
}
	
int main(){
	ll n,m;
	cin>>n>>m;
	vector<p> v;
	rep(i,0,n){
		ll a,b;
		cin>>a>>b;
		v.push_back(make_pair(b,a));
	}
	sort(v.begin(),v.end(),pairComparefirst);
	ll ans=0;
	ll s=0;
	while(m>0){
		v[s].first--;
		m--;
		ans+=v[s].second;
		if(v[s].first==0)s++;
	}
	cout<<ans<<endl;
		
		
		
}

Measured memory_bytes: 2420
#include <iostream>
using namespace std;
int main(void){
        int n = 0;
    cin >> n;
    for (int i=1; i<= n; i++){
        if(i%3==0 || i%10 == 3 || ((i/10) == 3)) {
            cout << ' ' << i;
        } else {
            int x = i;
            while (x >= 10) {
                x/=10;
                if (x%10==3) {
                    cout << ' ' << i;
                    break;
                }
            }
        }
    }
    cout <<  endl;
}

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

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

    long long n, all;
    vector<long long> a;

    cin >> n;
    a.resize(n);
    all = 0;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        all = all ^ a[i];
    }

    for (int i = 0; i < n; i++) {
        a[i] = a[i] ^ all;
        cout << a[i];
        if (i != n-1)
            cout << " ";
        else
            cout << endl;
    }
}


Measured memory_bytes: 4668
from collections import Counter
n = int(input())
l = list(map(int,input().split()))
odd = []
even = []
for i in range(n//2):
    odd.append(l[2*i])
    even.append(l[2*i+1])
c_odd = list(Counter(odd).items()) + [(-1,0)]
c_even = list(Counter(even).items()) + [(-1,0)]
c_odd = sorted(c_odd, key=lambda x:-x[1])
c_even = sorted(c_even, key=lambda x:-x[1])

c_odd = c_odd[:2]
c_even = c_even[:2]
# print(c_odd,c_even)

if c_odd[0][0] != c_even[0][0]:
    print(n-c_odd[0][1]-c_even[0][1])
    exit()
else:
    print(n-c_odd[0][1]-max(c_odd[1][1],c_even[1][1]))

Measured memory_bytes: 98940
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>

int main(){
    vl az(26);
    string S; cin >> S >> S;
    for (auto c : S) az[c - 'a']++;
    ll res = 1,mod=1e9+7;
    rep(i,26){
        res *= az[i] + 1;
        res %= mod;
    }
    cout << (res + mod - 1) % mod << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#define INF 1<<30
#define FinishFunction return 0
#define MAX 1000000
using namespace std;
      
struct edge {
  int from,to,cost,k;
};
    
edge es[MAX];
    
int main(){
  int n,u,k,E,c,v;
  E = 0;
  scanf("%d",&n);
    
  for(int i=0;i<n;i++){
    scanf("%d %d",&u,&k);
       
    for(int j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      es[E].from = u;
      es[E].to = v;
      es[E++].cost = c;
    }
  }
    
  // Ika berumanfo-do 
  int d[MAX];
  for(int i=0;i<n;i++)d[i] = INF;
  d[0] = 0;
  while(true){
    bool update = false;
    for(int i=0;i<E;i++){
      edge e = es[i];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
    d[e.to] = d[e.from] + e.cost;
    update = true;
      }
    }
    if(!update)break;
  }
  for(int i=0;i<n;i++)cout << i << " " << d[i] << endl;
  FinishFunction;// return 0
}

Measured memory_bytes: 9400
#D問題
import heapq
N = int(input())
AB = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    AB[a].append(b)
    AB[b].append(a)
    
C = list(map(int,input().split()))
C.sort(reverse=True)

var = [0 for i in range(N)]
var[0] = C[0]
Q = []
heapq.heappush(Q,0)
ind = 1

for i in range(N-1):
    q = heapq.heappop(Q)
    for j in AB[q]:
        if var[j] == 0:
            var[j] = C[ind]
            ind+=1
            heapq.heappush(Q,j)
            
print(sum(C)-C[0])
for v in var:
    print(v,end=" ")


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

int main(){
int h,a;
cin>>h>>a;
int c = 0;
if(h<=0)
  return 0;
 else{
 while(h>0)
 {
 c++;
   h = h-a;
 }
 }
  cout<<c;
  return 0;
}

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

using namespace std;

char s[60]; 
int len; 

int main() {

	scanf("%s", s+1); 
	len = strlen(s+1); 

	for(int i=1; i<=len-8; ++i) printf("%c", s[i]); 

	printf("\n"); 
	
	return 0; 

}

Measured memory_bytes: 256
#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 n, cnt = 1;
    string s;
    cin >> n >> s;
    for (int i = 1; i < n; i++)
    {
        if(s[i-1] != s[i])
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[500][500];
int I[500], J[500];

int main() {
	cin >> n;
	inc(i, n) {
	inc(j, n) {
		char c;
		cin >> c;
		a[i][j] = (c == '.');
	}
	}
	
	inc(i, n) {
	inc(j, n) {
		I[i] += a[i][j];
		J[j] += a[i][j];
	}
	}
	
	int ans = 1009;
	inc(i, n) {
		int ii = I[i] + (J[i] == n);
		setmin(ans, ii);
	}
	
	inc(j, n) {
		ans += (J[j] != 0);
	}
	
	cout << (ans == n * 2 + 1 ? -1 : ans) << endl;
	
	return 0;
}


Measured memory_bytes: 1280
from collections import deque
S=deque(input())
Q=int(input())
h=0
for i in range(Q):
    q=input().split()
    if q[0]=="1":
        h=1-h
    else:
        t=int(q[1])
        if t==h+1:
            S.appendleft(q[2])
        else:
            S.append(q[2])
if h==0:
    for i in S:
        print(i,end="")
else:
    for i in range(len(S)):
        print(S[-i-1],end="")

Measured memory_bytes: 95832
fn main() {
    let n: u32 = read();
    let mut ans = 0;
    for i in 0..n {
        ans += i+1;
    }
    println!("{}", ans);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 1_000_000_007;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

pub fn factorial(n: u32) -> u32 {
    if n == 0 {
        return 1;
    }
    let mut r = n;
    for i in 0..n - 1 {
        r *= n - i - 1;
    }
    r
}

pub fn combination(n: u32, m: u32) -> u32 {
    factorial(n) / factorial(m) / factorial(n - m)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int INF=1e9;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  string s;
  cin >> s;
  int n=s.size();
  for(int i=1;i<n/2;i++){
    string u=s.substr(0,n/2-i);
    string v=s.substr(n/2-i,n/2-i);
    if(u==v){
      cout<<u.size()*2<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define up(j,k,i) for(ll i=j;i<k;i++)
#define down(j,k,i) for(ll i=j;i>k;i--)
#define M 1000000007
#define pp(n) printf("%lld\n",ll(n))
#define ps(n) printf("%lld ",ll(n))
#define pd(x,y) printf("%lld %lld\n",ll(x),ll(y))
#define is(n) scanf("%lld",&n)
#define inf LLONG_MAX
#define id(n,m) scanf("%lld%lld",&n,&m)
#define it(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll> 
#define db cout<<"######\n"
#define null(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,255,sizeof(a))
typedef long double ld;
typedef long long int ll;
using namespace std;
ll i,j,k,z,t,n,m,sum,ans,x,y,maxm=0,minm=inf; bool flag;
int main()
{
	map<ll,ll> b;
	
	id(n,m);
	
	while(m--)
	{
		id(x,y);
		b[x]++;
		b[y]++;
	}
	
	for(auto c:b)
	if(c.S%2)
	{
		puts("NO");
		return 0;
	}
	
	
	puts("YES");
	
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  char a;
  map<string,int> m;
  for(int i=0;i<n;++i){ 
    string s;
    cin >>s;
    ++m[s];
    if(m[s]>1){
      cout<<"No"<<endl ;
      return 0;
    }
    if(i!=0){
    if(s[0]==a);
    else { 
      cout <<"No"<<endl;
      return 0;
    }
    }
    a=s[s.size()-1];
    
  }
  cout <<"Yes"<<endl ;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;

int n;
int a[105];

int main(void){
	stack<int> s;
	char c;
	while(scanf("%c",&c)!=EOF){
		if(c=='+'){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			s.push(a+b);
		}
		if(c=='-'){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			s.push(b-a);
		}
		if(c=='*'){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			s.push(a*b);
		}
		if(c>='0' && c<='9'){
			int d=c-'0';
			while(1){
				scanf("%c",&c);
				if(c>='0' && c<='9')d=d*10+(c-'0');
				else break;
			}
			s.push(d);
		}else scanf("%*c");
	}
	printf("%d\n",s.top());
	return 0;
}

Measured memory_bytes: 2692
/*
* ID: juryc
* PROG: Maze Master
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std; 
int main(){
int h,w; cin>>h>>w;
vector<string> v(h); 
for(string& i: v) cin>>i; 
int val=h*w;
vector<vector<int> > dp(val,vector<int>(val,0x3f3f3f3f)); 
for(int i=0;i<h*w;i++) dp[i][i]=0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(v[i][j]=='#') continue; 
int arx[]={-1,1,0,0};
int ary[]={0,0,-1,1};
for(int k=0;k<4;k++){
int nx=i+arx[k],ny=j+ary[k]; 
if(nx<0||nx>=h||ny<0||ny>=w) continue;
if(v[nx][ny]=='#') dp[i*w+j][nx*w+ny]=0x3f3f3f3f; 
else { dp[i*w+j][nx*w+ny]=1; }
}
}
}
for(int k=0;k<val;k++){
for(int i=0;i<val;i++){
for(int j=0;j<val;j++){
dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]); 
}
}
}
int mx=0;
for(int i=0;i<val;i++)
for(int j=0;j<val;j++)
if(dp[i][j]!=0x3f3f3f3f) mx=max(mx,dp[i][j]); 
cout<<mx<<"\n"; 
return 0;
}

   

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

namespace _0430_atcoder問題_06
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int ab = Convert.ToInt32(input[0]);
            int bc = Convert.ToInt32(input[1]);
            int ca = Convert.ToInt32(input[2]);
            Console.WriteLine(ab*bc/2);
        }
    }
}

Measured memory_bytes: 11220
import sys
stdin = sys.stdin
     
pi=3.1415
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

S,W=nm()
print('safe' if W<S else 'unsafe')

Measured memory_bytes: 9184
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
      	int H = input.nextInt();
      	int W = input.nextInt();
      	String[] HS = new String[H];
      	boolean[] rows = new boolean[H];
      	boolean[] cols = new boolean[W];
      	Arrays.fill(rows, false);
      	Arrays.fill(cols, false);
      
      	for (int i = 0; i < H; i++) {
        	HS[i] = input.next();
        }
      
      	for (int j = 0; j < H; j++) {
          if (HS[j].indexOf("#") != -1) {
          	rows[j] = true;
          }
          	
          for (int i = 0; i < W; i++) {
            if (HS[j].charAt(i) == '#') {
            	cols[i] = true;
            }
          }
        }
      
		
		for (int i = 0; i < H; i++) {
          	if (rows[i]) {
              for (int j = 0; j < W; j++) {
                if (cols[j]) {
                  System.out.print(HS[i].charAt(j));
                }
              }
            	System.out.println();
            }
        }
		
    }
}

Measured memory_bytes: 27112
s = input()[::-1]
t = input()[::-1]
for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if t[j] != s[i+j] != "?":break
    else: break
else:
    print("UNRESTORABLE")
    exit()
s = s[:i] + t + s[i+len(t):]
print(s.replace("?","a")[::-1])

Measured memory_bytes: 3064
n,k=gets.split.map(&:to_i)
s,p,r=gets.split.map(&:to_i)
t=gets.chomp
cs=t.count("s")
cp=t.count("p")
cr=t.count("r")
k.times do |i|
  j=i+k
  while j<n
    if t[j]==t[j-k]
      if t[j]=="s"
        cs-=1
      elsif t[j]=="p"
        cp-=1
      else
        cr-=1
      end
      t[j]="q"
    end
    j+=k
  end
end
puts cs*s+cp*p+cr*r


Measured memory_bytes: 2044
#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 n, d;
  cin >> n >> d;

  int w = 2 * d + 1;
  int ans = (int)((float)(n + (w - 1)) / w); // 切り上げ
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

int main(){
  int r;
  while(cin >> r){
    cout << r*r << endl;
  }

  return 0;
}


Measured memory_bytes: 256