akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <iostream>
using namespace std;

int main(void)
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int T_HP = A;
    int T_AT = B;
    int A_HP = C;
    int A_AT = D;
    int turn = 0;

    while(T_HP > 0 && A_HP > 0){
        if(turn == 0){
            A_HP = A_HP - T_AT;
            turn = 1;
        }
        else{
            T_HP = T_HP - A_AT;
            turn = 0; 
        }

        if(T_HP <= 0){
            cout << "No" << endl;  
        }

        if(A_HP <= 0){
            cout << "Yes" << endl;  
        }

    }

    return 0;

}

Measured memory_bytes: 3632
object Main extends App {
  val read = scala.io.StdIn.readLine()
  val v1 = (read(0).toString + read(1).toString).toInt
  val v2 = (read(2).toString + read(3).toString).toInt

  def isMonth(i: Int):Boolean = {
    i < 13 && i > 0
  }

  if (isMonth(v1) && isMonth(v2)) {
    print("AMBIGUOUS")
  } else if (isMonth(v1)) {
    print("MMYY")
  } else if (isMonth(v2)) {
    print("YYMM")
  } else {
    print("NA")
  }
}

Measured memory_bytes: 25408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;


int main(){
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]) cnt+=1;
    }
    cout<<cnt<<endl;
    return 0;
}

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

#define N 2009
int n,x,y,d[N][N],cnt[N];

int main()
{
	cin >> n >> x >> y;
	for(int i = 1;i<=n-1;i++)
	{
		for(int j = i+1;j<=n;j++)
		{
			if(i<=x)
			{
				if(j>x)d[i][j] = x-i+min(j-x,abs(j-y)+1);
				else d[i][j] = j-i;
			}
			else if(j>=y)
			{
				if(i<y)d[i][j] = j-y+min(abs(i-y),abs(i-x)+1);
				else d[i][j] = j-i;
			}
			else d[i][j] = min(j-i,i-x+y-j+1);
			cnt[d[i][j]]++;
		}
	}
	for(int i = 1;i<n;i++)cout << cnt[i] << endl;
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#N = int(input())
#J,K = map(int(input().split()))
#A = list(map(int(input().split())))
#A = [list(map(int(input().split()))) for _ in range(N)]
#for i in range():
S = input()
T = input()

if S == T[0:-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9096
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int n;
    int i;

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

    sort(v.begin(), v.end());
    if(sum % 10 != 0)
    	cout << sum << endl;
    else
    {
	    for(i = 0; i < n; i ++)
	    {
	    	if((sum - v[i]) % 10 != 0)
	    	{
	    		cout << sum - v[i];
	    		break;
	    	}
	    }

	    if(i == n)
	    	cout << "0" << endl;
    } 
}


Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, op, b) = get!(i32, String, i32);
    if op == "+" {
        println!("{}", a + b);
    } else {
        println!("{}", a - b);
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>>
#include<functional>
using namespace std;
int main(){
	int a[5];
	for(int i=0;i<5;i++)cin>>a[i];
	sort(a,a+5,greater<int>());
	cout<<a[0];
	for(int i=1;i<5;i++)cout<<' '<<a[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1176
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int m = sc.nextInt();

    Map<Integer, Set<Integer>> checkingSwitches = new HashMap<>();
    int[] checkingSwitchCondition = new int[m + 1];

    for (int i = 0; i < m; i++) {
      int switchNum = sc.nextInt();
      Set<Integer> checkingSwitch = new HashSet<>();
      for (int j = 0; j < switchNum; j++) {
        checkingSwitch.add(sc.nextInt());
      }
      checkingSwitches.put(i + 1, checkingSwitch);
    }

    for (int i = 0; i < m; i++) {
      checkingSwitchCondition[i + 1] = sc.nextInt();
    }

    boolean[] on = new boolean[n + 1];
    on[1] = true;
    int result = 0;
    result += check(1, n, on, checkingSwitches, checkingSwitchCondition);
    on[1] = false;
    result += check(1, n, on, checkingSwitches, checkingSwitchCondition);

    os.println(result);
  }

  private static int check(int switchIndex, int totalSwitchNum, boolean[] on,
      Map<Integer, Set<Integer>> checkingSwitches, int[] checkingSwitchCondition) {
    if (switchIndex == totalSwitchNum) {
      for (int lampIndex : checkingSwitches.keySet()) {
        int onCount = 0;
        for (int checkingSwitchIndex : checkingSwitches.get(lampIndex)) {
          if (on[checkingSwitchIndex]) {
            onCount++;
          }
        }
        if (onCount % 2 != checkingSwitchCondition[lampIndex]) {
          return 0;
        }
      }
      return 1;
    }
    int total = 0;
    on[switchIndex + 1] = true;
    total += check(switchIndex + 1, totalSwitchNum, on, checkingSwitches, checkingSwitchCondition);
    on[switchIndex + 1] = false;
    total += check(switchIndex + 1, totalSwitchNum, on, checkingSwitches, checkingSwitchCondition);
    return total;
  }
}

Measured memory_bytes: 22996
//02
#include<iostream>
#include<queue>
#include<algorithm>
#include<string>

using namespace std;

struct S{
  int x,y,t,p;
  char f[6];
  int hash(){
    int h=x*30*6+y*6+p;
    string s=f;
    for(int i=0;i<6;i++){
      int c=s.find(*min_element(s.begin(),s.end()));
      h=h*s.size()+c;
      s.erase(c,1);
    }
    return h;
  }
};

int main(){
  for(int w,d;cin>>w>>d,w|d;){
    char g[30][30];
    queue<S> que;
    for(int i=0;i<d;i++){
      for(int j=0;j<w;j++){
	cin>>g[i][j];
	if(g[i][j]=='#'){
	  g[i][j]='w';
	  S is={j,i,0,0,{'r','m','b','g','y','c'}};
	  que.push(is);
	}
      }
    }
    char pm[7];
    cin>>pm;
    static bool p[3888000];
    fill(p,p+3888000,false);
    while(!que.empty()){
      S c=que.front();
      if(c.p==6)break;
      que.pop();
      if(p[c.hash()]++)continue;
      for(int i=0;i<4;i++){
	S n=c;
	n.t++;
	int dx[]={0,-1,0,1};
	int dy[]={-1,0,1,0};
	n.x+=dx[i];
	n.y+=dy[i];
	if(n.x<0||w<=n.x||n.y<0||d<=n.y)continue;
	int fd[][4]={{0,1,5,3},{0,2,5,4},{0,3,5,1},{0,4,5,2}};
	int *cf=fd[i];
	char t=n.f[cf[0]];
	n.f[cf[0]]=n.f[cf[1]];
	n.f[cf[1]]=n.f[cf[2]];
	n.f[cf[2]]=n.f[cf[3]];
	n.f[cf[3]]=t;
	if(g[n.y][n.x]=='w'){
	  que.push(n);
	}else if(g[n.y][n.x]!='k'&&g[n.y][n.x]==n.f[0]&&n.f[0]==pm[n.p]){
	  n.p++;
	  que.push(n);
	}
      }
    }
    if(!que.empty()){
      cout<<que.front().t<<endl;
    }else{
      cout<<"unreachable"<<endl;
    }
  }
  return 0;
}
	  

Measured memory_bytes: 5112
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	a := readInt()
	b := readInt()

	fmt.Println(solve(a, b))
}

