akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int r, d;
  vll x(11);
  scan(r, d, x[0]);
  rep (i, 10) {
    x[i+1] = x[i] * r - d;
    print(x[i+1]);
  }
  return 0;
}


Measured memory_bytes: 760
/**
 *    author: apurba_debnath
**/
#include <bits/stdc++.h>


#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


using namespace std;

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

    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2;

    return 0;
}


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

using namespace std;

int n, x;
int a[2222];
int b[2222][2222];

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d",&n,&x);
	for(int i = 1; i <= n; ++i) scanf("%d",&a[i]);
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			int d;
			if (j <= i) d = i - j;
			else d = n - (j - i);
			b[i][d] = a[j];
		}
	}
	long long an = 1e18;
	for(int i = 0; i < n; ++i){
		long long tmp = 0;
		for(int j = 1; j <= n; ++j){
			if (i) b[j][i] = min(b[j][i], b[j][i - 1]);
			tmp += b[j][i];
		}
		an = min(an, tmp + 1ll * x * i);
	}
	printf("%lld",an);
	return 0;
}

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

int main(){
    int r,c;
    int matrix[101][101]={};
    cin>>r>>c;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin>>matrix[i][j];
            matrix[i][c]+=matrix[i][j];
            matrix[r][j]+=matrix[i][j];
            matrix[r][c]+=matrix[i][j];
        }

    }
    for(int k=0;k<=r;k++){
        for(int l=0;l<c;l++){
            cout<<matrix[k][l]<<" ";
        }
        cout<<matrix[k][c]<<endl;
    }
}


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

