akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	k := nextInt()
	a := nextInts(n)
	a = append(a, 0)
	var Sum int
	for i := 0; i < k; i++ {
		Sum += a[i]
	}
	var l, r int
	for i := k; i < n; i++ {
		if a[i] > 0 {
			r += a[i]
		}
	}
	Max := l + r + max(Sum, 0)
	for i := 1; i+k-1 < n; i++ {
		if a[i-1] > 0 {
			l += a[i-1]
		}
		if a[i+k-1] > 0 {
			r -= a[i+k-1]
		}
		Sum += a[i+k-1] - a[i-1]
		Max = max(Max, l+r+max(Sum, 0))
	}
	fmt.Println(Max)
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	log.Println(a)
	for _, b := range a {
		r += b
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 4096
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        s: chars
    }

    let mut ans = 0;

    for i in 0..n {
        ans = cmp::max(ans, z_algorithm(&s[i..]));
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet
fn z_algorithm(s: &[char]) -> usize {
    // sとs[i;|S|]との最長共通接頭辞の長さが入る。
    let mut z = vec![0; s.len()];
    z[0] = s.len();

    let mut i = 1;
    let mut j = 0;
    let mut max = 0;
    while i < s.len() {
        while i + j < s.len() && s[j] == s[i + j] {
            j += 1;
        }
        z[i] = j;
        max = cmp::max(max, cmp::min(z[i], i));

        if j == 0 {
            i += 1;
            continue;
        }

        let mut k = 1;
        while k < j && k + z[k] < j {
            z[i + k] = z[k];
            max = cmp::max(max, cmp::min(z[i + k], i + k));
            k += 1;
        }
        i += k;
        j -= k;
    }

    max
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

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


void solve()
{
    int A, B, C; cin >> A >> B >> C;
    if(B >= A * C) cout << C << endl;
    else cout << B / A << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

using namespace std;

#define int long long
#define LL long long
#define ULL unsigned long long

const int LL_INF = ~(ULL)0 >> 1;

signed main() {
    int m, n, a[102], point[102] = {0};
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
        a[i]--;
    }

    for (int i = 0; i < m; ++i) {
        int count = 0;
        for (int j = 0; j < n; ++j) {
            int temp;
            cin >> temp;
            temp--;
            if (temp == a[i])
                point[j] += 1;
            else
                count++;
        }
        point[a[i]] += count;
    }

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

    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define INF (ll)1e19
#define N 200005

using namespace std;

ll n, a, b, c, d, x, y;

int main() {
    //freopen("txt.in", "r", stdin);
    //freopen("txt.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> a >> b >> c >> d;
    for (int i = 0; i < n; i++) {
        x = i * c - (n - i - 1) * d;
        y = i * d - (n - i - 1) * c;
        if (x <= b - a && b - a <= y) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,X;
    cin >> A >> B >> X;
    if(A+B < X){
        cout << "NO" << endl;
    }
    else if(A > X){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
}

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

int main(){
    string n;
    cin>>n;
    if (n[0]=='7'||n[1]=='7'||n[2]=='7')
    {
        /* code */
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    }

Measured memory_bytes: 3628
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  vector<ll> masks;
  for (ll m = K; m > 0; m &= m - 1) {
    masks.push_back(m - 1);
  }
  masks.push_back(K);
  ll res = 0;
  for (ll m : masks) {
    ll sum = 0;
    for (int i = 0; i < N; i++) {
      if ((A[i] & m) == A[i]) {
        sum += B[i];
      }
    }
    res = max(res, sum);
  }
  cout << res << endl;
  return 0;
}


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

int main()
{
	string s;
	cin >> s;
	vector<int> v(4);
	vector<char> op(3);
	for (int i = 0; i < 4; i++)
	{
		v[i] = s[i] - '0';
	}

	int ans = 0;
	for (int bit = 0; bit < (1 << 3); bit++)
	{
		int ans = v[0];
		for (int i = 0; i < 3; i++)
		{
			if (bit & (1 << i))
			{
				ans += v[i + 1];
				op[i] = '+';
			}
			else
			{
				ans -= v[i + 1];
				op[i] = '-';
			}
		}
		if (ans == 7)
		{
			cout << v[0];
			for (int i = 0; i < 3; i++)
			{
				cout << op[i] << v[i + 1];
			}
			cout << "=7" << '\n';
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Snack
            var line = ReadLine();
            int A = line[0];
            int B = line[1];

            var lib = new Library.Gcd();
            Console.WriteLine(lib.GetLcm(A, B));            
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

namespace Library
{
    public class Gcd
    {
        public long GetGcd(long a, long b)
        {
            //[summary]a,b2つの数の最大公約数を求める
            //Gcd: Greatest Common Divisor
            //以下リンクを参考に実装
            //https://qiita.com/gushwell/items/e9614b4ac2bea3fc6486

            if (a < b)
            {
                //引数を入れ替えて自分を呼び出す
                return GetGcd(b, a);
            }
            else
            {
                while (b > 0)
                {
                    long remainder = a % b;

                    a = b;
                    b = remainder;
                }

                return a;
            }
        }

        public long GetLcm(long a, long b)
        {
            //[summary]a,b2つの数の最小公倍数を求める
            //Lcm: Least Common Multiple
            //以下リンクを参考に実装
            //https://qiita.com/gushwell/items/f08d0e71fa0480dbb396

            long gcd = GetGcd(a, b);

            //先に割り算をしておくとオーバーフローしない
            return a / gcd * b;
        }
    }
}

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

int main() {
  int a, b;
  cin >> a;
  cin >> b;
  int int_avg = (a + b)/2;
  int decimal = int(((a + b)/2.0 - int_avg)*2);
  cout << int_avg + decimal  << endl;
}

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

int main() {
    int cards[4][13] = {};
    int n, a, b;
    char c;

    cin >> n;
    for(int i=0; i<n; i++) {
	cin >> c >> b;
	if(c == 'S') {
	    a = 0;
	} else if(c == 'H') {
	    a = 1;
	} else if(c == 'C') {
	    a = 2;
	} else {
	    a = 3;
	}
	cards[a][b-1]++;
    }

    for(int i=0; i<4; i++) {
	for(int j=0; j<13; j++) {
	    if(cards[i][j] == 0) {
		if(i == 0) {
		    c = 'S';
		} else if(i == 1) {
		    c = 'H';
		} else if(i == 2) {
		    c = 'C';
		} else {
		    c = 'D';
		}
		cout << c << " " << j+1 << endl;
	    }
	}
    }
}

Measured memory_bytes: 1160
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}



func main() {
    let nk = readInts()
    let (n, k) = (nk[0], nk[1])
    var aryA = readInts()
    //__________________________ここまで入力
    aryA.sort()
    
    if k <= n {
        aryA.removeLast(k)
    } else {
        aryA.removeAll()
    }
    
    print(aryA.reduce(0) { $0 + $1 })
}

main()





Measured memory_bytes: 27392
#include <bits/stdc++.h>
typedef long long ll; 
typedef long double ld ; 
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
using namespace std;

 
int main() {
  	
  	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;
 	
 	int n ; 
 	cin >> n ; 
 	int ans = 1^n ; 
 	cout << ans ;
	
 	return 0 ; 
}

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

using namespace std;

long long mod = 1000000007;

long long power(long long n, long long k) {
    long long powered = 1;
    while(k) {
        if(k & 1) {
            powered *= n;
            powered %= mod;
        }
        k >>= 1;
        n = n * n;
        n%=mod;
    }

    return powered;
}
int main()
{
    long long n;
    cin>>n;

    long long a = power(10ll,n);
    long long b = (2 * power(9ll,n)) % mod;
    long long c = power(8ll,n);
    long long answer = (a - b);
    if(answer < 0)answer += mod;
    answer += c;
    answer = answer % mod;
    cout<<answer;
    return 0;
}


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

using namespace std;

void solve(){

    int d, t, s; cin >> d >> t >> s;
    cout << ((double)d / t <= (double)s ? "Yes" : "No");

}

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

	return 0;
}

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

using namespace std;

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

    int n, m;
    priority_queue<int, vector<int>, greater<int>> q;
    priority_queue<pair<int, int>> o;
    cin >> n >> m;

    while (n--) {
        int t;
        cin >> t;
        q.push(t);
    }

    while (m--) {
        int b, c;
        cin >> b >> c;
        o.push({c, b});
    }

    while (!o.empty() && q.top() < o.top().first) {
        int b, c;
        b = o.top().second;
        c = o.top().first;
        o.pop();
        while (b-- && q.top() < c)
            q.pop(), q.push(c);
    }

    long long ans = 0;
    while (!q.empty())
        ans += 1ll * q.top(), q.pop();
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1784
# from https://atcoder.jp/contests/abc122/submissions/4932940


def main():
    n = int(input())
    MOD = 10 ** 9 + 7

    dpa = [0, 0, 1]
    dpc = [0, 0, 1]
    dpg = [0, 0, 1]
    dpt = [0, 0, 1]
    for i in range(2, n + 2):
        total = dpa[i] + dpc[i] + dpg[i] + dpt[i]
        if i == n + 1:
            break
        dpa.append(total)
        dpc.append(total - dpa[i-1] - dpg[i-1] - 3 * dpa[i-2])
        dpg.append(total - dpa[i-1] + dpg[i-2])
        dpt.append(total)
    print(total % MOD)


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

    lol n;
    cin >> n;
    lol a[n + 5],sum[n + 5] = {};
    reps(i, n){
      cin >> a[i];
      sum[a[i]] ++;
    }
    lol ans = 0;
    reps(i, n){
      ans += (sum[i] * (sum[i] - 1)) / 2;
    }
    for(int i = 1;i <= n;i ++){
      lol c = sum[a[i]] * (sum[a[i]] - 1) / 2;
      lol b = (sum[a[i]] - 1) * (sum[a[i]] - 2) / 2;
      cout << ans - c + b  << '\n';
    }
	      
    return 0;
} 


Measured memory_bytes: 5760
a,b,m = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
tmp = min(a) + min(b)
for i in range(m):
    x,y,c = map(int,input().split())
    tmp = min(a[x-1] + b[y-1] - c, tmp)
print(tmp)

Measured memory_bytes: 18488
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    VI l(m), r(m);
    FOR(i, 0, m) {
        cin >> l[i] >> r[i];
        l[i]--;
    }

    VI imos(n, 0);
    FOR(i, 0, m) {
        imos[l[i]]++;
        if (r[i] < n)imos[r[i]]--;
    }
    FOR(i, 1, n)imos[i] += imos[i - 1];

    int ans = 0;
    FOR(i, 0, n)if (imos[i] == m)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define in freopen("input.txt", "r" ,stdin)
#define out freopen("output.txt", "w" , stdout)
#define ll long long
#define inf 200005
#define fr first
#define  sc second
#define pb push_back
#define p_b pop_back
#define mp make_pair
using namespace std;
int n;
int h[100005];
int dp[100005];
int main (){
//in;out;
ios_base::sync_with_stdio(0);
cin >> n;
for (int i = 1;i <= n; i++) {
     cin >> h[i];
}

dp[1] = 0;
dp[2] = abs (h[2] - h[1]);

for (int i = 3; i <= n; i++) {
        int a1 = dp[i-2] + abs (h[i] - h[i-2]);
        int a2 = dp[i-1] + abs (h[i] - h[i-1]);
        dp[i] = min (a1, a2);
}

cout << dp[n];
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num[] = new int[3];
		num[0] = sc.nextInt();
		num[1] = sc.nextInt();
		num[2] = sc.nextInt();
		int a = 0;
		for(int i=0;i<2;i++){
			for(int j=1;i+j<3;j++){
				if(num[i] < num[i+j]){
				}else	{
					a = num[i];
					num[i] = num[i+j];
					num[i+j] = a;
				}
			}
		System.out.print(num[i]+" ");
		}
		System.out.println(num[2]);
	}
}


Measured memory_bytes: 26100
#include<stdio.h>
#include<string.h>

int main(){
	int n,count=0;
	char s[100];
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;i++){
		if(s[i]!=s[n-i-1]) count=1;
	}
	for(int i=0,j=(n-1)/2;i<(n-1)/2;i++,j--){
		if(s[i]!=s[j-1]) count=1;
	}
	for(int i=(n+3)/2,j=n-1;i<n;j--,i++){
		if(s[i]!=s[j-1]) count=1;
	}
	if(count==0)
		puts("Yes");
	else
		puts("No");
	return 0;
	
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>
using namespace std;
bool st(vector<int> v){
  if(
     v[1]+1==v[2]&&
     v[2]+1==v[3]&&
     v[3]+1==v[4]){
    if(v[0]+1==v[1]) return true;
    if(v[0]==1&&v[4]==13) return true;
  }
  return false;
}
int main(){
  string buf;
  int i,j,k;
  while(cin >> buf){
    vector<int> v,p;
    for(i=0;i<buf.size();i++) if(buf[i]==',') buf[i]=' ';
    stringstream ss(buf);
    for(i=0;i<5;i++){
      ss >> k;
      v.push_back(k);
    }
    sort(v.begin(),v.end());
    k=1;
    for(i=1;i<5;i++){
      //cout << v[i] << endl;
      if(v[i-1]==v[i]) k++;
      else {
    p.push_back(k);
    k=1;
      }
    }
    if(k!=1) p.push_back(k);
    sort(p.begin(),p.end(),greater<int>());
    //for(i=0;i<p.size();i++) cout << p[i] << endl;
    if(p[0]==4) cout << "four card" << endl;
    else if(p[0]==3&&p[1]==2) cout << "full house" << endl;
    else if(p[0]==3) cout << "three card" << endl;
    else if(p[0]==2&&p[1]==2) cout << "two pair" << endl;
    else if(p[0]==2) cout << "one pair" << endl;
    else if(st(v)) cout << "straight" << endl;
    else cout << "null" << endl;
  }
 
}


Measured memory_bytes: 3160
import math
 
def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChar():
	return input()

def readChars():
	return input().split()
 
s = readChar()

if s=="ABC":
	print("ARC")
else:
	print("ABC")


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

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

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int w;
  while(cin >> w) {
    if(w == -1) return 0;
    int ans = 0;
    if(w > 30) ans += (w - 30) * 160, w = 30;
    if(w > 20) ans += (w - 20) * 140, w = 20;
    if(w > 10) ans += (w - 10) * 125, w = 10;
    ans += 1150;
    cout << 4280 - ans << endl;
  }
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, N) for(int i = 0; i < int(N); i++)
#define rep1(i, N) for (int i = 1; i <= int(N); i++)
#define fs first
#define sc second
#define pb push_back
#define PB push_back
#define MP make_pair
#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)

int main() {
    int n;
    cin >> n;
    V<int> a(n);
    int sm = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sm += a[i];
        a[i] *= n;
    }
    int md = TEN(9), mi = -1;
    for (int i = 0; i < n; i++) {
        int d = abs(sm - a[i]);
        if (d < md) {
            md = d;
            mi = i;
        }
    }
    cout << mi << endl;
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;

using namespace std; 

#define REP(inc, bgn, end) for (int inc = bgn; inc < end; inc++)

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n), a(n);
    REP(i, 0, n) cin >> p[i];
    REP(i, 0, n) cin >> q[i];

    /* 
    next_permutation()のための順列を作ります。
    この順列は、辞書順で一番小さいものです。
    */
    REP(i, 0, n) a[i] = i + 1;

    /* 
    連想配列に作った順列を格納ていきます。
    構造は以下のようになっています。
    Key: value = [順列]: 辞書順で数えたときの番号
    例) [1, 2, 3]: 1
     */
    map<vector<int>, int> mp;

    do {
        mp[a] = mp.size();
    } while (next_permutation(a.begin(), a.end()));

    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
}

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

class FenwickTree {
public:
  FenwickTree(int n): a(n + 1) {}

  void add(int x, int v) {
    for (int i = x; i < a.size(); i += i & (-i))
      a[i] += v;
  }

  int get_sum(int x) {
    int sum = 0;
    for (int i = x; i > 0; i -= i & (-i))
      sum += a[i];
    return sum;
  }

private:
  vector<int> a;
};

int main() {
  int n;
  scanf("%d", &n);
  string s;
  cin >> s;
  
  vector<FenwickTree> fts(26, FenwickTree(n));
  for (int i = 0; i < n; i++)
    fts[s[i] - 'a'].add(i + 1, 1);
  
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int i;
      char c;
      scanf("%d %c", &i, &c);
      
      fts[s[i - 1] - 'a'].add(i, -1);
      s[i - 1] = c;
      fts[s[i - 1] - 'a'].add(i, 1);
    }
    else {
      int l, r;
      scanf("%d %d", &l, &r);

      int ans = 0;
      for (int j = 0; j < fts.size(); j++) {
        int a = fts[j].get_sum(l - 1);
        int b = fts[j].get_sum(r);
        if (b > a) ans++;
      }
      printf("%d\n", ans);
    }
  }

  return 0;
}