func solve(a, b int) int {
	_, answer := max([]int{a + b, a - b, a * b})
	return answer
}

func max(nums []int) (index, max int) {
	max = math.MinInt64
	for i, n := range nums {
		if n > max {
			index = i
			max = n
		}
	}
	return
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


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

using namespace std;

const int N = 105;

int n, k, u, v, clok;
int d[N], f[N], mark[N];
vector<int> a[N];

void DFS(int p)
{
  mark[p] = 1;
  d[p] = clok;
  clok++;
  for(int i = 0; i < a[p].size(); i++)
    if(!mark[a[p][i]]){
      DFS(a[p][i]);
    }
  f[p] = clok;
  clok++;
}

int main()
{
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> u >> k;
    for(int j = 1; j <= k; j++) {
      cin >> v;
      a[u].push_back(v);
    }
    sort(a[u].begin(), a[u].end());
  }
  clok = 1;
  for(int i = 1; i <= n; i++)
    if(!mark[i]) DFS(i);
  for(int i = 1; i <= n; i++){
    cout << i << " " << d[i] << " " << f[i] << endl;
  }
  return 0;
}



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

int main(){
  int n, l;
  cin >> n >> l;
  int s = 0, q = INF;
  int a[n];
  rep(i,n) {
    s += l + i;
    if(abs(l+i) < abs(q)) q = l+i;
  }
  cout << s - q << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n1 = 0, n2 = 0, n3 = 0;
	int temp, temp2;
	int i;
	for(i = 0; i < 10; ++i){
		scanf("%d", &temp);
		if(n1 < temp){
			temp2 = n1;
			n1 = temp;
			temp = temp2;
		}
		if(n2 < temp){
			temp2 = n2;
			n2 = temp;
			temp = temp2;
		}
		if(n3 < temp){
			temp2 = n3;
			n3 = temp;
			temp = temp2;
		}
	}
	printf("%d\n%d\n%d\n", n1, n2, n3);
	return 0;
}

Measured memory_bytes: 600
n, q = gets.chomp.split.map(&:to_i)
s = gets.chomp

table = []
0.upto(s.length - 2){|x| table[x + 1] = 1 if s[x, 2] == "AC"}

cum = 0
0.upto(s.length - 1){|pos|
    table[pos] = (table[pos].nil?) ? cum : cum + 1
    cum = table[pos]
}

q.times{
    l, r = gets.chomp.split.map(&:to_i)
    puts table[r - 1] - table[l - 1]
}

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

using namespace std;

int main() {
  int n, q;
  cin >> n >> q;
  vector<priority_queue<int> > que(n);
  while(q--) {
    int k, t;
    cin >> k >> t;
    if(k == 0) {
      int x;
      cin >> x;
      que[t].push(x);
    } else if(k == 1) {
      if(que[t].empty()) continue;
      cout << que[t].top() << endl;
    } else if(k == 2) {
      if(que[t].empty()) continue;
      que[t].pop();
    } else {
      assert(false);
    }
  }
  return 0;
}



Measured memory_bytes: 4100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();

		if ((double)d / t <= s) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();

	}

}

Measured memory_bytes: 35636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
 int x=n%100;
 int y=x%10;
  if(y==2||y==4||y==5||y==7||y==9){
    cout<<"hon"<<endl;}
  else if (y==0||y==1||y==6||y==8){
    cout<<"pon"<<endl;}
  else{cout<<"bon"<<endl;}
}

