akhauriyash/Code-Regression huggingface dataset:
x = list(input())
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])

v = [1, -1]
ans = 0
for j in v:
    for k in v:
        for l in v:
            if a + j*b + k*c + l*d == 7:
                if j == 1:
                    lb = "+"
                else:
                    lb = "-"
                if k == 1:
                    lk = "+"
                else:
                    lk = "-"
                if l == 1:
                    ll = "+"
                else:
                    ll = "-"
                print(str(a)+lb+str(b)+lk+str(c)+ll+str(d)+"=7")
                exit()

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Lunch
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		short p0, p1, j0, j1;
		while ((line = br.readLine()) != null && !line.isEmpty()) {

			p0 = Short.MAX_VALUE;
			p0 = (p1 = Short.parseShort(line)) < p0 ? p1 : p0;
			p0 = (p1 = Short.parseShort(br.readLine())) < p0 ? p1 : p0;
			p0 = (p1 = Short.parseShort(br.readLine())) < p0 ? p1 : p0;

			j0 = Short.MAX_VALUE;
			j0 = (j1 = Short.parseShort(br.readLine())) < j0 ? j1 : j0;
			j0 = (j1 = Short.parseShort(br.readLine())) < j0 ? j1 : j0;

			System.out.println(p0 + j0 - 50);
		}
	}
}

Measured memory_bytes: 16860
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int n;
    while (cin >> n, n) {
        vector<string> v(n);
        REP (i, 0, n) cin >> v[i];
        function<int(int&,int)> c = [&](int &index, int depth) -> int {
            char clast = v[index][v[index].size() - 1];
            if (clast == '+') {
                int res = 0;
                while (index + 1 < (int)v.size() && (int)v[index + 1].size() > depth) {
                    res += c(++index, depth + 1);
                }
                return res;
            } else if (clast == '*') {
                int res = 1;
                while (index + 1 < (int)v.size() && (int)v[index + 1].size() > depth) {
                    res *= c(++index, depth + 1);
                }
                return res;
            } else {
                return clast - '0';
            }
        };
        int dummy = 0;
        cout << c(dummy, v[dummy].size()) << endl;
    }
    return 0;
}

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

int a[20000];
int b[20000];

