akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>

#include <string>

#include <vector>
#include <list>
#include <map>

#include <algorithm>
#include <utility>

using namespace std;

int main(const int argc, const char **argv){
  int N;
  scanf("%d", &N);

  vector<int> x(N), y(N), h(N);
  for(int i = 0; i < N; i++){
    scanf("%d %d %d", &x[i], &y[i], &h[i]);
  }

  for(int X = 0; X <= 100; X++){
    for(int Y = 0; Y <= 100; Y++){

      //find H
      int H;
      for(int i = 0; i < N; i++){
        if(h[i] != 0){
          H = h[i] + abs(X - x[i]) + abs(Y - y[i]);
          break;
        }
      }

      //Test
      for(int i = 0; i < N; i++){
        int test_h = max(H - abs(X - x[i]) - abs(Y - y[i]), 0);
        if(test_h != h[i]){
          break;
        }
        if(i == N - 1){
          printf("%d %d %d\n", X, Y, H);
          return 0;
        }
      }

    }
  }

  return 0;
}


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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    string S;
    cin >> S;
    char before = S[0];
    bool check = false;
    int ans = 1;
    for (int i = 1; i < S.length(); i++)
    {
        if (check)
        {
            before = S[i];
            check = false;
        }
        else
        {
            if (before == S[i])
            {
                check = true;
                i++;
                if (i == S.length())
                {
                    break;
                }
            }
            else
            {
                before = S[i];
            }
        }
        ans++;
    }
    cout << ans << endl;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

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

const int MAX   = 100;
const int INF   = (1 << 21);
const int white = 0;
const int gray  = 1;
const int black = 2;

int n, m[MAX][MAX];

int prim() {
    int u, minV;
    int d[MAX], p[MAX], color[MAX];
    rep(i, n) {
        d[i]     = INF;
        p[i]     = -1;
        color[i] = white;
    }

    d[0] = 0;
    while (1) {
        minV = INF;
        u    = -1;
        rep(i, n) {
            if (minV > d[i] && color[i] != black) {
                u    = i;
                minV = d[i];
            }
        }
        if (u == -1) break;
        color[u] = black;
        rep(v, n) {
            if (color[v] != black && m[u][v] != INF) {
                if (d[v] > m[u][v]) {
                    d[v]     = m[u][v];
                    p[v]     = u;
                    color[v] = gray;
                }
            }
        }
    }
    int sum = 0;
    rep(i, n) {
        if (p[i] != -1) sum += m[i][p[i]];
    }
    return sum;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    cin >> n;
    rep(i, n) {
        rep(j, n) {
            int e;
            cin >> e;
            m[i][j] = (e == -1) ? INF : e;
        }
    }
    cout << prim() << endl;

    return 0;
}



Measured memory_bytes: 3212
N,W=map(int,input().split())
wv = [tuple(map(int,input().split())) for _ in range(N)]

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(1,N+1):
  for j in range(1, W+1):
    if j >= wv[i-1][0]:
      dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i-1][0]]+wv[i-1][1])
    else:
      dp[i][j] = dp[i-1][j]
      
print(dp[-1][-1])

Measured memory_bytes: 150540
import math
a,b,C=map(int,input().split())
s=(a*b*math.sin(math.radians(C)))/2
c=(a**2+b**2-2*a*b*math.cos(math.radians(C)))**(1/2)
h=s*2/a
print(f'{s:4f}')
print(f'{a+b+c:4f}')
print(f'{h:4f}')



Measured memory_bytes: 5732
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

int N;

int main(){
  cin >> N;

  vector<int> primes;
  vector<int> table(101, 1);
  table[0] = 0;
  table[1] = 0;

  for(int i = 2; i < 101; i++){
    if(table[i] == 0) continue;

    int j = 2*i;
    while(j < 101){
      table[j] = 0;
      j += i;
    }
  }

  for(int i = 0; i < 101; i++){
    if(table[i] == 1) primes.push_back(i);
  }

  map<int, int> cnt;

  for(auto it = primes.begin(); it != primes.end(); it++){
    for(int i = 1; i <= N; i++){
      int val = i;

      while(val % (*it) == 0){
	val /= (*it);
	cnt[(*it)]++;
      }
    }
  }

  int count3 = 0;
  int count5 = 0;
  int count15 = 0;
  int count25 = 0;
  int count75 = 0;

  for(auto it = cnt.begin(); it != cnt.end(); it++){
    if(it->second >= 2) count3++;
    if(it->second >= 4) count5++;
    if(it->second >= 14) count15++;
    if(it->second >= 24) count25++;
    if(it->second >= 74) count75++;
  }

  int ans = 0;

  ans += count75;
  ans += count25 * (count3 - 1);
  ans += count15 * (count5 - 1);
  ans += count5 * (count5 - 1) / 2 * (count3 - 2);

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


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

int main()
{
	int n, m = 0;
	string s;

	cin >> n >> s;

	for (int i = 0; i < n - 1; i++) {
		if ((s[i] == 'O' && s[i + 1] == 'X') || (s[i] == 'X' && s[i + 1] == 'O')) {
			m++;
			i++;
		}
	}

	cout << m << endl;
	
	return 0;
}


Measured memory_bytes: 3336
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a%2 != 0 && b%2 != 0) {
      System.out.println("Odd");
    } else {
      System.out.println("Even");
    }
  }
}