Measured memory_bytes: 3588
#https://atcoder.jp/contests/abc087/tasks/arc090_a

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

if n==1:
    print(a[0]+b[0])
else:
    l = [0 for _ in range(n-1)]
    for i in range(n-1):
        l[i] = a[i+1]-b[i]
    if max([sum(l[:j+1]) for j in range(n-1)]) > 0:
        print(a[0]+sum(b)+max([sum(l[:j+1]) for j in range(n-1)]))
    else:
        print(a[0]+sum(b))


Measured memory_bytes: 3064
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count = 0

for ac in range(A+1):
    for bc in range(B+1):
        for cc in range(C+1):
            if 500*ac+100*bc+50*cc == X:
                count += 1

print(count)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	for(;;){
		int h, w, i, j;

		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0)
			break;

		for(i = 0; i < h; i++){
			for(j = 0; j < w; j++)
				putchar('#');
			putchar('\n');
		}
		putchar('\n');
	}
}



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


"""
input:
11
7
8
9
10
11
12
13
14
15
16
17

output:
4
"""

import sys


def is_prime(x):
    if x == 2:
        return True
    elif x < 2 or not x % 2:
        return False

    return pow(2, x - 1, x) == 1


def solve(_c_list):
    cnt = 0
    for ele in _c_list:
        if is_prime(ele):
            cnt += 1
    return cnt


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    c_num = int(_input[0])
    c_list = list(map(int, _input[1:]))
    ans = solve(c_list)
    print(ans)

Measured memory_bytes: 8820
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::str::FromStr;

// stone-monument.rs --- Stone Monument
// author: Seong Yong-ju <sei40kr@gmail.com>

#[allow(unused_macros)]
macro_rules! get {
  ($t:ty) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.trim().parse::<$t>().unwrap()
    }
  };
  ($($t:ty),*) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      let mut iter = line.split_whitespace();
      (
        $(iter.next().unwrap().parse::<$t>().unwrap(),)*
      )
    }
  };
  ($t:ty; $n:expr) => {
    (0..$n).map(|_|
                get!($t)
    ).collect::<Vec<_>>()
  };
  ($($t:ty),*; $n:expr) => {
    (0..$n).map(|_|
                get!($($t),*)
    ).collect::<Vec<_>>()
  };
  ($t:ty ;;) => {
    {
      let mut line: String = String::new();
      stdin().read_line(&mut line).unwrap();
      line.split_whitespace()
        .map(|t| t.parse::<$t>().unwrap())
        .collect::<Vec<_>>()
    }
  };
  ($t:ty ;; $n:expr) => {
    (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
  };
}

#[allow(unused_macros)]
macro_rules! debug {
  ($($a:expr),*) => {
    println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
  }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("Failed to parse token")
}

#[allow(dead_code)]
fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer);
}

fn main() {
    let (a, b) = get!(u32, u32);
    let ans = (b - a) * (b - a + 1) / 2 - b;

    with_bufwriter(|mut out| writeln!(out, "{}", ans).unwrap());
}


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

int main(){
 	string s;
  	cin >> s;
  	
 	if(s == "A"){
      cout << "T" << endl;
    }
  if(s == "T"){
      cout << "A"<< endl;
    }
  if(s == "G"){
      cout <<"C" << endl;
    }
  if(s == "C"){
      cout <<"G" << endl;
    }
  
}

Measured memory_bytes: 256
from itertools import product

K, S = map(int, input().split(' '))
zero_to_k = tuple(range(K + 1))
max_k = min(K, S) + 1

print(len([0 for x, y in product(range(max_k), range(max_k)) if 0 <= S - (x + y) <= K]))