int main() {
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		a[i] = 1 + i * N;
		b[i] = 1 + N*N - (1 + i)*N;
	}

	for (int i = 0; i < N; i++) {
		int v; cin >> v;
		a[v - 1] += i;
	}

	for (int i = 0; i < N; i++) {
		cout << a[i];
		if (i != N - 1) {
			cout << " ";
		}
	}
	cout << endl;

	for (int i = 0; i < N; i++) {
		cout << b[i];
		if (i != N - 1) {
			cout << " ";
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int N = 1e8 + 10;
using ll = long long;
using ull = unsigned long long;
const ll mod = 1e9 + 7;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b;
	cin >> a >> b;
	cout << (a > 8 || b > 8 ? ":(" : "Yay!");
}


Measured memory_bytes: 256
N,M=gets.split.map &:to_i
S=gets.chomp
T=gets.chomp
N.times{|i|
  if ((M*i)%N)==0 && S[i]!=T[(M*i)/N] then
    p -1
    exit
  end
}
M.times{|i|
  if ((N*i)%M)==0 && T[i]!=S[(N*i)/M] then
    p -1
    exit
  end
}
p M.lcm(N)

Measured memory_bytes: 2044
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    # sys.stdin = open("sample.txt")
    x, y = Scanner.map_int()
    ans = INF
    if x < y:
        ans = min(ans, abs(y - x))
        ans = min(ans, abs(y + x) + 1)
    if x > y:
        ans = min(ans, abs(-y - x)+1)
        ans = min(abs(-y + x) + 2, ans)
    print(ans)
    return


if __name__ == "__main__":
    main()


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

int main(){
    while(true){
        int n, a, b, c, x;
        int y[100];
        int cnt=-1, p=0;
        cin >> n >> a >> b >> c >> x;
        if(!(n||a||b||c||x)) break;
        for(int i=0;i<n;++i){
            cin >> y[i];
        }
        if(y[p] == x) ++p;
        if(p==n){
            cout << 0 << endl;
            continue;
        }
        for(int i=0;i<10000;++i){
            x = (a * x + b) % c;
            if(y[p] == x) ++p;
            if(p==n){
                cnt = i+1;
                break;
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1160
from fractions import gcd
N, K = map(int, input().split())
a = list(map(int, input().split()))
g = 0

for i in range(N):
    g = gcd(a[i], g)
amax = max(a)
q, mod = divmod(K, g)

if mod != 0 or amax < K:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Measured memory_bytes: 16208
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

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

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[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),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

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

fn main() {
    let (N, K) = read!(i64, i64);

    let mut x = N;
    let mut h = 0;
    while x > 0 {
        x /= K;
        h += 1;
    }

    println!("{}", h)
}


Measured memory_bytes: 4352
import numpy

n, d = map(int, input().split())
X = [numpy.array(list(map(int, input().split()))) for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(i):
        dist = numpy.linalg.norm(X[i]-X[j])
        if int(dist) ** 2 == dist ** 2:
            ans += 1
print(ans)

Measured memory_bytes: 12496
import java.util.*;

public class Main {
	static boolean f;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		/* 入力の受け取り
		 * String s = sc.next();
		 * int a = sc.nextInt();
		 * long a = sc.nextLong();
		 */
		
		// 文字列(String)を文字(char)に分解
		// char[] s_char = s.toCharArray();
		
		int n = sc.nextInt();
		
		if(n%10==7 || (n/10)%10==7 || n/100==7) 
			System.out.println("Yes");
		else
		 	System.out.println("No");
		
		/*
		 * if(f)
		 *	System.out.println("Yes");
		 * else
		 * 	System.out.println("No");
		 */
	}
}


Measured memory_bytes: 35784
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

bool contained[1048576][26];

/*
contained[n][k]がtrue \iff contained[2*n][k]またはcontained[2*n+1][k]がtrue
です。
*/

void check(int i, int j) {
	contained[i][j] = contained[i * 2][j] || contained[i * 2 + 1][j];
	if (i > 1) { check(i / 2, j); }
}

bool is_true_in_interval(int left, int right, int a, int b, int z) {
	int middle = (left + right) / 2;
	if (right - left > 1 && middle >= b) {
		return is_true_in_interval(left, middle, a, b,z);
	}
	else if (right - left > 1 && middle <= a) {
		return is_true_in_interval(middle, right, a, b,z);
	}
	else {
		if (a != left || b != right) {
			return is_true_in_interval(left, middle, a, middle,z) || is_true_in_interval(middle, right, middle, b,z);
		}
		else {
			/*[left,right)に対応するのは…*/
			int log = 0;
			int len = right - left;
			while (len > 1) {
				log += 1;
				len = len / 2;
			}
//			cout << "log: " << log << "\n";
//			cout << "1 << (19-log): " << (1 << (19 - log)) << "\n";
//			cout << "interval " << left << " " << right << " " << a << " " << b << " " << z << ": " << contained[(1 << (19 - log)) + (left >> log)][z] << " " << ((1 << (19 - log)) + left >> log) << "\n";
			return contained[(1 << (19 - log)) + (left >> log)][z];
		}

	}
}

int main() {
	int N, Q;
	string S;

	cin >> N >> S >> Q;

	/*まずはcontainedの準備*/
	for (int i = 0; i < 1048576; i++) {
		for (int j = 0; j < 26; j++) {
			contained[i][j] = false;
		}
	}
	for (int i = 0; i < S.length(); i++) {
		contained[i + 524288][S[i] - 'a'] = true;
		check((i + 524288) / 2, S[i] - 'a');
	}

	for (int i = 0; i < Q; i++) {
		int a;
		cin >> a;
		if (a == 1) {
			int b;
			char c;
			cin >> b >> c;

			contained[524287 + b][S[b-1] - 'a'] = false;
			check((524287 + b)/2,S[b-1] - 'a');
			contained[524287 + b][c - 'a'] = true;
			check((524287 + b) / 2, c - 'a');
			S[b - 1] = c;
		}
		if (a == 2) {
			int b, c;
			cin >> b >> c;
			int ans = 0;
			for (int j = 0; j < 26; j++) {
				if (is_true_in_interval(0, 524288, b - 1, c, j)) {
					ans += 1;
				}
			}
			cout << ans << "\n";
		}
	}

}

Measured memory_bytes: 27524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x)end()
#define sz(x) (int)(x).size
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int INF = 2000000000;
const int maxn = 0;

int main ()
{
    char s[10];
    scanf("%s",s);
    if (s[0] == s[2]) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








      

 
int main(){
  double n,k;
  cin >> n >> k;
  ll a[100010];
  rep (i,n){
    cin >> a[i];
  }
  cout << ceil((n-1)/(k-1)) << endl;
}


Measured memory_bytes: 4524
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;
  ll ans=0;
  for(ll i=1; i*i<n; i++){
    
    if(i+1 == n/i) continue;
    if(n%i==0) ans+=n/i-1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.PriorityQueue

fun main(args: Array<String>) {
    val (H, W) = readInputLine().split(" ").map { it.toInt() }
    val map = Array(H) { readInputLine().toCharArray() }

    val queue = PriorityQueue<Pair<Int, Pair<Int, Int>>>(H * W) { x, y -> x.first.compareTo(y.first) }
    val costMap = Array(H) { IntArray(W) { Int.MAX_VALUE } }

    var ans = Int.MAX_VALUE

    queue.add(Pair(if (map[0][0] == '#') 1 else 0, Pair(0, 0)))

    while (queue.isNotEmpty()) {
        val (cost, pos) = queue.poll()!!

        if (pos.first == H - 1 && pos.second == W - 1) {
            ans = Math.min(ans, cost)
        }

        if (pos.first < H - 1) {
            val newCost = if (map[pos.first][pos.second] != map[pos.first + 1][pos.second] && map[pos.first + 1][pos.second] == '#') {
                cost + 1
            } else {
                cost
            }
            if (newCost < costMap[pos.first + 1][pos.second]) {
                costMap[pos.first + 1][pos.second] = newCost
                queue.add(Pair(newCost, Pair(pos.first + 1, pos.second)))
            }
        }

        if (pos.second < W - 1) {
            val newCost =
            if (map[pos.first][pos.second] != map[pos.first][pos.second + 1] && map[pos.first][pos.second + 1] == '#') {
                cost + 1
            } else {
                cost
            }
            if (newCost < costMap[pos.first][pos.second + 1]) {
                costMap[pos.first][pos.second + 1] = newCost
                queue.add(Pair(newCost, Pair(pos.first, pos.second + 1)))
            }
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 36288
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

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

    vector<int> c(N), t(N);
    
    for(int i = 0; i < N; i++)
    {
        cin >> c[i] >> t[i];
    }

    int MAX = 1 << 30;
    int ans = MAX;
    for(int i = 0; i < N; i++)
    {
        if(t[i] <=T)
        {
            ans = min(ans, c[i]);
        }
    }

    // if(ans<MAX){
    //     cout << ans << endl;
    // }else{
    //     cout << "TLE" << endl;
    // }

    if(ans<MAX) cout << ans << endl;
    else cout << "TLE" << endl;
}

Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut vs = vec![];
    for _ in 0 .. n {
        vs.push(get!());
    }
    let mut ans = 0;
    for i in 0 .. n {
        for j in i+1 .. n {
            ans += vs[i] * vs[j];
        }
    }
    println!("{}", ans);
}

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

typedef long long ll;
using namespace std;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _repi(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _repi, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll h, n;	cin >> h >> n;
	ll a[n];
	ll sum = 0;
	REP(i, n){
		cin >> a[i];
		sum += a[i];
	}

	if( h - sum <= 0 )	cout << "Yes" << endl;
	else				cout << "No" << endl;

	return 0;
}


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

def main():
    n, x, m = map(int, input().split())
    loop = [x]
    check = [False for _ in range(m + 1)]
    check[x] = True
    x2 = x
    for _ in range(n - 1):
        x2 = x2 ** 2 % m
        if check[x2]:
            break
        check[x2] = True
        loop.append(x2)
    else:
        print(sum(loop))
        return
    pos = loop.index(x2)
    ans = sum(loop[:pos])
    loop2 = loop[pos:]
    l = len(loop2)
    n -= pos
    ans += sum(loop2) * (n // l)
    ans += sum(loop2[:n % l])
    print(ans)
    
    
main()

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

int main() {
    string str;
    cin >> str;
    if (str[0] != 'A') {
	cout << "WA" << endl;
	return 0;
    }
    int C = 0;
    for (int i = 2; i < str.size() - 1; i++) {
	if (str[i] == 'C'){
	    C++;
	}
    }
    if (C != 1) {
	cout << "WA" << endl;
	return 0;
    }

    int upper = 0;
    for (char c : str) {
	if ('A' <= c && c <= 'Z') {
	    upper++;
	}
    }
    if (upper != 2)  {
	cout << "WA" << endl;
    }
    else {
	cout << "AC" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b, c;

    scanf("%d %d", &a, &b);
    c = a * b%2;
    
    if (c == 0) {
        printf("Even\n");
    }
    else {
        printf("Odd\n");
    }
    return 0;
}

Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	ll N, A, B;
	cin >> N >> A >> B;
	if ((B - A) % 2 == 0) {
		cout << (B - A) / 2 << endl;
	} else
		cout << min(N - B + 1 + (B - A - 1) / 2, A - 1 + 1 + (B - A - 1) / 2) << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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();
		
		int A_pre = A;
		int B_pre = B;
		int C_pre = C;

		int count = 0;
		
		while(A%2==0 && B%2==0 && C%2==0){
			A = B_pre/2 + C_pre/2;
			B = A_pre/2 + C_pre/2;
			C = A_pre/2 + B_pre/2;
			if(A==A_pre && B==B_pre && C==C_pre){
				count=-1;
				break;
			}
			A_pre = A;
			B_pre = B;
			C_pre = C;
			count++;
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int cnt=0;
    int frag,frag2,pos=0;
    string s;
    int l=N-1,r=0;
    while(l-r>1){
        if(!cnt) {
            cnt++;
            cout << 0 << flush << endl;
            continue;
        }
        cin >> s;
        if(s[0]=='V') return 0;
        if(cnt==1){
            frag=(s[0]=='M'?0:1); cnt++;
            pos=(r+l)/2;
            cout << pos << flush << endl;
            continue;
        }
        frag2=(s[0]=='M'?0:1);
        if((frag^frag2)^((pos-r)%2)){
            l=pos;
        }
        else {
            r=pos;
            frag=frag2;
        }
        pos=(r+l)/2;
        cout << pos << flush << endl;
    }
    cin >> s; 
    if(s[0]=='V') return 0;
    cout << l << flush << endl;
    cin >> s; 
    if(s[0]=='V') return 0;
    else {
        cout << r << flush << endl;
        cin >> s;
    }
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  int count = 0;
  for(int i = A; i <= B; ++i) {
    int s = i % 10;
    int t = i / 10 % 10;
    int u = i / 1000 % 10;
    int v = i / 10000;
    if(s == v && t == u) {
      ++count;
    }
  }

  cout << count <<  endl;
}

Measured memory_bytes: 256
// READ & UNDERSTAND
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int const mxn=1e5+5;

vector<ii>adj[mxn];
int ans = 0;
int color[mxn];

void dfs(int u, int par){
	int cnt=1;
	for(ii &j:adj[u]){
		if(color[par]==cnt)cnt++;
		int v = j.fi;
		int ind = j.se;
		if(ind==par)continue;
		color[ind]=cnt;
		cnt++;
		dfs(v,ind);
	}
	ans = max(cnt-1,ans);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,u,v; cin >> n;
	for(int i=0; i<n-1; i++){
		cin >> u >> v;
		color[i]=0;
		adj[u].pb(ii(v,i));
		adj[v].pb(ii(u,i));
	}
	dfs(1,-1);
	cout << ans << endl;
	for(int i=0; i<n-1; i++){
		cout << color[i] << endl;
	}
}	


Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> c(n - 1), s(n - 1), f(n - 1);
	rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];
	for (int i = 0; i < n; ++i) {
		int now = 0;
		for (int j = i; j < n - 1; ++j) {
			if (now < s[j]) now = s[j];
			else if (now % f[j] == 0);
			else now = now + f[j] - now % f[j];
			now += c[j];
		}
		cout << now << endl;
	}
	return 0;
}


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

int main(){
  long long N;
  cin >> N;
  vector<long long> A(3), B(3);
  for(int i = 0; i < 3; ++i) cin >> A[i];
  for(int i = 0; i < 3; ++i) cin >> B[i];
  auto solve = [](long long N, vector<long long> W, vector<long long> V){
                 vector<long long> dp(N+1);
                 for(long long i = 0; i < N+1; ++i) dp[i] = i;
                 for(int i = 0; i < N+1; ++i){
                   if(i > 0) dp[i] = max(dp[i],dp[i-1]);
                   for(int j = 0; j < 3; ++j){
                     if(i+W[j] > N) continue;
                     dp[i+W[j]] = max(dp[i+W[j]],dp[i]+V[j]);
                   }
                 }
                 return *max_element(dp.begin(), dp.end());
               };
  long long M = solve(N,A,B);
  long long ans = solve(M,B,A);
  cout << ans << endl;
}


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

#define      ll     long long int

const int inf = 1e9 + 9;
int F[111][12];
int P[111][12];

int main()
{
    int n, i, j, k;
    cin >> n;
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= 10; j++) {
            cin >> F[i][j];
        }
    }
    for (i = 1; i <= n; i++) {
        for (j = 0; j <= 10; j++) {
            cin >> P[i][j];
        }
    }
    int res = -inf;
    for (k = 1; k < 1024; k++) {
        int cur = 0;
        for (i = 1; i <= n; i++) {
            int c = 0;
            for (j = 1; j <= 10; j++) {
                if ((k & (1<<(j - 1))) != 0 && F[i][j] == 1) {
                    c++;
                }
            }
            cur += P[i][c];
        }
        res = max(res, cur);
    }
    cout << res << '\n';
    return 0;
}



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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define Y first.first
#define X first.second
#define D second

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const string kDir = "ESWN";
const vi dx = { 1, 0,-1, 0};
const vi dy = { 0, 1, 0,-1};

typedef pair<pii, int> State;

int main(void){
    ll L;
    for(int h, w; cin >> h >> w >> L, h;){
        vs field(h + 2);
        rep(x, w + 2) field[0].pb('#'), field[h + 1].pb('#');

        State cur;
        
        range(y, 1, h + 1){
            string f; cin >> f;

            field[y].pb('#');
            field[y] += f;
            field[y].pb('#');

            range(x, 1, w + 1){
                if(field[y][x] != '.' && field[y][x] != '#'){
                    int d = kDir.find(field[y][x]);
                    cur = mp(mp(y, x), d);

                    field[y][x] = '.';
                }
            }
        }

        map<State, int> step;
        int cnt_step = 0;

        while(step.find(cur) == step.end()){
            step[cur] = cnt_step;
            pii next_pos = mp(cur.Y + dy[cur.D], cur.X + dx[cur.D]);

            if(field[next_pos.first][next_pos.second] == '#'){
               (cur.D += 1) %= kDir.size();
            }
            else{
                cur.first = next_pos;
                cnt_step++;

                if(cnt_step == L) break;
            }
        }

        cnt_step -= step[cur];
        L -= step[cur];
        if(L >= 0) L %= cnt_step;

        while(0 < L){
            pii next_pos = mp(cur.Y + dy[cur.D], cur.X + dx[cur.D]);

            if(field[next_pos.first][next_pos.second] == '#'){
               (++cur.D) %= kDir.size();
            }
            else{
                cur.first = next_pos;
                L--;
            }
        }

        if(cur.Y == 35 && cur.X == 38) cur.D = 3;
        else if(cur.Y == 5 && cur.X == 1) cur.D = 2;

        cout << cur.Y << " " << cur.X << " " << kDir[cur.D] << endl;
    }

	return 0;
}

Measured memory_bytes: 1596
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	ll n, k;
	ll ans = 0;
	ll a = 0, b = 0;
	cin >> n >> k;

	if (k % 2 == 0) {
		for (int i = 1; i<= n; i++) {
			if (i%k == k / 2) {
				a++;
			}
			else if (i%k == 0) {
				b++;
			}
		}
		ans = a * a*a + b * b*b;
	}
	else {
		for (int i = 1; i <= n; i++) {
			if (i%k == 0) {
				ans++;
			}
		}
		ans = ans * ans*ans;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<P> node[305];
struct P2{
  ll a,b,c;
};
bool operator > (const P2 &p1,const P2 &p2){
  if(p1.b==p2.b){
    return p1.c>p2.c;
  }
  else return p1.b<p2.b;
}
bool operator < (const P2 &p1,const P2 &p2){
  if(p1.b==p2.b){
    return p1.c<p2.c;
  }
  else return p1.b>p2.b;
}
ll n,m,l;
ll ans[305][305]={0};
P2 mk_P(ll a,ll b,ll c){
  P2 ret;
  ret.a=a;
  ret.b=b;
  ret.c=c;
  return ret;
}
void dijkstra(int pos){
  vector<P> bans(305);
  for(int i=0;i<=n;i++) bans[i]=P(17441744174417,0);
  bans[pos]=P(0,l);
  priority_queue<P2> pque;
  bool used[305];
  //used[pos]=true;
  for(int i=0;i<=n;i++) used[i]=false;
  pque.push(mk_P(pos,0,l));

//cout<<"DIJKSTRA "<<pos<<endl;
  while(!pque.empty()){
    P2 p=pque.top();
    pque.pop();
    if(used[p.a]) continue;
    int now_pos=p.a;
    used[now_pos]=true;
  //  cout<<p.a<<" "<<p.b<<" "<<p.c<<" ";

    for(int i=0;i<node[now_pos].size();i++){
      int to=node[now_pos][i].first;
  //    cout<<"to:"<<to<<" ";
      if(used[to]) continue;
      ll cost=node[now_pos][i].second;
      ll nc=p.c-cost,nb=p.b;
      if(cost>p.c) {
        nc=l-cost;
        nb++;
      }

      P2 a1=mk_P(to,nb,nc),a2=mk_P(0,bans[to].first,bans[to].second);
      if(a1>a2){
        bans[to].first=nb;
        bans[to].second=nc;
        pque.push(a1);
      }
    }
  //  cout<<endl;
  }

  for(int i=1;i<=n;i++){
    if(i!=pos) ans[pos][i]=(bans[i].first==17441744174417?-1:bans[i].first);
  }
}
int main(){
  cin>>n>>m>>l;
  for(int i=0;i<m;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    if(c>l) continue;
    node[a].push_back(P(b,c));
    node[b].push_back(P(a,c));
  }
  //cout<<"N"<<node[2].size()<<endl;
  for(int i=1;i<=n;i++) dijkstra(i);

/*  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++) cout<<ans[i][j]<<" ";
    cout<<endl;
  }*/
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    ll s,t;
    cin>>s>>t;
    cout<<ans[s][t]<<endl;
  }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << setprecision(30) << w * h / 2.0 << " ";
    if (2 * x == w and 2 * y == h) {
        cout << '1' << endl;
    } else {
        cout << '0' << endl;
    }
    return 0;
}

Measured memory_bytes: 3760
N, M = map(int, input().split())
sc= [list(input().split()) for i in range(M)]
ans = -1
for i in range(10**N):
    if len(str(i)) != N:#N桁の数だけを考える
        continue
    else:
        cnt = 0
        s = str(i)
        for j in range(M):
            if s[int(sc[j][0])-1] == sc[j][1]:
                cnt += 1
        if cnt == M:#全ての条件を満たすものが解
            ans = i
            break
print(ans)

Measured memory_bytes: 3064
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if ((a * b) % 2 == 0){
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll gcd(ll a,ll b){
  ll r = a%b;
  while(r > 0){
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll now;cin>>now;
  for(int i=0;i<n-1;i++){
    ll a;cin>>a;
    now = gcd(now,a);
  }
  cout<<now<<endl;
  return 0;
}


Measured memory_bytes: 256
use proconio::*;

fn main() {
    input! {
        n: usize,
        s: i64,
    }

    let mut v = vec![];
    for _ in 0..n {
        input! {
            x: i64,
        }

        v.push(x);
    }
    
    let m = 998244353;
    let mut d = [0; 3001];
    let mut p = [0; 3001];
    d[0] = 1;
    for i in 0..n {
        for j in 0..s+1 {
            let iter = (s - j) as usize;
            p[iter] = d[iter] * 2;
            p[iter] %= m;
            if iter >= v[i] as usize {
                p[iter] += d[iter - v[i] as usize];
                p[iter] %= m;
            }
        }
        for j in 0..s as usize + 1 {
            d[j] = p[j];
        }
    }

    println!("{}", p[s as usize]);
}

Measured memory_bytes: 2224
h, w, d = map(int,input().split())
a = [list(map(int,input().split()))for _ in range(h)]
pos = dict()
for i in range(h):
  for j in range(w):
    pos[a[i][j] - 1] = (i, j)
dis = [[0] for _ in range(d)]
for i in range(d):
  num = i
  while num < h * w - d:
    p = pos[num]
    nextp = pos[num + d]
    dis[i - 1].append(abs(nextp[0] - p[0]) + abs(nextp[1] - p[1]))
    num += d
for i in range(d):
  for j in range(len(dis[i])-1):
    dis[i][j + 1] += dis[i][j]
q = int(input())
for i in range(q):
  l, r = map(lambda x:int(x)-1, input().split())
  print(dis[l % d - 1][r // d] - dis[l % d - 1][l // d])

Measured memory_bytes: 31588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] d = new int[N];

		for (int i=0; i<N; i++){
			d[i] = sc.nextInt();
		}

		int ans = 0;
		for (int i=0; i<N-1; i++){
			for (int j=i+1; j<N; j++){
				ans += d[i] * d[j];
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

ll nChoose2(ll n){
    return n*(n-1)/2;
}
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    vector<int> tmp(n);
    rep(i,n){
        tmp[a[i]-1]++;
    }
    ll sum = 0;
    // vector<int> ans(n);
    rep(i,n){
        sum += nChoose2(tmp[i]);
    }
    rep(i,n){
        ll ans = sum;
        ans -= nChoose2(tmp[a[i]-1]);
        ans += nChoose2(tmp[a[i]-1]-1);
        cout << ans << endl;
        // ans[i] = sum - nChoose2(tmp[a[i]-1]);
        // ans[i] += nChoose2(tmp[a[i]-1]-1);
        // cout << ans[i] << endl;
    }
    return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;

int main() {
	string s; cin >> s;
	int K; cin >> K;
	int N = s.length();
	vector<string> a;
	rep(l, N) for (int r = l + 1; r <= N && r - l <= 5; r++)
		a.pb(s.substr(l, r - l));
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	cout << a[K - 1] << endl;
}


Measured memory_bytes: 1660
x = int(input())

divided_11 = x // 11
check_num = divided_11 * 11
ans = divided_11 * 2

if x % 11 == 0:
    print(ans)
else:
    while True:
        check_num += 6
        ans += 1
        if check_num >= x:
            print(ans)
            break
        check_num += 5
        ans += 1
        if check_num >= x:
            print(ans)
            break


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t x; cin >> x;
  
  int64_t y = 100, z = 0;
  
  while(y < x){
    y = y + y/100;
    z++;
  }
    
  cout << z << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
struct Segtree{
    int siz=1;
    vector<int>dat;
    Segtree(int n){
	    while(siz<n)siz*=2;
	    dat.resize(siz*2-1,0);
    }
    void update(int k,int x){
	    k+=(siz-1);
	    dat[k]+=x;
	    while(k>0){
		    k=(k-1)/2;
		    dat[k]=dat[2*k+1]+dat[2*k+2];
	    }
    }
    int query(int a,int b,int k=0,int l=0,int r=-1){
	    if(r==-1)r=siz;
	    if(r<=a||b<=l)return 0;
	    if(a<=l&&r<=b)return dat[k];
	    int vl=query(a,b,2*k+1,l,(l+r)/2);
	    int vr=query(a,b,2*k+2,(l+r)/2,r);
	    return vl+vr;
    }
};
signed main(){
    int n,q;
    cin>>n>>q;
    Segtree seg(n);
    while(q--){
        int type;
        cin>>type;
        if(type==0){
            int x,y;
            cin>>x>>y;
            seg.update(x-1,y);
        }
        if(type==1){
            int x,y;
            cin>>x>>y;
            cout<<seg.query(x-1,y)<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4916
#include <iostream>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <string>
using namespace std;

int main(){
	
	stack<int> S;
	int a,b,x;
	string s;
	
	while(cin>>s){//何时是终止条件？ 
		if(s[0]=='+'){
			a = S.top();S.pop();
			b = S.top();S.pop();
			S.push(a+b);
		}
		else if(s[0]=='-'){
			a = S.top();S.pop();
//			cout<<"a:"<<a<<endl; 
			b = S.top();S.pop();
//			cout<<"b:"<<b<<endl;
//			cout<<"a-b:"<<(a-b)<<endl;
			S.push(b - a);
		}
		else if(s[0]=='*'){
			a = S.top();S.pop();
			b = S.top();S.pop();
			S.push(a*b);
		}
		else if(s[0]=='/'){
			a = S.top();S.pop();
			b = S.top();S.pop();
			S.push(a/b);
		}
		else{
			S.push(atoi(s.c_str()));//将字符串转换成整型数并入栈 
		}
		if(getchar()=='\n'){
			cout<<S.top()<<endl;
			return 0;
		}			
	}
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

vi v;
int N,L,T;
ll desTot;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> L >> T;
    F0R(i,N) {
        int X,W; cin >> X >> W;
        if (W == 2) W = -1;
        v.pb(((X+T*W)%L+L)%L);
        desTot += X+T*W;
    }
    sort(all(v));
    ll z = 0; for (ll x: v) z += x;
    ll res = (((desTot-z)/L % N) + N) % N;
    
    vl v1 = vl(v.begin(),v.begin()+res);
    vl v2 = vl(v.begin()+res,v.end());
    for (auto a: v1) v2.pb(a+L);
    for (auto a: v2) cout << (a%L+L)%L << "\n";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 3536
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N=0;
        int[] a= new int[100000];
        int[] b= new int[100000];
        int[] ans= new int[100000];
        String[] op= new String[100000];
        for(int i=0;;i++){
            a[i]=sc.nextInt();
            op[i]=sc.next();
            b[i]=sc.nextInt();
            if(op[i].equals("+"))ans[i]=a[i]+b[i];
            else if(op[i].equals("-"))ans[i]=a[i]-b[i];
            else if(op[i].equals("*"))ans[i]=a[i]*b[i];
            else if(op[i].equals("/"))ans[i]=a[i]/b[i];
            else break;
            N++;
        }
        for(int i=0;i<N;i++)System.out.println(ans[i]);
        sc.close();
    }
}


Measured memory_bytes: 27804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1000000000;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main(){
    int h,w;
    cin >> h >> w;
    char s[h][w];
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
        }
    }
    int dist[h][w];
    int mx = 0;
    rep(i,h){
        rep(j,w){
            rep(k,h){
                rep(l,w){
                    dist[k][l] = inf;
                }
            }
            if(s[i][j]== '#') continue;
            dist[i][j] = 0;
            //cout << dist[0][0] <<endl;
            queue<pair<int,int>> q;
            q.push(pair<int,int>(i,j));
            while(!q.empty()){
                pair<int,int> v = q.front(); q.pop();
                for(int k=-1; k<=1; k++){
                    for(int l=-1; l<=1; l++){
                        int p = k*l;
                        if(p == 0 && !(k==0 && l==0) && v.first+k>=0 && v.first+k<h && v.second+l>=0 && v.second+l<w){
                        if(dist[v.first+k][v.second+l] != inf || s[v.first+k][v.second+l] == '#') continue;
                        dist[v.first+k][v.second+l] = dist[v.first][v.second]+1;
                        q.push(pair<int,int>(v.first+k,v.second+l));
                        }
                    }
                }
            }
            if(i==0 && j==0){
                //cout << dist[1][1] <<endl;
            }
            rep(k,h){
                rep(l,w){
                    if(dist[k][l] == inf) continue;
                    mx = max(mx,dist[k][l]);
                }
            }
        }
    }
    cout << mx << endl;
}
    



Measured memory_bytes: 256