akhauriyash/Code-Regression huggingface dataset:
input = STDIN.readline.split()
n = input[0].to_i
k = input[1].to_i
a_list = STDIN.readline.split().map{|a|a.to_i}

max = (10**12).to_s(2)
masks = Range.new(0, max.size, true).to_a.map{|m|1 << m}.reverse
bit_counts = Array.new(max.size, 0)
for a in a_list do
    i = 0
    masks.each_index do |i|
        bit_and = masks[i] & a
        if bit_and > 0 then
            bit_counts[i] += 1
        end 
    end
end
bit_more = bit_counts.map do |c|
    if c * 2 > n then
        "0"
    else
        "1"
    end
end
sum_max = 0
k_2 = ("%0#{max.size}b" % k).split("")
result = []

k_2.each_index do |tmp|
    if k_2[tmp] == "0" then
        sum_max += bit_counts[tmp] * (2 ** (max.size - 1 - tmp))
    else
        sum_max += (n - bit_counts[tmp]) * (2 ** (max.size - 1 - tmp))
    end
end

k_2.each_index do |i|
    if k_2[i] == '1' then
        x = result + ["0"] + bit_more.slice(Range.new(i + 1, max.size, true))
        sum = 0
        x.each_index do |tmp|
            if x[tmp] == "0" then
                sum += bit_counts[tmp] * (2 ** (max.size - 1 - tmp))
            else
                sum += (n - bit_counts[tmp]) * (2 ** (max.size - 1 - tmp))
            end
        end
        if sum > sum_max then
            sum_max = sum
        end
    end
    result.push(k_2[i])
end
puts(sum_max)

Measured memory_bytes: 8980
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                if l[i]+l[j] > l[k] and l[j]+l[k] > l[i] and l[k]+l[i] > l[j]:
                    ans += 1
print(ans)


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

int n;
string str;
map<string,bool> vis;

int main() 
{
    scanf("%d",&n);
    char last;
    cin>>str;
    last=str[str.length()-1];
    vis[str]=true;
    for(int i=1; i<n; i++) 
	{
        cin>>str;
        if(vis[str] || str[0]!=last) 
		{
            printf("No\n");
            return 0;
        }
        last=str[str.length()-1];
        vis[str]=true;
    }
    printf("Yes\n");
    return 0;
}

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

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

ll pref_sum(vi &f, int r){ // range query [0..r]
    ll ret = 0;
    for(; r >= 0; r = (r&(r + 1)) - 1){
        ret += f[r];
    }

    return ret;
}

ll get_sum(vi &f, int l, int r){ // arbitary range query [l..r]
	return pref_sum(f, r) - pref_sum(f, l - 1);
}

void update(vi &f, int idx, ll val){ // point update
    for(; idx < sz(f); idx |= (idx + 1)){
        f[idx] += val;
    }
}

int main() {
    ll tt = 1, n, m, l, r, c, i, j, k, w, x, y;
    boost;

    // cin >> tt;
    ll ans = 0;
    ll x1, y1, z1, x2, y2, z2;
    for(int _ = 1; _ <= tt; _++) {
        string s;
        cin >> s;
        
        for(auto &z: s){
            ans += (z - '0');
        }

        cout << ((ans%9 == 0)?"Yes":"No") << nl;
    }
}

Measured memory_bytes: 3708
// Date: 2020-03-08

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if(n & 1) cout << "No";
    else {
        int f = 1;
        rep(i, 0, n-1) {
            if(i % 2 == 0 && s[i] != 'h') f = 0;
            else if(i % 2 == 1 && s[i] != 'i') f = 0;
        }
        if(f) cout << "Yes";
        else cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  string s;
  cin>>s;
  x=s.find("A");
  reverse(s.begin(),s.end());
  y=s.find("Z");
  cout<<s.size()-x-y<<endl;
  return(0);
}


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

enum Suit {
  S, H, C, D
};