Measured memory_bytes: 40956
#include <iostream>
#include <functional>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    int d;
    vector<int> A(N);
    // vector<int> B(N);
    for (int i = 0; i < K; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
           // vector<int> A(d);
          int a;
          cin >> a;
          //A[a-1]++;
            a--;
            A.at(a)++;
        }
    }
    int ct = 0;
    for(int k=0; k<N; k++){
        if(A.at(k)==0){
            ct++;
        }
    }
    cout << ct << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string ans = "";
    for(int i = 0; i < 3; i++){
        string s;
        cin >> s;
        ans += s[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

enj = ['AC', 'WA', 'TLE', 'RE']
cnt = {res: 0 for res in enj}
for res in s:
    cnt[res] += 1
for res in enj:
    print('{} x {}'.format(res, cnt[res]))


Measured memory_bytes: 16084
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,m;
  cin >> n >> m;
  vi ans(n,INF);

  vector<pair<int,int>> p(n),c(m);

  rep(i,n) cin >> p[i].first >> p[i].second;
  rep(i,m) cin >> c[i].first >> c[i].second;

  rep(i,n)
  {
    unsigned long long l = ULLONG_MAX;
    int no = 0;
    rep(j,m)
    {
      unsigned long long x;
      x = abs(p[i].first - c[j].first) + abs(p[i].second - c[j].second);
      
      if(l > x)
      {
        ans[i] = j + 1;
        l = x;
      }
    }
  }

  rep(i,n) cout << ans[i] << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    if((a*b)&1) cout << "Odd" << endl;
    else cout << "Even" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    A = [list(readnums()) for _ in range(3)]
    c = [[False] * 3 for _ in range(3)]
    N = readint()
    for i in range(N):
        a = readint()
        pos = [(x, y) for y, row in enumerate(A) for x, elem in enumerate(row) if A[x][y] == a]
        if pos:
            x, y = pos[0]
        else:
            continue
        c[x][y] = True

    if all(c[0]) or all(c[1]) or all(c[2]) or all([c[0][0], c[1][0], c[2][0]]) or all([c[0][1], c[1][1], c[2][1]]) or all([c[0][2], c[1][2], c[2][2]]) or all([c[0][0], c[1][1], c[2][2]]) or all([c[2][0], c[1][1], c[0][2]]):
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    int a[3] = {0};
    int b[3];
    rep(j, 3) b[j] = c[0][j];
    rep(i, 3) a[i] = c[i][0] - b[0];
    // outa(a, 3); outa(b, 3);
    rep3(i, 1, 3) rep3(j, 1, 3) if (a[i] + b[j] != c[i][j]) { out("No"); return 0; }
    out("Yes");
}


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

v_list = []
for _ in range(N):
	v_list.append(tuple(map(int, input().strip().split())))

import math

v_list2 = []
for x, y in v_list:
	r = math.atan2(x, y)
	v_list2.append((r, x, y))

v_list2.sort()

max_dist = 0
for i in range(N):
	for w in range(1, N + 1):
		x = 0
		y = 0
		for j in range(w):
			r, dx, dy = v_list2[(i + j) % N]
			x += dx
			y += dy
		dist = x * x + y * y
		if dist > max_dist:
			max_dist = dist

print(math.sqrt(max_dist))


Measured memory_bytes: 3188
def main():
    N, K, S = map(int, input().split())
    l = [S] * K
    if S == 10 ** 9:
        l.extend([1] * (N - K))
    else:
        l.extend([S + 1] * (N - K))
    print(' '.join(str(i) for i in l))
main()


Measured memory_bytes: 12540
#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 K, X;
  cin >> K >> X;

  for (int i = 0; i < 2 * K - 1; i++) {
    cout << (X - K + 1 + i);
    if (i < 2 * K - 2) cout << SP;
  }
  cout << BR;

  return 0;
}

Measured memory_bytes: 256
N, S, K = gets.chomp.split.map(&:to_i)
ans = []

if K == 10**9
  S.times do
    ans << K
  end
  (N-S).times do
    ans << 10**9 - 1
  end
else
  S.times do
    ans << K
  end
  (N-S).times do
    ans << 10**9
  end
end

puts ans


Measured memory_bytes: 3708
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#include <algorithm>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};

int main() {
  ll n,k;
  cin >> n >> k;
  ll ans = 0;
  
  if(k%2 == 0 && n%k < k/2)
    ans = 2*pow(n/k, 3);
  else if(k%2 == 0 && n%k >= k/2)
    ans = pow(n/k, 3) + pow((n/k+1),3);
  else if(k%2 == 1)
    ans = pow(n/k, 3);
  
 cout << ans << endl;
}

Measured memory_bytes: 1024
s=list(input())
N=len(s)
a=s[0:(N-1)//2]
b=s[(N+3)//2 -1:N]

S=list(reversed(s))
A=list(reversed(a))
B=list(reversed(b))


if s==S and a==A and b==B:
    print("Yes")
    exit()

print("No")


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

int main() {
  int N,Z=0;
  cin>>N;
  vector<vector<pair<int,int>>> g(N);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    g.at(a).push_back(make_pair(b,i));
    g.at(b).push_back(make_pair(a,i));
  }
  
  queue<pair<int,int>> q;
  vector<int> p(N-1);
  q.push(make_pair(0,0));
  while(!(q.empty())){
    int a=q.front().first,b=q.front().second;
    q.pop();
    int t=1;
    for(pair<int,int> x:g.at(a)){
      if(p.at(x.second)==0){
        if(t==b){
          t++;
        }
        p.at(x.second)=t;
        q.push(make_pair(x.first,t));
        t++;
      }
    }
  }
  for(int i=0;i<N-1;i++){
    Z=max(Z,p.at(i));
  }
  cout<<Z<<endl;
  for(int i=0;i<N-1;i++){
    cout<<p.at(i)<<endl;
  }
}

Measured memory_bytes: 7040
import java.util.*;

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

    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int ans = Math.max(a + b, a - b);
    ans = Math.max(ans, a * b);
    
    System.out.println(ans);
    
  }
}


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

int main(){
	int price,count,x,n;
	int coin[] = {500,100,50,10,5,1};
	while(cin >> n && n){
		price = 1000 - n;
		count = 0;
		for(int i = 0;i<6;i++){
			x = price / coin[i];
			count += x;
			price -= coin[i] * x; 
		}
		cout << count << endl;
	}
	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (auto & _a : a)
    cin >> _a;
  auto next = a[0] - 1;
  a[0] = 0;
  int cnt = 1;
  for (; 1 != next; ++cnt)
  {
    if (0 == a[next])
    {
      cout << -1;
      return 0;
    }
    int now = next;
    next = a[now] - 1;
    a[now] = 0;
  }
  cout << cnt;
  return 0;
}


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

using namespace std;
using   ll=long long;

#define fast            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl            "\n"
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define int             long long int
#define pll                pair<int , int>

