akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]

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

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

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        $(writeln!(stderr(), "{} = {:?}", stringify!($arg), $arg).unwrap());*
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

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

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let mut A = read![[i32]];
    A.sort();
    println!("{}", A[2] * 10 + A[1] + A[0])
}


Measured memory_bytes: 4352
function main(input: string) {
  const N: number = Number(input.split("\n")[0]);
  let sum: number = 0;
  for (let i: number = 1; i <= N; i += 1) {
    sum += i;
  }
  console.log(sum);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<stdio.h>
int main()
{
  int n;
  scanf("%d",&n);
  long long int sum=0;
  for(int i=1;i<=n;i++)
  {
    if(i%3==0||i%5==0);
    else
      sum+=i;
  }
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 1704
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			double a[] = new double[6];
			for(int i=0;i<6;i++){
				a[i]=sc.nextDouble();
			}

			double x,y;

			if(a[0]==0 && a[4]==0){
				y=a[2]/a[1];
				x=a[5]/a[3];
			}else if(a[1]==0 && a[3]==0){
				x=a[2]/a[0];
				y=a[5]/a[4];
			}else if(a[4]==0){
				x=a[5]/a[3];
				y=(a[2]-a[0]*x)/a[1];	
			}else if(a[3]==0){
				y=a[5]/a[4];
				x=(a[2]-a[1]*y)/a[0];
			}else{
				x = (a[2]-a[1]*a[5]/a[4])/(a[0]-a[1]*a[3]/a[4]);
				y = (a[2]-a[0]*a[5]/a[3])/(a[1]-a[0]*a[4]/a[3]);
			}
			System.out.println(String.format("%.3f",x)+" "+String.format("%.3f",y));
		}
	}
}


Measured memory_bytes: 28324
def solve(string):
    h, w, *s = string.split()
    h, w = map(int, [h, w])
    hg = []
    hi = []
    vg = []
    vi = []

    for _s in s:
        gn = 0
        _hi = [0] * w
        _hg = []
        c = 0
        for i, __s in enumerate(_s):
            if __s == "#":
                _hi[i] = -1
                gn += 1
                _hg.append(c)
                c = 0
                continue
            _hi[i] = gn
            c += 1
        _hg.append(c)
        hg.append(_hg)
        hi.append(_hi)
    for _s in zip(*s):
        gn = 0
        _vi = [0] * h
        _vg = []
        c = 0
        for i, __s in enumerate(_s):
            if __s == "#":
                _vi[i] = -1
                gn += 1
                _vg.append(c)
                c = 0
                continue
            _vi[i] = gn
            c += 1
        _vg.append(c)
        vg.append(_vg)
        vi.append(_vi)

    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, hg[i][hi[i][j]] + vg[j][vi[j][i]])
    return str(ans - 1)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 197872
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a, b) << " " << max(0, a + b - n) << endl;

    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 200003,INF=0x7f7f7f7f;
int n,b[MaxN],pre[MaxN],q;
vector<int> e[MaxN];

struct Segtree{
    int mn[MaxN*4];
    void modify(int p,int x,int l,int r,int ll,int rr) {
        if (ll<=l && r<=rr) {
            mn[p]=min(mn[p],x);
            return;
        }
        int mid=(l+r)/2;
        if (ll<=mid) modify(p*2,x,l,mid,ll,rr);
        if (rr>mid) modify(p*2+1,x,mid+1,r,ll,rr);
    }
    void modify(int l,int r,int x) {modify(1,x,0,n,l,r);}
    int query(int p,int l,int r,int ll,int rr) {
        int ret=mn[p];
        if (ll<=l && r<=rr) return ret;
        int mid=(l+r)/2;
        if (ll<=mid) ret=min(ret,query(p*2,l,mid,ll,rr));
        if (rr>mid) ret=min(ret,query(p*2+1,mid+1,r,ll,rr));
        return ret;
    }
    int query(int l,int r) {return query(1,0,n,l,r);}
    int query(int x) {return query(1,0,n,x,x);}
    void clear() {memset(mn,0x7f,sizeof mn);}
}sg;

int dp[MaxN];