int main(){
        int dp[200][200];
	int r,c;
	cin>>r>>c;
	for(int i=0;i<=r;i++)
		dp[i][c]=0;
	for(int i=0;i<c;i++)
		dp[r][i]=0;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>dp[i][j];
			dp[i][c]+=dp[i][j];
			dp[r][j]+=dp[i][j];
			dp[r][c]+=dp[i][j];
		}
	}
	for(int i=0;i<=r;i++){
		for(int j=0;j<c;j++)
			cout<<dp[i][j]<<" ";
		cout<<dp[i][c]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 2000000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int n,a,b;
int h[100000];
int check(ll t){
	int i,d=a-b;
	ll k=b*t;
	FOR(i,0,n){
		if(h[i]>k){
			t-=((h[i]-k+d-1)/d);
		}
	}
	return t>=0;
}
int main(void)
{
	int i;
	ll l=0,r=INF,mid;
	scanf("%d%d%d",&n,&a,&b);
	FOR(i,0,n) scanf("%d",&h[i]);
	while(r>l){
		mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
    int p,q,r;
    int a,b,c;

    scanf("%d %d %d", &p , &q , &r);
    a = p + q;
    b = q + r;
    c = r + p;

    if(a <= b && a <= c){
        printf("%d\n",a);
    }else if(b <= a && b <= c){
        printf("%d\n",b);
    }else if(c <= a && c <= b){
        printf("%d\n",c);
    }  
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll X, Y;
    cin >> X >> Y;

    int ans = 0;
    ll c = 1;
    while(X * c <= Y) {
        ++ans;
        c *= 2;
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int K, A, B;
	cin >> K >> A >> B;
	string ans = "NG";

		rep2 (i, A, B+1)
		{
			if (i % K == 0)
			{
				ans = "OK";
				break;
			}
		}


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


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC110B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = RInt;
            var m = RInt;
            var x = RInt;
            var y = RInt;
            var xs = RInts;
            var ys = RInts;

            bool ans = false;
            for (int i = x + 1; i <= y; i++)
            {
                if (xs.Max() < i && i <= ys.Min()) ans = true;
            }

            if (ans) Console.WriteLine("No War");
            else Console.WriteLine("War");

        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    let m: u64 = read();
    let mut ac: Vec<bool> = (0..n).map(|_| false).collect();
    let mut wa: Vec<u64> = (0..n).map(|_| 0).collect();
    let a: Vec<(usize, bool)> = (0..m).map(|_| (read::<usize>() - 1, read::<String>() == String::from("AC"))).collect();
    for &(id, is_ac) in &a {
        if is_ac {
            ac[id] = true;
        } else if !ac[id] {
            wa[id] += 1;
        }
    }

    for i in 0..n {
        if !ac[i] {
            wa[i] = 0;
        }
    }

    let ac_n: u64 = (&ac).into_iter().fold(0, |s, i| if *i { s + 1 } else { s });
    let wa_n: u64 = (&wa).into_iter().fold(0, |s, i| s + *i);
    println!("{} {}", ac_n, wa_n);
}


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

int main() {
  int Q;
  cin >> Q;
  vector<vector<int>> vec(Q, vector<int>(2));
  int min_Q = 100000;
  int max_Q = 0;
  for(int i=0; i<Q; i++){
    for(int j=0; j<2; j++){
      cin >> vec.at(i).at(j);
    }
    min_Q = min(min_Q, vec.at(i).at(0));
    max_Q = max(max_Q, vec.at(i).at(1));
  }
  
  if(min_Q %2 == 0){
    min_Q++;
  }
  if(min_Q == 1){
    min_Q = 3;
  }
  
  vector<int> similar(0);
  for(int i=min_Q; i<=max_Q; i += 2){
    bool sosu = true;
    int x = (i+1)/2;
    for(int j=2; j*j <=i; j++){
      if(i %j == 0){
        sosu = false;
      }
      if(x %j == 0){
        sosu = false;
      }
    }
    if(sosu == true){
      similar.push_back(i);
    }
  }
  
  vector<int> ans(max_Q+1);
  int a = 0;
  int sum = 0;
  for(int i=0; i<max_Q+1; i++){
    if(i != similar.at(a)){
      ans.at(i) = sum;
    }
    else{
      sum++;
      if(a < similar.size()-1){
        a++;
      }
      ans.at(i) = sum;
    }
  }
  
  
  
  for(int i=0; i<Q; i++){
    int p = vec.at(i).at(0);
    int q = vec.at(i).at(1);
    if(p == q && p == 1){
      cout << 0 << endl;
    }
    else if(p == q){
      cout << ans.at(p) - ans.at(p-1) << endl;
    }
    else{  
      cout << ans.at(q) - ans.at(p-1) << endl;
    }
  }
  
}

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


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

    dic = {}
    for i in a:
        dic[i] = dic.get(i, 0) + 1

    a.sort(reverse=True)

    ans = 0
    for i in a:
        if i not in dic:
            continue
        dic[i] -= 1
        if not dic[i]:
            del dic[i]

        j, cnt = i, 1
        while j:
            j >>= 1
            cnt *= 2

        num = cnt - i
        if num in dic:
            dic[num] -= 1
            ans += 1
            if not dic[num]:
                del dic[num]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 113400
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var s = rstr();
        if(s[0] == s[1] && s[1] == s[2])
        {
            Write("No");
            return;
        }
        Write("Yes");
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 25788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n, y; cin >> n >> y;
	for(ll i = 0; i <= n; i++){
		for(ll j = 0; i + j <= n; j++){
			if(1000 * i + 5000 * j + 10000 * (n - i - j) == y){
				cout << n - i - j << " " << j << " " << i << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
# numbers = input('')

# first_numbers = int(numbers[0] + numbers[1])
# second_numbers = int(numbers[2] + numbers[3])

# if first_numbers > 12 and second_numbers > 12:
#   print('NA')
# elif first_numbers > 12:
#   if second_numbers == 0:
#     print('NA') 
#   else:
#     print('YYMM') 
# elif second_numbers > 12:
#   if first_numbers == 0: 
#     print('NA') 
#   else:
#     print('MMYY')
# else:
#   print('AMBIGUOUS')

s = input()

s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])

if 0<s1<13 and 0<s2<13:
    print("AMBIGUOUS")

elif not(0<s1<13) and 0<s2<13:
    print("YYMM")

elif 0<s1<13 and not(0<s2<13):
    print("MMYY")

else:
    print("NA")


Measured memory_bytes: 3060
n=int(input())
d={}
for i in range(n):
    s=input()
    try:
        if d[s]>0:
            d[s]+=1
    except:
        d[s]=1
l=[]
maxi=-1
for i in d:
    if d[i]>maxi:
        maxi=d[i]
for i in d:
    if d[i]==maxi:
        l.append(i)
l.sort()
for i in l:
    print(i)


Measured memory_bytes: 92456
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
}

typedef long long ll;
const ll MOD = 1e9 + 7;
const int N = 2e5 + 1, M = 1e6, OO = 0x3f3f3f3f;
ll arr[N];
int main()
{
  int n,k;
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;++i) scanf("%lld",arr+i);
  sort(arr,arr+n);
  ll ans = 0;
  for(int i=n-1-k;i>=0;--i)  ans+=arr[i];
  printf("%lld\n",ans);
  
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0;
}

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

using namespace std;

typedef long long ll;

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

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

    int ans = -1;
    for (int x = 1; x <= 5050; x++) {
        if (x * 8 / 100 == a && x * 10 / 100 == b) {
            ans = x;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())


def point(hand):
    if hand == "r":
        return p
    elif hand == "s":
        return r
    elif hand == "p":
        return s


score = 0
for i in range(n):
    if i < k:
        score += point(t[i])
    elif k <= i and i+k < n:
        if t[i] == t[i-k] and t[i] == t[i+k]:
            if t[i-k] != "r":
                t[i] = "r"
            elif t[i-k] != "s":
                t[i] = "s"
            elif t[i-k] != "p":
                t[i] = "p"
        elif t[i] == t[i-k] and t[i] != t[i+k]:
            if t[i-k] != "r" and t[i+k] != "r":
                t[i] = "r"
            elif t[i-k] != "s" and t[i+k] != "s":
                t[i] = "s"
            elif t[i-k] != "p" and t[i+k] != "p":
                t[i] = "p"
        else:
            score += point(t[i])
    else:
        if t[i] == t[i-k]:
            if t[i-k] != "r":
                t[i] = "r"
            elif t[i-k] != "s":
                t[i] = "s"
            elif t[i-k] != "p":
                t[i] = "p"
        else:
            score += point(t[i])
print(score)


Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
int n,ma,mb,a[45],b[45],k[45],kk=1,mn=1e9;
int arr[405][405];
bool su[405][405];
int main(){
	memset(su,0,sizeof su);
	su[0][0]=1;
	scanf("%d%d%d",&n,&ma,&mb);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a[i-1],&b[i-1],&k[i-1]);
	}
	for(int i=0;i<=400;i++){
		for(int j=0;j<=400;j++){
			arr[i][j]=1e9;
		}
	}
	arr[0][0]=0;
	for(int c=1;c<=n;c++){
		for(int i=400;i>=0;i--){
			for(int j=400;j>=0;j--){
				if(su[i][j]==1){
					su[i+a[c-1]][j+b[c-1]]=1;
					arr[i+a[c-1]][j+b[c-1]]=min(arr[i+a[c-1]][j+b[c-1]],arr[i][j]+k[c-1]);
				}
			}
		}
	}
	while(1){
		//printf("%d %d\n",ma*kk,mb*kk);
		if(ma*kk>400||mb*kk>400)break;
		if(arr[ma*kk][mb*kk]!=1e9){
			mn=min(mn,arr[ma*kk][mb*kk]);
		}
		++kk;
	}
	if(mn==1e9){
		printf("-1");
	}else printf("%d",mn);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#define ll long long
using namespace std;

ll mod=1000000007;

int main() {
	int N;
	string S;
	cin >> N >> S;
	if(S[0]=='W' || S[N*2-1]=='W'){
	    cout << 0 << endl;
	    return 0;
	}
	vector<int> v(N*2, 1);
	ll ans=1, now=1;
	for(int i=1; i<N*2; ++i){
	    if(S[i-1]==S[i]) v[i]=-v[i-1];
	    else v[i]=v[i-1];
	    if(v[i]<0){
	        if(now==0){
	            cout << 0 << endl;
	            return 0;
	        }
	        ans=(ans*now)%mod;
	    }
	    now += v[i];
	}
	if(now!=0){
	    cout << 0 << endl;
	    return 0;
	}
	for(int i=1; i<=N; ++i) ans=(ans*i)%mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1412
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
 while(1){
     int m,f,r;
     cin>>m>>f>>r;
     if(m==-1&&f==-1&&r==-1){
         break;
     }
     else if(m==-1||f==-1||m+f<30){
         cout<<"F"<<endl;
     }
     else if(m+f>=80){
         cout<<"A"<<endl;
     }
     else if(m+f>=65){
         cout<<"B"<<endl;
     }
     else if(m+f>=50||r>=50){
         cout<<"C"<<endl;
     }
     else if(m+f>=30){
         cout<<"D"<<endl;
     }
 }   
}



Measured memory_bytes: 3084
import numpy as np
A=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
b=[int(input()) for _ in range(N)]
B=np.zeros((3,3))
for i in range(3):
  for j in range(3):
    for k in range(N):
      if A[i][j]==b[k]:
        B[i][j]=1
flag=False

for i in range(3):
  if B[i][0]==1 and B[i][1]==1 and B[i][2]==1:
    flag=True
  elif B[0][i]==1 and B[1][i]==1 and B[2][i]==1:
    flag=True
  elif B[0][0]==1 and B[1][1]==1 and B[2][2]==1:
    flag=True
  elif B[2][0]==1 and B[1][1]==1 and B[0][2]==1:
    flag=True
if flag==True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 12492
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	bs := make([]int, n)

	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	for i := range as {
		s.Scan()
		as[i], _ = strconv.Atoi(s.Text())
		s.Scan()
		bs[i], _ = strconv.Atoi(s.Text())
	}
	sort.Sort(sort.IntSlice(as))
	sort.Sort(sort.IntSlice(bs))
	if n%2 == 0 {
		fmt.Println((bs[n/2-1] + bs[n/2]) - (as[n/2-1] + as[n/2]) + 1)
	} else {
		fmt.Println(bs[(n-1)/2] - as[(n-1)/2] + 1)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 8432
from math import gcd
def main():
    K = int(input())
    r = 0
    l = {}
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                x = gcd(i,j)
                x = gcd(x,k)
                r += x
    return r
print(main())


Measured memory_bytes: 67540
def resolve():
    import sys

    input = lambda: sys.stdin.readline().rstrip()

    n = input()
    c = n[-1]
    if c in ["2", "4", "5", "7", "9"]:
        print("hon")
    elif c in ["0", "1", "6", "8"]:
        print("pon")
    else:
        print("bon")
        


resolve()

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

const int maxn = 3e3;
const int mod = 1e9 + 7;
const int maxdimsum = 2e5;
ll pw(ll x, ll y) {
  ll cur = x;
  ll ans = 1;
  while (y > 0) {
    if (y % 2 == 1) ans = (ans * cur) % mod;
    cur = (cur * cur) % mod;
    y /= 2;
  }
  return ans;
}
ll fact[maxdimsum + 10], invfact[maxdimsum + 10];
int h, w, n;
int r[maxn + 10], c[maxn + 10];
ll dp[maxn + 10];

ll mul(ll x, ll y) {
  return (x * y) % mod;
}
ll choose(int n, int k) {
  return mul(fact[n], mul(invfact[k], invfact[n - k]));
}
ll paths(int x, int y) {
  return choose(x + y, x);
}
ll find(int i) {
  if (dp[i] == -1) {
    dp[i] = paths(h - r[i], w - c[i]);
    for (int j = 1; j <= n; j++) {
      if (j == i) continue;
      if (r[i] <= r[j] && c[i] <= c[j]) {
        dp[i] = (dp[i] - mul(paths(r[j] - r[i], c[j] - c[i]), find(j)) + mod) % mod;
      }
    }
  }
  return dp[i];
}

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

  cin >> h >> w >> n;
  for (int i = 1; i <= n; i++) {
    cin >> r[i] >> c[i];
  }
  r[0] = c[0] = 1;
  invfact[0] = fact[0] = 1;
  for (int i = 1; i <= maxdimsum; i++) {
    fact[i] = mul(i, fact[i - 1]);
    invfact[i] = pw(fact[i], mod - 2);
  }
  memset(dp, -1, sizeof(dp));
  cout << find(0) << '\n';

  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == '1') ++counter;
  if (s[1] == '1') ++counter;
  if (s[2] == '1') ++counter;
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int N;
  int tmp, sum = 0;
  scanf("%d", &N);
  tmp = N;
  while(tmp) {
    sum += tmp % 10;
    tmp /= 10;
  }
  if(N % sum == 0) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}
  

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

int main(){
  double n, ans;
  cin >> n;
  ans=(n-floor(n/2))/n;
  printf("%.6lf", ans);

  return 0;
}

Measured memory_bytes: 3756
#include <stdio.h>
#include <unordered_map>

using namespace std;

#define N 110000

typedef long long ll;

ll a[N], pre[N];

int main() {
    unordered_map<ll, ll> ma;
    ll n, m; scanf("%lld%lld", &n, &m);
    ll sum = 0, tot = 0; pre[0] = 0;
    for (ll i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]);
        pre[i] = (pre[i - 1] + a[i]) % m;
    }
    for (int i = 0; i <= n; ++i) {
        if (ma[pre[i]]) sum += ma[pre[i]];
        ma[pre[i]]++;
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 5536
using System;

namespace ConsoleApplication24
{
    class Program
    {
        static void Main(string[] args)
        {
            string alpha = "abcdefghijklmnopqrstuvwxyz";
            int[] Sum = new int[alpha.Length];
            while (true)
            {
                string input = Console.ReadLine();
                if (input == null || input.Length == 0)
                {
                    break;
                }
                else
                {
                    for (int i = 0; i < input.Length; i++)
                    {
                        for (int j = 0; j < alpha.Length; j++)
                        {
                            input = input.ToLower();
                            if ('a' <= input[i] && input[i] <= 'z')
                            {
                                if (input[i] == alpha[j])
                                    Sum[j] = Sum[j] + 1;
                            }
                         }
                     }
                 }
                
            }
            for (int k = 0; k < alpha.Length; k++)
            {
                Console.WriteLine(alpha[k] + " : " + Sum[k]);
            }
        }
    }
}

Measured memory_bytes: 9236
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 
 =================================================================
 
 解説=============================================================
 
 ================================================================
 */
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll A,B; cin >> A >> B;
    ll cA = 0, cB = 0;
    ll h = 0,w = 0;
    if(A == 0){
        cout << 1 << " " << 1 << endl;
        cout << "#" << endl;
        return 0;
    }
    if(B == 0){
        cout << 1 << " " << 1 << endl;
        cout << "." << endl;
        return 0;
    }
    vector<vector<char>> masu(110,vector<char>(110,'.'));
    for(int i = 0; i < 50;i++){
        for(int j = 0; j < 100;j++){
            masu[i][j] = '.';
        }
    }
    for(int i = 50; i < 100;i++){
        for(int j = 0; j < 100;j++){
            masu[i][j] = '#';
        }
    }
    A--; B--;
    [&]{
        for(int i = 0; i < 25;i++){
            for(int j = 0; j < 100; j+=2){
                if(B!=0){
                    B--;
                    masu[2*i][j] = '#';
                }else{
                    return;
                }
            }
        }
    }();
    [&]{
        for(int i = 0; i < 25;i++){
            for(int j = 0; j < 100; j += 2){
                if(A!=0){
                    A--;
                    masu[2*i+51][j] = '.';
                }else{
                    return;
                }
            }
        }
    }();
    cout << 100 << " " << 100 <<endl;
    for(int i = 0;i  < 100;i++){
        for(int j = 0; j < 100;j++){
            cout << masu[i][j];
        }
        cout << endl;
    }
    return 0;
}



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