int main() {
  int n, m, o, cards[4] = {};
  char c;

  cin >> n;

  while (n --> 0) {
    cin >> c >> m;
    switch (c) {
      case 'S': cards[S] |= 1 << m; break;
      case 'H': cards[H] |= 1 << m; break;
      case 'C': cards[C] |= 1 << m; break;
      case 'D': cards[D] |= 1 << m; break;
    }
  }

  for (n = 0; n < 4; n++) {
    for (m = 1; m <= 13; m++) {
      if (!(cards[n] & (1 << m))) {
        cout << "SHCD"[n] << ' ' << m << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1160
xx, kk, dd= list(map(int,input().split()))

xx = abs(xx)

if dd * kk <= xx:
    ans = xx - dd*kk
else:
    aa_int = int(xx/dd)
    remaining_move = kk - aa_int
    if (remaining_move % 2) == 0:
        ans = xx - dd*aa_int
    else:
        ans = xx - dd*(aa_int+1)

print(abs(ans))

Measured memory_bytes: 61716
#include "bits/stdc++.h"
using namespace std; 
vector<string> vec;
vector<int> num;
char tmps[11];
string tmpstr;
int main()
{
	int n,m,len;
	int i,j;
	int maxn=0,flag;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",tmps);
		flag=0;
		tmpstr=tmps;
		len=vec.size();
		for(j=0;j<len;j++)
		{
			if(vec[j]==tmpstr)
			{
				num[j]++;
				flag=1;
				break;	
			}
		}
		if(!flag)
		{
			vec.push_back(tmpstr);
			num.push_back(1);
		}
	}
	scanf("%d",&m);	
	for(i=0;i<m;i++)
	{
		scanf("%s",tmps);
		tmpstr=tmps;
		len=vec.size();
		for(j=0;j<len;j++)
		{
			if(vec[j]==tmpstr)
			{
				num[j]--;
				break;
			}
		}
	}
	len=vec.size();
	for(i=0;i<len;i++)
	{
		if(maxn<num[i])
		{
			maxn=num[i];
		}
	}
	printf("%d\n",maxn);
	return 0;
}

Measured memory_bytes: 256
from sys import stdin

s = stdin.readline().strip()
left, right = int(s[:2]), int(s[2:])
if 1 <= left <= 12 and 1 <= right <= 12:
  print('AMBIGUOUS')
elif 1 <= left <= 12 and 0 <= right <= 99:
  print('MMYY')
elif 0 <= left <= 99 and  1 <= right <= 12:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060
import java.util.*;

class Pair{
    int H,W;
    Pair(int H,int W){
        this.H = H;
        this.W = W;
    }
}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Pair> list = new ArrayList<Pair>();
        while(true){
            int H=sc.nextInt(),W=sc.nextInt();
            if(H==0&&W==0){
                break;
            }
            Pair p = new Pair(H,W);
            list.add(p);
        }
        for(int i=0;i<list.size();i++){
            Pair p = list.get(i);
            for(int j = 0;j < p.H ; j++){
                for(int k = 0;k < p.W;k++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 36772
#include<stdio.h>

int main(void) {
  int N;
  int K;
  int i;
  int ans = 1;

  scanf("%d %d",&N, &K);
  int array[N];
  for(i=0; i<N ;i++) {
      scanf("%d",&array[i]);
  }
  N -= K;
  if(N >= 0 && N%(K-1) != 0) {
      ans += N/(K-1) + 1;
  }
  else if(N >= 0 && N%(K-1) == 0) {
      ans += N/(K-1);
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int64_t K,n=0;

void dfs(int64_t num,int idx){
    if(idx<0){
        n++;
        if(n>=K){cout<<num<<endl; exit(0);}
        return;
    }

    int k=(num/(int)pow(10,idx+1))%10;
    if(k==0){
        dfs(num,idx-1);
        dfs(num+(k+1)*pow(10,idx),idx-1);
    }else if(k==9){
        dfs(num+(k-1)*pow(10,idx),idx-1);
        dfs(num+k*pow(10,idx),idx-1);
    }else{
        dfs(num+(k-1)*pow(10,idx),idx-1);
        dfs(num+k*pow(10,idx),idx-1);
        dfs(num+(k+1)*pow(10,idx),idx-1);
    }
}

int main(){
    cin>>K;

    int keta=0;
    while(n<K){
        rep(i,1,10){
            dfs(i*pow(10,keta),keta-1);
        }
        keta++;
    }
}

Measured memory_bytes: 384
N = gets.to_i
S = gets.chomp
x = 0
ans = 0

N.times do |i|
  if S[i] == "I"
    x += 1
  elsif S[i] == "D"
    x -= 1
  end
  if ans < x # もし、ans が x よりも小さくなったら
      ans = x
  end
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define pb(x) push_back((x))
#define line() cerr << "DEBUG @" << __LINE__ << endl;
#define debug(x) \
  cerr << "DEBUG @" << __LINE__ << " -> " << #x << " = " << x << endl;
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll d, t, s;
  cin >> d >> t >> s;
  cout << ((d <= t * s) ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 1000000000000
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    ll ans = n;
    for(ll i=0;i<=n;i++){
        ll j = i;
        ll sum=0;
        while(j>0){
            sum += j%6;
            j /= 6;
        }
        j = n-i;
        while(j>0){
            sum += j%9;
            j /= 9;
        }
        ans = min(sum,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    int m, n_min, n_max, p;
    vector<int> v;

    while (cin>>m>>n_min>>n_max, m||n_min||n_max) {
        for (int i = 0; i < m; ++i) {
            cin>>p;
            v.push_back(p);
        }
        sort(v.begin(), v.end(), greater<int>());
        int size = static_cast<int>(v.size());
        int diff = 0;
        int ans = 0;
        for (int i = n_max - 1; i >= n_min - 1; --i) {
            if (v[i] - v[i+1] > diff) {
                diff = v[i] - v[i+1];
                ans = i;
            }
        }
        cout<<ans+1<<endl;
        v.clear();
    }
    return 0;
}

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
char n[15];
int i;
int cout=0;
int kk=0;
scanf("%s",n);

for(i=0;i<sizeof(n);i++){
if(n[i]=='o'){
cout+=1;
}
if(n[i]=='x'){
kk+=1;
}

}
//(sizeof(n)/sizeof(n[0]))
if(kk<=7){
printf("YES");
}
else{
printf("NO");
}
//printf("%d",cout);


return 0;
}

Measured memory_bytes: 128
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n - i + 1):
    if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
      print(i, j, n - i - j)
      exit()

print("-1 -1 -1")

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string a, b, c;
	cin >> a >> b >> c;

	a.at(0) -= 32;
	b.at(0) -= 32;
	c.at(0) -= 32;

	cout << a.at(0) << b.at(0) << c.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    int a,b; cin>>a>>b;
    cout<<a*b;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#define int long long
signed main(){
  int N;
  int zero=0;
  std::cin>>N;
  int ans=0,plus=0;
  std::vector <int>town(N+1),power(N);
  for (int i=0;i<N+1;++i){
    std::cin>>town[i];
  }
  for (int i=0;i<N;++i){
    std::cin>>power[i];
  }
  for (int i=0;i<N;++i){
    ans+=std::min(std::max(plus,zero),town[i]);
    town[i]=std::max(town[i]-plus,zero);
    plus=std::max(power[i]-town[i],zero);
    ans+=std::min(power[i],town[i]);
  }
  ans+=std::min(std::max(plus,zero),town[N]);
  std::cout<<ans<<std::endl;
}


Measured memory_bytes: 1792
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,m;
cin>>n>>m;
vector<ll>v;
ll sum=0;
for(ll i=0;i<m;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
    sum+=a;
}
ll ans=max(-1ll,n-sum);
cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
const int BASE = 998244353;

long long fact[3000300], invFact[3000300];

long long power(long long x, long long y)
{
  if (!y)
    return 1;
  long long res = power(x, y >> 1);
  res = res * res % BASE;
  if (y & 1)
    res = res * x % BASE;
  return res;
}

long long c(int n, int k)
{
  if (k >= n)
    return n == k;
  return fact[n] * invFact[k] % BASE * invFact[n - k] % BASE;
}

int main()
{
  fact[0] = invFact[0] = 1;
  for (int i = 1; i <= 2500000; i++)
  {
    fact[i] = fact[i - 1] * i % BASE;
    invFact[i] = power(fact[i], BASE - 2);
  }

  int n, m;
  cin >> n >> m;

  long long bad = 0;
  // greatest value <= 2m
  for (int i = m * 2 + 1; i <= m * 3; i++)
    bad = (bad + c(m * 3 - i + n - 2, n - 2)) % BASE;
  bad = bad * n % BASE;

  long long ans = 0;
  for (int odd = 0; odd <= min(m, n); odd++)
    if (odd % 2 == m % 2)
    {
      int rem = (m * 3 - odd) / 2;
      ans = (ans + c(rem + n - 1, n - 1) * c(n, odd)) % BASE;
    }

  cout << (ans - bad + BASE) % BASE << endl;
}


Measured memory_bytes: 41216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=20,M=1<<20;
const ll ms=1e9+7;
ll read(){
	ll x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1; ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
ll a[M],inv[M],fac[M],f[2][M];
void pre(ll n){
	inv[0]=inv[1]=fac[0]=fac[1]=1;
	for (ll i=2;i<=n;i++){
		inv[i]=(ms-ms/i)*inv[ms%i]%ms;
		fac[i]=fac[i-1]*i%ms;
	}
	for (ll i=2;i<=n;i++)
	inv[i]=inv[i-1]*inv[i]%ms;
}
ll C(ll n,ll k){
	return (fac[n]*inv[n-k]%ms*inv[k]%ms)%ms;
}
bool cmp(ll a,ll b){
	return a>b;
}
int main(){
	ll n=read(),m=read();
	for (ll i=1;i<=m;i++)
    scanf("%lld",&a[i]);
    sort(a+1,a+1+m,cmp);
    pre(1<<n);
    ll now=0;
    f[now][0]=1;
    for (ll i=1;i<=m;i++){
    	now^=1;
    for (ll j=0;j<(1<<n);j++){
    	if (f[now^1][j]==0) continue;
    	f[now][j]=(f[now][j]+f[now^1][j])%ms;
    	ll res=(1<<n)-j-1;
    	for (ll k=0;k<(n);k++){
    		if ((j&(1<<k))==0){
    			f[now][j|(1<<k)]+=((f[now^1][j]*C(res-a[i]+1,(1<<k)-1)%ms*fac[1<<k])%ms);
    			f[now][j|(1<<k)]%=ms;
			}
		}
	   }	
	   memset(f[now^1],0,sizeof(f[now^1]));
	}
	ll ans=0;
	for (ll i=0;i<(1<<n);i++){
		if (f[now][i]==0) continue;
		ll fs=1;
		if ((__builtin_popcount(i)%2)==1) fs*=-1;
		ans=(ans+fs*f[now][i]*fac[(1<<n)-1-i]%ms)%ms;
	}
	if (ans<0) ans+=ms;
	(ans<<=n)%=ms;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 22784
# -*- coding: utf-8 -*-
n = int(input())
p_list = list(map(int, input().split()))

q_list = list(range(1, n + 1))
unmatch_p = []
for p, q in zip(p_list, q_list):
    if p == q:
        pass
    else:
        unmatch_p.append(p)
        
if len(unmatch_p) == 2:
    print("YES")
elif len(unmatch_p) == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
# import numpy as np
from collections import deque

def solve(H, W, CH, CW, DH, DW):#, S):
	# 後の条件分岐を簡略化するためワープしても迷路外に出ないように壁で囲む
	S=[input() for _ in range(H)]
	S = ['##{}##'.format(row) for row in S]
	S.insert(0, '##{}##'.format('#' * W))
	S.insert(0, '##{}##'.format('#' * W))
	S.append('##{}##'.format('#' * W))
	S.append('##{}##'.format('#' * W))


	MAX_COST = 10 ** 9
	Cost=[ [ MAX_COST for _ in range(W+4)] for _ in range(H+4)]
	# Cost = np.full((H,W),MAX_COST)

	# print(S)

	ans = -1

	cost0 = deque()

	cost0.append((CH+1,CW+1,0))
	Cost[CH+1][CW+1] = 0;

	# used = set()
	walk=[(1,0),(0,1),(-1,0),(0,-1)]
	warp = [ (i,j) for i in range(-2,3) for j in range(-2,3) if (i, j) not in [(0, 0)] + walk ]
	# print(warp)

	cost1 = deque()

	while cost0:
		h,w,c=cost0.popleft()
		cost1.append((h,w,c))

		for i,j in walk:
			dh = h+i
			dw = w+j
			if S[dh][dw] == '.' and c < Cost[dh][dw]:
				Cost[dh][dw] = c
				# print("updl ", i,j,dh,dw,c)
				cost0.appendleft((dh,dw,Cost[dh][dw]))

		if len(cost0) == 0:

			while cost1:
				h,w,c=cost1.popleft()
				# print(h,w,c)
				for i,j in warp:
					dh = h+i
					dw = w+j
					# print(i,j)
					if S[dh][dw] == '.' and c + 1 < Cost[dh][dw]:
						Cost[dh][dw] = c + 1
						cost0.append((dh,dw,Cost[dh][dw]))


	if Cost[DH+1][DW+1] == MAX_COST:
		print(-1)
	else:
		print(Cost[DH+1][DW+1])


if __name__ == "__main__":
	H,W=map(int,input().split())
	CH,CW=map(int,input().split())
	DH,DW=map(int,input().split())

	# S=[input() for _ in range(H)]

	solve(H, W, CH, CW, DH, DW)#, S)


Measured memory_bytes: 24344
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

const ll di[4] = {1, 0, -1, 0};
const ll dj[4] = {0, 1, 0, -1};

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数
    if(b == 0) {
        return 0;
    }
    return (a+b-1)/b;
}

struct Data {
    ll id, x;  // いまの状態id, 移動距離x
    Data(ll id, ll x): id(id), x(x) {}
    bool operator<(const Data& hoge) const {
        return x > hoge.x;
    }
};

int main() {
    ll h, w, k;
    cin >> h >> w >> k;

    ll si, sj, gi, gj;
    cin >> si >> sj >> gi >> gj;
    si--;  sj--;  gi--;  gj--;

    vector<string> board(h);
    rep(i, h) {
        cin >> board[i];
    }
    
    vl dp(4*h*w, INF);  // dp[id] : idの状態となる移動距離の最小値
    priority_queue<Data> Q;
    auto push = [&](ll id, ll x) {
        if(dp[id] <= x) {
            return;
        }
        dp[id] = x;
        Q.emplace(id, x);
    };

    auto toId = [&](ll i, ll j, ll dir) {
        return 4*(i*w + j) + dir;
    };

    // 拡張ダイクストラ法。計算量はO((V+E)*log(V))
    rep(dir, 4) {
        push(toId(si, sj, dir), 0);
    }
    while(!Q.empty()) {
        Data hoge = Q.top();  Q.pop();
        ll id = hoge.id, x = hoge.x;
        if(dp[id] != x) {
            continue;
        }
        ll i = id/4/w;
        ll j = id/4%w;
        ll dir = id%4;
        // 向きを変える場合
        rep(ndir, 4) {  
            push(toId(i, j, ndir), k*ceil(x, k));
        }
        // 向きを変えずに直進する場合
        ll ni = i + di[dir];
        ll nj = j + dj[dir];
        if(ni < 0 || h <= ni || nj < 0 || w <= nj) {
            continue;
        }
        if(board[ni][nj] == '@') {
            continue;
        }
        push(toId(ni, nj, dir), x+1);
    }

    ll ans = INF;
    rep(dir, 4) {
        chmin(ans, dp[toId(gi, gj, dir)]);
    }

    if(ans == INF) {
        out(-1);
    }
    else {
        ans = k*ceil(ans, k)/k;
        out(ans);
    }

    re0;
}

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

int main(){
	int a,b;
	cin>>a>>b;
	if(a==1)a=14;
	if(b==1)b=14;
	if(a>b){
		cout<<"Alice"<<endl;
	}else if(a<b){
		cout<<"Bob"<<endl;
	}else{
		cout<<"Draw"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
string s;
signed main(){
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])puts("Yes");
    else puts("No");
    return 0;
}

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


int main(void) {
	int n,l,i,j;
	char str[100][101],tmp[101];
	
	scanf("%d %d",&n,&l);
	
	for (i = 0;i < n;i++) {
		scanf("%s",str[i]);
	}
	
	for (i = 0;i < n;i++) {
		for (j = i+1;j < n;j++) {
			if(strcmp(str[i],str[j]) > 0) {
				strcpy(tmp,str[i]);
				strcpy(str[i],str[j]);
				strcpy(str[j],tmp);
			}
		}
	}
	
	for (i = 0;i < n;i++) {
		printf("%s",str[i]);
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
D = defaultdict(int)
for e in A:
    D[e] += 1
l1 = []
l2 = []
for key,value in D.items():
    if value > 1:
        l1.append(key)
    if value > 3:
        l2.append(key)
if len(l1) < 2:
    print(0)
    exit()
l1.sort()
l2.sort()
if len(l2) > 0:
    print(max(l1[-1]*l1[-2],l2[-1]*l2[-1]))
else:
    print(l1[-1]*l1[-2])

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, a, b;
	cin>>n>>a>>b;
	cout<<min(b, a*n)<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;

int main(){
    int x;
    int i = 0;
    int n;
    cin >> n;

    while(++i <= n){
        x = i;
        if(x % 3 == 0) {
            cout << " " << i;
            continue;
        }

        while(true){
            if(x % 10 == 3){
                cout << " " << i;
                break;;
            }
            x /= 10;
            if(x == 0) break;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3096
// ~/SolverToBe/Developers/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <assert.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 100005, M = 1000005;
const ll MOD = 1e9 + 7;
const double eps = 1e-9;

int n,h[N],dp[N];

int main() {
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    scanf("%d",h+i);
    h[n] = 1e9;
    dp[n-1] = 0;
    for(int i=n-2; i>=0; i--) 
        dp[i] = min(dp[i+1] + abs(h[i]-h[i+1]), dp[i+2] + abs(h[i]-h[i+2]));
    printf("%d\n", dp[0]);
    return 0;
}

Measured memory_bytes: 1024
using System;
 
class Program
{
    static void Main(string[] args)
    {
        var abcd = Console.ReadLine().Split(' ');
        var a = int.Parse(abcd[0]);
        var b = int.Parse(abcd[1]);
        var c = int.Parse(abcd[2]);
        var d = int.Parse(abcd[3]);
 
        if (a + b > c + d)
        {
            Console.WriteLine("Left");
        }
        else if (a + b < c + d)
        {
            Console.WriteLine("Right");
        }
        else
        {
            Console.WriteLine("Balanced");
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int n,q;
main()
{
	cin>>n>>q;
	if(n==1)
	{
		int v,w;
		for(int i=0;i<q;i++)
		{
			cin>>v>>w;
			cout<<v<<endl;
		}
		return 0;
	}
	for(int i=0;i<q;i++)
	{
		int v,w;cin>>v>>w;
		while(v!=w)
		{
			if(v>w)v^=w^=v^=w;
			w=(w+n-2)/n;
		}
		cout<<v<<endl;
	}
}


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

typedef long long ll;
typedef vector<int> vi;

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

    int n, m, a, b;
    cin >> n >> m;
    int ind[n] = {};
    int res[n] = {};
    vi par[n];
    vi chi[n];
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        a --; b--;
        ind[b] ++;
        par[b].push_back(a);
        chi[a].push_back(b);
    }
    queue<int> que;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (!ind[i]) {
            que.push(i);
        }
    }
    while (!que.empty()) {
        int cur = que.front();
        if (par[cur].size() == 0) {
            res[cur] = 0;
        } else {
            for (auto p : par[cur]) {
                res[cur] = max(res[cur], res[p] + 1);
            }
        }
        ans = max(ans, res[cur]);
        que.pop();
        for (auto to : chi[cur]) {
            --ind[to];
            if (ind[to] == 0) que.push(to);
        }
    }

    cout << ans << endl;

    return 0;
}



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

int main(void)
{
    int a, b;
    cin >> a >> b;

    vector<int> tower(1000, 0);
    tower[0] = 1;
    for (int i = 1; i < 1000; i++)
    {
        tower[i] = tower[i - 1] + (i + 1);
        // printf("%d ", tower[i]);
    }

    int diff = abs(a - b);
    int snow = tower[diff - 1] - b;
    cout << snow << endl;
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N;
  cin >> N;
  ll A[N];
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  ll p = ((N*(N+1LL)) / 2LL);
  if (sum % p != 0) {
    cout << "NO" << endl;
    return 0;
  }
  ll S = sum / p;
  ll Ssum = 0;
  for (int i = 1; i < N; i++) {
    if (A[i] - A[i-1] > S) {
      cout << "NO" << endl;
      return 0;
    }
    ll a = S - (A[i] - A[i-1]);
    if (a % N != 0) {
      cout << "NO" << endl;
      return 0;
    }
    Ssum += a / N;
  }
  if (A[0] - A[N-1] > S) {
    cout << "NO" << endl;
    return 0;
  }
  ll ab = S - (A[0] - A[N-1]);
  if (ab % N != 0) {
    cout << "NO" << endl;
    return 0;
  }
  Ssum += ab / N;
  
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 4356
#include <stdio.h>
int main(void){
    int n,m,i,j,a[100][100],b[100],c[100];
    for(i=0,scanf("%d%d",&n,&m);i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(j=0;j<m;j++){
        scanf("%d",&b[j]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            c[i]+=a[i][j]*b[j];
        }
        printf("%d\n",c[i]);
    }
}

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



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

	int m, n;
	cin >>  n >> m;
	int a = 1, b = n, c, d;
	for (int i = 1; i <= m; i++)
	{
		cin >> c >> d;
		a = max(a, c);
		b = min(b,  d);
	}
	int ans = 0;
 	if (b >= a)
		ans = (b - a + 1);
	cout << ans;
}


Measured memory_bytes: 256
from sys import stdin
import collections

s = stdin.readline().rstrip().split()[0]

if len(s) % 2 == 1 and s[0] == s[len(s)-1]:
    print('Second')
elif len(s) % 2 == 1 and s[0] != s[len(s)-1]:
    print('First')
elif len(s) % 2 == 0 and s[0] == s[len(s)-1]:
    print('First')
elif len(s) % 2 == 0 and s[0] != s[len(s)-1]:
    print('Second')


Measured memory_bytes: 3572
//#line 2 "SubstringQueries.cpp"

#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N, X;
const LL MOD = 998244353;
LL dp[515][515];
LL ndp[515][515];

int main() {
	cin >> N >> X;
	dp[0][0] = 1;
	for (int i = 0; i < N; ++i) {
		memset(ndp, 0, sizeof(ndp));
		//dpの累積和をとる
		for (int j = 0; j <= X; ++j) {
			for (int k = 0; k < 512; ++k) {
				dp[j + 1][k] += dp[j][k];
				dp[j + 1][k] %= MOD;
			}
		}
		//ndpに遷移
		for (int j = 0; j <= X; ++j) {
			for (int k = 0; k < 512; ++k) {
				ndp[j][k] = dp[j][j ^ k];
			}
		}
		//ndpをdpに移す
		for (int j = 0; j <= X; ++j) {
			for (int k = 0; k < 512; ++k) {
				dp[j][k] = ndp[j][k];
			}
		}
	}
	LL ans = 0;
	for (int j = 0; j <= X; ++j) {
		ans += dp[j][X];
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7208
N=int(input())
A=list(map(int, input().split())) 
tmp=[]
ans=True
for i in A:
  if i%2==0:
    tmp.append(i)
  else:
    continue

for i in tmp:
  if i%3==0 or i%5==0:
    continue
  else:
    ans=False
    
if ans:
  print("APPROVED")
else:
  print("DENIED")

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

int main() {
    string s;
    cin >> s;
    //bool a = false, b = false;
    int a = 0, b = 0;

    for (int i = 0; i < s.size(); i++) {
        if ('A' == s[i]) a++;
        if ('B' == s[i]) b++;
    }

    if (a > 0 && b > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
use std::str::FromStr;

fn main(){
  let mut buf = String::new();
  loop {
    match std::io::stdin().read_line(&mut buf){
      Ok(0) => break,
      Ok(_) => {
        let x : Vec<i32> = buf.trim().split_whitespace().map(|c| i32::from_str(c).unwrap()).collect();
        println!("{}", x[0]+x[1]);
        buf.clear();
      },
      Err(_) => break
    }
  }
}



Measured memory_bytes: 5036
#include <bits/stdc++.h>
#define debug(...)
#include <complex.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;


int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);
    vector<char> s ;
    for(int i = 0; i < 26; i++){
        s.push_back((char)('A' + i) );
    }
    int n;
    cin >> n;
    string A;
    cin >> A;
    for(char c : A){
        cout << s[ (c - 'A' + n) % 26 ] ;
    }
    cout << '\n';



    return 0;
}













Measured memory_bytes: 256
N,K=map(x->parse(Int,x),split(readline()))
X=map(x->parse(Int,x),split(readline()))
ans=10^15
for i=K:N
	L=X[i-K+1]
	R=X[i]
	if R<0
		ans=min(ans,-L)
	elseif L>0
		ans=min(ans,R)
	else
		ans=min(ans,R-2L,-L+2R)
	end
end
println(ans)


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=a;
  int y=c;
  bool n=0;
  
  for(int i=0;i<110;i++){
    y=y-b;
    x=x-d;
    
    if(y<=0){
      n=1;
      break;
    }
    if(x<=0){
      break;
    }
  }
  if(n==1)
    cout<<"Yes"<<endl;
  if(n==0)
    cout<<"No"<<endl;
}

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


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;



int main()
{
    SAM;
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";
    
   
    
    return 0;
}




Measured memory_bytes: 3644
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;


public class Main {
	public void exec() throws IOException {
		Scanner input = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a = input.nextInt();
		int b = input.nextInt();
		int c = input.nextInt();
		int cSqrt = (int)Math.sqrt(c);
		int divcnt = 0;
		int div = 0;
		for (int i=1; i<=cSqrt && i<=b; i++) {
			if(c%i == 0){
				if(a <= i && i <= b) divcnt++;
				div = c/i;
				if(i != div && a <= div && div <= b) divcnt++;
			}
		}
		out.println(divcnt);
		out.flush();
		input.close();
	}

	public static void main(String[] args) throws IOException {
		new Main().exec();
	}
}

Measured memory_bytes: 26236
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    long res = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        for (int j = i - 1; j >= 0; j--)
        {
            vector<int>::iterator itr = lower_bound(L.begin(), L.end(), L[i] - L[j] + 1);
            int idx = distance(L.begin(), itr);
            res += max(0, j - idx);
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

# N <= 300 O(n ** 3)まで
# 何通り dp or combo
N = getN()
# 1つ目の譜面
B = []
for i in range(N):
    q = list(input())
    B.append(q * 2)
B += B
# 2つ目にはなにも書かれてない
# 2つ目の盤面に縦にi、横にjずらして数字を記入する

# 対角線に対して線対称なものの数を求める
# 整数a, bの選び方が何通りあるか

def judge(a, b):
    """
    res = [[''] * N for i in range(N)]
    # 盤面１のB[i][j]を盤面2に書き込む
    for i in range(N):
        for j in range(N):
            res[(i + a) % N][(j + b) % N] = B[i][j]
    """

    for i in range(N):
        for j in range(i, N):
            if B[i + a][j + b] != B[j + a][i + b]:
                return 0
        else:
            continue
        break
    else:
        return 1

# 全てのa, bについて調べるなら１つの(a, b)についてO(N)で求める必要がある
# 判定する際、節約出来ないか？

# N * N のゾーンをずらしていく
# a [b  a] b
# c [a  c] a
# a  b  a  b
# c  a  c  a 対称軸がずれる 軸は2N - 1本ある
# 良い盤面になる条件

# 斜めにずらしていくことで前の結果を利用できる
# 1本の軸について判定した時、1つの盤面が良い盤面なら他全ても良い盤面
# 軸に刺さっている盤面の数を求めればいい

# 軸は2N - 1本ある
# 縦に対角線をずらす
ans = 0
for i in range(N):
    # 軸(0, i)にはN - i本の盤面が連なっている
    # 連なっている全ての盤面は全てTrueか全てFalse
    ans += (N - i) * judge(i, 0)

# 横に対角線をずらす
for i in range(1, N):
    ans += (N - i) * judge(0, i)
print(ans)

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  int n;
  cin >> n;
  cout << n*n << endl;
}

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


Measured memory_bytes: 256
a1 = 0
c11, c12, c13 = map(int, input().split())
b1 = c11 - a1
b2 = c12 - a1
b3 = c13 - a1

c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

if c21 - b1 == c22 - b2 == c23 - b3 and c31 - b1 == c32 - b2 == c33 - b3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int N, K;
int a[101][101];

int main(){
    INIT;
    cin >> N >> K;
    if(K > (N-1)*(N-2)/2) {
        cout << -1 << "\n";
        return 0;
    }

    for(int i = 2; i <= N; i++) {
        a[1][i] = 1;
    }

    int cnt = (N-1)*(N-2)/2;
    if(cnt == K) {
        int ans = 0; 
        FOR(x,1,N+1) FOR(y,1,N+1) if(a[x][y]) ans++;
        cout << ans << "\n";
        FOR(x,1,N+1) FOR(y,1,N+1) if(a[x][y]) cout << x << " " << y << "\n";
        return 0;
    }

    FOR(i,2,N+1) {
        FOR(j,i+1,N+1) {
            a[i][j] = 1;
            cnt--;
            if(cnt == K) {
                int ans = 0; 
                FOR(x,1,N+1) FOR(y,1,N+1) if(a[x][y]) ans++;
                cout << ans << "\n";
                FOR(x,1,N+1) FOR(y,1,N+1) if(a[x][y]) cout << x << " " << y << "\n";
                return 0;
            }
        }
    }

    cout << -1;
}

Measured memory_bytes: 384
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    int counter = 0;
    for (int i = 1; i <= n; i++) {
        int p;
        cin >> p;

        if (i != p) ++counter;
    }

    if (counter == 2 || counter == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}


#define VERTEX_MAX 10000
#define EDGE_MAX 100000
struct list {
    struct list *next;
    int dst;
};

struct list *create_graph(int vs) {
    static struct list graph[VERTEX_MAX];
    int i;
    for(i = 0; i < vs; i++) {
        graph[i].next = &graph[i];
    }
    return graph;
}

struct list lpool[EDGE_MAX];
int lidx = 0;

void add_list(struct list *head, int v) {
    struct list *elem = &lpool[lidx++];
    elem->dst = v;
    elem->next = head->next;
    head->next = elem;
    return;
}

static int ans[VERTEX_MAX];
static int pos = 0;
static char checked[VERTEX_MAX];
void dfs(struct list *graph, int *outdeg, int node) {
#ifdef DEBUG
    printf("dfs(%d)\n", node);
#endif
    struct list *head = &graph[node];
    struct list *elem;
    ans[pos++] = node;
    checked[node] = 1;
    for(elem = head->next; elem != head; elem = elem->next) {
        int dst = elem->dst;
        outdeg[dst]--;
        if(outdeg[dst]) continue;
        dfs(graph, outdeg, dst);
    }
}

int main(void) {
    int vs, es;
    get_int2(&vs, &es);
    struct list *graph = create_graph(vs);
    static int outdeg[VERTEX_MAX];

    int i;
    for(i = 0; i < es; i++) {
        int src, dst;
        get_int2(&src, &dst);
        add_list(&graph[src], dst);
        outdeg[dst]++;
    }

    for(i = 0; i < vs; i++) {
        if(!outdeg[i] && !checked[i]) dfs(graph, outdeg, i);
#ifdef DEBUG
        int j;
        printf("%d: ", i);
        for(j = 0; j < vs; j++) {
            printf("%d ", outdeg[j]);
        }
        putchar('\n');
#endif
    }

    // presentation
    for(i = 0; i < vs; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 2656
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int N;
  cin >> N;
  VI A(N);
  REP(i, N) {
    cin >> A[i];
  }

  SORT(A);
  int pre = A[0];
  int ans = N, same = 0;

  NREP(i, N - 1) {
    if (A[i] != pre) {
      pre = A[i];
    } else {
      same++;
      if (same > 1) {
        ans -= 2;
        same = 0;
      }
    }
  }

  cout << ans - same * 2 << endl;
  return 0;
}

Measured memory_bytes: 640
std_value = []
while True:
    n = int(input())
    if n == 0:
        break
    s = [int(i) for i in input().split()]#生徒の点数
    sum_value=0
    s_ave = 0
    for i in range(len(s)):#平均値計算
        sum_value += s[i]
    ave = sum_value/len(s)
    for j in range(len(s)):
        s_ave += (s[j]-ave)**2
    std_value.append((s_ave/len(s))**(1/2))
for k in range(len(std_value)):
    print("{:.8f}".format(std_value[k]))


Measured memory_bytes: 5676
#include <cstdio>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    int sum = 0;
    int tmp = n;
    while (tmp > 0) {
        sum += tmp % 10;
        tmp /= 10;
    }
    if (n % sum) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256