int main() {
    scanf("%d",&n);
    for (int i=1;i<=n;++i) scanf("%d",b+i),pre[i]=pre[i-1]+1-b[i];
    scanf("%d",&q);
    for (int i=1;i<=q;++i) {
        int l,r;
        scanf("%d%d",&l,&r);
        e[r].push_back(l);
    }
    sg.clear();
    for (int i=1;i<=n;++i) {
        sg.modify(i-1,i-1,dp[i-1]-pre[i-1]);
        for (int j:e[i]) sg.modify(j,i,sg.query(j-1));
        dp[i]=min(dp[i-1]+b[i],sg.query(i)+pre[i]);
    }
    printf("%d\n",dp[n]);
    return 0;
}

Measured memory_bytes: 15232
from string import ascii_lowercase

code = input()
hint = input()

def is_match(code, s):
  """
  >>> is_match('abc', 'abc')
  True
  >>> is_match('a?c', 'axc')
  True
  >>> is_match('???', 'xyz')
  True
  >>> is_match('abc', 'abd')
  False
  >>> is_match('abc', 'abcd')
  False
  >>> is_match('?p?', 'abc')
  False
  >>> is_match('', 'abc')
  False
  """
  if len(code) != len(s):
    return False
  for a, b in zip(code, s):
    if not (a == b or a == '?'):
      return False    
  return True


def guess(code, hint):
  """
  >>> guess('?tc????', 'coder')
  'atcoder'
  >>> guess('?p??d??', 'abc')
  'UNRESTORABLE'
  >>> guess('?????er', 'coder')
  'aacoder'
  >>> guess('a', 'b')
  'UNRESTORABLE'
  >>> guess('?', 'b')
  'b'
  >>> guess('abc', 'abcabc')
  'UNRESTORABLE'
  >>> guess('?????coder', 'coder')
  'aaaaacoder'
  >>> guess('?????coder?????', 'coder')
  'aaaaacoderaaaaa'
  """
  reversed_code = code[::-1] 
  reversed_hint = hint[::-1] 

  answers = []

  for i in range(len(code)):
    if is_match(reversed_code[i:i + len(hint)], reversed_hint):
      merged = reversed_code[:i] + reversed_hint + reversed_code[i + len(hint):]
      answers.append(merged[::-1].replace('?', 'a'))

  if len(answers) < 1:
    return 'UNRESTORABLE'

  answers.sort()

  return answers[0]

print(guess(code, hint))

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

using namespace std;

const int N = 1e5 + 3;

int n, m;
int used[N];
vector <int> g[N];