int N, Q;
string s;
vector<string> t, d;

bool vanish(int n, int m){
    // 初期位置 n のゴーレムが消えるか否かを判定。
    //  m=0：左で消えるとき true, それ以外のときfalse
    //  m=1：右で消えるとき true, それ以外のときfalse

    int x = n-1;  // 文字列 s は 0-indexed なので調整する
    int L = s.length();
    for(int i=0; i<Q; i++){
        if(t[i][0]==s[x]){
            x += (d[i][0]=='R'?1:-1);
            if(x==-1 || x==L) break;
        }
    }

    if(x==-1 && m==0){
        return true;
    }else if(x==L && m==1){
        return true;
    }else{
        return false;
    }
}

int main(){    
    cin >> N >> Q >> s;
    t = vector<string>(Q);
    d = vector<string>(Q);
    for(int i=0; i<Q; i++) cin >> t[i] >> d[i];

    // 左で消えるゴーレムの境界を求める
    int l1 = 0, r1 = N+1;    
    int Lleft = 0, Lright = N+1;
    while(r1 - l1 > 1){
        int mid = l1 + (r1 - l1)/2;
        if(vanish(mid, 0)){
            l1 = mid;
        }else{
            r1 = mid;
        }
    }

    // 右で消えるゴーレムの境界を求める
    int l2 = 0, r2 = N+1;
    while(r2 - l2 > 1){
        int mid = l2 + (r2 - l2)/2;
        if(vanish(mid, 1)){
            r2 = mid;
        }else{
            l2 = mid;
        }
    }
    
    if(l2 >= r1){
        cout << l2 - r1 + 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


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

int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
            sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

const int maxN = 1e5; int n, k;
char s[maxN + 1];
int lt[maxN + 1], rt[maxN + 1], rem[maxN + 1];

int binarySearch(int sum[], int i, int lo, int hi = n - 1)
{
  while (lo < hi)
  {
    int mid = ((lo + hi) >> 1) + ((lo + hi) & 1);
    if (sum[mid] - sum[i] <= k) lo = mid;
    else hi = mid - 1;
  }
  return lo;
}

int main()
{
  while (scanf("%d %d\n%s", &n, &k, s) != EOF)
  {
    memset(lt, 0, sizeof(lt)), memset(rt, 0, sizeof(rt)), memset(rem, 0, sizeof(rem));
    for (int i = 0; i < n; i ++)
    {
      lt[i + 1] = lt[i];
      rt[i + 1] = rt[i];
      rem[i + 1] = rem[i];
      if (i + 1 < n && s[i] == 'L' && s[i + 1] == 'R')
        lt[i + 1] ++;
      if (i + 1 < n && s[i] == 'R' && s[i + 1] == 'L')
        rt[i + 1] ++;
      if (i + 1 < n && s[i] == s[i + 1])
        rem[i + 1] ++;
    }

    // for (int i = 0; i <= n; i ++)
    //   printf("%d%c", lt[i], i < n ? ' ' : '\n');
    // for (int i = 0; i <= n; i ++)
    //   printf("%d%c", rt[i], i < n ? ' ' : '\n');

    int ans = 0;
    for (int i = 0; i < n; i ++)
    {
      int j = binarySearch(s[i] == 'L' ? lt : rt, i, i);
      ans = max(ans, j - i + rem[i] + (rem[n] - rem[j]));
    }
    printf("%d\n", ans);
  }

  return(0);
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define LL long long
using namespace std;
int N, K;
LL T[100010];
LL ans;
priority_queue<LL> pq;
int main(){
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> T[i];
		if(i > 0) pq.push(T[i] - T[i - 1] - 1);
	}
	ans = T[N - 1] - T[0] + 1;
	for(int i = 0; i < K - 1; i++){
		ans -= pq.top();
		pq.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4684
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define cin_desync()                      \
	do {                                  \
		ios_base::sync_with_stdio(false); \
		cin.tie(0);                       \
	} while (0)                           \

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

int v[3][2];

int main()
{
    int hit[5] = {0};
    for (int i = 0; i < 3; ++i) {
        cin >> v[i][0] >> v[i][1];
        hit[v[i][0]] += 1;
        hit[v[i][1]] += 1;
    }

    for (int i = 1; i <= 4; ++i) {
        if (!hit[i] || hit[i] > 2) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int max(vector < vector<unsigned int>> ab, unsigned int  n) {
	unsigned int max = ab.at(0).at(0);

	for (unsigned int i = 1; i < n; i++) {
		if (max <= ab.at(0).at(i)) {
			max = ab.at(0).at(i);
		}
	}
	return max;
}

int main() {
	unsigned int n;
	cin >> n;
	vector<vector<unsigned int>>ab(2, vector<unsigned int>(n));
	for (unsigned int i = 0; i < n; i++) {
		cin >> ab.at(0).at(i) >> ab.at(1).at(i);
	}
	unsigned int k=0;
	unsigned int m = max(ab, n);
	for (unsigned int i = 0; i < n; i++) {
		if (ab.at(0).at(i) == m)k = i;
	}
		cout << m + ab.at(1).at(k) << endl;
	
}


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

 int main()
 {
     string s;
     int c;


    cin>>s;

     if(s == "RRS" || s == "SRR"){
        c = 2;
     }
     else if(s == "SRR"){
        c = 2;
     }
     else if( s == "SSS"){
        c = 0;
     }
     else if(s == "RRR"){
        c = 3;
     }
     else if(s == "RSR" || s == "SRS" || s =="RSS" || s == "SSR"){
        c = 1;
     }

     cout<<c<<endl;

     return 0;
 }


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

int main(){
    int N, M;
    cin >> N >> M;
    int used[N];
    fill(used, used + N, 0);
    for(int i = 0; i < M; i++){
        int start, goal;
        cin >> start >> goal;
        used[start - 1]++;
        used[goal - 1]++;
    }
    for(int i = 0; i < N; i++){
        if(used[i] % 2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


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

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  int A,B;
  cin>>A>>B;
  cout<<max(A+B,max(A-B,A*B))<<endl;
}


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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int health1, power1;
  int health2, power2;

  cin >> health1 >> power1 >> health2 >> power2;

  int turn = 1;
  while (health1 > 0 && health2 > 0) {
    if (turn) {
      health2 -= power1;
    } else {
      health1 -= power2;
    }
    turn = (turn + 1) % 2;
  }
  if (health2 <= 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define met(a,b) memset(a,b,sizeof(a))

int a[100005];
int even[100005],odd[100005];

bool cmp(int a,int b)
{
    return a>b;
}

int main()
{
    int n,x=0,y=0,Maxe=-1,Maxo=-1,ei=-1,oi=-1;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(i&1){
            even[a[i]]++;
            if(Maxe<even[a[i]]){
                Maxe=max(Maxe,even[a[i]]);
                ei=i;
            }
        }
        else{
            odd[a[i]]++;
            if(Maxo<odd[a[i]]){
                Maxo=max(Maxo,odd[a[i]]);
                oi=i;
            }
        }
    }
    if(a[oi]!=a[ei]) printf("%d\n",n-odd[a[oi]]-even[a[ei]]);
    else{
        sort(odd,odd+100001,cmp);
        sort(even,even+100001,cmp);
        printf("%d\n",min(n-odd[0]-even[1],n-odd[1]-even[0]));
    }
    return 0;
}


Measured memory_bytes: 1408
from itertools import combinations
s = input()
n = int(input())

le = len(s)
tmp = s[:5]

for i in range(le - 4):
    tmp = min(tmp, s[i:i+5])

seed = tuple(combinations(range(min(6, le+1)), 2))
res = set()
for i, j in seed:
    res.add(tmp[i:j])
ans = sorted(res)
print(ans[n - 1])


Measured memory_bytes: 9196
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int x, a;
  cin >> x >> a;
  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = list(map(int,input().split()))

A = []
B = []
for i in range(n):
    if i%2==0:A.append(v[i])
    else:B.append(v[i])
A = Counter(A).most_common(2)
B = Counter(B).most_common(2)
A.append((-1,0))
B.append((-2,0))
ans = float("inf")
if A[0][0]==B[0][0]:
    ans = min(n-A[0][1]-B[1][1],n-A[1][1]-B[0][1])
else:
    ans = n-A[0][1]-B[0][1]
print(ans)

Measured memory_bytes: 16100
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
        int S = sc.nextInt();
        int count = 0;
        
        for(int x=0; x<=K; x++){
          for(int y=0; y<=K; y++){
            int z = S-x-y;
            if(z>=0 && z<=K){
              count++;
            }
          }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 24020
def read_input(trans=int):
    return list(map(trans, input().split()))


X, N = read_input()
if N == 0:
    print(X)
else:
    list_p = read_input()

    for i in range(N+1):
        if X-i in list_p:
            if X+i in list_p:
                continue
            else:
                print(X+i)
                break
        else:
            print(X-i)
            break


Measured memory_bytes: 9200
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main() {
        var n = NextInt();
        var a = NextInt();
        var b = NextInt();
        WriteLine(Math.Max(0, (long)(b - a) * (n - 2) + 1));
    }

    static int NextInt() {
        return int.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

Measured memory_bytes: 13268
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}





int main() {
	ll N;

	cin >> N;
	vector<ll> a(N), b(N);

	rep(i, N) {
		cin >> a[i];
	}
	
	ll M = 0;
	for (int i = N; i >= 1; i--) {

		ll k = 2, sum = 0;

		while (k * i <= N) {
			sum += b[k*i - 1];
			k++;
		}


		if (sum % 2 == a[i-1]) {
			b[i-1] = 0;
		}
		else if(sum % 2 != a[i-1]) {
			b[i-1] = 1;
			M += 1;
		}

	}
	cout << M << endl;
	rep(i, N) {
		if (b[i] == 1) {
			cout << i + 1 << " ";
		}
	}

	return 0;
}

Measured memory_bytes: 3968
import sys
import math
from functools import reduce

input = sys.stdin.readline

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def main():
    K = int(input())

    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            tmp = math.gcd(i, j)
            if tmp == 1:
                ans += K
                continue
            for k in range(1, K+1):
                ans += gcd(i, j, k)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9632
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
    reverse(s.begin(), s.end());
    vector<vector<int> > dp(s.size() + 1, vector<int>(2, INF));
    dp[1][0] = s[0] - '0'; dp[1][1] = 11 - s[0] + '0';
    for (int i = 1 ; i < s.size() ; i++) {
        int cur = s[i] - '0';
        dp[i + 1][0] = min(dp[i][0], dp[i][1]) + cur;
        dp[i + 1][1] = min(dp[i][0] + 11 - cur, dp[i][1] + 10 - (cur + 1));
    }
    cout << min(dp.back()[0], dp.back()[1]) << '\n';
}

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

using namespace std;

#define mkp(x,y) (make_pair(x,y))
typedef long long ll;
typedef pair<ll,ll> pil;

int main()
{
    ll N,K,L,R;

    while(cin>>N>>K>>L>>R)
    {
        vector<ll> a(N);
        for(int i=0;i<N;i++)
        {
            cin>>a[i];
        }
        vector<pil> ps;
        for(int i=0;i<(1<<N/2);i++)
        {
            int tmp=i;
            int now=0;
            int cnt=0;
            ll res=0;
            while(tmp)
            {
                if(tmp&1)
                {
                    cnt++;
                    res+=a[now];
                }
                tmp>>=1;
                now++;
            }
            ps.emplace_back(cnt,res);
        }
        sort(ps.begin(),ps.end());
        ll ans=0;
        for(int i=0;i<(1<<(N-N/2));i++)
        {
            int tmp=i;
            int now=0;
            int cnt=0;
            ll res=0;
            while(tmp)
            {
                if(tmp&1)
                {
                    cnt++;
                    res+=a[now+N/2];
                }
                tmp>>=1;
                now++;
            }
            ans+=upper_bound(ps.begin(),ps.end(),mkp(K-cnt,R-res))-lower_bound(ps.begin(),ps.end(),mkp(K-cnt,L-res));
        }
        cout<<ans<<endl;
    }


    return 0;
}



Measured memory_bytes: 19464