akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>

using namespace std;

bool CheckAvaiableArea(double s){
  double i, j;
  int k;
  for(i=3; i<=sqrt(s); ++i){
    if(modf(s/i, &j) != 0) continue;
    k = (int)j;
    if(k%2 == 0) continue;
    return true;
  }
  return false;
}

int main(){
  int i, n, count;
  double s;
  cin >> n;
  for(i=0, count=0; i<n; ++i){
    cin >> s;
    if(!CheckAvaiableArea(2*s+1)) ++count;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1236
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  vvi x(4, vi(4, 0));
  rep(i, 3){
    int a,b;
    cin>>a>>b;a--;b--;
    x[a][b] = 1;
    x[b][a] = 1;
  }

  rep(i, 4){
    rep(j, 4){
      rep(k, 4){
        rep(h, 4){
          set<int> s = {i, j, k, h};
          if (s.count(0) && s.count(1) && s.count(2) && s.count(3)){
            if (x[i][j] && x[j][k] && x[k][h]){
              cout << "YES" << endl;
              return 0;
            }
          }
          else{
          }
        }
      }
    }
  }
  cout << "NO" << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))

ans=0
prev=-1
for _a in a:
    ans+=b[_a-1]
    if prev+1 == _a:
        ans+=c[_a-2]
    prev=_a

print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a=scan.next();
		String b=scan.next();
		String c=scan.next();
		System.out.println(String.valueOf(a.charAt(0)).toUpperCase()+""+String.valueOf(b.charAt(0)).toUpperCase()+""+String.valueOf(c.charAt(0)).toUpperCase());
		}
}

Measured memory_bytes: 23252
// Poll

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>
#include <map>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector <string> S(N);
    map<string, int> S_map;

    int max_count = -1;
    // string max_str;
    for (int i = 0; i < N; i++) {
        string str;
        cin >> str;
        S[i] = str;
        S_map[str] += 1;

        if (S_map[str] > max_count) {
            max_count = S_map[str];
            // max_str = str;
        }
    }
    sort(S.begin(), S.end());

    for (int i = 0; i < N; i++) {
        string str = S[i];
        if (S_map[str] != max_count) {
            continue;
        }

        int j = i + 1;
        if (j >= N) {
            cout << str << endl;
            return 0;
        }
        
        while (j < N && S[j] == str) {
            j++;
        }
        i = j - 1;
        cout << str << endl;
    }

    return 0;
}


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

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

  map<string,long long> mp;

  for (int i = 0; i < N; i++)
  {
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    mp[S]++;
  }
  long long ans = 0;
  for (auto MP:mp)
  {
    ans += MP.second * (MP.second - 1) / 2;
  }

  cout<< ans;


}

Measured memory_bytes: 11136
//https://atcoder.jp/contests/dp/tasks/dp_j

#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long int ll;

const int precision = 16;
const int modulo =  1000000007; // 10^9 + 7
using ll = long long;
const double EPS = 1e-9;

const int nax = 305;
double p[nax][nax][nax]; // probability of getting to state abc.
double ev[nax][nax][nax];


double solveSushi() {
	int n; cin >> n;
	
	vector<int> cnt(4);
	for(auto i = 0; i < n; ++i) {
		int v; cin >> v;
		++cnt[v];
	}
	
	p[cnt[1]][cnt[2]][cnt[3]] = 1;

	for(int c = n; c >= 0; c--) { //3 
		for(int b = n; b >= 0; b--) { // 2
			for(int a = n; a >= 0; --a) { //1
				if(a == 0 and b == 0 and c == 0) { 
					continue;
				}

				if((a + b + c) > n) {
					continue;
				}

				double pWaste = (double) (n - (a + b + c)) / n;
				//pWaste + pWaste^2 + ... = S
				// 1 + S = S / pWAste  
				double evWaste = pWaste / (1 - pWaste) + 1;

				ev[a][b][c] += evWaste * p[a][b][c];

				//remove 1 -> dp[a - 1][b][c]
				// we will eventually choose one of a + b + c

				if(a != 0) {
					double p_go = (double) a / (a + b + c);
					p[a - 1][b][c] += p[a][b][c] * p_go;
					ev[a - 1][b][c] += ev[a][b][c] * p_go;
				}

				//remove 2 -> dp[a + 1][b - 1][c]
				if(b != 0) {
					double p_go = (double) b / (a + b + c);
					p[a + 1][b - 1][c] += p[a][b][c] * p_go;
					ev[a + 1][b - 1][c] += ev[a][b][c] * p_go;
				}

				//remove 3 -> dp[a][b + 1][c - 1]

				if(c != 0) {
					double p_go = (double) c / (a + b + c);
					p[a][b + 1][c - 1] += p[a][b][c] * p_go;
					ev[a][b + 1][c - 1] += ev[a][b][c] * p_go;
				}
			}
		}
	}

	return ev[0][0][0];
}