void dfs(int v) {
    used[v] = 1;
    for (int to : g[v]) {
        if (used[to]) continue;
        dfs(to);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 0, u, v; i < m; i++) {
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int comp_size = 0;
    for (int i = 1; i <= n; i++) {
        if (!used[i]) {
            dfs(i);
            comp_size++;
        }
    }
    cout << comp_size - 1 << endl;
}

Measured memory_bytes: 9980
s = str(input())
l = len(s)
x,y = map(int,input().split())
Fs = []
count = 0
for i in range(l):
    if s[i] == "T":
        Fs.append(count)
        count = 0
    else:
        count+=1
if s[-1] == "F":
    Fs.append(count)
xFs = [Fs[j] for j in range(len(Fs)) if j%2 == 0 and j!=0]
yFs = [Fs[k] for k in range(len(Fs)) if k%2 == 1]
x-=Fs[0]

def part_sum(a,A):
    n = len(a)
    dp = [[0 for i in range(A+1)] for j in range(n+1)]
    dp[0][0]=1
    
    for i in range(n):
        for j in range(A+1):
            if a[i]<=j:
                dp[i+1][j]=dp[i][j-a[i]] or dp[i][j]
            else:
                dp[i+1][j]=dp[i][j]
    return dp[n][A]


if sum(xFs) < abs(x) or sum(yFs) < abs(y):
    print("No")
else:
    sax = (sum(xFs)-abs(x))
    say = (sum(yFs)-abs(y))
    if sax%2 == 0 and say%2 == 0:
        sax = int(sax/2)
        say = int(say/2)
        if part_sum(xFs,sax) == 1 and part_sum(yFs,say) == 1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 18932
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  if((s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) ||
     (s[0] == s[2] && s[1] == s[3] && s[2] != s[3]) ||
     (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

vector<LL> h;
LL N;
LL A,B;

bool calc(LL a){    // a回爆破するときにすべての魔物を消し去れるかの判定 1クエリO(N)
    LL sum = 0;
    rep(i,N){
        LL t = h[i] - B*a;
        LL b = A - B;
        if(t > 0){
            sum += (t + b - 1)/b;       // A-Bで割った数の切り上げ
        }
    }
    return sum <= a;
}

int main(){
    cin >> N;
    cin >> A >> B;
    h.resize(N);
    rep(i,N)cin >> h[i];

    // 二分探索
    LL lb = 0;
    LL ub = 1000000001;
    while(ub - lb > 1){     // calc　を用いた二分探索で O(NlogN)程度
        LL mid = (lb + ub)/2;
        if(calc(mid))ub = mid;
        else lb = mid;
    }

    cout << ub << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n - 1];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
			sum += b[i];
		}
		for (int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
		}
		for (int i = 0; i < n - 1; i++) {
			if (a[i + 1] - a[i] == 1) {
				sum += c[a[i] - 1];
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n ;
    cin >> n ;
    int a = 0, b = 0 ;
    int c[n] ;
    for(int i = 0 ; i < n ; i++ ){
        cin >> c[i] ;
    }

    sort(c , c+ n) ;
    bool cha = true;
    for(int i = 0 ; i < n ; i++ ){
        if(cha == true){
            a += c[n - i - 1 ] ;
            cha = false ;
        }else{
            b += c[n - i - 1] ;
            cha = true ;
        }
    }

    cout << abs(a - b) << endl;

    return 0;
}

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

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

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

  cout << ans << endl;
  return 0;
}


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

int main() {
  ll N;
  cin >> N;
  cout << (N * (N - 1)) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
d, g = map(int, input().split())
pc = [tuple(map(int, input().split())) for _ in range(d)]

ans = 10 ** 18
import itertools
for i in itertools.product([0, 1], repeat=d):
    point = 0
    num = 0
    for j in range(d):
        if i[j] == 1:
            num += pc[j][0]
            point += pc[j][1] + 100 * (j+1) * pc[j][0]
    #print('-b-', i, g, point, num)
    for j in reversed(range(d)):
        if g <= point:
            continue
        if i[j] == 0:
            c = (g - point) // (100 * (j+1))
            if c < pc[j][0]:
                num += c
                point += 100 * (j+1) * c
            else:
                num += pc[j][0] - 1
                point += 100 * (j+1) * (pc[j][0] - 1)
        #print(i,j, g, point, num)
    #print('---', ans, num, point)
    if g <= point:
        ans = min(ans, num)
print(ans)





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

#define debug(a) cerr << #a << " = " << (a) << endl;
#define fst first
#define snd second
#define sz(x) (int)(x).size()
#define all(X) begin(X), end(X)

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

template<typename T, typename U> ostream& operator<<(ostream& o, const pair<T, U>& x) { 
  o << "(" << x.fst << ", " << x.snd << ")"; return o;
}

template<typename T> ostream& operator<<(ostream& o, const vector<T>& x) {
  o << "["; int b = 0; for (auto& a : x) o << (b++ ? ", " : "") << a; o << "]"; return o;
}

template<typename T> ostream& operator<<(ostream& o, const set<T>& x) {
  o << "{"; int b = 0; for (auto& a : x) o << (b++ ? ", " : "") << a; o << "}"; return o;
}

template<typename T, typename U> ostream& operator<<(ostream& o, const map<T, U>& x) {
  o << "{"; int b = 0; for (auto& a : x) o << (b++ ? ", " : "") << a; o << "}"; return o;
}

int n, w;
ll V[104], W[104];
ll dp[104][100004];

//f(i,j) gives max value of items from i to n when we have wght remaining in our knapsack
ll f(int i, int wght) {
  if(i == n || wght == 0) return 0;
  
  ll& x = dp[i][wght];
  if(x != -1) return x;
  
  x = f(i+1, wght);
  if(wght - W[i] >= 0) x = max(x, V[i] + f(i+1, wght - W[i]));

  return x;
}

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

  cin >> n >> w;
  for(int i = 0; i < n; ++i) cin >> W[i] >> V[i];

  for(int i = 0; i <= n; ++i) for(int j = 0; j <= w; ++j) dp[i][j] = -1;

  cout << f(0, w) << endl;
}



Measured memory_bytes: 80128
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b) {
    return *(int*)b - *(int*)a ;
}

int main(int argc, char* argv) {
        int n;
        int res[2] = {0, 0};
        scanf("%d", &n);

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

        for (int i = 0; i < n; i++) {
                res[i%2] += a[i];
        }

        printf("%d\n", res[0] - res[1]);

        return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define N 8
#define NOT_FREE 1
#define FREE 0

void printBoard();
void putQueen(int);

int row[N],col[N],dpos[2*N-1],dneg[2*N-1],x[N][N];

int main(){
  int i,j,n,r,c;

  for(i=0;i<N;i++) row[i]=col[i]=FREE;

  for(i=0;i<2*N-1;i++) dpos[i]=dneg[i]=FREE;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      x[i][j]=0;
    }
  }

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    x[r][c]=1;
  }

  putQueen(0);
  
  return 0;
}