Measured memory_bytes: 53636
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int t=0;
	loop:;
	t=0;
	if(a>b){
		t=t+1;
		swap(a,b);
	}
	if(b>c){
		t=t+1;
		swap(b,c);
	}
	if(t!=0){
		goto loop;
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0 ;
}



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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


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

    vector<ll> h(n+1,0);

    for(ll i=1;i<=n;i++){
        cin>>h.at(i);
    }

    vector<ll> dp(n+1,1000000000);
    dp.at(0)=0;
    dp.at(1)=0;

    for(ll i=2;i<=n;i++){
        for(ll j=1;j<=k;j++){
            if(i-j<=0)break;
            dp.at(i)=min(dp.at(i),dp.at(i-j)+abs(h.at(i)-h.at(i-j)));
        }
    }

    cout<<dp.at(n)<<endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast", "unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

#define MAX (100000)

const ll MOD = 1000000007LL;

signed main() {
	int n, x; cin >> n >> x;
	vector<int> s(n);
	for (int i = 0; i < n; ++i) cin >> s[i];

	// sを降順ソート
	sort(s.begin(), s.end());
	reverse(s.begin(), s.end());

	// dpする
	vector<vector<ll>> dp(n + 1);
	for (int i = 0; i <= n; ++i) dp[i].resize(MAX + 1, 0);
	dp[0][x] = 1;
	for (int i = 1; i <= n; ++i) {
		int si = s[i - 1];
		// siを使う.
		for (int j = 0; j <= MAX; ++j) {
			dp[i][j % si] += dp[i - 1][j];
			dp[i][j % si] %= MOD;
		}
		// siを使わない.
		for (int j = 0; j <= MAX; ++j) {
			dp[i][j] += (n - i) * dp[i - 1][j] % MOD;
			dp[i][j] %= MOD;
		}
	}

	// 答えの計算.
	ll ans = 0LL;
	for (ll i = 0; i <= MAX; ++i) {
		ans += i * dp[n][i];
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}

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

int main()
{
	bool isPrime[1000000];
	int num[1000000];
	memset(isPrime,false,sizeof(isPrime));
	isPrime[0]=isPrime[1]=true;
	for (int i = 2; i < 1000000; i++) {
		if(isPrime[i])
		{
			num[i]=num[i-1];
			continue;
		}

		for(int j=i*2;j<1000000;j+=i)
		{
			isPrime[j]=true;
		}
		num[i]=num[i-1]+1;
	}

	int n;
	while(cin>>n) cout<<num[n]<<endl;
	return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int N = S.size();
  
  string ans = "No";
  
  for (int i = 0; i < N; i++) {
    bool same = true;
    for (int j = 0; j < N; j++) {
      if (S.at(j) != T.at((i + j) % N)) {
        same = false;
      }
    }
    if (same) {
      ans = "Yes";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    even = True if K % 2 == 0 else False
    if even:
        a1 = N//K
        a2 = N//(K//2) - a1
        print(a1**3 + a2**3)
    else:
        print((N//K) ** 3)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38352
MOD = 10**9 + 7


def main():
    # TDPC E or EDPC S
    S = [s for s in input()]
    N = len(S)
    D = int(input())
    dp = [[[0]*D for _ in range(2)] for _ in range(N+1)]
    dp[0][0][0] = 1
    from itertools import product
    for i, smaller, dsum in product(range(N), range(2), range(D)):
        lim = 9 if smaller else int(S[i])
        for d in range(lim+1):
            dp[i+1][smaller or d < lim][(dsum+d) % D] += dp[i][smaller][dsum]
            dp[i+1][smaller or d < lim][(dsum+d) % D] %= MOD
    print((dp[N][0][0] + dp[N][1][0] - 1) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62300
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=[(i+1)/2 for i in p]
s=0
for i in range(k):
  s+=a[i]
m=s
for i in range(k,n):
  s-=a[i-k]
  s+=a[i]
  m=max(m,s)
print(m)

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

int main() {
  double D, T, S; cin >> D >> T >> S;
  if((D / S) <= T) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	ll a[3],k;
	cin >> a[0] >> a[1] >> a[2] >> k;
	int mx = 0;
	for (int i=0;i<3;++i) {
		if (a[i]>a[mx])
			mx = i;
	}
	ll sum = 0;
	for (int i = 0;i<3; ++i) {
		if (i==mx) {
			sum += a[i] * (1<<k);
		} else {
			sum += a[i];
		}
	}

	cout << sum << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
def gcd(x, y):
    a, b = x, y

    while True:
        r = a % b

        if r == 0:
            print(b)
            break

        a, b = b, r

def main():
    a, b = map(int, input().split())

    if a < b:
        a, b = b, a

    gcd(a, b)

main()


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

int main(){
    int n,k;
    cin>>n>>k;
    
    vector<int> a(n), dp(n,-1);
    
    for(int i = 0; i < n; i++) cin>>a[i];
    
    dp[0] = 0;
    
    for(int i = 1; i < n; i++){
        int j = i-1;
        while(j >= 0 && i - j <= k){
            if(dp[i] == -1) dp[i] = dp[j] + abs(a[i]-a[j]);
            else dp[i] = min(dp[i],dp[j] + abs(a[i]-a[j]));
            j--;
        }
    }
    
    cout<<dp[n-1]<<endl;
    
    return 0;

}


Measured memory_bytes: 4028
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;
int n,q;
int a[1000];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	cin>>q;
	for(int i=0;i<q;i++)
	{
		int c,b,e;cin>>c>>b>>e;
		cout<<count(a+c,a+b,e)<<endl;
	}
}


Measured memory_bytes: 3096
n,m = map(int, input().split())
d = m//n
ans = []
for i in range(1,min(d+1,int(m**0.5)+1)):
    if (m % i == 0):
        ans.append(i)
        if (m//i<=d):
            ans.append(m//i)
print(max(ans))

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

const double TAX = 1.08;
int N;

int main() {
	cin >> N;
	int X = (int)(N / TAX);
	if ((int)(X * TAX) <= N) {
		while ((int)(X * TAX) < N) {
			X++;
		}
		if ((int)(X * TAX) > N) {
			cout << ":(" << endl;
		}
		else {
			cout << X << endl;
		}
	}
	else if ((int)(X * TAX) > N) {
		while ((int)(X * TAX) > N) {
			X--;
		}
		if ((int)(X * TAX) < N) {
			cout << ":(" << endl;
		}
		else {
			cout << X << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  vector<i64> cnt(N + 1);
  for (i64 i = 1; i <= N; i++)
    for (i64 j = 1; i * j <= N; j++)
      cnt[i * j]++;
  i64 ans = 0;
  for (i64 i = 1; i <= N; i++)
    ans += cnt[i] * i;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 81360
N = int(input())
l = list()
for n in range(N):
    l.append([int(x) for x in input().split()])
l = sorted(l, key=lambda x:x[1])
sum = [l[0][0]]
for n in range(1,N):
    sum.append(l[n][0]+sum[n-1])
c = True
for n in range(N):
    if sum[n] > l[n][1]:
        c = False
if c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 45832
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vi a(n);
    ll ave = 0LL;
    rep(i, n) {
        cin >> a[i];
        ave += a[i];
    }

    vi ap(n/2), am(n/2);
    ave /= n;
    ll ans = 0LL;

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

    rep(i, n/2) {
        am[i] = a[i];
        ans += 2*ave - 2*a[i];
    }

    reverse(a.begin(), a.end());

    rep(i, n/2) {
        ap[i] = a[i];
        ans += 2*a[i] - 2*ave;
    }

    reverse(am.begin(), am.end());
    reverse(ap.begin(), ap.end());


    ans -= ap[0] - am[0];
    
    if(1&n) {
        ans += max(a[n/2] -am[0], ap[0]-a[n/2]);
    }

    cout << ans << endl;

}

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

using namespace std;

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - a + b) << '\n';
    return 0;
}


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

int main(){
  int N, L;
  cin >> N >> L;
  string str[N];
  for(int i=0; i<N; i++){
    cin >> str[i];
  }
  
  sort(str,str+N);
    
  for(int n=0; n<N; n++){
  cout << str[n];
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long LL;
const int N=4003,M=200005,p=1000000007;
int A[M],B[M],c[N<<1],fc[N<<1],f[N][N],i,j,k,n,m,an,D=2001,X=8000,ni2=p+1>>1;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ char c; int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

void Plus(int &a,int b){ a+=b,a-=a<p?0:p; }
void Minus(int &a,int b){ a-=b,a+=a<0?p:0; }

int power(int z,int k)
{
	int d=1;
	for (;k;z=(LL)z*z%p,k>>=1) if (k&1) d=(LL)d*z%p;
	return d;
}

int C(int n,int m)
{
	return (LL)c[n]*fc[m]%p*fc[n-m]%p; 
}

int main()
{
	//freopen("1.in","r",stdin);
	for (c[0]=i=1;i<=X;++i) c[i]=(LL)c[i-1]*i%p;//printf("%d %d\n",i,c[i]);
	for (fc[X]=power(c[X],p-2),i=X;i;--i) fc[i-1]=(LL)fc[i]*i%p;//printf("%d %d\n",i,fc[i]);
	n=read();
	for (i=1;i<=n;++i) A[i]=read(),B[i]=read(),++f[-A[i]+D][-B[i]+D];
	for (i=1;i<=(D<<1)-1;++i)
		for (j=1;j<=(D<<1)-1;++j)
			Plus(f[i][j],(f[i-1][j]+f[i][j-1])%p);
	for (i=1;i<=n;++i)
		Plus(an,f[A[i]+D][B[i]+D]);
	//printf("%d\n",an);
	for (i=1;i<=n;++i) Minus(an,C(A[i]+B[i]<<1,A[i]<<1));//printf("%d ",C(A[i]+B[i]<<1,A[i]<<1));
	//puts("");
	//printf("%d\n",an);
	printf("%d\n",(LL)an*ni2%p);
	return 0;
}

Measured memory_bytes: 67840
#include<iostream>
#include<cstring>
#include<map>
using namespace std;
const int maxn=1005;
typedef long long ll;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n;
	string s;
	map<string,int>ma;
	cin>>n;
	int ans=0;
	while(n--){
		cin>>s;
		if(!ma[s]){
			ans++;
			ma[s]++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
	int N, m;
	cin >> N >> m;
	vector<int> st(N + 2);
	for (int i = 0, c, d; i < m; i++) {
		cin >> c >> d;
		st[c]++;
		st[d]--;
	}
	int res = N + 1;
	for (int i = 1; i <= N; i++) {
		st[i] += st[i - 1];
		if (st[i]) {
			res += 2;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3100
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 x = b - a;

        int ret = 0;
        while(x > 0){
            ret += x;
            x--;
        }
        ret = ret - b;

        System.out.println(ret);
    }

}


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

int main(){
	
	int a, b, sum;
	sum = a + b;
	int x[114514];
	int n = 0;
	
	
	while(cin >> a >> b){
		
		sum = a + b;
		int z = 0;
		
		while(sum != 0){
			sum = sum / 10;
			z++;
			
		}
		
		x[n] = z;
		n++;	
			
	}
	
	for(int c=0; c<n; c++){
		cout << x[c] << endl;
	}
	
	
	

	return 0;
	
}

Measured memory_bytes: 3004
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = stdin.nextInt();
        int k = stdin.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = stdin.nextInt();

        Map<Integer, Long> counter =  Arrays.stream(a).boxed().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
        List<Long> vals = counter.values().stream().sorted().collect(Collectors.toList());

        int sum = 0;
        for (int i = 0; i < vals.size() - k; i++) {
            sum += vals.get(i);
        }

        System.out.println(sum);
    }

}


Measured memory_bytes: 78508
#include <iostream>
using namespace std;
int main(){
	int ans=0;
	int N=0;
	int M=0;
	int X=0;
	int Y=0;
	int x[101];
	int y[101];
	int i=0;
	int max=0;
	int min=0;
	
	cin>>N>>M>>X>>Y;
	max=-100;
if(max<X)max=X;
	for(i=0;i<N;i++){
		cin>>x[i];
		if(max<x[i])max=x[i];
	}
	min=100;
if(min>Y)min=Y;
	for(i=0;i<M;i++){
		cin>>y[i];
		if(min>y[i])min=y[i];
}

	if(max<min && X<Y){
	cout<<"No War"<<endl;
	}else{
		cout<<"War"<<endl;
	}
}

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

A = []
for _ in range(3):
    A.append([int(x) for x in input().split()])
N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            A[i][j] = 0

flag = 0

for k in A:
    if k[0] == 0 and k[1] == 0 and k[2] == 0:
        flag = 1

for k in range(3):
    flag_2 = 1
    for j in range(3):
        if A[j][k] != 0:
            flag_2 = 0
    if flag_2:
        flag = 1

if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    flag = 1
if A[2][0] == 0 and A[1][1] == 0 and A[2][0] == 0:
    flag = 1

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

template<class T> inline bool chmin(T& a, T b) 
{ if (a > b) { a = b; return true; } return false; }

template<class T> inline bool chmax(T& a, T b) 
{ if (a < b) { a = b; return true; } return false; }

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


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

    print(max(A+B, max(A-B, A*B)));

    return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		keisan();
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0)break;
			else calc(n);
			
		}
	}
	int max = (int)Math.pow(2, 15);
	int m = (int)Math.sqrt(max) +1;
	int[] memo = new int[max + 1]; 
	public void keisan(){
		for(int i = 0; i < m; i++){
			for(int j = i; j < m; j++){
				for(int k = j; k < m; k++){
					for(int h = k; h < m; h++){
						if(i*i + j*j + k*k + h*h > max) break;
						memo[i*i + j*j + k*k + h*h] = memo[i*i + j*j + k*k + h*h] + 1;
					}
				}
			}
		}
	}
	public void calc(int n){
		System.out.println(memo[n]);
	}
	
	

	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main() {
	while(1){
		int n, x;
		cin >> n >> x;
		if(n==0) break;
        int cnt=0;
		for(int i=1; i<n-1; i++){
            for(int j=i+1; j<n; j++){
                if(j<x-(i+j) && x-(i+j)<=n) cnt++;
            }
        }
        cout << cnt << endl;
	}

}



Measured memory_bytes: 3136
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Simple String Queries
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500000;
const int MAX_E2 = 1 << 20; // = 1048576
const int BN = 13;
const int BBITS = 1 << BN;
const int BMSK = BBITS - 1;

/* typedef */

template <typename T, const int MAX_E2>
struct SegTreeBits {
  int n, e2;
  T nodes[MAX_E2];
  SegTreeBits() {}

  void init(int _n) {
    n = _n;
    for (e2 = 1; e2 < n; e2 <<= 1);
  }

  T &get(int i) { return nodes[e2 - 1 + i]; }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;
    while (j > 0) {
      j = (j - 1) / 2;
      nodes[j] = nodes[j * 2 + 1] | nodes[j * 2 + 2];
    }
  }

  void setall() {
    for (int j = e2 - 2; j >= 0; j--)
      nodes[j] = nodes[j * 2 + 1] | nodes[j * 2 + 2];
  }
  
  T or_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return 0;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int im = (i0 + i1) / 2;
    T v0 = or_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = or_range(r0, r1, k * 2 + 2, im, i1);
    return v0 | v1;
  }
  T or_range(int r0, int r1) { return or_range(r0, r1, 0, 0, e2); }
};

/* global variables */

int bnums[BBITS];
char s[MAX_N + 4];
SegTreeBits<int,MAX_E2> st;

/* subroutines */

inline int bitnum(int bits) {
  return bnums[bits >> BN] + bnums[bits & BMSK];
}

/* main */

int main() {
  bnums[0] = 0;
  for (int bits = 1, msb = 1; bits < BBITS; bits++) {
    if ((msb << 1) <= bits) msb <<= 1;
    bnums[bits] = bnums[bits ^ msb] + 1;
  }

  int n, q;
  scanf("%d%s%d", &n, s, &q);

  st.init(n);
  for (int i = 0; i < n; i++)
    st.set(i, 1 << (s[i] - 'a'));
  st.setall();

  while (q--) {
    int t;
    scanf("%d", &t);

    if (t == 1) {
      int p;
      char c[4];
      scanf("%d%s", &p, c);
      p--;
      st.set(p, 1 << (c[0] - 'a'));
    }
    else {
      int l, r;
      scanf("%d%d", &l, &r);
      l--;
      printf("%d\n", bitnum(st.or_range(l, r)));
    }
  }
  return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
 
const int MAXL = 128;
const int Q = 850;
 
int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	const string chars = 
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
		"abcdefghijklmnopqrstuvwxyz"
		"0123456789";
	assert(chars.size() == 62);
 
	const bool testing = false;
	string test_ans;
	if (testing) {
		mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
		//int L = uniform_int_distribution<int>(1, MAXL)(mt);
		int L = MAXL-1;
		for (int i = 0; i < L; i++) {
			test_ans += chars[uniform_int_distribution<int>(0, 61)(mt)];
		}
	}
	int query_cnt = 0;
	auto query = [&](string q) -> int {
		query_cnt++;
		cout << '?' << ' ' << q << '\n' << flush;
		int v;
		cin >> v;
		return v;
	};
	auto get_cnt = [&](char c) -> int {
		if (testing) {
			query_cnt++;
			int res = 0;
			for (char v : test_ans) {
				res += v == c;
			}
			return res;
		}
		return MAXL - query(string(MAXL, c));
	};
	vector<int> cnts(62);
	int L = 0;
	for (int i = 0; i < 62; i++) {
		cnts[i] = get_cnt(chars[i]);
		L += cnts[i];
	}
	auto is_subseq = [&](string q) -> int {
		assert(int(q.size()) <= L);
		if (testing) {
			query_cnt++;
			int i = 0;
			for (char c : test_ans) {
				if (c == q[i]) {
					i++;
					if (i == int(q.size())) return true;
				}
			}
			return false;
		} else {
			return query(q) == L - int(q.size());
		}
	};
	auto combine = [&](const string& a, const string& b) -> string {
		string res;
		int ia = 0, ib = 0;
		while (ia < int(a.size()) && ib < int(b.size())) {
			if (is_subseq(a.substr(0, ia+1) + b.substr(ib))) {
				res += a[ia++];
			} else {
				res += b[ib++];
			}
		}
		while (ia < int(a.size())) res += a[ia++];
		while (ib < int(b.size())) res += b[ib++];
		return res;
	};
	function<string(int , int)> solve = [&](int lx, int rx) {
		if (lx + 1 == rx) {
			return string(cnts[lx], chars[lx]);
		} else {
			return combine(solve(lx, (lx + rx) / 2), solve((lx + rx) / 2, rx));
		}
	};
	string ans = solve(0, 62);
	assert(query_cnt <= Q);
	if (testing) {
		assert(ans == test_ans);
	}
	cout << '!' << ' ' << ans << '\n';
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  char c;
  cin >> c;
  if(c == 'A') {cout << "A" << endl; return 0;}
  else if(c == 'B') {cout << "A" << endl; return 0;}
  else if(c == 'C') {cout << "A" << endl; return 0;}
  else if(c == 'D') {cout << "A" << endl; return 0;}
  else if(c == 'E') {cout << "A" << endl; return 0;}
  else if(c == 'F') {cout << "A" << endl; return 0;}
  else if(c == 'G') {cout << "A" << endl; return 0;}
  else if(c == 'H') {cout << "A" << endl; return 0;}
  else if(c == 'I') {cout << "A" << endl; return 0;}
  else if(c == 'J') {cout << "A" << endl; return 0;}
  else if(c == 'K') {cout << "A" << endl; return 0;}
  else if(c == 'L') {cout << "A" << endl; return 0;}
  else if(c == 'M') {cout << "A" << endl; return 0;}
  else if(c == 'N') {cout << "A" << endl; return 0;}
  else if(c == 'O') {cout << "A" << endl; return 0;}
  else if(c == 'P') {cout << "A" << endl; return 0;}
  else if(c == 'Q') {cout << "A" << endl; return 0;}
  else if(c == 'R') {cout << "A" << endl; return 0;}
  else if(c == 'S') {cout << "A" << endl; return 0;}
  else if(c == 'T') {cout << "A" << endl; return 0;}
  else if(c == 'U') {cout << "A" << endl; return 0;}
  else if(c == 'V') {cout << "A" << endl; return 0;}
  else if(c == 'W') {cout << "A" << endl; return 0;}
  else if(c == 'X') {cout << "A" << endl; return 0;}
  else if(c == 'Y') {cout << "A" << endl; return 0;}
  else if(c == 'Z') {cout << "A" << endl; return 0;}
  else cout << "a" << endl; return 0;
}

Measured memory_bytes: 3580
import java.util.*;
public class Main{
	static boolean PostNumCheck(String s, int p, int q){
		if(s.charAt(p)!='-')return false;
		for(int i=0; i<p; i++){
			if(s.charAt(i)=='-')return false;
		}
		for(int i=p+1; i<p+q+1; i++){
			if(s.charAt(i)=='-')return false;
		}
		return true;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String S = sc.next();
		System.out.println(PostNumCheck(S, a, b)==true ? "Yes" : "No");
	}
}

Measured memory_bytes: 23764
/*
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B&lang=jp
?????????: Getting Started - Greatest Common Divisor
?????°
7/5
14:17 Online Programming Lesson???????????¢????????????????????£??????????????????2
14:21 ????????????
*/
#include <iostream>
using namespace std;

long long gcd(long long a, long long b)
{
	if(a == 0){
		return b;
	}
	if(b == 0){
		return a;
	}
	if(a == 1 || b == 1){
		return 1;
	}
	if(a>=b){return gcd(a%b,b);}else{return gcd(b,a);}
}

int main()
{
	long long x,y;
	cin >> x >> y;
	cout << gcd(x,y) << endl;
}

Measured memory_bytes: 3064
#include <iostream>

int solve(int a, std::string str, int k){
    int m = str[str.length()-a] - '0';
    if(a < k) return 0;
    if(!m) return solve(a-1, str, k);
    switch (k) {
    case 1:
        return m + 9*(a-1); break;
    case 2:
        return (m-1)*(a-1)*9 + (a-1)*(a-2)/2*81 + solve(a-1, str, 1); break;
    case 3:
        return (m-1)*(a-1)*(a-2)/2*81 + (a-1)*(a-2)*(a-3)/6*729 + solve(a-1, str, 2); break;
    }
}

int main(int argc, char *argv[])
{
    std::string s;
    int k;
    std::cin >> s >> k;
    std::cout << solve(s.length(), s, k) << std::endl;
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  for(int i=0;i<n;i++){
    if(A[i]%2==0){
      if(A[i]%3!=0&&A[i]%5!=0){
        cout << "DENIED";
        return 0;
      }
    }
  }
  cout << "APPROVED";
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int maxl=1e5+5;
int len;char a[maxl],b[maxl];
int main(){
	#ifdef local
	freopen("data.in","r",stdin),freopen("data.out","w",stdout);
	#endif
	scanf("%s",a);len=strlen(a);
	for(int i=0;i<len;++i)
	  switch(a[i]){
	  	case 'b':b[i]='d';break;
	  	case 'd':b[i]='b';break;
	  	case 'p':b[i]='q';break;
	  	case 'q':b[i]='p';break;
	  }
	for(int i=0;i<len;++i)
	  if(a[i]^b[len-i-1]) return printf("No\n"),0;
	return printf("Yes\n"),0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
	int n,m;
	int a[100],sum=0,num=0;
	
	cin >> n >> m;
	
	for(int i=0;i<n;i++){
		cin >> a[i], sum+=a[i];
	}
	
	for(int i=0;i<n;i++){
		if(a[i]*4*m>=sum){
			num++;
		}
	}
	
	cout << (num>=m ? "Yes":"No") << endl;
	
	return 0;
}
	
			

Measured memory_bytes: 256