typedef  double ld;
const int MX = 305;

double solveSushi2(){
	int n; cin >> n;

	vector<int> cnt(4);

	for(auto i = 0; i < n; ++i) {
		int x; cin >> x;
		cnt[x]++;
	}

	for( int c = 0; c <=n; ++c) {
		for(int b = 0; b  + c <=n; ++b) {
			for(int a = 0; a + b + c <=n; ++a) {
				if(a == 0 and b == 0 and c == 0) continue;

				double platesWithSushi = a + b + c;
			
				if(platesWithSushi > n) continue;

				double pWaste = 1.0 + (double)(n - platesWithSushi) / platesWithSushi;
				double pa = (double) a / platesWithSushi;
				double pb = (double) b / platesWithSushi;
				double pc = (double) c / platesWithSushi;

				if(a > 0){
					ev[a][b][c] += ev[a - 1][b][c] * pa;
				}
				
				if(b > 0) {
					ev[a][b][c] += ev[a + 1][b - 1][c] * pb;	
				}
				
				if(c > 0) {
					ev[a][b][c] += ev[a][b + 1][c - 1] * pc;
				}

				ev[a][b][c] += pWaste;
			}
		}
	}

	
	return ev[cnt[1]][cnt[2]][cnt[3]];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(precision);
	cout.setf(ios_base::fixed);

	
	double ret = solveSushi2();
	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 219392
#include <stdio.h>
int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == 1)
    {
        if (b == 2)
        {
            printf("3\n");
        }
        else
        {
            printf("2\n");
        }
    }
    else if (a == 2)
    {
        if (b == 1)
        {
            printf("3\n");
        }
        else
        {
            printf("1\n");
        }
    }
    else
    {
        if (b == 1)
        {
            printf("2\n");
        }
        else
        {
            printf("1\n");
        }
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

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

		int[] time_get = henkan(scan.nextInt());
	
		for(int i = 0; i < 3; i++) {
			if(i != 2) System.out.print(time_get[i] + ":" );
			else System.out.println(time_get[i]);
		}

	}

	static int[] henkan(int time_input) {
		int[] times = new int[3];
		times[0] = time_input / 3600;
		time_input = time_input - times[0] * 3600;
		times[1] = time_input /60;
		times[2] = time_input - times[1] * 60;
		
		return times;
	}
}

Measured memory_bytes: 17232
# coding: utf-8
# Your code here!

s=input()
t=s.replace("A","")

if(t!="KIHBR"):
    print("NO")
    exit()
if("KAI" in s):
    print("NO")
    exit()
if("KAH" in s):
    print("NO")
    exit()
if("IAH" in s):
    print("NO")
    exit()
u=s.replace("K","*")
u=u.replace("I","*")
u=u.replace("H","*")
u=u.replace("B","*")
u=u.replace("R","*")
for v in u.split("*"):
    if(len(v)>1):
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 3188
// https://atcoder.jp/contests/abc143/tasks/abc143_b

#include <bits/stdc++.h>
using namespace std;
int main() {
    #define int long long
    int N;
    cin >> N;

    int d[N];
    for(auto &x: d) cin >> x;

    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;

}

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

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;

bool solve(){
  ll n;
  scanf("%lld", &n);
  if(n == 0) return 0;

  int digit = 1;
  ll sum = 0;
  while(sum < n){
    sum += 9*9*((1LL << digit) - 1);
    digit++;
  }

  sum -= 9*9*((1LL << (digit-1)) - 1);
  
  bool f = false;
  int prev_num = -1;

  string ans;

  int a[2] = {-1, -1};
  
  for(int i=0;i<digit;i++){

    for(int j=0;j<=9;j++){
      if(i == 0 && j == 0) continue;
      if(a[1] != -1 && a[0] != j && a[1] != j) continue;
      
      ll next_sum = sum;
      
      if(f || (prev_num != j && i != 0)){
        next_sum += 1LL << (digit-i-1);
      }else{
        next_sum += ((1LL << (digit-i-1)) - 1) * 9;
      }
      
      if(next_sum >= n){
        if(a[0] == -1 || a[0] == j){
          a[0] = j;
        }else if(a[1] == -1){
          a[1] = j;
        }
        ans += '0' + j;
        f |= prev_num != j && prev_num != -1;
        prev_num = j;
        break;
      }

      sum = next_sum;
    }
  }

  cout << ans << endl;

  return 1;
}

int main(){

  while(solve());

  return 0;
}