void printBoard(){
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(x[i][j]==1){
        if(row[i]!=j) return;
      }
    }
  }

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void putQueen(int i){
  int j;

  if(i==N){
    printBoard();
    return;
  }

  for(j=0;j<N;j++){
    if(col[j]==NOT_FREE||dpos[i+j]==NOT_FREE||dneg[i-j+N-1]==NOT_FREE) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
  
    putQueen(i+1);
  
    col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }

}


Measured memory_bytes: 2112
#include <iostream>

using namespace std;

int main(){
  int A,B,X; cin>>A>>B>>X;
  bool ans=true;
  if(A>X){ans=false;}
  else if((A+B)<X){ans=false;}
  
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl; 

  return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, K) = Slice2<long>();
            if (K == 0)
            {
                WriteLine(N * N);
                return;
            }
            var ans = 0L;
            for (var b = K + 1; b <= N; ++b)
            {
                var mg = (N - b + 1) / b;
                ans += (mg + 1) * (b - K);
                ans += Max(0, N - (mg + 1) * b - K + 1);
            }
            WriteLine(ans);
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27568
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b && b < c)
			System.out.println("Yes");
		else 
			System.out.println("No");
	}
}



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

using ll = long long;
const int MOD = 2019;

int main(){
    ll L, R;
    std::cin >> L >> R;

    int L_rest = L % MOD;
    int R_rest = R % MOD;

    if(R - L >= MOD || R_rest <= L_rest){
        // LとRの間に余り0が存在
        std::cout << 0 << std::endl;
    }else{
        int minVal = MOD;
        for(int i = L_rest; i <= R_rest; i++){
            for(int j = i + 1; j <= R_rest; j++){
                minVal = std::min(minVal, (i * j) % MOD);
            }
        }
        std::cout << minVal << std::endl;
    }
    
    return 0;
}


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

using namespace std;

bool isCross(int l,int r){
	if(l==1 || l==4 || l==7)	return false;
	if(l==2 || l==8)	return (r==1 || r==4 || r==7);
	return !(r==3 || r==6 || r==9);
}

