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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX;

int main() {
  ll n, k, a[100], sum, ans = INF, mx, q;
  cin >> n >> k;
  rep(i, n) cin >> a[i];

  rep(i, 1 << n) {
    sum = 0;
    q = 1;
    rep(j, n) {
      if (j == 0) mx = a[0];
      if (i & (1 << j) && j != 0) {
        if (mx >= a[j])
          sum += (mx + 1) - a[j], mx++, q++;
        else
          mx = a[j], q++;
      } else {
        if (mx < a[j]) mx = a[j], q++;
      }
    }
    if (q == k) ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    ll a,b;
    cin>>a>>b;
    if((a+b)>=10)
    {
        cout<<"error"<<endl;
    }else
    {
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#import <iostream>
using namespace std;
int main(){
	long long N,K,a,b,group,sum=0;
	cin>>N>>K;
	//Kが0の時だけ分ける
	if(K==0)sum=N*N;
	//a,b両方動かすとあれなのでbだけ動かす
	//あるbについて0~Nの数をそれぞれbで割った値は0~b-1を繰り返す
	//そのグループ一つに関して条件を満たすのが何個あるか考える
	else{
		for(b=K;b<=N;b++){
		//グループが何個できるか計算。
		group=(N-N%b)/b;

		//そのグループ一つで条件を満たすのは何個か数え、グループ倍
		sum+=(b-K)*group;

		//グループに入らんかった分計算して足す
		if(N%b>=K)sum+=N%b-K+1;
		}
	}

	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
    public static void Main()
    {
        while (true) {
            int n = int.Parse(Console.ReadLine());
            if (n == 0) return;
            string str = Console.ReadLine();
            for (int i = 0; i < n; i++)
            {
                string temp = "";
                int len = 1;
                for (int j = 1; j < str.Length; j++)
                {
                    if (str[j] == str[j - 1])
                    {
                        len++;
                    }
                    else
                    {
                        temp += len.ToString() + str[j - 1];
                        len = 1;
                    }
                }
                temp += len.ToString() + str[str.Length - 1];
                str = temp;
            }
            Console.WriteLine(str);
        }
    }
}

Measured memory_bytes: 10288
#include <cstdio>
#include <cstring> 
#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a
#define N 200006
long long n,a,b,x,y,ans;
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	scanf("%lld",&x);
	for(int i=2;i<=n;i++){
		scanf("%lld",&y);
		ans+=min(b,(y-x)*a);
		x=y;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N;
  cin>>K;
  int x[N];
  for(int i=0;i<N;i++) {
    cin>>x[i];
  }
  int ans=0;
  
  for(int i=0;i<N;i++) {
    if(x[i]<=K-x[i]) {
      ans+=x[i]*2;
    }
    
    else{
      ans+=(K-x[i])*2;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

/* プロダクト宣言 */
void int_hantei(); 


int main() {

	int_hantei();

	return 0;
}

/* int_hanteiの関数 */
void int_hantei(){

	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if( 0 > x-r || 0 > y-r || W < x+r || H < y+r) {
		cout << "No" <<endl;
	}
	else{
		cout << "Yes" << endl;
	}
}


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


import sys


def counting_sort(A, max_occurance):
    result = [0] * array_length
    count_list = [0] * max_occurance

    for j in range(array_length):
        count_list[A[j]] += 1
    # print('step-1', C[:array_length])

    for i in range(1, max_occurance):
        count_list[i] += count_list[i - 1]
    # print('step-2', C[:array_length])

    for m in array[::-1]:
        result[count_list[m] - 1] = m
        count_list[m] -= 1

    return result


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    assert len(array) == array_length
    max_elem = int(1e4)
    result = counting_sort(A=array, max_occurance=max_elem)
    print(*result)

Measured memory_bytes: 220968
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int N;
    cin >> N;
    constexpr int kNum = 100;

    map<uint64_t, int> freq;

    for(int x=1; x <= kNum; ++x) {
        int x2 = x*x;
        for(int y=1; y <= kNum; ++y) {
            int y2 = y*y;
            for(int z=1; z <= kNum; ++z) {
                uint64_t tmp = x2 + y2 + z*z + x*y + y*z + z*x;
                freq[tmp]++;
            } 
        }
    }

    rep(i, N) {
        cout << freq[i+1] <<endl;
    }
    return 0;

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld EPS = 1e-11;
const ld PI = acos(-1.0);
const int INF = (int)1e9 + 5;
const ll LINF = (ll)1e18 + 5;

template<class T> 
ll abs(const T & x) { return x < 0 ? -x : x; }

template<class T> 
ll round(const T & x) { return x < 0 ? x - 0.5 : x + 0.5; }

template<class T> 
bool chmin(T & x, const T & y) {
	if (y < x) {
		x = y;
		return true;
	}
	return false;
}

template<class T> 
bool chmax(T & x, const T & y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

#define all(a) (a).begin(), (a).end()

int main() {
#ifdef LOCAL 
	freopen("input.txt", "r", stdin);
#else
#endif

	int n;
	scanf("%d", &n);
	vector<int> a(n * 2);

	for (int i = 0; i < n * 2; i++) {
		scanf("%d", &a[i]);
	}

	
	sort(all(a));
	reverse(all(a));
	
	ll s = 0;

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

	cout << s << endl;

}

Measured memory_bytes: 256
// B - Increment Decrement
// https://atcoder.jp/contests/abc052/tasks/abc052_b
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n;
  cin >> s;
  vi d;
  rep(i, 0, s.size())
  {

    if (s[i] == 'I')
    {
      ans++;
    }
    else
    {
      ans--;
    }
    d.eb(ans);
  }
  if (MAX(d) < 0)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << MAX(d) << "\n";
  }
}

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

int main() {

  std::string str;
  int count[26] = {};

  while( std::cin >> str ) {
    for(int i = 0; i < str.size(); ++i) {
      if( 'a' <= str[i] && str[i] <= 'z' ) {
	count[str[i]-'a'] += 1;
      }
      if( 'A' <= str[i] && str[i] <= 'Z' ) {
	count[str[i]-'A'] += 1;
      }
    }
  }
  for(int i = 0; i < 26; ++i) {
    printf("%c : %d\n", i+'a', count[i]);
  }
  
  return 0;
}

Measured memory_bytes: 1176
import sys
S = list(input())
if len(S)%2 != 0:
    print("No")
    sys.exit()
for i in range(len(S)):
    if i%2 == 0:
        if S[i] != 'h':
            print("No")
            sys.exit()
    else:
        if S[i] != 'i':
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n > 0){
    if(n % 10 == 9){
      cout << "Yes" << endl;
      return 0;
    }
    n /= 10;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 11;

int a[MAX_N];
int n;

ll gcd(ll a,ll b)
{
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}

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

int main()
{
	scanf("%d",&n);
	rep(i,n){
		scanf("%d",&a[i]);
	}
	ll ans = 1;
	rep(i,n){
		ans = lcm(ans,a[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3220
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    S = list(_in[0])  # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    ans = 0
    if S[-1] == 's':
        S[-1] += 'es'
    else:
        S[-1] += 's'
    ans = ''.join(S)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61748
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	String a = scan.next();
	String s = scan.next();
	String c = scan.next();

	System.out.println(a.charAt(0)+""+s.charAt(0)+""+c.charAt(0));
    }
}


Measured memory_bytes: 23252
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LL long long
#define uLL unsigned long long
int cmp(LL a,LL b,LL c,LL d)
{
	if (a==c)
	{
		return c-d;
	}
	else
	{
		return a-c;
	}
}
int main()
{
	LL i,j,k,a,b,c,d,ans;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	k=1;
	for (i=1;i<=d;i++)
	{
		k=k*2;
	}
	ans=0;
	i=a+b+c*k;
	if (ans<i) {ans=i;}
	i=a*k+b+c;
	if (ans<i) {ans=i;}
	i=a+b*k+c;
	if (ans<i) {ans=i;}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    int n,m,x;
    cin>>n>>m>>x;
    int c[n],a[n][m];
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    int ans=1200001;
    for(int i=0 ; i < (1<<n) ; i++)
    {
        int temp=0,p[n]={};
        for(int j=0;j<n;j++)
        {
            if((i & (1<<j)) != 0)
            {
                temp+=c[j];
                for(int k=0;k<m;k++)
                {
                    p[k]+=a[j][k];
                }
            }   
        }
        bool flag=true;
        for(int j=0;j<m;j++)
        {
            if(p[j]<x)
            {
                flag=false;
                break;
            }
        }
        if(flag==true)
        {
            ans=min(temp,ans);
        }
    }
    if(ans==1200001)
    {
        ans=-1;
    }
    cout<<ans;
    return 0; 
}

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

namespace AtCoder_20190707_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int appleCount = int.Parse(input[0]);
            int watchWidth = int.Parse(input[1]);

            int watcherCount = 0;

            while(appleCount > 0)
            {
                appleCount = appleCount - (2 * watchWidth + 1);

                watcherCount = watcherCount + 1;
            }

            Console.WriteLine(watcherCount);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int c = 0;
  for(int i = 1; i <= N/2; i++){
    if(N-i != i){
      c += 1;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
import itertools
import copy
h, w, k = map(int, input().split())
table = [list(input()) for _ in range(h)]
ans = 0
for ptr_h in itertools.product([0, 1], repeat=h):
    for ptr_w in itertools.product([0, 1], repeat=w):
        times = 0
        tmp = copy.deepcopy(table)
        for i, v in enumerate(ptr_w):
            if v == 1:
                for p in tmp:
                    p[i] = "red"
        for i, v in enumerate(ptr_h):
            if v == 1:
                for ind, l in enumerate(tmp):
                    if ind == i:
                        for n in range(w):
                            l[n] = "red"
        for i in tmp:
            for j in i:
                if j == "#":
                    times += 1
        if times == k:
            ans += 1
print(ans)

Measured memory_bytes: 71704
def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        flg = False
        flg2 = False
        for x in range(N):
          if flg2:
            break
          if not flg:
            if S[x] == i:
              flg = True
          else:
            if S[x] == j:
              flg2 = True
              if k in S[x+1:]:
                ans +=1
  print(ans)
main()

Measured memory_bytes: 3640
def d_maze_master(INF=float('inf')):
    from collections import deque
    H, W = [int(i) for i in input().split()]
    Maze = [list(input()) for _ in range(H)]

    def bfs(start_row, start_col):
        diff = ((-1, 0), (0, 1), (1, 0), (0, -1))

        def is_inside(row, col):
            return 0 <= row < H and 0 <= col < W

        queue = deque([(start_row, start_col)])
        dist = [[INF for _ in range(W)] for _ in range(H)]
        dist[start_row][start_col] = 0
        while queue:
            row, col = queue.pop()
            for dr, dc in diff:
                nr, nc = row + dr, col + dc
                if is_inside(nr, nc) and Maze[nr][nc] != '#' and dist[nr][nc] == INF:
                    queue.appendleft((nr, nc))
                    dist[nr][nc] = dist[row][col] + 1
        return dist

    ans = 0
    for start_row in range(H):
        for start_col in range(W):
            if Maze[start_row][start_col] == '#':
                continue
            dist = bfs(start_row, start_col)
            for row in range(H):
                for col in range(W):
                    if Maze[row][col] != '#':
                        ans = max(ans, dist[row][col])
    return ans

print(d_maze_master())


Measured memory_bytes: 3316
N=int(input())
F=[int(input().replace(' ',''),2) for _ in range(N)]
P=[list(map(int,input().split())) for _ in range(N)]

ans=-10**10
for i in range(1,1<<10):
    prof=0
    for j,f in enumerate(F):
        prof+=P[j][bin(i&f).count("1")]
    ans=max(ans,prof)

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int main() {
  LL n,x;
  cin >> n >> x;
  x = min(x, n - x);
  if(2 * x == n) {
    printf("%lld\n",3*x);
    return 0;
  }
  LL ans = n + 2 * x;
  LL l = n - 2 * x;
  LL b = x;
  while(l && b) {
    if(l % b == 0) {
      ans += ((l / b) * 2 - 1) * b;
      break;
    }
    ans += ((l / b) * 2) * b;
    LL c = l % b;
    l = b;
    b = c;
  }
  cout << ans << "\n";
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    if (s[0] == '9' || s[1] == '9')
        OP("Yes");
    else
        OP("No");

    return 0;
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n"

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; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll modPow(ll x,ll n,ll mod=MOD){
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod);
}
using namespace std;
//-------------------------------------------

int main(void){
  string S;cin>>S;
  cout<<(S=="SUN"?7:S=="MON"?6:S=="TUE"?5:S=="WED"?4:S=="THU"?3:S=="FRI"?2:S=="SAT"?1:0);
}


Measured memory_bytes: 256
X = int(input())
break_flag = 0
for i in range(1000):
  for j in range(i):
    a, b = i, j
    if a**5 - b**5 == X:
      print(a, b)
      break_flag = 1
      break
    elif a**5 + b**5 == X:
      print(a, -b)
      break_flag = 1
      break
  if break_flag == 1:
    break 

Measured memory_bytes: 9180
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  ll n, m;

  cin >> n >> m;

  if(n == 1 || m == 1) {
    cout << 1;
    return 0;
  }

  cout << (n % 2 == 0 ? (m * n / 2) : (m * (n - 1) / 2 + (m / 2) + (m % 2)));

  return 0;
}
/*
x
x
x
*/


Measured memory_bytes: 3644
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]


def recur(n, i, a, b, c):
    if i == n:
        if a < 1 or b < 1 or c < 1:
            return 10 ** 18
        return abs(A-a) + abs(B-b) + abs(C-c)
    return min([
        recur(n, i + 1, a, b, c),
        recur(n, i + 1, a + l[i], b, c) + (10 if a > 0 else 0),
        recur(n, i + 1, a, b + l[i], c) + (10 if b > 0 else 0),
        recur(n, i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)
    ])


print(recur(n, 0, 0, 0, 0))


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt();
		int[] x=new int[n];
		for(int i=0;i<n;i++){
			x[i]=sc.nextInt();
		}
		Arrays.sort(x);
		int sum=0;
		for(int i=0;i<a;i++){
			sum+=x[i];
		}
		System.out.println(sum);
	}
}


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

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll a[99];
int main(){
	ll a;
	scanf("%lld",&a);
	ll temp=a,s=0;
	while(temp){
		s+=temp%10;
		temp/=10;
	}
	puts(a%s==0?"Yes":"No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    ll C;
    cin >> N >> C;
    ll x[N], y[N], v[N];
    rep(i, N){
        cin >> x[i] >> v[i];
        y[i] = C-x[i];
    }
    //cx[i]:=時計回りにi+1個寿司をとったときのエネルギーの差し引き
    //cy[i]:=反時計回りにi+1個寿司をとったときのエネルギーの差し引き
    ll cx[N], cy[N];
    cx[0] = v[0]-x[0];
    cy[0] = v[N-1]-y[N-1];
    rep2(i, 1, N-1){
        cx[i] = cx[i-1]+v[i]-(x[i]-x[i-1]);
        cy[i] = cy[i-1]+v[N-1-i]-(y[N-1-i]-y[N-i]);
    }
    //mx[i]:=cx[0]からcx[i]までの最大値
    ll mx[N], my[N];
    mx[0] = cx[0], my[0] = cy[0];
    rep2(i, 1, N-1){
        mx[i] = max(mx[i-1], cx[i]);
        my[i] = max(my[i-1], cy[i]);
    }
    ll ans = 0;
    //最初時計回りにi+1個回収してからから折り返す場合
    rep(i, N-1){
        ll tmp = cx[i]-x[i]+my[N-2-i];
        ans = max(ans, tmp);
    }
    //最初反時計回りにi+1個回収してから折り返す場合
    rep(i, N-1){
        ll tmp = cy[i]-y[N-1-i]+mx[N-2-i];
        ans = max(ans, tmp);
    }
    //折り返さない場合
    ans = max(ans, mx[N-1]);
    ans = max(ans, my[N-1]);
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>

int main(void){
	int num;
	std::string str;
	std::string::size_type index;

	std::cin >> num;
	std::cin.ignore();

	for(int i; i < num; ++i){
		getline(std::cin, str);

		for(index = str.find("Hoshino"); index != std::string::npos; index = str.find("Hoshino",index + 6)){
			str.replace(index,7,"Hoshina");
		}

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

Measured memory_bytes: 1208
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::{HashSet, VecDeque};

fn main() {
    input!{
        n: usize,
        a: [usize; n],
        b: [usize; n]
    }
    let inf = usize::max_value() >> 1;
    let mut dp = vec![vec![inf; 51]; 1 << n];
    dp[(1 << n) - 1][0] = 0;
    let mut q = VecDeque::new();
    q.push_back((0, (1 << n) - 1));
    let mut set = HashSet::new();
    while let Some((next, s)) = q.pop_front() {
        if !set.insert(s) {
            continue;
        }
        for i in 0..50 {
            dp[s][i + 1] = min(dp[s][i], dp[s][i + 1]);
        }
        let mut c = 0;
        for i in 0..n {
            let bit = 1 << i;
            if s & bit == 0 {
                continue;
            }
            let y = if (i + next) % 2 == 0 {a[i]} else {b[i]};
            dp[s ^ bit][y] = min(dp[s ^ bit][y], dp[s][y] + c);
            q.push_back((next + 1, s ^ bit));
            c += 1;
        }
    }
    let ans = dp[0].iter().cloned().min().unwrap();
    if ans == inf {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 151932
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int H,W,N;
    cin >> H;
    cin >> W;
    cin >> N;

    cout << int(ceil((float)N/max(H,W))) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int X, myNum[] = {7, 5, 3};
    bool celebra = false;

    cin >> X;

    for(int i = 0; i < 3; i++) {

        if(X == myNum[i]) {
            cout << "YES" << endl;

            return 0;
        }
    }

    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

if n >= 2 and m >= 2:
  print((n-2)*(m-2))
elif n == 1 and m >= 2:
  print(m - 2)
elif n >= 2 and m == 1:
  print(n - 2)
else:
  print(1)

Measured memory_bytes: 3060
from collections import deque

if __name__ == '__main__':

	n = int(input())

	for _ in range(n):
		cmd = input()
		A = deque()
		flg = 0
		for y in cmd:
			if y != "-":
				if y == ">":
					flg = 0
				elif y == "<":
					flg = 1
				else:
					if y not in A:
						if flg == 0:
							A.append(y)
						else:
							A.appendleft(y)

		B = ""
		for x in A:
			B += x
		print(B)







Measured memory_bytes: 5996
while True:
  h, w = [int(x) for x in input().split()]
  if h == 0 and w == 0:
    break
  for i in range(h):
    for j in range(w):
      if i == 0 or i == h-1 or j == 0 or j == w-1:
        print("#", end = "") #改行コードを入れない
      else:
        print(".", end= "")
    print()
  print()
  


Measured memory_bytes: 7008
package main
import (
  "fmt"
  "sort"
)

func main() {

 var S string;
  fmt.Scan(&S)
  var results = make([]int,0)
  var tmp = 0
  for _,val := range S {
    if val == 'A' || val == 'T' || val == 'G' || val == 'C' {
      tmp++
    } else if tmp != 0 {
      results = append(results,tmp)
      tmp = 0
    }
  }
  if tmp != 0 {
    results = append(results,tmp)
  }
  if len(results) != 0{
    sort.Ints(results)
    fmt.Print(results[len(results)-1])
  }else {
    fmt.Print(0)
  }
  
}


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

using namespace std;

int main(){
	int n,t;
	cin>>n>>t;
	long long ans=0;
	int now=0,pre=0;
	cin>>now;

	for(int i=0;i<n-1;i++){
		pre=now;
		cin>>now;

		ans+=min(t,now-pre);
	}

	cout<<ans+t<<endl;

	return 0;
}


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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;

ll  qpow(ll x,ll n)
{
     ll sum=1;
     while(n){
        if(n&1)  sum=sum*x%mod;
        x=x*x%mod;
        n>>=1;
     }
     return sum;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x=max(a*c,b*d);
    ll y=max(a*d,b*c);
    cout<<max(x,y)<<endl;
     return 0;
}


Measured memory_bytes: 3628
s = list(input())

# print(s)

ans = []

for i in range(len(s)):
  if s[i] == '0':
    ans.append(s[i])
  elif s[i] == '1':
    ans.append(s[i])
  else:
    if len(ans) != 0:
      del ans[-1]

str_ans = ''
for i in range(len(ans)):
  str_ans += ans[i]

print(str_ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int a,b,ret=0,total=1;
	cin >> a >> b;
	while(total< b){
		ret++;
		total += (a -1);
	}
	println(ret);
	return 0;
}


Measured memory_bytes: 256
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;   

const int MAXN = (int)1e5 + 5;

int arr[MAXN];

int n, L;

void solve() {
    scanf("%d %d", &n, &L);

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
    }

    for (int i = 1; i < n; ++i) {
        if (arr[i] + arr[i + 1] >= L) {
            printf("Possible\n");

            for (int j = 1; j < i; ++j) {
                printf("%d\n", j);
            }

            for (int j = n - 1; j > i; --j) {
                printf("%d\n", j);
            }

            printf("%d\n", i);
            return;
        }    
    }

    printf("Impossible\n");
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1152
s = list(map(int, input()))
n = 7 - s[0]
b, c, d = s[1], s[2], s[3]

for bit in range(1 << 3):
    n = 7 - s[0]
    ans = str(s[0])
    for i in range(3):
        if bit & (1 << i):
            n -= s[i+1]
            ans += "+" + str(s[i+1])
        else:
            n += s[i+1]
            ans += "-" + str(s[i+1])
    if not n:
        print(ans + "=7")
        break


Measured memory_bytes: 3064
//
// Created by 今村秀明 on 2016/09/07.
//
#include <stdio.h>

int n, a;
int x[51];

int main() {
    scanf("%d %d", &n, &a);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", x + i);
    }

    int X = a;
    for (int i = 1; i <= n; ++i) {
        if (X < x[i]) X = x[i];
    }

    long long int dp[51][5000];//dp[j][t]はx1からxjから0枚以上選んで合計をt-NXにする選び方の総数
    int y[51];
    for (int i = 1; i <= n; ++i) {
        y[i] = x[i] - a;
    }

    for (int j = 0; j <= n; ++j) {
        for (int t = 0; t <= 2 * n * X; ++t) {
            if (j == 0 && t == n * X) {
                dp[j][t] = 1;
            } else if (j >= 1 && (2 * n * X < t - y[j] || t - y[j] < 0)) {
                dp[j][t] = dp[j - 1][t];
            } else if (j >= 1 && 0 <= t - y[j] && t - y[j]) {
                dp[j][t] = dp[j - 1][t] + dp[j - 1][t - y[j]];
            } else {
                dp[j][t] = 0;
            }
        }
    }

    printf("%lld\n", dp[n][n*X]-1);

    return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>

int main(){
    
    int a, b, c;
    scanf("%d %d %d" , &a, &b, &c);  
if(a>b && a>c){
         if(c>b) printf("%d %d %d\n", b, c, a);
         else    printf("%d %d %d\n", c, b, a);
              }
if(b>a && b>c){
        if(a>c) printf("%d %d %d\n", c, a, b);
        else    printf("%d %d %d\n", a, c, b);
              }
if(c>b && c>a){
        if(a>b) printf("%d %d %d\n", b, a, c);
        else    printf("%d %d %d\n", a, b, c);
              }
    return 0; 
}


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
n = gets.to_i
card = Array.new(13).map{ Hash["S" => true, "H" => true, "C" => true, "D" => true] }

for i in 1..n
  mark, numbur = gets.split(" ")
  card[numbur.to_i - 1][mark] = false
end

for mark in ["S", "H", "C", "D"]
  for numbur in 1..13
    puts "#{mark} #{numbur}" if card[numbur.to_i - 1][mark] == true
  end
end

Measured memory_bytes: 6108
use std::cmp::min;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        s: [chars; n],
    }

    let mut res = 0;
    let mut cnt_a = 0;
    let mut cnt_b = 0;
    let mut cnt_c = 0;
    for subs in s {
        if subs.iter().last() == Some(&'A') {
            cnt_a += 1;
        }
        if subs[0] == 'B' {
            cnt_b += 1;
        }

        if subs.iter().last() == Some(&'A') && subs[0] == 'B' {
            cnt_c += 1;
        }

        let sub = subs.into_iter().collect::<String>();
        if sub.contains("AB") {
            res += sub.matches("AB").collect::<Vec<&str>>().len();
        }
    }

    if cnt_c > 0 && cnt_a == cnt_c && cnt_b == cnt_c {
        res += cnt_c - 1;
    } else {
        res += min(cnt_a, cnt_b);
    }

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

Measured memory_bytes: 4476
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split(' ');
	var a = toInt(input[0]);
	var b = toInt(input[1]);
	var ans = (a+b===15)? '+': (a*b===15)? '*': 'x';

	console.log(ans);
}

Measured memory_bytes: 21064
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

const int INF=1e18;

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

    int N; cin>>N;
    vector<int> h(N);
    for(int i=0;i<N;i++) cin>>h[i];

    vector<int> dp(N,INF);
    dp[0]=0;
    for(int i=0;i<N;i++){
        if(i+1<N) chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        if(i+2<N) chmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
    cout<<dp[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7

ans = 0

for aa in a:
  ans += aa
  ans %= mod
ans *= ans
ans %= mod
for aa in a:
  ans -= aa*aa
  ans %= mod


if ans%2 == 1:
  print((ans+mod)//2)
else:
  ans //= 2
  print(ans)	

Measured memory_bytes: 31756
import sys

N = int(input())
matrix = [[0]*N for _ in [0]*N]
for u, k, *v_a in (map(int, l.split()) for l in sys.stdin):
    for v in v_a:
        matrix[u-1][v-1] = 1

print(*(" ".join(map(str, row)) for row in matrix), sep="\n")


Measured memory_bytes: 5684
/*#include <stdio.h>
int main()
{
    int a,b,c,i=0;
    scanf("%d %d %d",&a,&b,&c);
    while(a>=i&&b>=i*2&&c>=i*4)
    {
        i++;
    }
    printf("%d\n",(i-1)*7);
	return 0;
}*/
#include <stdio.h>
int main()
{
    int a,b;
    char c[2];
    scanf("%d %s %d",&a,c,&b);
    if(c[0]=='+')
    {
        printf("%d\n",a+b);
    }
    else
    {
        printf("%d\n",a-b);
    }
    return 0;
}


Measured memory_bytes: 128
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
char s[200007];
int mi2[200007],num[200007];
const int mod = 998244353;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n>>s+1;
    mi2[0]=1;
    for(int i=1;i<=n;++i)
        mi2[i]=2ll*mi2[i-1]%mod;
    for(int i=1;i<=n;i+=2)if(n%i==0){
        int frequency=n/i;//从大到小枚举次数的一半，即经过frequency次操作使得串变成它的取反
        bool flag=1;
        for(int j=1;j<=n&&flag;++j){
            if(s[j]=='1'){
                if(j<=frequency||s[j-frequency]=='1'){
                    num[frequency]=(num[frequency]+(j<=frequency?mi2[frequency-j]:1))%mod;
                }
            }
            if(j>frequency&&s[j]==s[j-frequency])
                flag=0;
        }
        if(flag)
            num[frequency]=(num[frequency]+1)%mod;
    }
    int ans=0;
    for(int i=1;i<=n;++i)if(n%i==0&&(n/i)&1&&num[i]){
        ans=(ans+2ll*num[i]*i)%mod;
        for(int j=i*2;j<=n;j+=i)
            num[j]=(num[j]+mod-num[i])%mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static long MOD = 1000000007l;

	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		System.out.println(a*b%2==0 ? "No" : "Yes");
	}
}


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

int main() {
  int n;cin>>n;
  if(n%1000==0)cout<<0<<endl;
  else cout<<1000-n%1000<<endl;
}

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

int main()
{
    char a[5],b[5];
    int i,j,d,s,l=1;
    scanf("%s%s",a,b);
    strcat(a,b);
    d=0;
    if(strlen(a) == 6)
        d = ((a[0]-'0')*100000) + ((a[1]-'0')*10000) + ((a[2]-'0')*1000) + ((a[3]-'0')*100) + ((a[4]-'0')*10) + (a[5]-'0');
    else if(strlen(a) == 5)
        d = ((a[0]-'0')*10000) + ((a[1]-'0')*1000) + ((a[2]-'0')*100) + ((a[3]-'0')*10) + (a[4]-'0');
    else if(strlen(a) == 4)
        d = ((a[0]-'0')*1000) + ((a[1]-'0')*100) + ((a[2]-'0')*10) + (a[3]-'0');
    else if(strlen(a) == 3)
        d = ((a[0]-'0')*100) + ((a[1]-'0')*10) + (a[2]-'0');
    else if(strlen(a) == 2)
        d = ((a[0]-'0')*10) + (a[1]-'0');

    for(i=1;i<=317;i++)
    {
        s = i*i;
        if(d == s)
        {
            l=0;
            break;
        }
    }
    if(l==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;



void oneCase () {
    int n;
    cin >> n;
   string l, r;
   cin >> l >> r;
   string st;
   for (int pos=0;pos < n; ++pos) {
       st += l[pos];
       st += r[pos];
   }
   cout << st << "\n";

}




int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static int ptn = 3;
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int[] price= new int[ptn];
		for(int i=0; ptn > i; i++) { 
			price[i] = sc.nextInt();
		}
		int min = 0;
		for(int i=0; ptn-1 > i; i++) {
			for(int j=i; ptn-1 > j; j++) {
				if ( min > price[i] + price[j+1] || min == 0) {
					min = price[i] + price[j+1];
				}
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
	char s[100];
    scanf("%s", s);
    int i = 0;
  	BOOL result = YES;
    while (s[i] != '\0') {
        if ( (i + 1) % 2 == 1 ) {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
                result = NO;
              	break;
            }
        } else {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
                result = NO;
              	break;
            }
        }
        i++;
    }
  	printf("%s", result ? "Yes" : "No");
  	return 0;
}
      

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(all(v));
    double ans = v[0];
    for(int i = 1; i < n; ++i) {
        ans = (ans + v[i])/2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)cin >> v[i];

    int x = 0;
    for (int i = 0; i < n; i++)x ^= v[i];
    cout << (x == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
	int n;
	int i = 0;
	int b, c;
	int a[10];
	int sum = 0;
	cin >> n;
	while (n >= 3 && n <= 10)
	{
		while (i <= n-1)
		{
			cin >> a[i];
			i++;
		}
		b = c = 0;
		while (c <= n - 1)
		{
			if (a[b] < a[c])
			{
				b = c;
			}
			c++;
		}
		c = 0;
		while (c <= n - 1)
		{
			if(c!=b)
			   sum = sum + a[c];
			c++;
		}
		
		break;
	}
	if (sum > a[b])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();
	int A[] = new int[N];
	for (int i = 0; i < N; i++)
	    A[i] = sc.nextInt();

	Arrays.sort(A);

	boolean bl = true;
	int check = A[0];
	for (int i = 1; i < N; i++) {
	    if (check == A[i]) {
		bl = false;
		break;
	    }

	    check = A[i];
	}

	if (bl)
	    System.out.println("YES");
	else
	    System.out.println("NO");
    }
}

Measured memory_bytes: 65252
#include<stdio.h>
int main(void)
{
  int num,sum,t1a,t1b=0,t5,t10=0;
  scanf("%d%d",&num,&sum);
  sum=sum/1000;
  t1a=sum%5;
  sum=sum-t1a;
  num=num-t1a;
  t5=sum/5;
  while(t1b+t5+t10<num)
  {
    t5=t5-1;
    t1b=t1b+5;
  }
  while(t1b+t5+t10>num)
  {
    t5=t5-2;
    t10=t10+1;
  }
  if(t1b<0||t5<0||t10<0) printf("-1 -1 -1");
  else printf("%d %d %d", t10,t5,t1a+t1b);
  return 0;
}

Measured memory_bytes: 256
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
l=list(mi())
ans=l[0]
for i in range(a-2):
  ans+=min(l[i],l[i+1])
print(ans+l[-1])

Measured memory_bytes: 69100
#include <stdio.h>
#define MAX 100000
#define S 100000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct 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].value = R[n2].value = S;
  i=j=0;
  for(k=l;k<r;k++){
    if(L[i].value<=R[j].value) A[k] = L[i++];
    else A[k] = R[j++];
  }
  
}

void sort(struct Card A[], int n, int l, int r){
  int m;
  if(l+1<r){
    m = (l + r) / 2;
    sort(A, n, l, m);
    sort(A, n, m, r);
    merge(A, n, l, m, r);
  }
}

int partition(struct Card A[], int n, int p, int r){
  int i,j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      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 quick(struct Card A[], int n, int p, int r){
  int q;
  if(p<r){
    q = partition(A,n,p,r);
    quick(A,n,p,q-1);
    quick(A,n,q+1,r);
  }

}

int main(){
  int n,i,v;
  struct Card A[MAX], B[MAX];
  char s[10];
  int stable = 1;
  scanf("%d", &n);

  for(i=0;i<n;i++){
 scanf("%s %d",s, &v);
 A[i].suit = B[i].suit= s[0];
 A[i].value = B[i].value = v;
  }

  sort(A,n,0,n);
  quick(B,n,0,n-1);

  for(i=0;i<n;i++){if(A[i].suit!=B[i].suit) 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].suit, B[i].value);

  return 0;
}



Measured memory_bytes: 4068
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

#define mod (long)(1e9+7)

using namespace std;

long C(int n, int k) {
    if (k == 0) return 1;
    else {
        long num = C(n-1, k-1) * n;
        while (num % k) num += mod;
        return (num / k) % mod;
    }
}

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    int root = (int)sqrt(M)+1;
    vector<int> factors;
    for (int i=2; i<=root; i++) {
        if (M % i == 0) {
            int count = 0;
            for ( ; M%i==0; M/=i) count++;
            factors.push_back(count);
        }
        if (M == 1) break;
    }
    if (M > 1) factors.push_back(1);
    size_t len = factors.size();
    long result = 1;
    if (M > 1 && len == 0) result = N;
    for (size_t i=0; i<len; i++)
        result = (result * C(N+factors[i]-1, factors[i])) % mod;
    printf("%ld\n", result);
    return 0;
}

Measured memory_bytes: 256
A,B,C = map(int,input().split())
count=0
if A==B==C and A%2==0 :
    print(-1)
elif A==B==C and A%2==1 :
    print(0)
else :
    while True :
        if A%2 != 0 or B%2 != 0 or C%2 != 0 :
            print(count)
            break
        elif A==B and B==C :
            print(-1)
            break
        else :
            count += 1
            dA=A
            dB=B
            dC=C
            A=dB/2+dC/2
            B=dA/2+dC/2
            C=dA/2+dB/2

Measured memory_bytes: 3064