Measured memory_bytes: 3284
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        map<int,int> odd,even;
        FOR(i,0,n) {
            int a; cin >> a;
            if (i & 1)
                odd[a]++;
            else
                even[a]++;
        }
        vector<PII> A,B;
        FOR_ALL(x,odd)
            A.push_back(PII(x->second,x->first));
        FOR_ALL(x,even)
            B.push_back(PII(x->second,x->first));
        sort(ALL(A)); reverse(ALL(A));
        sort(ALL(B)); reverse(ALL(B));
        int ans = n;
        FOR(i,0,min(2,int(A.size()))) FOR(j,0,min(2,int(B.size()))) {
            const int c1 = A[i].first;
            const int v1 = A[i].second;
            const int c2 = B[j].first;
            const int v2 = B[j].second;
            int res = n - c1 - c2;
            if (v1 == v2) {
                if (c1 < c2)
                    res += c1;
                else
                    res += c2;
            }
            ans = min(ans,res);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 6140
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
  int n,index,ice[10];
  while(1){
    scanf("%d",&n);
    if(n==0) break;

    fill(ice,ice+10,0);
    for(int i=0;i<n;i++){
      scanf("%d",&index);
      ice[index]++;
    }
    for(int i=0;i<10;i++){
      if(ice[i]==0) printf("-\n");
      else{
	for(int j=0;j<ice[i];j++){
	  printf("*");
	}
	printf("\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3100
N = int(input())
h = list(map(int, input().split()))
INF = 10**10
dp = [INF]*N
dp[0]=0
for i in range(N):
    if i+1 < N:
        dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    if i+2 < N:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))
print(dp[N-1])


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

// 看了题解，发现当时想不出的原因主要不是倍长，而是倍长的前一步的DP没想清楚

const int mxn = 500006;
const int emp = 26;

char a[mxn];
int n;
int f[mxn][27]; // 无效均为0
int s[mxn][20];

int main() {
	scanf("%s", a + 1);
	n = strlen(a + 1);
	for (int i = 1; i <= n; ++i)
		a[i] -= 'a';
	
	for (int i = n; i >= 1; --i) {
		f[i][a[i]] = i + 1;
		for (int j = a[i] + 1; j <= 26; ++j)
			f[i][j] = f[f[i][j - 1]][j - 1];
		for (int j = 0; j < a[i]; ++j)
			f[i][j] = f[f[i][emp]][j];
	}
	
	for (int i = n; i >= 1; --i) {
		s[i][0] = f[i][emp];
		for (int j = 1; j < 20; ++j)
			s[i][j] = s[s[i][j - 1]][j - 1];
	}
	
	int q;
	cin >> q;
	while (q--) {
		int l, r;
		scanf("%d%d", &l, &r);
		++r;
		for (int i = 20; i--; ) if (s[l][i] && s[l][i] <= r)
			l = s[l][i];
		puts(l == r ? "Yes" : "No");
	}
	
	return 0;
}

Measured memory_bytes: 92928
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    N = II()
    a_list = []
    for i in range(N):
        a = II()
        a_list.append(a)

    from collections import Counter
    c = Counter(a_list)
    mx = max(a_list)

    k = c.keys()
    second = None
    if len(k) > 1:
        second = sorted(k, reverse=True)[1]

    for i in range(N):
        a = a_list[i]
        if a != mx:
            # これがmax出ない場合
            print(mx)
        else:
            if c[a] == 1:
                # maxが唯一で、これの場合
                print(second)
            else:
                # maxがこれでも複数ある場合
                print(mx)


solve()

Measured memory_bytes: 20644
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

vector< pair<int,int> > doll;
int dp[200];
int n,m,tmp1,tmp2;

int main(){
  while(cin>>n && n){
    for(int i=0;i<n;i++){
      cin>>tmp1>>tmp2;
      doll.push_back(make_pair(tmp1,tmp2));
    }
    cin>>m;
    for(int i=0;i<m;i++){
      cin>>tmp1>>tmp2;
      doll.push_back(make_pair(tmp1,tmp2));
    }

    sort(doll.begin(),doll.end());

    int ans=0;

    for(int i=0;i<n+m;i++){
      dp[i]=1;
      for(int j=0;j<n+m;j++){
        if(doll[i].first>doll[j].first && doll[i].second>doll[j].second){
          dp[i]=max(dp[i],dp[j]+1);
        }
      }
      ans=max(ans,dp[i]);
    }

    cout<<ans<<endl;

    while(doll.size()) doll.pop_back();
    memset(dp,0,sizeof(dp));
  }
  return 0;
}

Measured memory_bytes: 3080
import scala.io.StdIn

object Main extends App {
  val dx = Array(-1, 0, 1, -1, 1, -1, 0, 1)
  val dy = Array(-1, -1, -1, 0, 0, 1, 1, 1)
  val out = new java.io.PrintWriter(System.out)

  val Array(h, w) = StdIn.readLine.split(" ").map(_.toInt)
  val map = Iterator.continually(StdIn.readLine)
    .take(h)
    .toArray

  val res = for {
    i <- 0 until h
    j <- 0 until w
  } yield {
    if(map(i)(j) == '#') "#"
    else {
      (0 until 8)./:(0)((a,e) => {
        val y = i + dy(e)
        val x = j + dx(e)
        if(0 <= x && x < w && 0 <= y && y < h) a + ( if(map(y)(x) == '#') 1 else 0 )
        else a
      })
    }
  }
  // ans.transpose.toArray
  val ite = res.grouped(w)
  ite.foreach(ans => out.println(ans.mkString("")))
  out.flush
}

Measured memory_bytes: 27328
import java.util.*;
import java.math.BigInteger;
 
public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();

        List<Long> list = new ArrayList<Long>();
        for (int i = 0; i < n; i++) {
            long a = scan.nextLong();
            list.add(a);
        }

        Collections.sort(list);//System.out.println(list);
        // listの先頭が0だったら、0を出力して即終了
        if (list.get(0) == 0) {
            System.out.println(0);
            return;
        }

        // 1. BigIntegerクラスを用いて、オーバーフローが起きないようにする。
        BigInteger ans = BigInteger.ONE;
        boolean isOver = false;
        for (int i = 0; i < n; i++) {
            ans = ans.multiply(BigInteger.valueOf(list.get(i)));
            if (ans.compareTo(BigInteger.valueOf(1000000000000000000l)) > 0) {
                isOver = true;
                break;
            }
        } 

        if (isOver) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
        /*
        * 2. multiplyExactメソッド（オーバーフローすると例外送出）を利用する方法。
        long ans = 1l;
        boolean isOver = false;
        try {
            for (int i = 0; i < n; i++) {
                long a = list.get(i);
                ans = Math.multiplyExact(ans, a);
                if (ans > 1000000000000000000l) {
                    isOver = true;
                    break;
                }
            } 
        } catch (ArithmeticException e) {
            isOver = true;
        }
        
        if (isOver) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
        */
        
        /* 
        * 3. オーバーフローすると、負の数や0になる可能性があることを考慮して場合わけする。
        long ans = 1l;
        for (int i = 0; i < n; i++) {
            long a = list.get(i);
            ans *= a;
            if (ans > 1000000000000000000l || ans <= 0) {
                break;
            }
        }
        if (ans > 1000000000000000000l || ans <= 0) {
            //System.out.println(ans);
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
        */
        
    }
}

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

using namespace std;

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

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

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

// (7i+j)*3*3+9
// 63i + 9j + 9
// 8i + 9j + 9 = k
// 8i = k-9j+9
// 1<=i<=n-2
// 1<=j<=7-2=5

int main(){
  ll n,k;
  cin>>n>>k;
  ll ans = 0;
  FOR(j,1,5+1){
    ll u = ((k - 9*j - 9)%11 + 11) % 11;
    // 8i = u (mod 11) (1<=i<=n-2)
    // 8i = u + 11x
    ll x=1, y=n-2;
    while(true){
      if(8*x%11 == u)break;
      x++;
    }
    while(y>=0){
      if(8*y%11 == u)break;
      y--;
    }
    if(y!=-1){
      // DEBUG(u);
      // DEBUG(j);
      // DEBUG(x);
      // DEBUG(y);
      ll plus = (y-x+11)/11;
      // DEBUG(plus);
      if(plus > 0){
        ans += plus;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var ans = 0;

            for(var i = 0; i < S.Length; i++)
            {
                if (S[i] == '+') ans++;
                else if (S[i] == '-') ans--;
            }

            Console.WriteLine(ans);
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  ll V = 0, E = 0;
  for (int i = 1; i <= n; ++i) V += ll(i)*(n-i+1);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a,b);
    E += ll(a)*(n-b+1);
  }
  ll ans = V-E;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(b>d){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;

public class Main {
	public static void main(String[] args) throws IOException, ParseException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		final int X = Integer.parseInt(str.split(" ")[0]);
		final int Y = Integer.parseInt(str.split(" ")[1]);
		
		System.out.println(X + Y / 2);
	}
}


Measured memory_bytes: 23124
#include <iostream>

using namespace std;

int main(){
  int x;
  std::cin >> x;

  int five_hundred_num = x / 500;
  int five_num = (x - five_hundred_num * 500) / 5;
  std::cout <<  five_hundred_num * 1000 + five_num * 5 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(3*n);
  rep(i, 3*n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  rep(i, n)
    ans += a[i*2+1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    string S;
    cin >> S;
    S[3] = '8';
    cout << S << endl;
    return 0;
}

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

const ll INF = 1000000009;
int main(){
	ll n,m; cin >> n >> m;
	vl p(m); vector<string> qwe(m); rep(i,m)cin >> p[i] >> qwe[i];
	vector<bool> s(m); 
	rep(i,m){
		if(qwe[i] == "AC")s[i] = true;
		else s[i] = false;
	}
	map<ll,ll> mp;
	ll miss = 0; ll cor = 0;
	rep(i,m){
		if(!mp.count(p[i])){//まだ一回も出てきてない
			if(s[i]){
				mp[p[i]] = INF;
				cor++;
			}
			else mp[p[i]] = 1;
		}
		else{//一回出てきた
			if(s[i]){
				if(mp[p[i]] == INF)continue;
				else{
					miss += mp.at(p[i]);
					cor++;
					mp.at(p[i]) = INF;
				}
			}
			else{
				if(mp[p[i]] == INF)continue;
				else{
					mp[p[i]]++;
				}
			}

		}
	}
	cout << cor << " " << miss << endl;

}

Measured memory_bytes: 12800
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

  static int n, m, x, ans;
  // static long ans;
  static int[] dp;
  static List<Integer> c;
  static List<List<Integer>> a;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    m = Integer.parseInt(in[1]);
    x = Integer.parseInt(in[2]);

    c = new ArrayList<>();
    a = new ArrayList<>();

    for (int i = 0; i < n; i++) {
      in = br.readLine().split(" ");
      a.add(new ArrayList<>());
      c.add(Integer.parseInt(in[0]));
      for (int j = 0; j < m; j++) {
        a.get(i).add(Integer.parseInt(in[j + 1]));
      }
    }

    br.close();

    ans = 1000000000;

    for (int bit = 0; bit < (1 << n); bit++) {
      int cost = 0;
      int[] uds = new int[m];
      for (int i = 0; i < n; i++) {
        if (((bit >> i) & 1) == 1) {
          cost += c.get(i);
          for (int j = 0; j < m; j++) {
            uds[j] += a.get(i).get(j);
          }
        }
      }

      long lessX = Arrays.stream(uds).filter(t -> t < x).count();
      if (lessX == 0) ans = Math.min(ans, cost);
    }

    out.println(ans < 1000000000 ? ans : -1);

    out.flush();
  }
}


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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const int N = 5e3 + 2;

int n,m;
int a[N],b[N][201];
ll p[N],rs,mx;
int t[N * 4][201],cur;

inline int max(int a, int b)
{
        return a > b ? a : b;
}
inline int min(int a, int b)
{
        return a > b ? b : a;
}

void build (int v = 1,int tl = 1,int tr = n) {
        if (tl == tr) {
                for (int i = 1; i <= m; i ++) {
                        t[v][i] = b[tl][i];
                }
        }
        else {
                int tm = (tl + tr) >> 1;
                build (v * 2,tl,tm);
                build (v * 2 + 1,tm + 1,tr);
                for (int i = 1; i <= m; i ++) {
                        t[v][i] = max(t[v * 2][i],t[v * 2 + 1][i]);
                }
        }
}
int get (int l,int r,int x,int v = 1,int tl = 1,int tr = n) {
        if (l > r || l > tr || tl > r)
                return -1;

        if (l <= tl && tr <= r)
                return t[v][x];

        int tm = (tl + tr) >> 1;
        return max(get(l,r,x,v + v,tl,tm),get(l,r,x,v + v + 1,tm + 1,tr));
}
ll calc (int  l,int  r) {
        ll res = 0;

        for (int  k = 1; k <= m; k ++) {
                res += get(l,r,k);
        }
        return res;
}
void compute(int l,int r,int L,int R) {

        if (l > r) return;


        int md = (l + r) >> 1;

        ll cur = -1;
        int opt = L;

        for (ll i = L; i <= min(md,R); i ++) {
                ll now = calc(i,md) - (p[md] - p[i]);
                if (now > cur)
                        cur = now,opt = i;
        }
        mx = max(mx,cur);
        compute(l,md - 1,L,opt);
        compute(md + 1,r,opt,R);
}
main () {
        cin >> n >> m;

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

        for (int i = 1; i <= n; i ++) {
                for (int j = 1; j <= m; j ++) {
                        scanf("%d", &b[i][j]);
                }
        }
        build();
        compute(1,n,1,n);
        cout << mx << endl;
}


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

    int main(){
    int n,a,b,ans = 0;
    cin >> n >> a >> b;
    for (int i=1; i <= n; i++){
        int k = i;
        int sum =0;
        while (k > 0)
        {
            sum += k % 10;
            k /= 10;
        }
        if (sum >= a && sum <= b)ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3],c5=0,c7=0;
  cin>>a[0]>>a[1]>>a[2];
  for(int i=0;i<3;i++){
    if(a[i]==5)
      c5++;
    if(a[i]==7)
      c7++;
  }
  if(c5==2 && c7==1)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}


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

using namespace std;

int main() {
    int n, cnt = 0;
    scanf("%d\n", &n);
    vector<char> s(n);
    scanf("%s", s.begin());
    for (int i = 0; i < n; ++i) if (s.at(i) == '.') ++cnt;
    int ans = cnt;
    for (int i = 0; i < n; ++i) cnt += (s.at(i) == '#') - (s.at(i) == '.'), ans = min(ans, cnt);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i; i < n; i++) cin >> h.at(i);
  
  int ans;
  for(int x : h){
    if(x >= k) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int main(void) {

	lli n, answer = 1000000000000;
	cin >> n;

	for (int i = 1; i <= sqrt(n); i++) {

		if (n % i == 0)
			answer = min(answer, n / i + i);

	}

	cout << answer - 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,A,B;
int C[300001];
void swa(int x,int y){
	//cout<<x<<y<<endl;
	/*REP(i,N){
		cout<<C[i];
		if(i==N-1){
			cout<<endl;
		}else{
			cout<<" ";
		}
	}*/
	while(x<y){
		int D=C[x];
		C[x]=C[y];
		C[y]=D;
		x++;
		y--;
	}
	/*REP(i,N){
		cout<<C[i];
		if(i==N-1){
			cout<<endl;
		}else{
			cout<<" ";
		}
	}*/
}
int Cnt[300001];

int main(){
	REP(i,300001){
		Cnt[i]=0;
	}
	cin>>N>>A>>B;
	if(A+B>N+1){
		cout<<-1<<endl;
		return 0;
	}
	if(A>N){
		cout<<-1<<endl;
		return 0;
	}
	if(B>N){
		cout<<-1<<endl;
		return 0;
	}
	if(A==1&&(B!=N)){
		cout<<-1<<endl;
		return 0;
	}
	if(B==1&&(A!=N)){
		cout<<-1<<endl;
		return 0;
	}

	
	REP(i,N){
		C[i]=i+1;
	}
	
	int res=N-A;
	int pos=0;
	while(res!=0){
		//cout<<pos<<" "<<pos+min(res+1,B)<<endl;
		swa(pos,pos+min(res+1,B)-1);
		res-=(min(res+1,B)-1);
		pos+=B;
	}
	int c=0;
	int now=0;
	REP(i,N){
		if(now<C[i]){
			c++;
			//cout<<now<<" "<<C[i]<<endl;
			now=C[i];
		}
		if(C[i]<=0||C[i]>N){
			cout<<-1<<endl;
			return 0;
		}
		Cnt[C[i]-1]++;
	}
	REP(i,N){
		if(Cnt[i]!=1){
			cout<<-1<<endl;
			return 0;
		}
	}
	//cout<<now<<" "<<A<<endl;
	if(A!=c){
		cout<<-1<<endl;
		return 0;
	}
	
	REP(i,N){
		cout<<C[i];
		if(i==N-1){
			cout<<endl;
		}else{
			cout<<" ";
		}
	}
	
	return(0);
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 50) - 1;
int MOD = 1e9+7;
main(){
    ll N,X;
    cin >> N >> X;
    vector<ll> V(N);
    rep(i,0,N)cin >> V[i];
    ll dp[N],ans = INF;
    rep(i,0,N)dp[i] = V[i];
    rep(i,0,N){
        ll sum = X * i;
        rep(j,0,N){
            dp[j] = min(dp[j], V[(j - i + N) % N]);
            sum += dp[j];
        }
        ans = min(ans, sum);
        //cout << sum << endl;
    }
    cout << ans << endl;
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;

vector<int> edge[10];
int cnt = 0;
int N, M;

bool use[10] = {};
void solve(int now, int many){
	if(many == N){
		cnt++;
		return;
	}

	for(int i = 0; i < edge[now].size(); i++)
		if(use[edge[now][i]] == false){
			use[edge[now][i]]++;
			solve(edge[now][i], many+1);
			use[edge[now][i]] = false;
		}

	return;
}

int main(){
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int a,b;
		cin >> a >> b;
		edge[a].pb(b);
		edge[b].pb(a);
	}

	use[1]++;
	solve(1,1);
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
     Scanner scan=new Scanner(System.in);
     int N=scan.nextInt();
     scan.nextLine();
     String S=scan.nextLine();
    for(int i=0;i<S.length();i++){
      System.out.print((char)(((S.charAt(i)-'A')+N)%26+'A'));
    }
  }
}

Measured memory_bytes: 26564
x,k,d=map(int,input().split())
if abs(x)>=k*d:
    print(abs(x)-k*d)
else:
    t=abs(x)%d
    n=k-abs(x)//d
    if n%2==0:
        print(t)
    else:
        print(abs(t-d))


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

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;



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

    ll v[100000];
memset(v,0,100000);
for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=100;k++)
            {
                ll x= i*i + j*j + k*k +i*j + j*k + k*i;
                v[x]++;

            }
        }

    }
 
    for(int i=1;i<=n;i++)
    {
        cout<<v[i]<<endl;
    }
    
     
    return 0;
}