int main(){
	for(string s;cin>>s,s!="#";){
		int len=s.length();
		for(int i=0;i<len;i++)	s[i]-='0';

		int lcnt=0;
		bool lflg=false;
		for(int i=1;i<len;i++){
			if(lflg){
				if(isCross(s[i],s[i-1]))	lcnt++;
				else	lflg=!lflg;
			}
			else{
				if(isCross(s[i-1],s[i]))	lcnt++;
				else	lflg=!lflg;
			}
		}

		int rcnt=0;
		bool rflg=false;
		for(int i=1;i<len;i++){
			if(rflg){
				if(isCross(s[i-1],s[i]))	rcnt++;
				else	rflg=!rflg;
			}
			else{
				if(isCross(s[i],s[i-1]))	rcnt++;
				else	rflg=!rflg;
			}
		}

		cout<<min(lcnt,rcnt)<<endl;
	}

	return 0;
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
#define Rep(i,j,n) for(int i=j; i<n; i++)
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; cin >> n;
    string ans;
    if(n<=999) ans="ABC";
    else ans="ABD";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main() {
	int X;

	cin >> X;
	int ans = 1;
	for (int i = 2; i*i <= X; i++) {
		int tmp = i * i;
		while (tmp <= X) {
			if (ans < tmp)
				ans = tmp;
			tmp *= i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    int len = n.length()-1;
    String ans;
    if(n.charAt(len)=='2'||n.charAt(len)=='4'||n.charAt(len)=='5'||n.charAt(len)=='7'||n.charAt(len)=='9'){
      ans = "hon";
    }else if(n.charAt(len)=='0'||n.charAt(len)=='1'||n.charAt(len)=='6'||n.charAt(len)=='8'){
      ans = "pon";
    }else{
      ans = "bon";
    }
    
    System.out.println(ans);
    
  }
}


Measured memory_bytes: 35620
A,B,C = map(int,input().split())
K = int(input())
count = 0

while True:
    if A<B:
        break
    else:
        B = B*2
        count += 1

while True:
    if B<C:
        break
    else:
        C = C*2
        count += 1

if count<=K:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9172
N = int(input())
L = list(map(int, input().split()))

S_1 = 0
S_2 = 0
T = 0
ans = []

for i in range(N):
    S_1= sum(L[:T + 1])
    S_2 = sum(L[T + 1:])
    ans.append(abs(S_1 - S_2))
    T += 1
print(min(ans))

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

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

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

	rep(i, s. size()-1) {
		if (s[i] == s[i + 1])n--;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <set>

using namespace std;

int v[200005];
int pos[200005];
int main() {
  int N;
  while (cin >> N) {
    for (int i = 0; i < N; i++) {
      cin >> v[i];
      pos[v[i]] = i;
    }
    set<int> s;
    s.insert(-1);
    s.insert(N);
    long long ans = 0;
    for (int i = 0; i < N; i++) {
      int p = pos[i+1];
      s.insert(p);
      set<int>::iterator it = s.find(p);
      int l = *(--it);
      it++, it++;
      int r = *it;
      // cout << p << ' ' << l << ' ' << r << endl;
      ans += (long long)(i+1) * (p - (l+1) + 1) * ((r-1) - p + 1);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b="CF";
	cin>>a;
	int c=0;
	for(int x=0;x<a.size();x++)
	{
		if(b[c]==a[x])
		{
			++c;
		}
		if(c==2)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
def getlist():
	return list(map(int, input().split()))

#受け取り
N, T = getlist()
A = getlist()
m = A[0]
plus = -float("inf")
cost = 1
for i in range(1, N):
	if A[i] - m == plus:
		cost += 1
	elif A[i] - m > plus:
		plus = A[i] - m
		cost = 1
	else:
		pass
	m = min(m, A[i])

print(cost)

Measured memory_bytes: 15020
#include <stdio.h>

int main()
{
	int n,i;
	long long int a[10000],min=1000000,max=-1000000,sum=0;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		
		scanf("%lld",&a[i]);
		
		if(a[i] >= max){
			
			max = a[i];
			
		}
		
		if(a[i] <= min){
			
			min = a[i];
			
		}
		
		sum+=a[i];
		
	}
	
	
	printf("%lld %lld %lld\n",min,max,sum);
	
	
  return 0;
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

string solve(int x, const string a) {
    string ans = "";
    REP(i, x) ans += a;
    return ans;
}

string solve(int x, int y, const string a, const string b) {
    if (x == 0) return solve(y, b);
    if (y == 0) return solve(x, a);
    if (x <= y) return solve(x, y - x, a + b, b);
    return solve(x - y, y, a, a + b);
}

string solve(int x, int y, int z, const string a, const string b, const string c) {
    if(x == 0) return solve(y, z, b, c);
    if(y == 0) return solve(x, z, a, c);
    if(z == 0) return solve(x, y, a, b);
    if(x <= z) return solve(x, y, z - x, a + c, b, c);
    if(x <= z + y) return solve(x - z, z, y - (x - z), a + b, a + c, b);
    return solve(x - y - z, y, z, a, a + b, a + c);
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    int x, y, z;
    cin >> x >> y >> z;
    cout << solve(x, y, z, "a", "b", "c") << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

mod = 10**9+7
sa = sum(A)%mod

ans = 0
for i in range(N):
    ans += (sa-A[i]) * A[i]
    ans %= mod

if ans%2== 1:
    ans += mod

print((ans//2)%mod)

Measured memory_bytes: 94100
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 1005
int A[N][N],Mk[N];
#define reg register
#define Max(a,b) a>b? a:b
#define Min(a,b) a>b? b:a
inline int read() {
	reg int c = getchar(),num = 0,sign = 1;
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') sign = -1;
	else num = c - '0';
	c = getchar();
	while(c <= '9' && c >= '0') num = (num<<3) + (num<<1) + c - '0',c = getchar();
	return sign * num;
}
int B[N],tmp[N];
int main() {
	int n;
	cin >> n;
	for(reg int i=1; i<=n; i++) {
		for(reg int j=1; j<n; j++) {
			A[i][j] = read();
		}
	}
	for(reg int i=1; i<=n; i++) A[i][0] = 1;
	int cot = n;
	for(int i=1; i<=n; i++) B[i] = i;
	int Ans = 0,cnt = n;
	while(cnt) {
		int flg = 0,z = cot;
		Ans ++,cot = 0;
		for(int i=1; i<=z; i++) tmp[i] = B[i];
		for(reg int i=1; i<=z; i++) {
			if(A[tmp[i]][0] == n) continue;
			if(Mk[tmp[i]] == Ans) continue;
			int e = A[tmp[i]][A[tmp[i]][0]];
			if(Mk[e] == Ans) continue;
			if(A[e][A[e][0]] == tmp[i]) {
				A[tmp[i]][0] ++,Mk[e] = Mk[tmp[i]] = Ans;
				A[e][0] ++,flg = 1;
				if(A[tmp[i]][0] == n) cnt --;
				else B[++cot] = tmp[i];
				if(A[e][0] == n) cnt --;
				else B[++cot] = e;
			}
			if(cnt == 0) break;
		}
		if(cnt == 0) break;
		if(!flg) {
			puts("-1");
			return 0;
		}
	}
	cout<<Ans;

	return 0;
}

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

bool compare(string s1,string s2){
  if(s1.size()>s2.size())return true;
  if(s1.size()<s2.size())return false;
  for(int i=0;i<s1.size();i++){
    if(s1[i]>s2[i])return true;
    if(s1[i]<s2[i])return false;
  }
  return false;
}

int main()
{
  int W,H;
  char C[70][70];
  string max,dp[70][70];
  while(cin>>W>>H,W|H){
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
      cin>>C[i][j];
      dp[i][j]="";
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(isalpha(C[i][j]))continue;
	string above,left;
	above=left=C[i][j];
	if(i>0 && dp[i-1][j]!="0")above=dp[i-1][j]+C[i][j];
	if(j>0 && dp[i][j-1]!="0")left=dp[i][j-1]+C[i][j];
	if( compare(above,left) ){
	  dp[i][j]=above;
	}else{
	  dp[i][j]=left;
	}
      }
    }
    max="";
    for(int i=0;i<H;i++)for(int j=0;j<W;j++)if(compare(dp[i][j],max))max=dp[i][j];
    cout<<max<<endl;
  }
}

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

int main() {
  int64_t H;
  cin >> H;
  for (int i=0; i<100000000000; i++){
    if(pow(2,i)-1>=H){
      cout << (int64_t)pow(2,i)-1 << endl;
      return 0;
    }
  }
}

// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));
 
  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
   // }
  //}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
typedef long long ll;
using namespace std;

int main(void) {
    ll N;cin>>N;
    N--;
    vector<int> num;
    while (true) {
        int tmp = N % 26;
        num.push_back(tmp);
        N /= 26;
        N--;
        if (N < 0) break;
    }
    for (int i = num.size() - 1; i >= 0; i--) {
        char r = 'a' + num[i];
        printf("%c", r);
    }
    cout << endl;
    return 0;
}

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

using namespace std;

const int maxn = 10000010;
const int mod = 998244353;

int N, A, B, ans;
int fac[maxn << 1], ifac[maxn << 1], inv[maxn << 1];

int binom(int x, int y) {
	if (x < 0 || y < 0) return 0;
	if (y > x) return 0;
	return 1LL * fac[x] * ifac[y] % mod * ifac[x-y] % mod;
}

int cal(int X, int Y) {
	return 1LL * (X - Y + 1) * inv[X + 1] % mod * binom(X+Y, X) % mod;
}

int main() {
	scanf("%d%d%d", &N, &A, &B);
	if (!B) {
		puts("1");
		return 0;
	}
	fac[0] = ifac[0] = 1, inv[1] = 1;
	for (int i = 2; i <= N * 2; i++) {
		inv[i] = mod - 1LL * inv[mod % i] * (mod / i) % mod;
	}
	for (int i = 1; i <= N * 2; i++) {
		fac[i] = 1LL * fac[i-1] * i % mod;
		ifac[i] = 1LL * ifac[i-1] * inv[i] % mod;
	}
	if (A != B && A + B == N) {
		ans = cal(B-1, A);
	}
	for (int K = B; K < N; K++) {
		int v1 = 0, v2 = 0;
		v1 = cal(B-1, K-B);
		v2 = binom(N-K-1+B+A-K+1-1, B+A-K+1-1);
		ans = (ans + 1LL * v1 * v2 % mod) % mod;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 234624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int main()
{
     ///"In the name of Allah,most gracious and most merciful"///

        ll i,j,x,y,z,count=0,sum=0,n;
        string s;
        cin>>s;
          vector<ll>v;
        for(i=0;i<s.size();i++)
        {
            count=0;
            if(s[i]== 'R')
            {
                count=1;
                for(j=i+1;j<s.size();j++)
                {
                    if(s[j]=='R')
                    {
                        count++;
                        i++;
                    }
                    else
                    {

                        break;
                    }

                }
            }
             v.pb(count);
        }
        sort(v.begin(),v.end());
        cout<<v[v.size()-1]<<endl;


    return 0;
}



Measured memory_bytes: 3624
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N, M, R;
    cin >> N >> M >> R;
    vector<ll> ris;
    for (ll i = 0; i < R; i++) {
        ll ri;
        cin >> ri;
        ri--;
        ris.push_back(ri);
    }
    auto distances = make_vec_nd(numeric_limits<ll>::max() / 2, N, N);
    for (ll m = 0; m < M; m++) {
        ll A, B, C;
        cin >> A >> B >> C;
        A--;
        B--;
        distances[A][B] = C;
        distances[B][A] = C;
    }
    for (ll k = 0; k < N; k++) {
        for (ll i = 0; i < N; i++) {
            for (ll j = 0; j < N; j++) {
                distances[i][j] = min(distances[i][j], distances[i][k] + distances[k][j]);
            }
        }
    }
    vector<ll> perm;
    for (ll i = 0; i < R; i++) {
        perm.push_back(i);
    }
    ll ans = numeric_limits<ll>::max();
    do {
        ll dist = 0;
        for (ll i = 0; i < perm.size()-1; i++) {
            dist += distances[ris[perm[i]]][ris[perm[i+1]]];
        }
        ans = min(ans, dist);
    } while (next_permutation(perm.begin(), perm.end()));
    cout << ans << endl;
}



Measured memory_bytes: 760
#include <iostream>
#include <string>
#include <numeric>

using namespace std;

int main()
{
	long int N, i, sum = 0;
	cin >> N;
	for (i = 1;i <= N;++i)
	{
		if (i % 15 == 0)
			continue;
		else if (i % 3 == 0)
			continue;
		else if (i % 5 == 0)
			continue;
		else
		{
			sum += i;
		}
	}
	cout << sum;
	return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int A, B, C, D;
int main() {
    std::cin >> A >> B >> C >> D;
    if(A+B == C+D) {
        std::cout << "Balanced" << std::endl;
    } else if(A+B > C+D) {
        std::cout << "Left" << std::endl;
    } else{
        std::cout << "Right" << std::endl;
    }
}

Measured memory_bytes: 764
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val A = Array.fill(sc.nextInt)(sc.next).map(x => x.head).filter(x => "MARCH".contains(x)).groupBy(a => a).mapValues(_.foldLeft(0)((a, b) => a + 1)).toArray
    var ans = 0L
    for (i <- Range(0, A.size)) (
      for (j <- Range(i + 1, A.size)) (
        for (k <- Range(j + 1, A.size)) (
          ans += A(i)._2.toLong * A(j)._2.toLong * A(k)._2.toLong
          )
        )
      )
    println(ans)
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

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

int main(){
  int N,M,X;cin>>N>>M>>X;
 // vector<int> A(M);
  int left=0;
  int right=0;
  for(int i=0;i<M;i++){
 //   cin>>A.at(i);
    int A;cin>>A;
    if(A<X) left++;
    else right++;
  }
  cout<<min(left,right)<<endl;
}


Measured memory_bytes: 3624
N = int(input())
data = list(map(int, input().split()))
min = 100000000000
ans = 0

for i in range(1, len(data)):
    # 最小値 => 差

    # print(i, "周目")
    # print("left:", sum(data[:i-len(data)]))
    # print("right:", sum(data[i:]))

    if abs( sum(data[:i-len(data)]) - sum(data[i:]) ) < min:
        min = abs( sum(data[:i-len(data)]) - sum(data[i:]) )

print(min)


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

int descending_compare(const void *a, const void *b){
    if (*(long long*)a > *(long long*)b){
        return -1;
    }else if (*(long long*)a == *(long long*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]);
        }
    }
}*/

int main(void){
    int a;
    int cnt5 = 0;
    int cnt7 = 0;
    for (int i = 0; i < 3; i++){
        scanf("%d", &a);
        if (a == 5){
            cnt5++;
        }else if(a == 7){
            cnt7++;
        }
    }
    if (cnt5 == 2 && cnt7 == 1){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final char[] s = sc.next().toCharArray();
			
			LinkedList<Character> list = new LinkedList<Character>();
			for(final char c : s) {
				list.addLast(c);
			}
			
			final int Q = sc.nextInt();
			boolean reverse = false;
			for(int q = 0; q < Q; q++) {
				final int ops = sc.nextInt();
				
				if(ops == 1) {
					reverse = !reverse;
				}else {
					final int pos = Math.abs((reverse ? 1 : 0) - (sc.nextInt() - 1));
					final char[] chs = sc.next().toCharArray();
					
					if(pos == 0) {
						list.addFirst(chs[0]);
					}else {
						list.addLast(chs[0]);
					}
				}
			}
			
			if(reverse) {
				for(ListIterator<Character> iter = list.listIterator(list.size()); iter.hasPrevious(); ) {
					System.out.print(iter.previous());
				}
			}else {
				for(ListIterator<Character> iter = list.listIterator(0); iter.hasNext(); ) {
					System.out.print(iter.next());
				}
			}
			System.out.println();
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 78908
#include <cstdio>
#include <cstring>

using int64 = long long;

int64 choose(int n, int k) {
  if (n < k) return 0;
  if (k == 0) return 1;
  if (k == 1) return n * 9;
  if (k == 2) return n * (n - 1) / 2 * 9 * 9;
  return n * (n - 1) * (n - 2) / 6 * 9 * 9 * 9;
}

const int N = 100 + 10;

char s[N];
int n, k;

int main() {
  scanf("%s%d", s, &k);
  n = strlen(s);
  int64 ret = 0, cnt = 0;
  for (int i = 0; i < n; ++i) {
    int o = s[i] - '0';
    for (int d = 0; d < o; ++d) {
      int t_cnt = cnt + (d != 0);
      if (t_cnt <= k) {
        ret += choose(n - i - 1, k - t_cnt);
      }
    }
    cnt += (o != 0);
  }
  ret += cnt == k;
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int main() {
	LL n, a, b;
	cin >> n >> a >> b;
	LL t = (n / (a + b));
	LL an = t * a;
	LL resi = (n - t * (a + b));
	if (resi >= a) {
		an += a;
	}
	else {
		an += resi;
	}
	cout << an << endl;
	return 0;
}

Measured memory_bytes: 256