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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeDSUof(arr))
#define frepi(a,b) for(int i=a;i<=b;++i)
// #define int long long
// --------------------------------------------------------------------------------
int parent[200009];
int sizeDSU[200009];

int root(int x){
	while(x!=parent[x])
		x = parent[parent[x]];
	return x;
}

void union1(int a,int b){
	int pa = root(a);
	int pb = root(b);

	if(pa==pb)return;

	if(sizeDSU[pa]<=sizeDSU[pb]){
		parent[pa] = parent[pb];
		sizeDSU[pb]+=sizeDSU[pa];
	}
	else{
		parent[pb] = parent[pa];
		sizeDSU[pa]+=sizeDSU[pb];
	}
}

void test_case(int tc)
{
	int n,m;cin>>n>>m;
	iota(parent,parent+n,0);
	for(int i=0;i<n+2;++i)sizeDSU[i]=1;
	int ans = -1;
	for(int i=0;i<m;++i){
		int u,v;cin>>u>>v;
		union1(u,v);
	}
	for(int i=0;i<n+2;++i){
		ans = max(ans,sizeDSU[i]);
	}
	cout<<ans;
}

int32_t main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
		freopen("/home/suryakant/input.txt","r",stdin);
		freopen("/home/suryakant/output.txt","w",stdout);
	#endif
	
    int tc=1;
    //cin>>tc;
    for(int i=1;i<=tc;++i)test_case(tc);
}

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	string s;
	cin >> s;
	if (s.find('7') != string::npos) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
  int n,m,co[1000],mo[1000],i,j,max=0,ans;
  int vo[1000]={0};

  scanf("%d %d", &n, &m);
  for(i=0;i<n;i++){
    scanf("%d", &co[i]);
  }
  for(i=0;i<m;i++){
    scanf("%d", &mo[i]);
    for(j=0;j<n;j++){
      if(mo[i]>=co[j]){
	vo[j]++;
	break;
      }
    }
  }
  for(i=0;i<n;i++){
    if(vo[i]>max){
      max=vo[i];
      ans=i+1;
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 608
#include<stdio.h>

int main(){
    int c1, c2, c3, i, count;
    int card[10];

    while(scanf("%d %d %d", &c1, &c2, &c3) != EOF){
        for(i = 0; i < 10; i++) card[i] = 0;
        card[c1-1] = 1;
        card[c2-1] = 1;
        card[c3-1] = 1;
        count = 0; 
        for(i = 1; i + c1+ c2 < 21; i++){
            if(card[i-1] == 0) count++;
        }
        if(count > 3) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include <iostream>

using namespace std;

int main()
{
   int n = 0, r = 0;
   cin >> n >> r;
   if(n >= 10){
       cout << r << endl;
   }
   else{
       int ans = 100 * (10 - n);
       cout << ans + r << endl;
   }
   
   return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    if(m >= n) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}


//
// Main
//

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}


fn main() {
    input! {
        a: u64,
        b: u64,
        c: u64,
        d: u64,
    }

    let gcd_c_d = gcd(c, d);
    let lcm_c_d = c * d / gcd_c_d;
    let divided = count(a, b, c) + count(a, b, d) - count(a, b, lcm_c_d);
    let ans = b - a + 1 - divided;
    println!("{}", ans);
}

fn count(a: u64, b: u64, d: u64) -> u64 {
    let q0 = a / d;
    let q1 = b / d;
    let divided = q1 - q0 + if a % d == 0 { 1 } else { 0 };

    divided
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define inf 1e18
using namespace std;

int main(){
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    if(N==1){
        cout << abs(a[0]-W) << endl;
    }else{
        cout << max(abs(a[N-1]-W), abs(a[N-1]-a[N-2])) << endl;
    }
}


Measured memory_bytes: 256
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
n = int(input())
a = list(map(int, input().split()))
ans = 0
num = a[0]

for i in range(n-1):
    if num < a[i+1]:
        num = a[i+1]

    else:
        ans += num - a[i+1]

print(ans)


Measured memory_bytes: 32368
# サイコロ        初期状態
#    [1]           N
# [4][2][3][5]   W[1]E
#    [6]           S
#
# 上記の順番でラベルに対する整数が与えられる
# l1 l2 l3 l4 l5 l6
# 複数のサイコロが全て異なっていれば'Yes'
# 1組でも一致していたら'No'
import copy

class Dice:
    def __init__(self, l1, l2, l3, l4, l5, l6):
        self.l1 = l1
        self.l2 = l2
        self.l3 = l3
        self.l4 = l4
        self.l5 = l5
        self.l6 = l6
        self.tmp = 0
    def move_n(self):
        self.tmp = self.l5
        self.l5 = self.l1
        self.l1 = self.l2
        self.l2 = self.l6
        self.l6 = self.tmp
    def move_s(self):
        self.tmp = self.l2
        self.l2 = self.l1
        self.l1 = self.l5
        self.l5 = self.l6
        self.l6 = self.tmp
    def move_e(self):
        self.tmp = self.l3
        self.l3 = self.l1
        self.l1 = self.l4
        self.l4 = self.l6
        self.l6 = self.tmp
    def move_w(self):
        self.tmp = self.l4
        self.l4 = self.l1
        self.l1 = self.l3
        self.l3 = self.l6
        self.l6 = self.tmp
    def show(self):
        return self.l1, self.l2, self.l3, self.l4, self.l5, self.l6

n = int(input())
yn_f = False
d_inf1 = []
d_inf2 = []
for _ in range(n):
    d_inf1.append(Dice(*map(int, input().split())))
d_inf2 = copy.deepcopy(d_inf1)

for i, d1 in enumerate(d_inf1):
    for j, d2 in enumerate(d_inf2):
        if i == j:
            continue
        if set(d1.show()) == set(d2.show()):
            ne_switch = 0
            while d1.l2 != d2.l2:
                if ne_switch <= 3:
                    d1.move_n()
                    ne_switch+=1
                elif 4 == ne_switch :
                    d1.move_e()
                    ne_switch = 0
            e_cnt = 0
            while d1.l1 != d2.l1 and e_cnt <= 3:
                d1.move_e()
                e_cnt+=1

            if d1.l3 == d2.l3 and d1.l4 == d2.l4 and d1.l5 == d2.l5 and d1.l6 == d2.l6:
                yn_f = True
        if yn_f: break
    if yn_f: break            

print('No' if yn_f else 'Yes')


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int f(int x) {
  int res = 0;
  while (x%2 == 0) {
    x /= 2;
    res++;
  }
  return res;
}

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

  // a -> a'
  rep(i,n) {
    if (a[i]%2 == 1) {
      cout << 0 << endl;
      return 0;
    }
    a[i] /= 2;
  }

  // a' -> a''
  int t = f(a[0]);
  rep(i,n) {
    if (f(a[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t; // a[i] /= 2^t
  }
  m >>= t;

  ll l = 1;
  rep(i,n) {
    l = lcm(l, a[i]);
    if (l > m) {
      cout << 0 << endl;
      return 0;
    }
  }

  m /= l;
  int ans = (m+1)/2;
  cout << ans << endl;
  return 0;
}


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

int main(){
    ll n;
    string s;
    cin>>n>>s;
    char t[s.size()];
    for(ll i=0;i<s.size();++i){
        t[i] = s[i];
    }

    for(ll i=0;i<s.size();++i){
        if(t[i]+n > 'Z'){
            t[i] = 'A' + n - ('Z'-t[i]) - 1;
        }else{
            t[i] = t[i] + n;
        }
        cout<<t[i];
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;
vll v(1000010,0);
void factorize(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        ll x=0;
        if (n % i != 0) continue;
        
        while (n % i == 0) {
            n /= i;
            x++;
        } 
        v[i]=max(v[i],x);
    }
    if (n != 1) {
      v[n]=max(v[n],1LL);
    }
    return;
}
ll extGCD(ll a,ll b,ll &x,ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}
ll modpow(ll x, ll n){
	ll r=1;
	while(n){
		if(n&1) r=r*x%MOD;
		x=x*x%MOD;
		n>>=1;
	}
	return r;
}
int main(){
  ll n,k=1,ans=0;cin>>n;
  vll a(n);
  rep(i,0,n){
    cin>>a[i];
    factorize(a[i]);
  }
  rep(i,2,1000000){
    k*=modpow(i,v[i]);
    k%=MOD;
  }
  rep(i,0,n){
    ans+=k*modinv(a[i],MOD);
    ans%=MOD;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 8192
import sys

p="perfect number"
d="deficient number"
a="abundant number"





number_list=[]


while True:
    N=int(input())
    if N==0:
        break
    else:
        number_list.append(N)


maximum=int(max(number_list)**0.5)



prime_table=[i for i in range(maximum+1)]
prime_table[1]=0

for i in range(2,int(maximum**0.5)):
    if prime_table[i]==i:
        k=2
        while k*i<=maximum:
            prime_table[k*i]==0
            k+=1
for N in number_list:
    N_origin=N
    devide_list=[]
    for i in prime_table:
        if i!=0:
            count=0
            while N%i==0:
                count+=1
                N=N/i
            devide_list.append([i,count])
    if N!=1:
        devide_list.append([N,1])

    S=1
    for i in devide_list:
        S*=(i[0]**(i[1]+1)-1)/(i[0]-1)
    S-=N_origin
    if N_origin==S:
        print(p)
    elif N_origin>S:
        print(d)
    else:
        print(a)
            

Measured memory_bytes: 9100
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int tmp,n;
  cin>>tmp>>n;
  map<int,map<int,int> >in;
  rep(i,n){
    int m;cin>>m;
    rep(j,m){
      cin>>tmp;
      in[i][tmp]=1;
    }
  }
  set<int>out;
  int m;cin>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    rep(j,n){
      if(in[j][a]&&in[j][b]){out.insert(a);out.insert(b);}
    }
  }
  cout<<out.size()<<endl;



}

Measured memory_bytes: 1312
n = int(input())

l = list(map(int,input().split()))
#n,m = map(int,input().split())
c=0
for i in l:
    c+=i

c=c//n
c1 = c+1 

#print(c,c1)

ans=0
for i in l:
    ans+=(c-i)*(c-i)
    
ans1=0
for i in l:
    ans1+=(c1-i)*(c1-i)
print(min(ans,ans1))

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

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

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

    long long n;
    cin >> n;

    long long ans = 0;
    while (n > 0) {
        long long t = n;
        
        if(t>=500){
            long long c = floor(t / 500);
            ans += 1000 * c;

            n = t - 500*c;

        }else if(t>=5){
            long long c = floor(t / 5);
            ans += 5*c;
            n = t - 5*c;
        }else{
            n = 0;
        }
    }

    cout << ans << endl;
}

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

#define MOD 1000000007

using namespace std;

typedef long long LL;

const int MAXN = 2e05 + 10;
const int MAXM = 4000 + 10;

const int q = 2002;

LL fact[MAXM << 1]= {0}, invfact[MAXM << 1]= {0};
inline LL C (int n, int m) {
	return fact[n] * invfact[m] % MOD * invfact[n - m] % MOD;
}

int f[MAXM][MAXM]= {0};

int N;
int x[MAXN], y[MAXN];

int getnum () {
	int num = 0;
	char ch = getchar ();

	while (! isdigit (ch))
		ch = getchar ();
	while (isdigit (ch))
		num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();

	return num;
}

int main () {
	N = getnum ();
	for (int i = 1; i <= N; i ++) {
		x[i] = getnum (), y[i] = getnum ();
		f[- x[i] + q][- y[i] + q] ++;
	}
	for (int i = 1; i <= (q << 1); i ++)
		for (int j = 1; j <= (q << 1); j ++)
			f[i][j] = (f[i][j] + (f[i - 1][j] + f[i][j - 1]) % MOD) % MOD;
	LL ans = 0;
	for (int i = 1; i <= N; i ++)
		ans = (ans + f[x[i] + q][y[i] + q]) % MOD;
	fact[0] = invfact[0] = invfact[1] = 1;
	for (int i = 1; i <= (q << 2); i ++) {
		fact[i] = fact[i - 1] * i % MOD;
		if (i > 1) invfact[i] = (MOD - MOD / i) * invfact[MOD % i] % MOD;
	}
	for (int i = 1; i <= (q << 2); i ++)
		invfact[i] = invfact[i] * invfact[i - 1] % MOD;
	for (int i = 1; i <= N; i ++)
		ans = (ans - C ((x[i] + y[i]) << 1, x[i] << 1) + MOD) % MOD;
	ans = ans * invfact[2] % MOD;
	cout << ans << endl;

	return 0;
}

/*
3
1 1
1 1
2 1
*/

/*
3
1999 1999
1999 1999
2000 1999
*/

Measured memory_bytes: 64640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int n,k=0;
	cin >> n;
	rep(i, n+1) k += i;
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int k;cin>>k;
  int h[n];
  for(int i=0;i<n;i++)
    cin>>h[i];
  int ans[n];
  ans[0]=0;
  ans[1]=abs(h[0]-h[1]);
  for(int i=2;i<n;i++)
  {
  int mi=INT_MAX;int a=k;int j=i-1;
  while(a>0&&j>=0)
  {
    mi=min(abs(h[i]-h[j])+ans[j],mi);
    j--;
    a--;
  }
  ans[i]=mi;
}
cout<<ans[n-1];
               
}


Measured memory_bytes: 4368
s = input().strip()

i = 0
isa = False
if i < len(s):
  if i < len(s) and s[i] == 'A':
    i += 1
  if i < len(s) and s[i] == 'K':
    i += 1
    if i < len(s) and s[i] == 'I':
      i += 1
      if i < len(s) and s[i] == 'H':
        i += 1
        if i < len(s) and s[i] == 'A':
          i += 1
        if i < len(s) and s[i] == 'B':
          i += 1
          if i < len(s) and s[i] == 'A':
            i += 1
          if i < len(s) and s[i] == 'R':
            i += 1
            if i >= len(s):
              print('YES')
              isa = True
            elif i < len(s) and s[i] == 'A' and i+1 >= len(s):
              print('YES')
              isa = True
            else:
              print('NO')
              isa = True
  if not isa:
    print('NO')
elif not isa:
  print('NO')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 2e9;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	string s;
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
 	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
int main(void)
{
  char a[102], b[102];
  int i;
  scanf("%s", a);
  scanf("%s", b);
  if(strlen(a) > strlen(b)){
    printf("GREATER\n");
    return 0;
  }
  if(strlen(b) > strlen(a)){
    printf("LESS\n");
    return 0;
  }

  for(i = 0; a[i] != '\0'; i++){
    if(a[i] + '0' > b[i] + '0'){
      printf("GREATER\n");
      return 0;
    }
    if(a[i] + '0' < b[i] + '0'){
      printf("LESS\n");
      return 0;
    }
  }
  printf("EQUAL\n");
  return 0;
}

Measured memory_bytes: 128
n=input()
if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9":
    print("hon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
    print("pon")
elif n[-1] == "3":
    print("bon")

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

import sys
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


N = int(input())
S = []
for i in range(N):
    s = [c for c in input()]
    s.sort()
    S.append("".join(s))

counter = Counter(S)

res = 0
for c in counter.values():
    res += c * (c-1) // 2


print(res)







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

int main()
{
    int a,b; cin >> a >> b;
    if(a==b) return 0;

    if ((a-b) % 2 != 0)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << abs((a-b)/2) + min(a,b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
{
int N,i,n,j,a;
n=0;
scanf("%d\n",&N);
int array[N];
for(i=0;i<N;i++) scanf("%d ",&array[i]);
for(i=0;i<N;i++)
{
for(j=N-1;j>i;j--)
{
if(array[j]<array[j-1]){
a=array[j-1];
array[j-1]=array[j];
array[j]=a;
n++;
}
}
}
for(i=0;i<N-1;i++) printf("%d ",array[i]);
printf("%d\n%d\n",array[N-1],n);
return 0;
}

Measured memory_bytes: 604
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    int n;
    cin >> n;
    n *= 2;
    vi a(n);
    forn(i, n) cin >> a[i];
    Sort(a);
    int ans = 0;
    forn(i, n / 2) ans += a[2 * i];
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	for i := 0; i <= 7; i++ {
		if S[:i] == "keyence"[:i] && S[len(S)-(7-i):] == "keyence"[i:] {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 1776
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
h = tuple(map(int,input().split()))

dp = [0] + [float("inf")]*(n-1)
#print(dp)

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
#print(dp)

print(dp[-1])



Measured memory_bytes: 58332
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (true) {
			int max = 0;
			int min = 1000;
			int sum = 0;
			int n = s.nextInt();
			if (n == 0) {
				break;
			}
			for (int i = 0; i < n; i++) {
				int k = s.nextInt();
				if (k > max) {
					max = k;
				}
				if (k < min) {
					min = k;
				}
				sum = sum + k;
			}
			int score = sum - max - min;
			System.out.println(score / (n - 2));
		}
	}
}

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

int main(){
  int N ; 
  cin >> N ; 
  ll cnt = 0 ; 
  for(int i = 1 ; i < N ; i++){
    cnt += (N-1)/i ; 
  }
  
  cout << cnt << endl ; 
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif


namespace Solver{
using namespace std;

struct Problem{
    int n,sum;
    vector<int > a,dp;
    Problem(LL n):n(n),sum(0),a(n){};

    void solve(){
        for(int i=0; i<n; ++i){
             cin >> a[i];
             sum+=a[i];
        }
        bitset<4000001> dp;
        dp.set(0);
        for(int i=0; i<n; ++i){
            dp|=(dp<<a[i]);
        }
        int ans = (sum+1)/2;
        while(!dp[ans])ans++;
        cout << ans <<"\n";
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n=0;
    std::cin >> n;
    Solver::Problem p(n);
    p.solve();
    return 0;
}



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


int main(){
  
    char a,b;

   scanf("%c %c", &a , &b);
   
   switch(a)
   {
   	 case 'H':
   	 	  if(b == 'H')
   	 	    printf("H");
   	 	  else
			printf("D");
			
		  break;
    case 'D':
   	 	  if(b == 'H')
   	 	    printf("D");
   	 	  else
			printf("H");
			
		  break;
	default :
	       printf("The is Wrong Input");
		   break;	  		  	     
   }
}
  
   	


Measured memory_bytes: 256
//author Forsaken
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.in", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.out", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 1e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
il int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll quick_pow(ll base, ll index) {
	ll res = 1;
	while (index) {
		if (index & 1)res = res * base % mod;
		base = base * base % mod;
		index >>= 1;
	}
	return res;
}
int n;
ll arr[maxn + 5], res[maxn + 5];
int main()
{
	n = read_int();
	for (int i = 1; i <= n; ++i)arr[i] = read_ll() * 2;
	for (int i = 1; i < n; ++i) {
		if (i & 1)arr[n] -= arr[i];
		else arr[n] += arr[i];
	}
	res[n] = arr[n] / 2;
	for (int i = n - 1; i > 0; --i)res[i] = (arr[i] - res[i + 1]);
	for (int i = 1; i <= n; ++i)printf("%lld%c", res[i], " \n"[i == n]);
	//system("pause");
	return 0;
}

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

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

int main(void){
    int n;
    string s, t;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> s >> t;
    REP(i, n) {
        cout << s[i] << t[i];
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#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 ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;

int main(){
  string s, t;cin >> s >> t;
  int n = s.size();
  int ans = 0;
  rep(i, n){
    if(s[i] != t[i]){
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int H, W, d; cin >> H >> W >> d;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << "RYGB"[((i - j + 1000) / d) % 2 * 2 + (i + j) / d % 2];
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 512
// --------------------------------------------
// ****************  gzhffIThh  ***************
// --------------------------------------------
// #pragma GCC optimize(2)
// #pragma GCC optimize(3)

#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);  
 
        int n, m;
        cin >> n >> m;

        vector<int> b(n);

        for (int i = 1; i <= m; i++) {
        	int x, y;
        	cin >> x >> y;
        	x--;
        	y--;
        	b[x] ^= 1;
        	b[y] ^= 1;        	
        }

        for (auto i : b) {
        	if (i) {
        		cout << "NO\n";
        		return 0;
        	}
        }
        cout << "YES\n";

        return 0; 
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////
//区間最大区間加算
struct RBQRAQ{
    ll n;
    vector<ll>data,lazy;
    RBQRAQ(ll vs){
        n=1;
        while(n<vs)n*=2;
        data.resize(2*n-1,0);
        lazy.resize(2*n-1,0);
    }
    void eval(ll k,ll l,ll r){
        if(lazy[k]!=0){
            data[k]+=lazy[k];
            if(r-l>1){
                lazy[2*k+1]+=lazy[k];
                lazy[2*k+2]+=lazy[k];
            }
            lazy[k]=0;
        }
    }
    void add(ll a,ll b,ll x,ll k,ll l,ll r){
        eval(k,l,r);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            lazy[k]+=x;
            eval(k,l,r);
        }else{
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            data[k]=max(data[2*k+1],data[2*k+2]);
        }
    }
    void add(ll a,ll b,ll x){add(a,b,x,0,0,n);}//[a,b)にxを加える
    ll query(ll a,ll b,ll k,ll l,ll r){
        eval(k,l,r);
        if(r<=a||b<=l)return -inf;
        if(a<=l&&r<=b){
            return data[k];
        }else{
            ll vl=query(a,b,2*k+1,l,(l+r)/2);
            ll vr=query(a,b,2*k+2,(l+r)/2,r);
            return max(vl,vr);
        }
    }
    ll query(ll a,ll b){return query(a,b,0,0,n);}//[a,b)の最大値
};
//////////////////////////////////////////////////////
int main(){
    ll n,q;cin>>n>>q;
    RBQRAQ r(n);
    while(q--){
        ll a,b,c,d;cin>>a;
        if(a==0){
            cin>>b>>c>>d;
            r.add(b,c+1,-d);
        }else{
            cin>>b>>c;
            cout<<-r.query(b,c+1)<<endl;
        }
    }
    
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define fore(i,x,n) for(int i=x;i<n;i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define ordenar(a) sort(all(a))
typedef long long ll;
typedef vector<int> vi;


int n, h, pre = 0, cont = 0;

int main(){
    IOS

    cin>>n;

    fore(i,0,n){
        cin>>h;
        if(h >= pre) {
            cont++;
            pre = h;
        }
    }

    cout<<cont;
    
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 1000000;
ll mod = INF;


int main(){
    ll x,k,d;
    ll ans=0;
    cin >> x>>k>>d;

    //to O
    if(x<0){
        x=-x;
    }

    ll cnt=x/d;
    ll dis1=x%d;
    ll dis2;
    if(cnt>k){
        ans=x-k*d;
    }else{
        ans=dis1;
        dis2=dis1-d;
        if((k-cnt)%2==0){
            ans=dis1;
        }else{
            ans=dis2;
        }
    }

    cout << abs(ans)<<endl;;

    return 0;
}

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

using namespace std;

int main()
{
    int n,max=0,h[100001],temp=0;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> h[i];
    for(int i=0; i<n-1;i++)
    {
        if(h[i]>=h[i+1])
        {
            temp++;
        }
        else temp=0;
        if(max<temp)max=temp;
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 768
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}

const int N=1000010;
VI p[N];
void main() {
    for ( int i=2; i<N; i++ ) {
        if ( SZ(p[i]) ) continue;
        for ( int j=i; j<N; j+=i ) {
            p[j].PB(i);
        }
    }
    
    int n;
    R(n);
    VI a(n);
    REP(i,n) R(a[i]);
    map<int,int> mp;
    REP(i,n) {
        for ( int j:p[a[i]] ) mp[j]++;
    }
    int ok=1,ok2=1;
    for ( auto it:mp ) {
        if ( it.second>1 ) ok=0;
        if ( it.second==n ) ok2=0;
    }
    if ( ok ) {
        W("pairwise coprime");
    } else if ( ok2 ) {
        W("setwise coprime");
    } else {
        W("not coprime"); 
    }
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}


Measured memory_bytes: 66376
#include <stdio.h>

int search(int *,int,int);

int main(){
  int i,n,q,c=0,s[100000],t;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%d",&t);
    c += search(s,t,n);
  }
   printf("%d\n",c);
   return 0;
}

int search(int s[],int t,int n){
  int left=0,right=n,mid;

  while(left < right){
    mid =(left+right)/2;
    if(t == s[mid])return 1;
    if(t > s[mid])left = mid +1;
    else if(t < s[mid])right = mid;
  }
  
  return 0;
}



Measured memory_bytes: 2108
from math import radians, sin, cos

a, b, c = [int(i) for i in input().split()]
area = 0.5 * a * b * sin(radians(c))
print(area, a + b + (a * a + b * b - 2 * a * b * cos(radians(c))) ** 0.5, area * 2 / a)



Measured memory_bytes: 5728
import Control.Monad
import Control.Arrow
import Control.Applicative

rotate :: Int -> String -> String
rotate 0 t = t
rotate n t = drop n t ++ take n t

cand :: Int -> String -> Int -> [String]
cand 0 xs _ = []
cand n xs tlen = (take tlen xs) : cand (n-1) (rotate 1 xs) tlen

main :: IO ()
main = do
  target <- getLine
  n <- read <$> getLine :: IO Int

  ringStrs <- forM [1..n] $ \_ -> do
    getLine

  let css = map (flip (uncurry cand) $ length target) $
            map (length &&& id) ringStrs

  putStrLn $ show $ length $ filter (==True) $ map (elem target) css

Measured memory_bytes: 3908
#include<cstdio>
int n,m;
signed main()
{
	scanf("%d%d",&n,&m);int t,h(m>>1),ans(0);
	while(n--)
		scanf("%d",&t),ans+=((t>h?(m-t):t)<<1);
	return printf("%d\n",ans),0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int maxn = 234567;
const int mod = 1000000007;
int mul(long long a, long long b){
	return a * b % mod;
}
int inv(int x){
	int r = 1, b = mod - 2;
	for(; b; b >>= 1, x = mul(x, x)) if(b&1) r = mul(r, x);
	return r;
}
int fat[maxn], ifat[maxn], sum[maxn];
void init(){
	fat[0] = 1;
	for(int i = 1; i < maxn; i++) fat[i] = mul(fat[i - 1], i);
       	ifat[maxn - 1] = inv(fat[maxn - 1]);	
	for(int i = maxn - 2; i >= 0; i--) ifat[i] = mul(ifat[i + 1], i + 1);
	for(int i = 1; i < maxn; i++){
		sum[i] = sum[i - 1] + i;
		if(sum[i] >= mod) sum[i] -= mod;
	}
}
int ncr(int n, int k){
	if(n < k) return 0;
	return mul(fat[n], mul(ifat[k], ifat[n - k]));
}
int main(){
	int n, m, ch; cin >> n >> m >> ch;
	if(n > m) swap(n, m);
	init();
	int magic = ncr(n * m - 2, ch - 2);
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			for(int k = 0; k < m; k++){
				int tot = sum[k] + sum[m - k - 1];
				if(tot >= mod) tot -= mod;
				tot += mul(j - i, m);
				if(tot >= mod) tot -= mod;
				ans += mul(tot, magic);
				if(ans >= mod) ans -= mod;
			}	
		}
		for(int j = 0; j < m; j++){
			int tot = sum[m - j - 1];
			ans += mul(tot, magic);
			if(ans >= mod) ans -= mod;
		}
	}
	cout << ans << endl;
	return 0;;
}


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

int main()
{
    ll n;
    cin >> n;
    ll a[n];
    ll ans = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        x -= (i+1);
        a[i] = x;
    }
    sort(a,a+n);
    if(n % 2 == 1){
        ll k = a[n/2];
        for(int i = 0; i < n; i++){
            ans += abs(a[i]-k);
        }
    }else{
        ll k = a[n/2];
        for(int i = 0; i < n; i++){
            ans += abs(a[i] - k);
        }
    }
    cout << ans;
}



Measured memory_bytes: 1792
#include <stdio.h>

typedef struct {
  char s;
  int v;
} card;

card L[100000/2+2],R[100000/2+2];

void me(card *a,int n,int l,int m,int r){
  int i,j,k;
  int n1 = m-l;
  int n2=r-m;

  for(i=0;i<n1;i++)L[i]=a[l +i];
  for(i=0;i<n2;i++)R[i]=a[m +i];
  L[n1].v=R[n2].v=2000000000;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    if(L[i].v<=R[j].v){
      a[k]=L[i++];
    }
    else {
      a[k]=R[j++];
    }
  }
}

void ms(card *a , int n, int l,int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    ms(a,n,l,m);
    ms(a,n,m,r);
    me(a,n,l,m,r);
  }
}

int partiton(card *a,int n,int p,int r){
  int i,j;
  card t,x;
  x=a[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(a[j].v<=x.v){
      i++;
      t=a[i];
      a[i]=a[j];a[j]=t;
    }
  }
  t=a[i+1];
  a[i+1]=a[r];
  a[r]=t;
  return i+1;
}

void qs(card *a,int n,int p,int r){
  int q;

  if(p<r){
    q=partiton(a,n,p,r);
    qs(a,n,p,q-1);
    qs(a,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  card a[200000],b[200000];
  char s[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s%d",s,&v);
    a[i].s=b[i].s=s[0];
    a[i].v=b[i].v=v;
  }

  ms(a,n,0,n);
  qs(b,n,0,n-1);

  for(i=0;i<n;i++){
    if(a[i].s!=b[i].s){
      stable=0;
    }
  }
  if(stable==1){
    printf("Stable\n");
  }
  else {
    printf("Not stable\n");
  }
  for(i=0;i<n;i++){
    printf("%c %d\n",b[i].s,b[i].v);
  }

  return 0;
}



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

int main()
{
  int A, B, ans;
  char op;
  cin >> A >> op >> B;
  if (op == '+')
  {
    ans = A + B;
  }
  else
  {
    ans = A - B;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int a,b,c;

int main(){
	cin >> a>> b >> c;
	
	int cnt = b;
	int d = b+a;
	for(;d>=0;d--){
		if(c){
			c--;
			cnt++;
		}
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> H(n);
    for(int i=0; i<n; ++i) cin >> H[i];
    sort(H.begin(), H.end());
    int res = (int) 1e10;
    for(int i=0; i<=n-k; ++i) res = min(res, abs(H[i]-H[i+k-1]));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
  int a, b, i, ab[9], ba[9], n, m;
  scanf("%d %d", &a, &b);
  for (i = 0; i < b; i++)
    ab[i] = a;
  for (i = 0; i < a; i++)
    ba[i] = b;
  if (a < b) {
    for (i = 0; i < b; i++)
      printf("%d", ab[i]);
  }
  else if (b < a || a == b) {
    for (i = 0; i< a; i++)
      printf("%d", ba[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
from collections import Counter
def solve():
    n = int(input())
    c = Counter(input() for _ in range(n))
    t = c.most_common()[0][1]
    ans = []
    for a in c.most_common():
        if a[1] != t:
            break
        ans.append(a[0])
    print(*sorted(ans), sep="\n")
solve()


Measured memory_bytes: 43484
#include<stdio.h>
 
int main(){
	int a, b, i;
	while(scanf("%d", &a) != 0){
		if(a == 0) break;
		for(i = 0; i < 9; i++){
			scanf("%d", &b);
			a -= b;
		}
		printf("%d\n", a);
	}
	return 0;
}

Measured memory_bytes: 600
import glob

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\166\\C'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class C(Common):

    def resolve(self):

        N, M = map(int, self.input_data().split())
        H = list(map(int, self.input_data().split()))
        H.insert(0,0)
        node = [None]*M
        for i in range(M):
            node[i] = list(map(int, self.input_data().split()))

        node_list = [[] for i in range(N+1)]

        for n in node:
            node_list[n[0]].append(n[1])
            node_list[n[1]].append(n[0])

        count = 0
        for i in range(1,N+1):
            for j in node_list[i]:
                if H[i] <= H[j]:
                    break
            else:
                count += 1

        print(str(count))

solver = C(REL_PATH)
solver.exec_resolve()

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


int main(){
    ll N;
    cin >> N;
    vector<ll> a;
    ll sum=0;
    for(ll i=0; i<=N; i++){
        ll x;
        cin >> x;
        a.push_back(x);
        sum += x;
    }
    
    //cout << sum << endl;
    vector<ll> ten(N+1);
    ten[0]=1;
    sum -= a[0];
    bool flg=true;
    for(ll i=1; i<=N; i++){
        sum -= a[i-1];
        ten[i] = min((ten[i-1] - a[i-1])*2, sum);
        if(ten[i]<=0){
            flg=false;
            break;
        }
    }
    
    if(ten[N] != a[N] || flg==false){
        cout << -1 << endl;
    }else{
        ll ans=0;
        for(ll x:ten){
            //cout << x << " ";
            ans += x;
        }
        cout << ans << endl;
    }
}


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

ll N, K;
vector<ll> candle;
const ll inf = 1 << 30;

int main() {
    scanf("%Ld%Ld", &N, &K);
    candle.resize(N);
    for (int i = 0; i < N; i++) scanf("%Ld", &candle[i]);

    sort(candle.begin(), candle.end());
    
    ll mini = inf;
    for (int i = 0; i < N - K + 1; i++) {
        int l = i; int r = K + i - 1;
        mini = min(mini, abs(candle[l]) + abs(candle[l] - candle[r]));
        mini = min(mini, abs(candle[r]) + abs(candle[l] - candle[r]));
    }
    cout << mini << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    int a[x];
    for(int i=0;i<x;i++){
        cin>>a[i];
    }
    int b[x];
    b[0]=0;
    b[1]=abs(a[1]-a[0]);
    long long s=0;
    for(int i=2;i<x;i++){
        int m1=b[i-2]+abs(a[i]-a[i-2]);
        int m2=b[i-1]+abs(a[i]-a[i-1]);
        b[i]=min(m1,m2);
    }
    cout<<b[x-1]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    if ((A + B) % 2 == 0) cout << "Alice" << endl;
    else cout <<"Borys" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int count = 0,k=0;
	string s;
	cin >> s;
	if (s[0]=='A') {
		count++;
	}
	for (int i = 2; i <= s.size() - 2;i++) {
		if (s[i]=='C') {
			k++;
		}
	}
	if (k==1) {
		count++;
	}
	k = 0;
	for (int i = 0; i < s.size();i++) {
		if (s[i]!='A'&&s[i]!='C') {
			k += isupper(s[i]);
		}
	}
	if (k==0) {
		count++;
	}
	if (count==3) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
}

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


int main() {
 int64_t N, sum = 0, total = 0;
 cin >> N;
 vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
    sort(S.at(i).begin(), S.at(i).end());
  }
  sort(S.begin(), S.end());
  for (int i = 0; i < N - 1; i++) {
    if (S.at(i) == S.at(i + 1)) {
      sum += 1;
    }
    else sum = 0;
    total += sum;
  }
  cout << total << endl;
}

Measured memory_bytes: 7296