Measured memory_bytes: 4036
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1) {
        res[n] += 1;
    }
    return res;
}

int main()
{
    ll N;
    cin >> N;
    map<ll, ll> s = sosuu(N);

    ll sum = 0;
    for (auto &&e : s)
    {
        ll se = e.second;
        ll pre = 1;
        while (se > 0)
        {
            if (se <= pre * 2) {
                sum += 1;
                break;
            } else {
                se -= pre;
                sum += 1;
                pre += 1;
            }
        }        
    }
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int a = 10, d, ret = 0;
  for (int i=0; i<5; i++) {
    cin >> d;
    ret += ((d + 9) / 10) * 10;
    if (d % 10 > 0) a = min(a, d % 10);
  }
  cout << ret - (10 - a) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += min(A[i], B[i])
    B[i] -= min(A[i], B[i])
    ans += min(A[i + 1], B[i])
    A[i + 1] -= min(A[i + 1], B[i])
print(ans)


Measured memory_bytes: 18476
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int a,b,x;
	cin >> x >> a >> b;
	
	if(a >= b)
		cout << "delicious" << endl;
	else if(x + a >= b)
		cout << "safe" << endl;
	else
		cout << "dangerous" << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    S = input()
    nums = []
    now = 1
    cnt = 0
    for s in S:
        if int(s) == now:
            cnt += 1
        else:
            nums.append(cnt)
            now ^= 1
            cnt = 1
    if cnt > 0:
        nums.append(cnt)
    if len(nums) % 2 == 0:
        nums.append(0)
    add = 2 * K + 1
    sum = [0 for _ in range(len(nums) + 1)]
    for i in range(len(nums)):
        sum[i + 1] = sum[i] + nums[i]
    ans = 0
    for cnt in range(0, len(nums), 2):
        left = cnt
        right = min(cnt + add, len(nums))
        tmp = sum[right] - sum[left]
        ans = max(tmp, ans)
    print(ans)


main()


Measured memory_bytes: 7884
#include <bits/stdc++.h>
using namespace std;
map<string, int> cnt;
int main(){
    string s;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s;
        cnt[s]++;
    }
    vector<string> ans;
    int mx = 0;
    for(auto i:cnt){
        if(i.second > mx) mx = i.second;
    }
    for(auto i:cnt){
        if(i.second == mx) ans.push_back(i.first);
    }
    sort(ans.begin(), ans.end());
    for(auto i:ans) printf("%s\n", i.c_str());
}