#define ALL(v)          v.begin(),v.end()
#define ALLR(v)         v.rbegin(),v.rend()
#define pii             3.14159265358979323
#define inf             LLONG_MAX
#define ones(x)         __builtin_popcount(x)
#define fill(a,b)       memset(a,b,sizeof(a))
#define mod             1000000007
#define hell            998244353

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
            res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a)
{
    return mod_pow(a , mod-2 , mod);
}

void solve()
{
	int n;
	
	cin >> n;
	
	int a[n];
	
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	int p[n+1] {};
	
	for(int i = n-1; i >= 0; --i) {
		p[i] = p[i+1] + a[i];
	}
	
	int ans = 0;
	
	for(int i = 0; i < n; ++i)  {
		ans = (ans + a[i]*(p[i+1] % mod)) % mod;
	}
	
	cout << ans;
}

signed main() {
    fast;

    int t = 1;
   
    //cin >> t;

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

    return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
int main() 
{
	 ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    ll k,a,b;
    cin>>k>>a>>b;
    int f=0;
    for(int i=a;i<=b;i++)
    {
		if(i%k==0)
		{
			f=1;
			break;
		}
	}
   if(f==1)
   cout<<"OK"<<endl;
   else
   cout<<"NG"<<endl;
            
}


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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
constexpr int INF = 0x3f3f3f3f; constexpr ll BINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

int solve() {
	string s; cin >> s;
	ll ans = 0;
	int cnt = 0;
	int n = s.size();
	for (int i=0;i<n;i++) {
		if (s[i] == 'A') {
			cnt++;
		} else if (s[i] == 'B') {
			if (i + 1 >= n || s[i + 1] != 'C') {
				cnt = 0;
			} else {
				ans += cnt;
				i++;
			}
		} else {
			cnt = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 720
n =int(input())

S=[]
ans = 0
count=1

for i in range(n):
    tmp=input()
    S.append(sorted(tmp))

S.sort()

for i in range(len(S)-1):
    if S[i] == S[i+1]:
        count+=1
    else:
        ans+=count*(count-1)/2
        count=1

ans+=count*(count-1)/2

print(int(ans))
    

Measured memory_bytes: 24624
{-# LANGUAGE Strict #-}

main :: IO ()
main = do
  [a, b, c, d] <- map read . words <$> getLine
  putStrLn $ if solve a b c d then "Yes" else "No"

solve :: Int -> Int -> Int -> Int -> Bool
solve a b c d = x >= y
  where x = ceilDiv a d
        y = ceilDiv c b

ceilDiv :: Int -> Int -> Int
ceilDiv a b = (a + b - 1) `div` b


Measured memory_bytes: 3892
#include<stdio.h>
#include<algorithm>
#define SZ 524288
using namespace std;
int n, K, w[501000], R[501000], top, INF = 1e8, G[501000], IT2[SZ+SZ+1];
struct Tree{
    long long M, K;
}IT[SZ+SZ+1];
void Add(int nd, long long k){
    IT[nd].M+=k, IT[nd].K+=k;
}
void UDT(int nd){
    IT[nd].M = min(IT[nd*2].M,IT[nd*2+1].M);
}
void init(int nd, int b, int e){
    if(b==e){
        Add(nd,INF);
        return;
    }
    int m = (b+e)>>1;
    init(nd*2,b,m);
    init(nd*2+1,m+1,e);
    UDT(nd);
}
void Spread(int nd){
    Add(nd*2,IT[nd].K);
    Add(nd*2+1,IT[nd].K);
    IT[nd].K=0;
}
void Ins(int nd, int b, int e, int s, int l, int x){
    if(b==s&&e==l){
        Add(nd,x);
        return;
    }
    Spread(nd);
    int m = (b+e)>>1;
    if(s<=m)Ins(nd*2,b,m,s,min(m,l),x);
    if(l>m)Ins(nd*2+1,m+1,e,max(m+1,s),l,x);
    UDT(nd);
}
void Put(int nd, int b, int e, int p, int x){
    if(b==e){
        IT[nd].M=IT[nd].K=x;
        return;
    }
    Spread(nd);
    int m = (b+e)>>1;
    if(p<=m)Put(nd*2,b,m,p,x);
    else Put(nd*2+1,m+1,e,p,x);
    UDT(nd);
}
int Min(int nd, int b, int e, int s, int l){
    if(b==s&&e==l)return IT[nd].M;
    Spread(nd);
    int r = INF;
    int m = (b+e)>>1;
    if(s<=m) r = min(r, Min(nd*2,b,m,s,min(m,l)));
    if(l>m) r = min(r, Min(nd*2+1,m+1,e,max(m+1,s),l));
    return r;
}
void Ins2(int a, int b){
    a+=SZ;
    IT2[a]=b;
    while(a!=1){
        a>>=1;
        IT2[a]=IT2[a*2]+IT2[a*2+1];
    }
}
int Get(int s){
    int nd = 1;
    while(nd<SZ){
        nd*=2;
        if(IT2[nd] < s){
            s-=IT2[nd];
            nd++;
        }
    }
    return nd-SZ;
}
int main(){
    int i, t;
    scanf("%d%d",&n,&K);
    for(i=1;i<=n;i++){
        scanf("%d",&R[i]);
        w[R[i]]=i;
    }
    init(1,1,n);
    for(i=1;i<=n;i++){
        t = min(Min(1,1,n,1,min(n,w[i]+K-1)), i);
        G[i] = i-t+1;
        Put(1,1,n,w[i],t);
        if(w[i]>1)Ins(1,1,n,1,w[i]-1,1);
    }
    for(i=1;i<=n;i++)Ins2(i,1);
    for(i=n;i>=1;i--){
        t = Get(G[i]);
        R[w[i]] = t;
        Ins2(t,0);
    }
    for(i=1;i<=n;i++)printf("%d\n",R[i]);
}

Measured memory_bytes: 29696
#include <iostream>
    #include <math.h>
    using namespace std;
    int main()
    {
      int n, d, result=0;
      cin >> n >> d;
      double a, b;
      while(n--)
      {
        cin >> a >> b;
        if(sqrt(a*a + b*b) <= d)
          result++;
      }
      cout << result;
      return(0);
    }

Measured memory_bytes: 3840
# coding: utf-8

N = int(input())
S = input()
result = ""
alpha2num = lambda c: ord(c) - ord("A") + 1
num2alpha = lambda c: chr(c+64)

for s in S:
    sum = N+alpha2num(s)
    if sum > 26:
        result += num2alpha(sum - 26)
    else: result += num2alpha(sum)
print(result)


Measured memory_bytes: 3060
n,k=map(int,input().split())
#1~k-1で続行
p=1/n
if n>=k:
    l=k
    win=(n-k+1)/n
else:
    l=n+1
    win=0
lst=[]
for i in range(1,l):
    x=i
    count=0
    while x < k:
        x*=2
        count += 1
    lst.append(count)
result=0
for i in lst:
    result+=(1/2)**i
print(result*p+win)
        

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

int main() {
  int h,w;
  cin>>h>>w;
  vector<int> a(h);
  vector<int> b(w);
  char x[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
      cin>>x[i][j];
  }
  for(int i=0;i<w;i++){
    for(int j=0;j<h;j++){
      if(x[j][i]=='#')
        break;
      if(j==h-1)
        b[i]=1;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(x[i][j]=='#')
        break;
      if(j==w-1)
        a[i]=1;
    }
  }
  for(int i=0;i<h;i++){
    if(a[i]==1)
      continue;
    for(int j=0;j<w;j++){
      if(b[j]==1){
        if(j==w-1)cout<<endl;
        continue;
      }
      cout<<x[i][j];
      if(j==w-1)cout<<endl;
    }
  }
}

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

using namespace std;

long long n, a, b;

int main() {
//	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);

	scanf("%lld%lld%lld", &n, &a, &b);
	if (a > b) swap(a, b);
	if ((b - a) % 2 == 0) {
		printf("%lld\n", (b - a) / 2);
		return 0;
	}

	printf("%lld\n", min(a - 1, n - b) + 1 + (b - a) / 2);
	return 0;
}

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

int main()
{
    int n, ara[120], mx = -152, mn = 200, ans = 1e9;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &ara[i]);
        mx = max(mx, ara[i]);
        mn = min(mn, ara[i]);
    }
    int lo = mn, hi = mx;
    for(int i = lo; i <= hi; i++)
    {
        int p = 0;
        for(int j = 0; j < n; j++)p+=((ara[j]-i)*(ara[j]-i));
        ans = min(p, ans);
    }
    printf("%d", ans);
    return 0;
}


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

string a;
int cnt, ans;
int main()
{
	int i;
	cin >> a;
	for (i = 0; i < a.size(); i++) {
		if (a[i] == 'T') {
			if (cnt > 0) {
				cnt--;
				ans += 2;
			}
		} else {
			cnt++;
		}
	}
	cout << a.size() - ans;
    return 0;
}


Measured memory_bytes: 640
gets;
a=gets.split().map(&:to_i).group_by(&:itself).to_a.sort

if a.size == 3 && a.map{|k,v|k}.reduce(:^) == 0 && a[0][1].size == a[1][1].size && a[0][1].size == a[2][1].size
    print 'Yes'
elsif a.size == 2 && a[0][0] == 0 && (a[0][1].size*2)== a[1][1].size
    print 'Yes'
elsif  a.size == 1 && a.map{|k,v|k}.reduce(:^) == 0
    print 'Yes'
else
    print 'No'
end


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

void mod_pow(long long &res, int x, int y, int mod) {
  for (int i = 0; i < y; ++i) {
    res *= x;
    res %= mod;
  }
}

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

  int n;
  cin >> n;
  long long res = 1;
  int mod = 998244353;

  vector<int> arr(n);
  map<int, int> cnt;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    ++cnt[arr[i]];
  }

  if (arr[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  if (cnt[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  int used = 1;
  for (int i = 1; i < n; ++i) {
    if (cnt[i] == 0) {
      break;
    }
    used += cnt[i];
    mod_pow(res, cnt[i-1], cnt[i], mod);
  }

  if (used == n) {
    cout << res << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 5376
#include<stdio.h>

int main(void){

  int tem;

  scanf("%d",& tem);

  if((-40<=tem)&&(tem<=40)){
    if(tem>=30){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }else{
    printf("error\n");
  }

  return 0;
}


Measured memory_bytes: 1616
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.141592653589793238
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld n, m;
      cin >> n;
      cin >> m;
      lld i, s;
      lld A[m];
      s = 0;
      foi(i, m)
      {
 		cin >> A[i];
 		s+= A[i];
      }
      if (s > n)
      {
      	cout <<"-1";
      }
      else
      {
      	cout << n-s;
      }
      return 0;
}

Measured memory_bytes: 3720
# -*- coding: utf-8 -*-


def main():
    s_list = list(input())
    dic = {}
    for s in s_list:
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1

    if len(dic) != 2:
        print('No')
        return
    else:
        for v in dic.values():
            if v != 2:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){
  int N;
  vector <int> C, S, F, ans;
  C.push_back(0);
  S.push_back(0);
  F.push_back(0);
  ans.push_back(0);

  ll c, s, f;
  cin >> N;
  for(int i = 1; i < N; i++){
    cin >> c >> s >> f;
    C.push_back(c);
    S.push_back(s);
    F.push_back(f);
  }
  for(int i = 1; i < N; i++){
    ll t, tmp;
    t = 0;
    for(int j = i; j < N; j++){
      if(t <= S[j]){
        t = S[j];
      }else{
        tmp = t % F[j];
        if(tmp != 0) t += (F[j] - tmp);
      }
      t += C[j];
    }

    ans.push_back(t);
  }

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


  return 0;

}

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

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int i;
  for (i = 0; i < n; i++) {
    int x, y, b, p;
    cin >> x >> y >> b >> p;
    cout << min((x * b + y * p), (int)((double)(x * max(b, 5) + y * max(p, 2)) * 0.8)) << endl;
  }
  return 0;
}



Measured memory_bytes: 3108
a = int(input())
b = list(map(int,input().split()))
c = 1
if 0 in b:
  print(0)
else:
  for i in range(a):
    c = c * b[i]
    if c > 10 ** 18:
      break
  if c > 10 ** 18:
    print(-1)
  else:
    print(c)


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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
    string s; cin >> s;
    int w; cin >> w;
    vector<string> str;
    for(int i = 0; i < s.size(); i += w){
        str.push_back(s.substr(i,w));
    }
    for(int i = 0; i < str.size(); i++){
        cout << str[i][0];
    }
    cout << endl;

    return 0;
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n,m;
  cin >> n >> m;
  vector<vector<ll>> v(n,vector<ll>(3));
  rep(i,n)rep(j,3)cin >> v[i][j];
  int c[] = {-1,1};
  ll res = 0;
  for(int bit = 0;bit < 8;bit++){
    vector<ll> k(n,0);
    rep(j,3)rep(i,n)k[i] += v[i][j]*c[bit >> j & 1];
    sort(ALL(k),greater<ll>());
    ll sum = 0;
    rep(i,m)sum += k[i];
    res = max(res,sum);
  }
  cout << res << endl;
  
  



  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,x,i;
    while(cin >> n >> a >> b)
    {
        int cnt=0;
        for(i=0;i<n;i++)
        {
            cin>>x;
            if(x<a)cnt++;
            if(x>=b)cnt++;
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat Jun 16 10:51:31 2018
//
package main

import (
	"fmt"
	"math"
)

type arg float64

type point struct {
	x, y float64
}

func (p point) diff(q point) point {
	return point{x: p.x - q.x, y: p.y - q.y}
}

func (p point) abs() float64 {
	return math.Sqrt(p.x*p.x + p.y*p.y)
}

func (p point) inner(q point) float64 {
	return p.x*q.x + p.y*q.y
}

func (p point) arg(q, r point) arg {
	p0 := q.diff(p)
	p1 := r.diff(p)

	return arg(math.Acos(p0.inner(p1) / (p0.abs() * p1.abs())))
}

func main() {
	points := [3]point{}
	for i := 0; i < len(points); i++ {
		fmt.Scan(&points[i].x)
		fmt.Scan(&points[i].y)
	}

	theta0 := points[0].arg(points[1], points[2])
	theta1 := points[1].arg(points[2], points[0])
	theta2 := points[2].arg(points[0], points[1])
	var x, y point
	var thetax, thetay arg
	if theta0 < theta1 {
		if theta1 < theta2 {
			x = points[1]
			thetax = theta1
			y = points[0]
			thetay = theta0
		} else {
			x = points[2]
			thetax = theta2
			y = points[0]
			thetay = theta0
		}
	} else {
		if theta0 < theta2 {
			x = points[1]
			thetax = theta1
			y = points[0]
			thetay = theta0
		} else {
			x = points[1]
			thetax = theta1
			y = points[2]
			thetay = theta2
		}
	}

	r := x.diff(y)
	d := r.abs()

	fmt.Println(d / (2 + 1/math.Tan(float64(thetax/2)) + 1/math.Tan(float64(thetay/2))))
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <queue>
#include <sstream>
using namespace std;

const int MAX_V = 108;
const int H = 106;
const int D = 107;

int m, n, k, d, calorie[6];

struct Edge { int to, cost, cakeFlag; };
vector<Edge> G[MAX_V];

int dist[64][108];

int toInt(string s) {
	stringstream ss(s);
	int ret = 0;
	ss >> ret;
	return ret;
}

int makeKey(string s) {
	if (s[0] == 'C') return toInt(s.substr(1)) - 1;
	if (s[0] == 'L') return toInt(s.substr(1)) + 5;
	if (s == "H") return H;
	return D;
}

void addEdge(string a, string b, int cost) {
	int ak = makeKey(a);
	int bk = makeKey(b);
	if (b[0] == 'C') {
		G[ak].push_back((Edge){bk, cost - calorie[bk], 1 << bk});
	} else {
		G[ak].push_back((Edge){bk, cost, 0});
	}
	if (a[0] == 'C') {
		G[bk].push_back((Edge){ak, cost - calorie[ak], 1 << ak});
	} else {
		G[bk].push_back((Edge){ak, cost, 0});
	}
}

int shortestPath(int from, int to) {
	fill((int*)dist, (int*)(dist + sizeof(dist) / sizeof(*dist)), INT_MAX);
	dist[0][from] = 0;
	queue<pair<int,int> > q;
	q.push(make_pair(from, 0));
	while ( ! q.empty()) {
		int now = q.front().first;
		int flag = q.front().second;
		q.pop();
		for (int i=0; i<(int)G[now].size(); ++i) {
			Edge &e = G[now][i];
			if (flag & e.cakeFlag) continue;
			if (dist[flag][now] + e.cost < dist[flag | e.cakeFlag][e.to]) {
				dist[flag | e.cakeFlag][e.to] = dist[flag][now] + e.cost;
				q.push(make_pair(e.to, flag | e.cakeFlag));
			}
		}
	}
	int ret = INT_MAX;
	for (int i=0; i<64; ++i) {
		ret = min(ret, dist[i][to]);
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	while (cin >> m >> n >> k >> d, m) {
		fill(G, G+MAX_V, vector<Edge>());
		for (int i=0; i<m; ++i) {
			cin >> calorie[i];
		}
		string a, b;
		int cost;
		for (int i=0; i<d; ++i) {
			cin >> a >> b >> cost;
			addEdge(a, b, cost * k);
		}
		cout << shortestPath(H, D) << endl;
	}
	return 0;
}

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

using namespace std;

int N, A, B, C;
int inf = 100000000;
vector<int> ls;
int dfs(int i, int a, int b, int c) {
  if (i == N) {
    if (min({a, b, c}) > 0) {
      return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }
    else {
      return inf;
    }
  }
  int ret0 = dfs(i + 1, a, b, c);
  int ret1 = dfs(i + 1, a + ls[i], b, c) + 10;
  int ret2 = dfs(i + 1, a, b + ls[i], c) + 10;
  int ret3 = dfs(i + 1, a, b, c + ls[i]) + 10;
  return min({ret0, ret1, ret2, ret3});
}

int main() {
  cin >> N >> A >> B >> C;

  int l;
  for (int i = 0; i < N; ++i) {
    cin >> l;
    ls.push_back(l);
  }

  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}



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

int _stoi(string s) {
    return atoi(s.c_str());
}

int popValue(stack<int> *S) {
    int retVal = S->top();
    S->pop();
    return retVal;
}

int main(int argc, const char * argv[]) {
    stack<int> S;
    string s;
    
    while(cin >> s){
        if (s[0] == '+') {
            S.push(popValue(&S) + popValue(&S));
        } else if (s[0] == '-') {
            int minus = - popValue(&S);
            S.push(minus + popValue(&S));
        } else if (s[0] == '*') {
            S.push(popValue(&S) * popValue(&S));
        } else {
            S.push(_stoi(s));
        }
    }

    cout << S.top() << endl;
    
    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int N;
    cin >> N;
    char c;
    vector<bool> v(4, false);
    REP(i, N){
        cin >> c;
        if(c == 'P') v[0] = true;
        else if (c == 'Y') v[1] = true;
        else if (c == 'G') v[2] = true;
        else if (c == 'W') v[3] = true;
    }

    if (v[0] && v[1] && v[2] && v[3]) cout << "Four" << endl;
    else cout << "Three" << endl;

    return 0;
}

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

using namespace std;

using ll = long long;

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

    std::vector<int> A(N);
    std::for_each(A.begin(), A.end(), [](auto &x) { cin >> x; });

    const ll sum = [&A, &N]() {
        ll sum = std::abs(A[0]);
        for (ll i = 1; i < N; ++i) {
            sum += std::abs(A[i - 1] - A[i]);
        }
        sum += (std::abs(A[N - 1]));

        return sum;
    }();

    //delete current
    auto generate_new_plan = [&sum](const auto prev, const auto current, const auto next) {
        auto new_plan = sum;
        new_plan -= std::abs(prev - current); //delete : prev -> current
        new_plan -= std::abs(current - next); //delete : current -> next
        new_plan += std::abs(prev - next); //add : prev -> next
        return new_plan;
    };

    cout << generate_new_plan(0, A[0], A[1]) << endl;

    for (ll i = 1; i < N - 1; ++i) {
        cout << generate_new_plan(A[i - 1], A[i], A[i + 1]) << endl;
    }

    cout << generate_new_plan(A[N - 2], A[N - 1], 0) << endl;


    return 0;
}


Measured memory_bytes: 1664
n, m = gets.split.map(&:to_i)
a = gets.split
num = {}
[0, 2, 5, 5, 4, 5, 6, 3, 7, 6].each_with_index{|i, idx| num[idx.to_s] = i }
dp = Array.new(n+1, "")
use = Array.new(n+1, 0)
for i in 1..n
    maxval = ""
    for j in 0..m-1
        num_aj = num[a[j]]

        next if i - num_aj < 0
        next if use[i - num_aj] + num_aj != i

        s = dp[i - num_aj] + a[j]

        if s.length > maxval.length || s.length == maxval.length && s > maxval
            maxval = s
            use[i] = use[i - num_aj] + num_aj
        end
    end
    dp[i] = maxval
end
puts dp.last


Measured memory_bytes: 72700