Measured memory_bytes: 20812
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    ll n, m;
    cin >> n >> m;
    ll ans = min(n, m / 2);
    m -= 2 * ans;
    ans += m/4;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



n,k,s = map(int, input().split())
if s==10**9:
    a = [10**9]*k + [1]*(n-k)
else:
    a = [s]*k + [s+1]*(n-k)
print(" ".join(map(str, a)))

Measured memory_bytes: 86224
import sys
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	h,w,k=MI()
	G=[]
	for _ in range(h):
		G.append(list(input().rstrip().decode()))
	#print(G)
	ans=0

	for i in range(1<<h):
		for j in range(1<<w):
			cnt=0
			for ii in range(h):
				for jj in range(w):
					#print(i,j,ii,jj,)
					if i&1<<ii and j&1<<jj and G[ii-1][jj-1]=="#":
						#print(1<<i)
						cnt+=1
			if cnt==k:
				ans+=1
	print(ans)







if __name__ == "__main__":
	main()


Measured memory_bytes: 74040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s, t;
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    
    for(int i=n-1; i>=0; i--){
        for(int j=m-1; j>=0; j--){
            if(s[i]==t[j]){
                dp[i][j] = 1 + dp[i+1][j+1];
            }
            else{
                dp[i][j] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }
    string ans = "";
    int i = 0;
    int j = 0;
    while(i<n && j<m){
        if(s[i]==t[j]){
            ans += s[i];
            i++;
            j++;
        }
        else{
            dp[i+1][j]>=dp[i][j+1]?i++:j++;
        }
    }
    cout<<ans;
    
}

Measured memory_bytes: 38724
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;


public class Main {
    public static void main(String[] args)throws Exception{
        Scanner scan = new Scanner(System.in);
        int n,x;
        while(true){
            n = scan.nextInt();
            x = scan.nextInt();
            if(n == 0 && x == 0){
                break;
            }
            result(n,x);
        }
    }
    
    public static void result(int n,int x){
        int sum = 0;
        for(int i = 1;i != n - 1;i++){
            for(int j = i + 1;j != n;j++){
                for(int I = j + 1;I != n + 1;I++){
                    if(i + j + I == x){
                        sum++;
                    }
                }
            }
        }
        System.out.println(sum);
    }
}


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

#define ll long long

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

    map<int, int> high[2];

    for (int i = 0; i < n; ++i)
    {
        int k;
        cin >> k;

        ++high[i % 2][k];
    }

    int mx[2] = {};

    for (auto it = high[0].begin(); it != high[0].end(); ++it)
        if (high[0][mx[0]] < high[0][it->first])
            mx[0] = it->first;

    for (auto it = high[1].begin(); it != high[1].end(); ++it)
        if (high[1][mx[1]] < high[1][it->first])
            mx[1] = it->first;

    int md[2] = {};

    for (auto it = high[0].begin(); it != high[0].end(); ++it)
        if (high[0][md[0]] < high[0][it->first] && it->first != mx[0])
            md[0] = it->first;

    for (auto it = high[1].begin(); it != high[1].end(); ++it)
        if (high[1][md[1]] < high[1][it->first] && it->first != mx[1])
            md[1] = it->first;

    if (mx[0] != mx[1])
        cout << n - high[0][mx[0]] - high[1][mx[1]];
    else cout << n - max(high[0][mx[0]] + high[1][md[1]], high[0][md[0]] + high[1][mx[1]]);

    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 60
using namespace std;
int n,m,a[szxb];
void qsort(int p,int q)
{
	if(p>=q)
	{
		return;
	}
	int i=p,j=q,key=a[p];
	while(i<j)
	{
		while(i<j&&a[j]>key)
		{
			j--;
		}
		if(i<j)
		{
			a[i++]=a[j];
		}
		while(i<j&&a[i]<key)
		{
			i++;
		}
		if(i<j)
		{
			a[j--]=a[i];
		}
	}
	a[i]=key;
	qsort(p,i-1);
	qsort(i+1,q);
	return;
}
int main()
{
	scanf("%d%d",&n,&m);
	int t;
	for(register int i=1;i<=n;i++)
	{
		scanf("%d",&t);
		a[i]=t;
	}
	qsort(1,n);
	int total=0;
	for(register int i=n;i>=(n-m+1);i--)
	{
		total+=a[i];
	}
	printf("%d",total);
	putchar(10);
	return 0;
}

Measured memory_bytes: 256
let () =
  let f = function
      1 -> 6000
    | 2 -> 4000
    | 3 -> 3000
    | 4 -> 2000
    | _ -> 0
  in
  let rec read = function
      0 -> ()
    | i -> let (x,y) = Scanf.scanf " %d %d\n" (fun x y -> (x,y)) in
           Printf.printf "%d\n" ((f x)*y)
           ;read (i-1)
  in read 4
;;

Measured memory_bytes: 2360
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

using ll = long long;

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

    vector<int> a;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 0) {
            if (a[i] % 3 == 0 || a[i] % 5 == 0) {
                continue;
            } else {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}


Measured memory_bytes: 256
n, m, l = map(int, input().split())
a = [0]*n
b = [0]*m
c = [[0]*l for i in range(n)]
for row in range(n):
    a[row] = list(map(int, input().split()))
for row in range(m):
    b[row] = list(map(int, input().split()))
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for i in range(n):
    print(' '.join(map(str, c[i])))


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



int p,q,r;
int it;
string s;
int formula()
{
  // cout<<"formula :"<<s[it]<<endl;
  if(s[it]=='-')
    {
      it++;
      int tmp = formula();
      return (-tmp)+2;
    }
  else if(s[it]=='(')
    {
      it++;
      int a = formula();
      it++;
      if(s[it]=='*')
	{
	  it++;
	  int b = formula();
	  it++;
	  //	  cout<<a<<" "<<b<<endl;
	  return min(a,b);
	}
      else
	{
	  it++;
	  int b = formula();
	  it++;
	  return max(a,b);
	}
    }
  else
    {
      char tmp=s[it];
      // it++;
      if(tmp=='0')
	return 0;
      if(tmp=='1')
	return 1;
      if(tmp=='2')
	return 2;
      if(tmp=='P')
	return p;
      if(tmp=='Q')
	return q;
      if(tmp=='R')
	return r;

    }
}

int parse(string s)
{
  //  string::iterator it=s.begin();
  it=0;
  return formula();
}



int main()
{
  for(;cin>>s,s!=".";)
    {
      int cnt=0;
      for(p=0;p<3;p++)
	for(q=0;q<3;q++)
	  for(r=0;r<3;r++)
	    {
	         int ans=parse(s);
	      if(ans==2)
		cnt++;
	      //cout<<p<<" "<<q<<" "<<r<<" "<<ans<<endl;
	    }
      cout<<cnt<<endl;


    }

}

Measured memory_bytes: 1196
Scanf.scanf "%d" (fun n ->
    let check a =
        let s = string_of_int a in
        let x = String.length s in

        let rec loop i =
            if i = x then true else
                if s.[i] = s.[0] then loop (i + 1) else false
        in
        loop 1
    in
    let rec loop i =
        if check i then i else loop (i + 1)
    in
    loop n |> Printf.printf "%d\n"
)

Measured memory_bytes: 3788
#include <iostream>
#include <set>
using namespace std;
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    set<char> x, y, sum;
    int cnt, maxCnt = 0;
    for (int i=1; i<n-1; i++) {
        //0番目からi-1番目までをxに入れ、それ以降をyに入れる
        for (int j=0; j<i; j++) {
            x.insert(s[j]);
        }
        for (int j=i; j<n; j++) {
            y.insert(s[j]);
        }
        cnt = 0;
        for (auto iter=x.begin(); iter!=x.end(); iter++) {
            if (y.find(*iter) != y.end()) {
                cnt++;
            }
        }
        maxCnt = max(maxCnt, cnt);
        x.clear();
        y.clear();
    }
    cout << maxCnt << endl;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int N,M;
// X[n][m]: nがmを好きか？
int X[35][35]; // 初期値0

int main()
{
  cin >> N >> M;
  REP(n,0,N) {
    int K;
    cin >> K;
    REP(k,0,K) {
      int m;
      cin >> m;
      --m; // 0-indexedに
      X[n][m] = 1;
    }
  }

  int ans = 0;
  REP(m,0,M) { // M種類
    int sum = 0;
    REP(n,0,N) sum += X[n][m];
    // N人全員が好き
    if (sum == N) ++ans;
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
	int i,j,a[4][4],cha;
	for (i=1;i<=3;i++){
		for (j=1;j<=3;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for (i=1;i<=2;i++){
		cha=a[i+1][1]-a[i][1];
		if (a[i+1][2]-a[i][2]!=cha || a[i+1][3]-a[i][3]!=cha){
			printf("No");
			return 0;
		}
	}
	for (j=1;j<=2;j++){
		cha=a[1][j+1]-a[1][j];
		if (a[2][j+1]-a[2][j]!=cha || a[3][j+1]-a[3][j]!=cha){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
    ll n;
    cin>>n;
    V<ll> a(n);
    map<ll,ll> mp;
    map<ll,bool> d;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
        d[a[i]]=true;
    }
    ll ans=0;
    for(auto p: mp){
        if(!d[p.fi])continue;
        if(p.se==1)ans++;
         for(ll i=2;i*p.fi<=(1e6);i++){
             if(mp.count(i*p.fi)){
                 d[i*p.fi]=false;
             }
         }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 29860
from collections import deque

def bfs(maze, visited,h,w,sx,sy):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    mx = 0
    while queue:
        y, x = queue.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if 0<=new_y<h and 0<=new_x<w:
                if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                    visited[new_y][new_x] = visited[y][x] + 1
                    if visited[new_y][new_x] > mx:
                        mx = visited[new_y][new_x]
                    queue.append([new_y, new_x])

    return mx

if __name__ == "__main__":
    h, w = map(int, input().split())

    maze = [list(input()) for i in range(h)]

    ans = []
    for idxi,i in enumerate(maze):
        for idxj,j in enumerate(i):
            if j == '.':
                sx,sy = idxj,idxi
                visited = [[-1]*w for j in range(h)]
                ans.append(bfs(maze, visited,h,w,sx,sy))

    print(max(ans))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    long long n = 0 ; 
    cin >> n ; 
    bool maximize = !(n&1) ;
    long long a[n+1] , diff[n+1][n+1] ;
    a[0] = 0 ;
    for(long long i = 1 ; i <= n ; i++)
        cin >> a[i] ;
    for(long long i = 0 ; i <= n ; i++)
        for(long long j = 0 ; j <= n ; j++)
            diff[i][j] = 0 , diff[1][j] = a[j] ;
    for(long long i = 1 ; i <= n-2+1 ; i++){
        if(maximize) diff[2][i] = max(a[i+1]-a[i], a[i]-a[i+1]) ;
        else diff[2][i] = min(a[i+1]-a[i], a[i]-a[i+1]) ;
    }
    maximize = !maximize ;
    for(long long L = 3 ; L <= n ; L++){
        for(long long i = 1 ; i <= n-L+1 ; i++){
            if(maximize) diff[L][i] = max(a[i] + diff[L-1][i+1] , a[L+i-1] + diff[L-1][i]) ;
            else diff[L][i] = min(-a[i] + diff[L-1][i+1] , -a[L+i-1] + diff[L-1][i]) ;
        }
        maximize = !maximize ;
    }
    cout << diff[n][1] ;
}


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

int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  rep(i,n){
    int count = 0;
    rep(j,n){
      if(s[j%n] == t[(j+i)%n]) ++count;
    }
    if(count == n){
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc155/tasks/abc155_b

read n ; read row ; A=($row)
ok="0"
for istr in ${A[@]} ; do
  i=$((istr))
  if [ $((i%2)) -eq $((0)) ] ; then
    if [ $((i%3)) -ne $((0)) -a $((i%5)) -ne $((0)) ]; then
      echo "DENIED"
      ok="1"
      break
    fi
  fi
done

if [ $ok = "0" ] ; then
  echo "APPROVED"
fi




Measured memory_bytes: 1396
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    if (s.length()>=3){
        for (int i=0; i<s.length()-2; i++){
            if (s[i]==s[i+1] ||s[i]==s[i+2] || s[i+1]==s[i+2]){
                cout << i+1 << " " << i+3 << endl;
                exit(0);
            }
        }
    }
    else {
        if (s[0]==s[1]){
            cout << 1 << " " << 2 << endl;
            exit(0);
        }
    }
    cout << -1 << " " << -1 << endl;
}



Measured memory_bytes: 512
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val d = new Array[Int](n)
    for (i <- 0 until n) {
      d(i) = sc.nextInt
    }

    val sorted = d.sorted
    println(sorted(n / 2) - sorted(n / 2 - 1))
  }
}


Measured memory_bytes: 51796
#include <bits/stdc++.h>
using namespace std;
int N, L[101], X;
int main(){
    scanf("%d %d", &N, &X);
    for(int i =0; i < N; i++){
        scanf("%d", L + i);
    }
    int ans = 0, sum = 0;
    for(int i = 0; i < N; i++){
        if(sum > X)    break;
        sum += L[i];
        ans++;
    }
    if(sum <= X) ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math


#t = int(input())
tmp = input().split()
x,y = list(map(lambda a: int(a), tmp))
if(y<2*x):
	print("No")
	sys.exit()
if(y>4*x):
	print("No")
	sys.exit()
if(((4*x)-y)%2==1):
	print("No")
	sys.exit()
print("Yes")


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int>a(N);
    for(int i=0; i<N; ++i) cin>>a[i];
    sort(a.begin(), a.end());
    cout << unique(a.begin(), a.end()) - a.begin() << endl;
}

Measured memory_bytes: 256
/*
@author: shubham
*/

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

string s;
int main() {
    cin>>s;
    string prefix="";
    string suffix="";
    int q;
    cin>>q;
    int flag=1;
    while(q--){
        int op;
        cin>>op;
        
        if(op==1){
            flag++;
        }
        else{
            int pos;
            cin>>pos;
            char ch;
            cin>>ch;
            
            if(flag%2 != 0){
                if(pos==1){
                    prefix.push_back(ch);
                }
                else{
                    suffix.push_back(ch);
                }
            }
            else{
                if(pos==1){
                    suffix.push_back(ch);
                }
                else{
                    prefix.push_back(ch);
                }
            }
        }
    }
    reverse(prefix.begin(), prefix.end());
    s = prefix + s + suffix;
    if(flag%2==0){
        reverse(s.begin(), s.end());
        cout<< s <<endl;
    }
    else{
        cout<< s <<endl;
    }
    return 0;
}


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

int main(){
  int h,w;
  cin >>h >>w;
  string board[50];
  rep(i,h) cin >>board[i];
  const int dx[8] = {-1,-1,-1,0,0,1,1,1};
  const int dy[8] = {-1,0,1,-1,1,-1,0,1};
  rep(i,h){
    rep(j,w){
      if(board[i][j]=='#') continue;
      int cnt = 0;
      rep(d,8){
        const int ni = i+dy[d];
        const int nj = j+dx[d];
        if(ni<0 or h<=ni) continue;
        if(nj<0 or w<=nj) continue;
        if(board[ni][nj]=='#') cnt++;
      }
      board[i][j] = char(cnt+'0');
    }
  }
  rep(i,h) cout << board[i] << endl;
  return 0; 
}


Measured memory_bytes: 256
M=10**9+7;n,k,*A=map(int,open(0).read().split());C=[[0]*(n+1)for _ in"_"*(n+1)]
for i in range(n+1):
 for j in range(i+1):C[i][j]=(1,C[i-1][j-1]+C[i-1][j])[j!=0]%M
F=[[0]*(n+1)for _ in"_"*(k+1)];F[0][0]=1
for i in range(k):
 for j in range(n+1):
  for m in range(j+1):F[i+1][j]+=C[j][m]*F[i][m]*C[n-j+m][A[i]-j+m]
print(F[k][n]%M)

Measured memory_bytes: 57740
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int

let choice ok ng bool = if bool then ok else ng

stdin.ReadLine()

readIntArray ()
|> fun x -> x |> Array.sort |> Array.zip x
|> Array.filter (fun (a, b) -> a <> b)
|> Array.length
|> ((>=) 2)
|> choice "YES" "NO"
|> printfn "%s"


Measured memory_bytes: 29728
N = int(input())
S = input()
S1 = []
if N % 2 != 0:
    print('No')
    exit()
for i in range(N // 2):
    S1.append(S[i])

S = S[N // 2 :]
S1 = ''.join(S1)
if S1 == S:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int H1,M1,H2,M2,K;
	cin>>H1>>M1>>H2>>M2>>K;
	int H=H2;
	int M=M2;
	int ans=0;
	M2-=K;
	while (M2<0){
		M2+=60;
		H2--;
	}
	if (H2<H1 || H2==H1 &&M2<=M1){
		cout<<0<<endl;
		return 0;
	}

	if (M2>=M1){
		ans=(H2-H1)*60+M2-M1;
	}else{
		ans=(H2-H1-1)*60+60+M2-M1;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3168
def solve():
    A,B,C,D = [int(i) for i in input().split()]
    takahashi_attack_cnt = (C+B-1) // B
    aoki_attack_cnt = (A+D-1) // D
    if takahashi_attack_cnt <= aoki_attack_cnt:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9040
def main():
    A= list(map( int, input().split()))
    ans = abs(A[0]+A[1]-A[2]-A[3])
    for i in range(4):
        for j in range(4):
            if i == j:
                continue
            now = 0
            for t in range(4):
                if t == i or t == j:
                    now += A[t]
                else:
                    now -= A[t]
            if abs( now) < ans:
                ans = abs(now)
    print(ans)
    
if __name__ == '__main__':
    main()



Measured memory_bytes: 5600
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int ac = 0,
            wa = 0,
            tle = 0,
            re = 0;
        int n = int.Parse(Console.ReadLine());
        string tmp;
        for (int i = 0; i < n; i++)
        {
            tmp = Console.ReadLine();
            switch (tmp)
            {
                case "AC":
                    ac++;
                    break;
                case "WA":
                    wa++;
                    break;
                case "TLE":
                    tle++;
                    break;
                case "RE":
                    re++;
                    break;
                default:
                    break;
            }
        }
        Console.WriteLine("AC x " + ac);
        Console.WriteLine("WA x " + wa);
        Console.WriteLine("TLE x " + tle);
        Console.WriteLine("RE x " + re);
    }
}

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  double n;
  cin >> n;
  printf("%.10lf\n", ((int)(n + 1) / 2) / n);
  return 0;
}


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

  double ans = (L * L * L + 0.0000001) / 27;
  cout << fixed << setprecision(15) << ans;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef tuple<int, int, int> T;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll x;

void solve() {
    map<ll, ll> m5;
    for (ll i = 0; i <= 1000; i++) {
        m5[i*i*i*i*i] = i;
    }
    for (ll a = 0; a <= 1000; a++) {
        ll a5 = a * a * a * a * a;
        ll b5 = a5 - x;
        if (m5.count(abs(b5)) > 0) {
            ll b = m5[abs(b5)];
            if (b5 < 0) b *= -1;
            cout << a << " " << b << endl;
            return;
        }
    }
}

void input() {
    cin >> x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Measured memory_bytes: 3184
def main():
    a,b,c,d = map(int,input().split())
    if a>=0 and b>=0 and c>=0 and d>=0:
        return b*d
    elif a<=0 and b>=0 and c>=0 and d>=0:
        return b*d
    elif a<=0 and b<=0 and c>=0 and d>=0:
        return b*c
    elif a>=0 and b>=0 and c<=0 and d>=0:
        return b*d
    elif a<=0 and b>=0 and c<=0 and d>=0:
        return (max(a*c,b*d))
    elif a<=0 and b<=0 and c<=0 and d>=0:
        return a*c
    elif a>=0 and b>=0 and c<=0 and d<=0:
        return a*d
    elif a<=0 and b>=0 and c<=0 and d<=0:
        return a*c
    elif a<=0 and b<=0 and c<=0 and d<=0:
        return a*c

print(main())


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

int a,b,d;
int x,y;

void check(int s,int t){
  if(x<0 || x+y>s+t || (x+y==s+t && a*x+b*y>a*s+b*t)){
    x = s; y = t;
  }
}

int main(){
  while(cin >> a >> b >> d,a){
    x=-1,y=-1;
    for(int i=0;a*i<=d;i++){
      if(!((d-a*i)%b))check(i,(d-a*i)/b);
    }
    
    for(int i=d/a+1;;i++){
      if(!((a*i-d)%b)){
	check(i,(a*i-d)/b);
	break;
      }
    }

    for(int i=d/b+1;;i++){
      if(!((b*i-d)%a)){
	check((b*i-d)/a,i);
	break;
      }
    }
    cout << x << " " << y << endl;
  }
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int bit(int x) {
  vll mima = {0, 0};
  for (int i = 0; ; ++i) {
    int j = (i+1) % 2;
    int pm = (i % 2 == 0) ? 1 : -1;
    mima[j] += ((1LL << i) * pm);
    if (mima[0] <= x && x <= mima[1]) {
      return i;
    }
  }
}

int m2j(int k) {
  if (k == 0) {
    return 1;
  }
  int y = m2j(k / 2);
  y *= y;
  if (k % 2 == 1) {
    y *= (-2);
  }
  return y;
}

int main() {
  int n;
  cin >> n;
  if (n == 0) {
    printf("0\n");
    return 0;
  }
  vi ansbit;
  while (n != 0) {
    int b = bit(n);
    if (m2j(b) == 0) {
      break;
    }
    n -= m2j(b);
    if ((int)ansbit.size() < b+1) {
      ansbit.assign(b+1, 0);
    }
    ansbit[b] = 1;
  }
  reverse(all(ansbit));
  for (int x : ansbit) {
    printf("%d", x);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 256
//
// Created by ryo on 2019/11/17.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    int n;
    string s, t;
    cin >> n >> s;

    t = s.substr(n / 2);
    s = s.substr(0, n / 2);



    if (t == s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [[int(n) for n in input().split()] for i in range(n)]
b = []
for i in range(m):
    b.append(int(input()))
c = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]
    print(c[i])

Measured memory_bytes: 8032
#include<stdio.h>

long long count = 0;


void merge(int A[],int left,int mid,int right) 
{
  int i,j=0,k;
  int n1 = mid-left, n2 = right - mid; 
  int L[n1+1],R[n2+1];
   
  for(i = 0;i < n1;i ++){
    
    L[i] = A[left+i];
  }
  
  for(i = 0;i < n2;i ++){
    R[i] = A[mid+i];
  }
  
  L[n1] = (1e+9)+1;
  R[n2] = (1e+9)+1;

  i = 0;
  
  for(k = left;k < right;k ++)
    {
      if(L[i]<=R[j]){
	A[k] = L[i ++];
      }else {
	A[k] = R[j ++];
	count += n1-i;
      }
    }
}
 
void mergeSort(int A[],int left,int right) 
{
  int mid;
  
  if(left+1 < right) {
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}
 
int main() 
{
  int i,n,S[200000];
  
  scanf("%d",&n);
  
  for(i = 0;i < n;i ++) 
    {
      scanf("%d",&S[i]);
    }
  
  mergeSort(S,0,n);
  
  printf("%ld\n",count);
   
  return 0;
}
 

Measured memory_bytes: 2156
#include <iostream>
#include <algorithm>


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

using namespace std;

int main() {
	int n,ans=0,i,count=0,j,flag=0;
	
	while(1){
		cin>>n;
		if(n==0){
			break;
		}
		for(i=1;i<n;i++){
			for(j=i;j<n;j++){
				ans+=j;
				if(ans==n && flag==1){
					count++;
					break;
				}
				if(ans>n){
					break;
				}
				flag=1;
			}
			ans=0;
			flag=0;
		}
		cout<<count<<endl;
		count=0;
	}
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 2988
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	int i,j;
	for(i=1;i<=9;i++)
		for(j=1;j<=9;j++)
			printf("%dx%d=%d\n",i,j,i*j);
    return 0;
}

Measured memory_bytes: 0
N = int(input())

lis = []

for i in range(N):

    A,B = map(int,input().split())

    lis.append([A+B,A,B])

lis.sort()
lis.reverse()

T = 0
K = 0

for i in range(N):

    if i % 2 == 0:
        T += lis[i][1]
    else:
        K += lis[i][2]

print (T-K)


Measured memory_bytes: 25068
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long
#define MAX_COST 1000000001
vector<ll> dp;
vector<ll> h;
ll N, K;
ll res(ll i)
{
    if (dp[i] != -1)
    {
        return dp[i];
    }

    ll ret;

    if (i >= 1)
    {
        ret = MAX_COST;
        ll jmin = max(i - K, (ll)0);
        for (ll j = i - 1; j >= jmin; j--)
        {
            ret = min(ret, res(j) + abs(h.at(j) - h.at(i)));
        }
    }
    else
    {
        ret = 0;
    }

    return dp[i] = ret;
}

void solve()
{
    cin >> N >> K;
    h = vector<ll>(N);
    dp = vector<ll>(N, -1);
    for (ll i = 0; i < N; i++)
        cin >> h[i];

    cout << res(N - 1) << endl;
    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int n;
    string s;

    cin >> n;
    cin >> s;

    long long sum = 0;
    /*int i,j,k,diff;
    int diff_max = n/2;
  	for ( diff = 1;diff < diff_max; diff++)
      {
          for (i =0;i<n;i++)
           {
              j=i+diff;
              k=j+diff;
              if (k>=n) continue;
              if (s[i] == s[j] || s[i] == s[k] || s[k] == s[j])
                continue;
                sum--;

          }
          
      }*/

    int nr = 0, ng = 0, nb = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            nr++;
        }
        else if (s[i] == 'G')
        {
            ng++;
        }
        else
        {
            nb++;
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            nr--;
        }
        else if (s[i] == 'G')
        {
            ng--;
        }
        else
        {
            nb--;
        }

        int jr = nr, jg = ng, jb = nb;
        for (int j = i + 1; j < n; j++)
        {
            if (s[j] == 'R')
            {
                jr--;
            }
            else if (s[j] == 'G')
            {
                jg--;
            }
            else
            {
                jb--;
            }
            if (s[i] == s[j])
                continue;
            int diff_ji = j - i;

            if (s[i] != 'R' && s[j] != 'R')
            {
                sum += jr;
            }
            else if (s[i] != 'G' && s[j] != 'G')
            {
                sum += jg;
            }
            else
            {
                sum += jb;
            }

            int k = diff_ji + j;
            if(k<n)
            {
                if(s[k]==s[i]||s[k]==s[j]) continue;
                sum--;
            }
       }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3628
def main():
    import sys
    input = sys.stdin.readline

    INF = 10 ** 10

    from math import sqrt

    xs, ys, xg, yg = map(int, input().split())

    N = int(input())
    XYR = [tuple(map(int, input().split())) for _ in range(N)]

    G = [[] for _ in range(N + 2)]

    def diff1(i, j):
        tmp = (XYR[i][0] - XYR[j][0]) ** 2 + (XYR[i][1] - XYR[j][1]) ** 2
        R = XYR[i][2] + XYR[j][2]
        return max(0, sqrt(tmp) - R)

    for i in range(N - 1):
        for j in range(i + 1, N):
            tmp = diff1(i, j)
            G[i].append((tmp, j))
            G[j].append((tmp, i))

    def diff2(x, y, i):
        tmp = (x - XYR[i][0]) ** 2 + (y - XYR[i][1]) ** 2
        R = XYR[i][2]
        return max(0, sqrt(tmp) - R)

    for i in range(N):
        tmp = diff2(xs, ys, i)
        G[N].append((tmp, i))
        G[i].append((tmp, N))


    for i in range(N):
        tmp = diff2(xg, yg, i)
        G[N + 1].append((tmp, i))
        G[i].append((tmp, N + 1))

    tmp = (xs - xg) ** 2 + (ys - yg) ** 2
    G[N].append((sqrt(tmp), N + 1))
    G[N + 1].append((sqrt(tmp), N))

    d = [INF] * (N + 2) #頂点sからの距離

    def dijksrea(s): #始点s
        from heapq import heappop, heappush
        d[s] = 0 #始点の距離を0にする
        pque = []
        heappush(pque, (0, s)) #要素を[距離、頂点]として管理　最初の位置を入れる

        while pque: #queの中に要素が残っている時
            p = heappop(pque) #最も距離が短いものを取り出す
            v = p[1] #距離が最も短い頂点
            if d[v] < p[0]: #取り出した値より既に小さい値がdに入っているときは無視して次へ
                continue
            for i in range(len(G[v])): #頂点vの隣接リストを走査
                e = G[v][i]
                if d[e[1]] > d[v] + e[0]: #距離が更新できるかを検討
                    d[e[1]] = d[v] + e[0]
                    heappush(pque, (d[e[1]], e[1])) #更新できた場合、その値をpqueに入れる

    dijksrea(N)
    print (d[N + 1])

    # print (d)

if __name__ == '__main__':
    main()

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    string S;
    cin >> S;
    if (S == "ABC")
    {
        std::cout << "ARC" << endl;
    }
    else
    {
        std::cout << "ABC" << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  ll X;
  cin >> X;
  
  if (X == 3 || X == 5 || X == 7) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }

  return 0;
}

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

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int cnt = 0;
    for(int i = L; i <= R; i++) {
        if(i % d == 0) cnt++;
    }
    cout << cnt << endl;
}

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

int main() {
    int n; cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1) cin >> b[i];
    if(n == 2){
        cout << 2*b[0];
    }
    else {
    int total = 0;
    total += b[0];
    total += b[n-2];
    for(int i = 0; i < n - 2; i++){
        total += min(b[i],b[i+1]);
    }
    cout << total << endl;
    }
}

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

int main()
{
    int n,cnt=0,i;
    cin>>n;
    int arr[n+10];
    int k=n;
    for(i=1,k; i<=n; i++,k--)
    {
        cin>>arr[i];
        if(arr[i]==i)
        {
            cnt++;
        }
    }
    if(cnt>=n-2 )
        cout<<"YES";
    else
        cout<<"NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
const ll MOD = 1000000007;

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}



void solve(long long A, long long B){
    if(A+B >= 24){
        cout << A + B - 24 << endl;
    }else{
        cout << A + B << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll N, ec, wc, aec, r;
string S;

int main()
{
  cin >> N >> S;
  aec = count(ALL(S), 'E');
  ec = aec;
  wc = 0;
  r = N;
  REP(i, N)
  {
    if (S[i] == 'E')
      ec--;

    r = min(r, ec + wc);

    if (S[i] == 'W')
      wc++;
  }

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a,b;
string s;
int main(void){
    cin>>a>>b;
    for(int i=0;i<a;i++){
        cin>>s;
        cout<<s<<endl<<s<<endl;
    }
    
}


Measured memory_bytes: 3616
/**
    AUTHOR:JUNSH
    TIME:19/5/25
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const int inf=0x3f3f3f3f;
int main(){
    int r,d,x;
    cin>>r>>d>>x;
    for(int i=1;i<=10;++i){
        x=r*x-d;
        cout<<x<<endl;
    }
}


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

using namespace std;

int main (void) {
    string S, T;
    cin >> S >> T;

    assert(S.size() == T.size());
    int str_len = S.size();
    int s_idx;
    bool ans_found = true;
    for ( int start = 0; start < str_len; start++ ) {
        ans_found = true;
        for ( int i = 0; i < str_len; i++ ) {
            s_idx = (start + i) % str_len;
            if ( S.at(s_idx) != T.at(i) ) {
                ans_found = false;
                break;
            }
        }
        if ( ans_found ) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    //my-code
    int N; cin >> N;
    ll ans = 0;
    REP(i, N+1) {
        if (i==0) continue;
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3648