Measured memory_bytes: 26868
import java.util.Scanner;

public class Main{
	static double power(double x, double y){
		return x*x + y*y;
	}

	static double cast(double x){
		double y = 1000*x;
		int z = (int) y;
		if( 10*(y-z) >= 5 ){
			x = (double) (z+1)/1000;
		}
		else 
			x = (double) z/1000;
		return x;
	}

	static void output(double[] x){
		System.out.printf("%.3f %.3f %.3f%n",cast(x[0]),cast(x[1]),cast(x[2]));
	}

	static double[] circle(double[] a, double[] b, double[] c){
		double x1 = a[0] - b[0];  // a-c
		double x2 = b[0] - c[0];  // c-e
		double x3 = a[0] + b[0];  // a+c
		double x4 = b[0] + c[0];  // c+e
		double y1 = a[1] - b[1];  // b-d
		double y2 = b[1] - c[1];  // d-f
		double y3 = a[1] + b[1];  // b+d
		double y4 = b[1] + c[1];  // d+f
		
		double[] result = new double[3];
		if( y1 == 0 ){
			result[0] = x3/2;
			result[1] = (-x2*(x1+x2)+y2*y4)/(2*y2);
		} else if ( y2 == 0 ){
			result[0] = x4/2;
			result[1] = (x1*(x1+x2)+y1*y3)/(2*y1);
		} else {
			result[0] = (y1*y2*(-(y1+y2))+x2*y1*x4-x3*y2*x1)/(2*(x2*y1-x1*y2));
			result[1] = (x1*x2*(-(x1+x2))+y2*x1*y4-y3*x2*y1)/(2*(y2*x1-y1*x2));
		}
		result[2] = Math.sqrt(power(a[0]-result[0], a[1]-result[1]));
		return result;
	}

	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		String[] str = new String[n+1];
		String[][] p = new String[n][6];
		double[][] a = new double[n][2];
		double[][] b = new double[n][2];
		double[][] c = new double[n][2];
		
		for(int i = 0; i < n+1; i++){
			str[i] = stdIn.nextLine();
		}
		for(int i = 0; i < n; i++){
			p[i] = str[i+1].split(" ");
			for(int j = 0; j < 2; j++){
				a[i][j] = Double.parseDouble(p[i][j]);
				b[i][j] = Double.parseDouble(p[i][j+2]);
				c[i][j] = Double.parseDouble(p[i][j+4]);
			}
		}
		
		for(int i = 0; i < n-1; i++){
			output(circle(a[i], b[i], c[i]));
		}
		output(circle(a[n-1], b[n-1], c[n-1]));
	}
}

Measured memory_bytes: 12000
n = int(input())
a = list(map(int, input().split()))
b = []
index = list(range(1, n+1))
dic_a = dict(zip(a, index))
#print(dic_a)
sorted_dic_a = dict(sorted(dic_a.items()))
for i in sorted_dic_a.values():
    print(i,end=" ")

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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  if (n > k) {
    cout << k * x + (n - k) * y << endl;
  }
  else {
    cout << n * x << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		String T = scanner.next();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String U = scanner.next();

		if (S.equals(U)) {
		    A--;
		} else {
			B--;
		}
		
		System.out.println(A + " " + B);
	}
}	

Measured memory_bytes: 20948
def gcd(a,b):
    while b != 0:
        a , b = b , a % b
    return a
def lcm(a,b):
    return int(abs(a*b) / gcd(a,b))

while True:
    try:
        a, b = [int(x) for x in input().split()]
    except:
        exit()
    print(gcd(a,b),lcm(a,b))

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<set<int>> vec(26);
  for(int i=0; i<N; i++){
    int x = S.at(i) - 'a';
    vec.at(x).insert(i);
  }
  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    int a;
    cin >> a;
    if(a == 1){
      int b;
      cin >> b;
      b--;
      char c;
      cin >> c;
      int x = S.at(b) - 'a';
      int y = c - 'a';
      S.at(b) = c;
      vec.at(x).erase(b);
      vec.at(y).insert(b);
    }
    else{
      int cnt = 0;
      int b,c;
      cin >> b >> c;
      b--; c--;
      for(int j=0; j<26; j++){
        if(vec.at(j).set::lower_bound(b) != vec.at(j).set::lower_bound(c+1)){
          cnt++;
        }
      }
      cout << cnt << endl;
    }
  }
} 

Measured memory_bytes: 24324
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main()
{
	int n, q;
	cin >> n >> q;
	pair <int, pair<int, int>> p[n];
	for (int i = 0; i < n; i++)
	{
		cin >> p[i].ss.ff >> p[i].ss.ss >> p[i].ff;
	}
	sort(p, p + n);
	set <int> st;
	map <int, int> m;
	for (int i = 0; i < q; i++)
	{
		int x;
		cin >> x;
		m[x] = i;
		st.insert(x);
	}
	vector <int> ans(q, -1);
	for (int i = 0; i < n; i++)
	{
		int l = max(0, p[i].ss.ff - p[i].ff);
		int r = max(0, p[i].ss.ss - p[i].ff);
		auto lt = st.lower_bound(l);
		auto rt = st.lower_bound(r);
		vector <int> t;
		while(lt != rt)
		{
			ans[m[*lt]] = p[i].ff;
			t.push_back(*lt);
			lt++;
		}
		for (auto g : t)
			st.erase(g);
	}
	for (int i = 0; i < q; i++)
	{
		cout << ans[i] << "\n";
	}
		
}


Measured memory_bytes: 23808
n = int(input())
p = [int(x) for x in input().split()]
cnt = 2

for i in range((n + 1) // 2):
    if p[i] != i + 1:
        cnt -= 1
    if p[n - i - 1] != n - i:
        cnt -= 1
        
print(["NO", "YES"][cnt >= 0])

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

int main() {
  
  string s;
  cin >> s;
  
  if ( s[0] == 'S' ){
    cout << "Cloudy" << endl;
  }else if ( s[0] == 'C' ){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
  
  
}


Measured memory_bytes: 256
S, T = input(), input()
nT = len(T)
f = lambda a, b: sum(1 for x, y in zip(a, b) if x != y)
m = 0 if S == T else nT
for i in range(len(S) - nT + 1):
    m = min(m, f(S[i:i+nT], T))
    if m == 0:
        break

print(m)


Measured memory_bytes: 9052