akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long[] Ti;
        long[] Ai;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            Ti = new long[N];
            Ai = new long[N];
            for (int i = 0; i < N; i++) {
                Ti[i] = sc.nextLong();
                Ai[i] = sc.nextLong();
            }
        }
        int[] Si = new int[N];

        for (int i = 1; i < N; i++) {
            long t = (Ti[i - 1] + Ti[i] - 1) / Ti[i];
            long a = (Ai[i - 1] + Ai[i] - 1) / Ai[i];
            long d = Math.max(t, a);
            //debug("d" + d);
            Ti[i] = (long) (Ti[i] * d);
            Ai[i] = (long) (Ai[i] * d);
        }
        long temp = Ti[N - 1] + Ai[N - 1];

        System.out.println(temp);
    }

}


Measured memory_bytes: 23380
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int h2, w2;
    cin >> h2 >> w2;
    cout << h * w - h2 * w - h * w2 + h2 * w2 << '\n';
}


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

namespace AtCoderTemplate {
    class Program {
        static void Main (string[] args) {
            var NQ = ReadInts ();
            var N = NQ[0];
            var Q = NQ[1];
            var S = Console.ReadLine ();
            var lr = ReadColumns (Q);
            var l = lr[0];
            var r = lr[1];

            var t = new int[N + 1];
            t[0] = 0;
            foreach (var k in Enumerable.Range (2, N - 1)) {
                if (S[k - 2] == 'A' && S[k - 1] == 'C') {
                    t[k] = t[k - 1] + 1;
                } else {
                    t[k] = t[k - 1];
                }
            }

            var result = Enumerable.Range (0, Q).Select (i => t[r[i]] - t[l[i]]);
            PrintLnEnum (result);
        }
        /* Input & Output*/
        static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }
        static List<int> ReadInts () {
            return Console.ReadLine ().Split (' ').Select (c => int.Parse (c)).ToList ();
        }
        static List<List<int>> ReadColumns (int n) {
            /*
            入力例
            A1 B1
            A2 B2
            ...
            An Bn

            出力例
            [[A1,A2,...,An], [B1,B2,...,Bn]]
            */
            var seq = Enumerable.Range (0, n).Select (i => ReadInts ()).ToList ();
            return Enumerable.Range (0, seq.First ().Count ()).Select (i => seq.Select (items => items[i]).ToList ()).ToList ();
        }
        static void PrintEnum<T> (IEnumerable<T> list) {
            Console.Write (list.First ());
            foreach (var item in list.Skip (1)) {
                Console.Write ($" {item}");
            }
            Console.Write ("\n");
        }
        static void PrintLnEnum<T> (IEnumerable<T> list) {
            foreach (var item in list) {
                Console.WriteLine (item);
            }
        }

        /* Numeric Function */
        static int Fact (int n) {
            return Enumerable.Range (1, n).Aggregate (1, ((i, k) => i * k));
        }
        static int PermNum (int n, int m) {
            if (m > n) {
                return 0;
            }
            return Enumerable.Range (n - m, m + 1).Aggregate (1, ((i, k) => i * k));
        }
        static int CombNum (int n, int m) {
            return PermNum (n, m) / Fact (m);
        }
        // 最大公約数 (m ≧ n)
        static int GCD (int m, int n) {
            if (n == 0) {
                return m;
            } else {
                return GCD (n, m % n);
            }
        }
        // 最小公倍数 (m ≧ n)
        static int LCM (int m, int n) {
            return GCD (m, n) / (m * n);
        }

    }
}

Measured memory_bytes: 31588
#include<bits/stdc++.h>
using namespace std;
int main(){
    string p;
    int count=0;
    cin >> p;
    for(int i=0;i<p.size();i++){
    if (p.at(i)=='o') count++;
    }
    for(int i=0;i<15-p.size();i++){
    count++;
    }

    if(count>=8) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s1[201],s2[201],p[101];
  char *ans;
  scanf("%s",s1);
  strcpy(s2,s1);
  strcat(s1,s2);
  scanf("%s",&p);
  ans = strstr(s1,p);
  if(ans != NULL){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 2112
//by sdfzchy
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int inf=(1<<30),N=100010;
int n,m;
inline int in()
{
	char ch=getchar();
	int f=1,tmp=0;
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {tmp=(tmp<<1)+(tmp<<3)+(ch-'0');ch=getchar();}
	return tmp*f;
}
int c[10][10];
int main()
{
//	freopen("in.in","r",stdin);
//	freopen("out.out","w",stdout);
	n=in(),m=in();
	for(int i=0;i<=9;i++)
		for(int j=0;j<=9;j++)
			c[i][j]=in();
	for(int k=0;k<=9;k++)
		for(int i=0;i<=9;i++)
			for(int j=0;j<=9;j++)
				c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			int x=in();
			if(x==-1) continue;
			ans+=c[x][1];
		}
	printf("%d",ans);
	return 0;
}


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

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

  if ((N % 1000) % 111 == 0) {
    cout << "Yes" << endl;
  }
  else if (((N - (N % 10)) / 10) % 111 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 1111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
# coding: utf-8

n = input()
xs = map(float, input().split())
ys = map(float, input().split())
abs_d = [abs(x - y) for (x, y) in zip(xs, ys)]
d = [sum([i ** p for i in abs_d]) ** (1 / p) for p in range(1, 4)]
d.append(max(abs_d))

print(*d, sep='\n')


Measured memory_bytes: 5656
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll x;cin>>x;
  cout<<1-x<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>

#define N 10000

int PrimeNumbers(int x)
{

  int j=3;


  if(x == 2) return 1;
  
  if(x<2 || x%2 == 0) return 0;
  

    while(j <= sqrt(x)){
      if(x%j ==0) return 0;
      j += 2;
    }
  return 1;
}

int main()
{

  int i;
  int n,count=0,x; 

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(PrimeNumbers(x)) count++;
  }
  
  printf("%d\n",count++);
    
    return 0;
}

Measured memory_bytes: 596
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>

int main() {

	int n, x;
	while (1) {
		scanf("%d%d", &n, &x);
		if (n == 0 && x == 0) break;

		int k;
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i+1; j <= n; j++) {
				k = x - i - j;
				if (k > j && k <= n) {
					ans++;
				}
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}




Measured memory_bytes: 2120
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

void solve(long long N, std::vector<long long> A) {
  sort(all(A));
  if (N % 2 == 0) {
    ll tmp1 = -A[N / 2 - 1] + A[N / 2];
    rep(i, 0, (N / 2) - 1) { tmp1 -= 2 * A[i]; }
    rep(i, (N / 2) + 1, N) { tmp1 += 2 * A[i]; }

    print(tmp1);
  } else {
    ll tmp1 = -A[(N - 1) / 2 - 1] - A[(N - 1) / 2];
    rep(i, 0, (N - 1) / 2 - 1) { tmp1 -= 2 * A[i]; }
    rep(i, (N + 1) / 2, N) { tmp1 += 2 * A[i]; }

    ll tmp2 = A[N / 2] + A[N / 2 + 1];
    rep(i, 0, N / 2) { tmp2 -= 2 * A[i]; }
    rep(i, N / 2 + 2, N) { tmp2 += 2 * A[i]; }

    print(max(tmp1, tmp2));
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


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

using namespace std;

int main(void)
{
	int n,k;
	cin >> n >> k;
	long long h[100005];
	for(int i=1;i<=n;i++)
		cin >> h[i-1];

	sort(h,h+n);

	long long dis=h[k-1]-h[0];

	for(int i=k;i<=n;i++)
	{
		if(dis>h[i-1]-h[i-k+1-1])
			dis=h[i-1]-h[i-k+1-1];
	}

	cout << dis << endl;
}
	

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int i, j, n, cls;
	char mark, dummy;
	int A[4][13] = {};
	
	//while( scanf("%d", &n) != EOF)
	scanf("%d", &n);

	for(i=0; i<n; i++) {
		scanf("%c", &dummy);
		scanf("%c %d", &mark, &cls);
		if(cls > 0 && cls <= 13) {
			switch(mark) {
				case 'S' : A[0][cls-1] = 1; break;
				case 'H' : A[1][cls-1] = 1; break;
				case 'C' : A[2][cls-1] = 1; break;
				case 'D' : A[3][cls-1] = 1; break;
				default : break;
			}
		}
	}

	for(j=0; j<4; j++) {
		switch(j) {
			case 0: mark = 'S'; break;
			case 1: mark = 'H'; break;
			case 2: mark = 'C'; break;
			case 3: mark = 'D'; break;
		}
		for(i=0; i<13; i++) {
			if(A[j][i]==0) printf("%c %d\n", mark, i+1);
		}
	}

	return 0;
}

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

int main(void)
{
    int i, j, t;
    int x[10];
    for(i=0;i<10;i++)
    {
        scanf("%d",&x[i]);
    }
    
    for(i=0;i<9;i++)
    {
        for(j=0;j<9-i;j++)
        {
            if(x[j]<x[j+1])
            {
                t=x[j];
                x[j]=x[j+1];
                x[j+1]=t;
            }
        }
    }
    
    for(i=0;i<3;i++)
    {
        printf("%d\n",x[i]);
    }
    
    return 0;
}

Measured memory_bytes: 600
<?php
// F
fscanf(STDIN, '%d', $n);
$ans = 0;

// N-1が倍数になるパターン
$divisors = divisors($n - 1);
$ans += count($divisors) - 1;

// Nが倍数になるパターン
$divisors = divisors($n);
// var_dump($divisors);
foreach ($divisors as $d) {
    if ($d === 1) continue;
    $n2 = $n;
    while ($n2 % $d === 0) {
        $n2 = intdiv($n2, $d);
    }
    if ($n2 % $d === 1) $ans++;
}

echo $ans;

/**
 * エラトステネスのふるい
 * $maxまでの整数のうち素数のみを格納した配列を返す
 */
function primesArr($max)
{
    $is_prime = isPrimeArr($max);
    $res = [];
    for ($i = 1; $i <= $max; $i++) {
        if ($is_prime[$i]) $res[] = $i;
    }
    return $res;
}

/**
 * エラトステネスのふるい
 * $maxまでの整数が素数かどうかboolを格納した配列を返す
 */
function isPrimeArr($max)
{
    $arr = array_fill(0, $max + 1, true);
    $arr[0]  = $arr[1] = false;
    $rmax = (int) floor(sqrt($max));
    for ($i = 2; $i <= $rmax; $i++) {
        for ($j = 2 * $i; $j <= $max; $j += $i) {
            $arr[$j] = false;
        }
    }
    return $arr;
}

// 素因数分解
function primeFactorization($n)
{
    $res = [];
    $res[1] = 1;
    if ($n === 1) return $res;

    $primes = primesArr((int) sqrt($n) + 1);

    foreach ($primes as $prime) {
        while ($n % $prime === 0) {
            if (isset($res[$prime])) {
                $res[$prime]++;
            } else {
                $res[$prime] = 1;
            }
            $n /= $prime;
        }
    }

    if ($n > 1) {
        if (isset($res[$n])) {
            $res[$n]++;
        } else {
            $res[$n] = 1;
        }
    }

    return $res;
}

function primes($max)
{
    $arr = [];
    for ($i = 2; $i <= $max; $i++) {
        if (isPrime($i)) $arr[] = $i;
    }
    return $arr;
}

function isPrime($n)
{
    if ($n === 1) return false;
    $rmax = (int) floor(sqrt($n));
    for ($i = 2; $i <= $rmax; $i++) {
        if ($n % $i === 0) return false;
    }
    return true;
}

function divisors($max)
{
    $arr = [];
    $rmax = (int) floor(sqrt($max));
    for ($i = 1; $i <= $rmax; $i++) {
        if ($max % $i === 0) {
            $arr[] = $i;
            $arr[] = $max / $i;
        }
    }
    sort($arr);
    return array_unique($arr);
}

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=1;i<=n;i++)
#define endl   "\n"







int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string user;
    cin>>user;
    int i=0;
    int j=user.size()-1;
    int count=0;
    while(i<j)
    {
        if(user[i]!=user[j]) {
            count++;
        }
        
        i++;
        j--;

    }
    cout<<count<<endl;











}

Measured memory_bytes: 3612
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
    int H,W;
    Scanner sc=new Scanner(System.in);
    
    while(true){
        H=sc.nextInt();
        W=sc.nextInt();
        if((H==0) && (W==0))break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if((i==0) || (j==0) || (i==(H-1)) || (j==(W-1)))
                    System.out.print("#");
                else
                    System.out.print(".");
                }
            System.out.println();
            }
        System.out.println();
        }
    }
}



Measured memory_bytes: 36164
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

a, b, c, x, y = gets_i_list

ts = []

0.upto([x,y].max) do |i|
  total = c * i * 2
  rx = x - i
  ry = y - i
  if rx > 0
    total += a * rx
  end

  if ry > 0
    total += b * ry
  end
  ts.push total
end

puts ts.min


Measured memory_bytes: 15344
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define REV(i,a,b) for(i=a-1;i>=b;i--)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define mp make_pair
#define ord(v) sort(v.begin(),v.end());
const ll MAXN=2*1e5+10;
#define MAX 2*1e9
#define fi first
#define se second
#define pi 3.141592653589793238
#define rem 1000000007
#define eps 1e-9

int main()
{
   // #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
    ll n,i,j;
    cin>>n;
    ll f[n][3];
    rep(i,n)
    {
        rep(j,3)
        cin>>f[i][j];
    }
    REP(i,1,n)
    {
        f[i][0]=f[i][0]+max(f[i-1][1],f[i-1][2]);
        f[i][1]=f[i][1]+max(f[i-1][0],f[i-1][2]);
        f[i][2]=f[i][2]+max(f[i-1][1],f[i-1][0]);

    }
    cout<<max(f[n-1][0],max(f[n-1][1],f[n-1][2]));

    
    return 0;
}

Measured memory_bytes: 5984
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int AB = A + B;
    if (AB < 10) {
      System.out.println(AB);
    }else {
      System.out.println("error");
    }
  }
}


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

typedef struct Edge{
    int w, s, t;
    
    bool operator < (const Edge r)const{
        return w < r.w;
    };
}Edge;

class UnionFind {
    vector<int> par;
    int cnt;
public:
    UnionFind(int size_) : par(size_, -1), cnt(size_) { }
    void unite(int x, int y){
        if ((x = find(x)) != (y = find(y))) {
            if (par[y] < par[x]) swap(x, y);
            par[x] += par[y]; par[y] = x; cnt--;
        }
    }
    bool same(int x, int y){ return find(x) == find(y); }
    int find(int x){ return par[x] < 0 ? x : par[x] = find(par[x]); }
    int size(int x){ return -par[find(x)]; }
    int size(){ return cnt; }
};

int N, M;

int main(){
    while(cin >> N >> M, N|M){
        auto uf = UnionFind(N);
        
        vector<Edge> edges;
        for(int i=0; i<M; i++){
            int s, t, w;
            cin >> s >> t >> w; s--; t--;
            edges.push_back({w, s, t});
        }
        sort(edges.begin(), edges.end());
        
        int cnt = 0;
        for(auto &e: edges){
            if(!uf.same(e.s, e.t)){
                uf.unite(e.s, e.t);
                cnt++;
            }
            if(cnt == N/2){
                cout << e.w << endl;
                break;
            }
        }
    }
    
    return 0;
}

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

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

    int n;
    cin >> n;

    ll c[n - 1], s[n - 1], f[n - 1];
    for (int i = 0; i < n - 1; ++i) {
        cin >> c[i] >> s[i] >> f[i];
    }
    
    for (int i = 0; i < n; ++i) {
        ll total = 0;
        for (int j = i; j < n - 1; ++j) {
            ll diff = s[j] - total;
            if (diff >= 0) {
                total += diff;
            } else {
                if (-diff % f[j]) total += f[j] - (-diff % f[j]);
            }
            total += c[j];
        }
        cout << total << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s,t;
    cin >> s >> t;
    bool flag = true;
    for(int i = 0; i < s.size();i++){
        if(s[i] != t[i]) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

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

int main() {
	int n;
	cin >> n;
	double ans = 0;
	double x;
	string t;
	string s = "BTC";
	rep(i, n) {
		cin >> x;
		cin >> t;
		if (t == s) {
			ans += 380000 * x;
		}
		else {
			ans += x;
		}
	}
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))

int main(void) {
	double l;
	scanf("%lf", &l);
	printf("%.6lf", (l / 3) * (l / 3) * (l / 3));
	//scanf("%lf", &l);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    cout << (N + 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define p_b push_back
#define all(c)              c.begin(), c.end()
using namespace std;
typedef long long ll; //printf("%lld ", ll); to out put long
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;
const double eps = 1e-6;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
bool ODD(ll O) {return (O % 2 != 0);}
ll gcd(ll a, ll b) {return __gcd(a , b);}
ll lcm(ll a, ll b) {return a * b / gcd(a , b);}
int dx[] = {1, 0, -1 ,0 , -1 , 0};
int dy[] = {0, 1, 0, -1 , -1 , 0};
ll power (ll x, ll y) {
    if(y == 0) return 1;
    if(ODD(y)) return x * power(x , y / 2) * power(x , y / 2);
    return power(x , y / 2) * power(x , y / 2);
}
/*------ never give up --------*/
int dp[MAXN + 105], arr[MAXN + 105];
int n, k;
int solve(int idx) {
    if(idx > n - 1) return MAXN;
    if(idx == n - 1) return 0;
    int &ret = dp[idx];
    if(ret != -1) return ret;
    ret = INT_MAX;
    int sol = INT_MAX;
    for(int i = 1; i <= k; i++) {
        sol = INT_MAX;
        sol = solve(idx + i) + abs(arr[idx] - arr[idx + i]);
        //cout << idx << " " << i << " " << sol << "\n";
        ret = min(ret , sol);
    }
    return ret;
}
int main () {
    int t = 1;
    //cin >> t;
    while(t--) {
        scanf("%d%d" , &n, &k);
        for(int i = 0; i < n; i++) cin >> arr[i];
        memset(dp , -1 , sizeof dp);
        printf("%d", solve(0));

    }

    return 0;
}


Measured memory_bytes: 10756
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define all(v) v.begin() , v.end()
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,f,x,y,z,k,m,n,l,h,w,t,ans=0;
vl v;
string s1,s2;
ll solve(void){
    a=1;
    rep(i,n){
        if(i==0||v[i]==a){
            ans+=(v[i]-1)/a;
            a++;
        }
        else{
            ans+=(v[i]-1)/a;
        }
    }
    return ans;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n){
        cin>>x;
        v.push_back(x);
    }
    cout<<solve()<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define max 1000000
int main()
{
    int n;
    cin >> n;
    if (n % 1000 == 0)
        cout << 0 << endl;
    else
    {
        int x = (n / 1000) + 1;
        int ans = (x * 1000) - n;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	string s;
	cin >> s;
	int size=s.length();
	string ans="yes";
	for(int i=0; i<size; i++){
		for(int j=i+1; j<size; j++){
			if(s[i]==s[j])ans="no";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int size=1e5+5;
typedef pair<int,int> pi;
int n;
void update(int x,int h[])
{
    for(int i=x;i<size;i += i & -i)
        h[i] = max(h[i],x);
}
int query(int x,int h[])
{
    int res = 0;
    for(int i=x;i>0;i -= i & -i)
        res = max(res,h[i]);
    return res;
}
int cal_left(int x,int h[])
{
    int i = query(x,h);
    return i;
}
int cal_right(int x,int h[])
{
    x = n-x+1;
    if(x < 0)
        return n+1;
    int i = query(x,h);
    return n+1-i;
}
int h[size],h2[size];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    vector <pi> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i].first,arr[i].second = i+1;
    sort(arr.begin(),arr.end(),[](pi a,pi b){
        return a.first > b.first;
    });
    ll ans = 0;
    for(int i=0;i<n;i++)
    {
        ll l1 = cal_left(arr[i].second,h);
        ll l2 = cal_left(l1-1,h);
        ll r1 = cal_right(arr[i].second,h2);
        ll r2 = cal_right(r1+1,h2);
//        cout<<arr[i].first<<" "<<(arr[i].second-l1)<<" "<<(r2-r1)<<endl;
//        cout<<arr[i].first<<" "<<(r1-arr[i].second)<<" "<<(l1-l2)<<endl;
        ans += 1LL*arr[i].first*(arr[i].second-l1)*(r2-r1);
        ans += 1LL*arr[i].first*(r1-arr[i].second)*(l1-l2);
        update(arr[i].second,h);
        update(n+1-arr[i].second,h2);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 1792
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,p;
	cin>>n;
	string s;
	pair<pair<string,int>,int>a[114];
	for(int i=0;i<n;i++)
	{
		cin>>s>>p;
		a[i].first.first=s;
		a[i].first.second=-p;
		a[i].second=i+1;
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)cout<<a[i].second<<endl;
	return 0;
}

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

using namespace std;

int main()
{
  int op1, op2;
  char oper;
  cin >> op1 >> oper >> op2;

  if (oper == '+') {
    cout << op1 + op2;
  } else {
    cout << op1 - op2;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>

#define MOD 1000000007
#define pi 3.14159265358979

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

	vector<int> l(n);

	for (int i = 0; i < n; i++)
		cin >> l[i];

	ull ans = 0;

	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				int a = l[i], b = l[j], c = l[k];
				if (a + b > c && a + c > b && b + c > a && a != b && a != c && b != c)
					ans++;
			}
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3184
def partial_match_table(word):
    table = [0] * (len(word) + 1)
    table[0] = -1
    i, j = 0, 1
    while j < len(word):
        matched = word[i] == word[j]
        if not matched and i > 0:
            i = table[i]
        else:
            if matched:
                i += 1
            j += 1
            table[j] = i
    return table

def kmp_search(text, word):
    table = partial_match_table(word)
    i, p = 0, 0
    results = []
    while i < len(text) and p < len(word):
        if text[i] == word[p]:
            i += 1
            p += 1
            if p == len(word):
                p = table[p]
                results.append((i-len(word), i))
        elif p == 0:
            i += 1
        else:
            p = table[p]
    return results

inf = 10**18
s = input().strip()
t = input().strip()
m=(len(t)+len(s)-1+len(s)-1)//len(s)
d = [-1] * (len(s)+1) 
for a, b in kmp_search(m*s, t):
    a, b = a%len(s)+1, b%len(s)+1
    d[a] = b


ls = [-1]*(len(s)+1)
vs = set()
for i in range(1, len(s)+1):
    if i in vs:
        continue
    c = 0
    j = i
    while True:
        vs.add(i)
        i = d[i]
        if i == -1:
            break
        c += 1
        if i == j:
            c = inf
            break
        if ls[i] != -1:
            c += ls[i]
            break
    if c == inf:
        break
    ls[j] = c
print(max(ls) if c != inf else -1)


Measured memory_bytes: 116452
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner in =new Scanner(System.in);
        int T=in.nextInt();
        int count=0;
        int[] arr=new int[T];
        for(int i=0;i<T;i++){
            arr[i]=in.nextInt();
        }
        for(int i=0;i<T;i++){
            if(arr[i]!=i+1)
                count++;
        }
        if(count==0 || count==2)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


Measured memory_bytes: 23764
n, m = [int(i) for i in input().split()]
wa = [0]*n
ac = [0]*n

for _ in range(m):
    p, s = input().split()
    if s == "WA":
        if ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    else:
        ac[int(p)-1] += 1

print(n-ac.count(0), sum([wa[i] for i in range(n) if ac[i] >= 1]))

Measured memory_bytes: 5528
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	int N;
	string S;
	cin >> N >> S;
	int cnt = 0;
	for (int i = 0; i < 1000; ++i) {
		int c[3] = { i / 100,(i / 10) % 10, i % 10 };
		int f = 0;
		for (int j = 0; j < N; ++j) {
			if (S[j] == ('0' + c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
}

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

using namespace std;

#define ull unsigned long long
#define ll long long
#define int long long
#define ld long double

#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define MX LLONG_MAX
#define MN LLONG_MIN

const ll mod=1e9+7;
const ll N=1e5+5;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

int32_t main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    ll l=1,r=1e5+5;
    ll mn=r,mx=l;
    while(l<=r)
    {
        ll mid = (l+r)>>1,c=0;
        for(ll i=0;i<n;i++)
        {
            if(a[i]<mid)
                c++;
            else
                break;
        }
        if(c == n-c)
        {
            mn = min(mn,mid);
            r = mid-1;
        }
        else if(c < n-c)
            l = mid+1;
        else
            r = mid-1;
    }
    l = 1;
    r = 1e5;
    while(l<=r)
    {
        ll mid = (l+r)>>1,c=0;
        for(ll i=0;i<n;i++)
        {
            if(a[i]<mid)
                c++;
            else
                break;
        }
        if(c == n-c)
        {
            mx = max(mx,mid);
            l = mid+1;
        }
        else if(c > n-c)
            r = mid-1;
        else
            l = mid+1;
    }
    cout<<max((ll)0,mx-mn+1);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll h;
  cin >> h;
  for (ll i = 0; true; i++) {
    if (ll(pow(2, i)) <= h && h < ll(pow(2, i + 1))) {
      cout << ll(pow(2, i + 1)) - 1 << "\n";
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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;
}

const ll INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    cin >> N;
    vi a(N-1), b(N,0);
    rep(i,N-1) cin >> a.at(i);
    rep(i,N-1) b.at(a.at(i)-1)++;
    rep(i,N) cout << b.at(i) << endl;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
 
long long baseW;
long long N, W;
vector<long long> val[4];
 
int main(){
	cin >> N >> W;
	for(long long i = 0; i < N; i++){
		long long tmpw, tmpv;
		cin >> tmpw >> tmpv;
		if(i == 0){
			baseW = tmpw;
		}
		val[tmpw - baseW].push_back(tmpv);
	}
	for(int i = 0; i < 4; i++){
		sort(val[i].begin(), val[i].end(), greater<long long>());
		val[i].insert(val[i].begin(), 0);
		for(int j = 0; j < val[i].size() - 1; j++){
			val[i][j+1] += val[i][j];
		}
	}
 
	long long ans = 0;
	//for(long long i = 0; i < val[0].size(); i++){
	//	for(long long j = 0; j < val[1].size(); j++){
	//		for(long long k = 0; k < val[2].size(); k++){
	//			long long curw;
	//			curw = i * baseW + j * (baseW + 1) + k * (baseW + 2);
	//			if(curw > W){
	//				continue;
	//			}else{
	//				long long l = (W - curw)/(baseW + 3);
	//				ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][l]);
	//			}
	//		}
	//	}
	//}

	for(long long i = 0; i < val[0].size(); i++){
		for(long long j = 0; j < val[1].size(); j++){
			for(long long k = 0; k < val[2].size(); k++){
				for(long long l = 0; l < val[3].size(); l++){
					long long curw;
					if(i * baseW + j * (baseW + 1) + k * (baseW + 2) + l * (baseW + 3) > W){
						continue;
					}else{
						ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][l]);
					}
				}
			}
		}
	}


	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
d,g=map(int,input().split())
ls=[list(map(int,input().split())) for i in range(d)]
P=list(map(lambda x:x[0],ls))
C=list(map(lambda x:x[1],ls))

tmp=10**9
for i in range(1<<d):
  total=0
  num=0
  for j in range(d):
    if (i>>j)&1:
      total+=C[j]+P[j]*100*(j+1)
      num+=P[j]
  if total>=g:
    tmp=min(num,tmp)
  else:
    for j in range(d-1,-1,-1):
      if (i>>j)&1:
        continue
      for k in range(P[j]):
        if total>=g:
          break
        total+=100*(j+1)
        num+=1
    tmp=min(tmp,num)
print(tmp)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int n,ans=0;
  cin >> n;

  rep(i,3){
    ans += n % 10;
    n /= 10;
  }
  cout << ans << endl;
  return 0;
} 

Measured memory_bytes: 3632
# 入力
a,b = gets.chomp.split.map(&:to_i)

# 配列は０から振り当てられるよ！
card = [2,3,4,5,6,7,8,9,10,11,12,13,1]
c = card.index(a)
d = card.index(b) 

# こたえ
if c > d
  puts "Alice"
elsif c < d
  puts "Bob"
else c == d
  puts "Draw"
end

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

string S;

int main() {
  cin >> S;
  
  if (S == "Sunny") {
    cout << "Cloudy"  << endl;
  } else if (S == "Cloudy") {
    cout << "Rainy"  << endl;
  } else if (S == "Rainy") {
    cout << "Sunny"  << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i <= n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, s, cnt = 0;
  cin >> k >> s;
  REP(x,k) {
    REP(y,k) {
      int z = s - x - y;
      if(z < 0 || z > k) continue;
      if(x + y + z == s) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
A,B = map(int, input().split())
S = list(input())
S_h = S.pop(A)

NUM = [str(i) for i in range(10)]
isCorrect = True

if S_h != '-':
    isCorrect = False

for i in S:
    flag = 0
    for j in NUM:
        if i==j:
            flag = 1
    if flag == 0:
        isCorrect = False

if isCorrect:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9172
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * AtCoder Beginner Contest 129<br>
 * B - Balance<br>
 * <br>
 * <a href=
 * "https://atcoder.jp/contests/abc129/tasks/abc129_b">AtCoderへのリンク</a><br>
 */
public class Main {

	/**
	 * エントリポイント
	 */
	public static void main(String[] args) {
		// 入力
		Model m = input(System.in);
		// 演算
		int result = proc(m);
		// 出力
		System.out.println(result);
	}

	/**
	 * 入力モデル
	 */
	static class Model {
		/** オモリの数 */
		int N;
		/** オモリの重さリスト */
		List<Integer> list = new ArrayList<Integer>();
	}

	/**
	 * 入力値より入力モデルを作成する
	 */
	private static Model input(InputStream in) {
		Model m = new Model();
		try (Scanner sc = new Scanner(in)) {
			String[] line1 = sc.nextLine().split(" ");
			String[] line2 = sc.nextLine().split(" ");

			m.N = Integer.parseInt(line1[0]);
			for (String str : line2) {
				m.list.add(Integer.parseInt(str));
			}
		}
		return m;
	}

	/**
	 * 演算を行う
	 */
	static int proc(final Model m) {
		int min = Integer.MAX_VALUE;

		for (int i = 1; i < m.N; i++) {
			int s1 = sumAll(m.list.subList(0, i));
			int s2 = sumAll(m.list.subList(i, m.list.size()));

			min = Math.min(min, Math.abs(s1 - s2));
		}
		return min;
	}

	static int sumAll(List<Integer> list) {
		int sum = 0;
		for (int item : list) {
			sum += item;
		}
		return sum;
	}
}


Measured memory_bytes: 21844
import sys

dictionary = dict()

for line in sys.stdin.readlines():
    line = line.strip()
    word, num = line.split()
    if not dictionary.has_key(word):
        dictionary[word] = list()
    dictionary[word].append(int(num))

for key in sorted(dictionary.keys()):
    print key
    print " ".join(map(str, sorted(dictionary[key])))

Measured memory_bytes: 5396
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define N 90010
int a[N],b[N];
vector<int> p[N];
vector<long long> q[N];
int main()
{
    int i,j,k,k1,k2,n,m,x,y,t,d;
    long long s;
    scanf("%d%d%d",&n,&m,&d);
    for(i=1;i<=n;i++)
    for(j=1;j<=m;j++)
    {
        scanf("%d",&x);
        a[x]=i;
        b[x]=j;
    }
    for(i=1;i<=n*m;i++)
    {
        j=i%d;
        p[j].push_back(i);
    }
    for(i=0;i<d;i++)
    {
        k=p[i].size();
        s=0;
        q[i].push_back(0);
        for(j=1;j<k;j++)
        {
            s=s+fabs(a[p[i][j-1]]-a[p[i][j]])+fabs(b[p[i][j-1]]-b[p[i][j]]);
            q[i].push_back(s);
        }
    }
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&x,&y);
        if(x==y)
        {
            printf("0\n");
            continue;
        }
        i=x%d;
        k1=x/d;
        k2=y/d;
        if(i==0)
        {
            printf("%lld\n",q[0][k2-1]-q[0][k1-1]);
        }
        else
            printf("%lld\n",q[i][k2]-q[i][k1]);
    }
    return 0;
}


Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {

	int N;
	cin >> N;

	bool valid = true;
	vector<string> words;
	string s;

	for (int i = 0; i < N; i++) {
		cin >> s;

		if (valid) {
			if (words.size() > 0) {
				if (s.front() != words[i - 1].back()) {
					valid = false;
//					break;
				}
			}

			words.push_back(s);
		}
	}

	if (valid) {
		size_t pre = words.size();
		sort(words.begin(), words.end());
		words.erase(unique(words.begin(), words.end()), words.end());
		if (words.size() != pre) {
			valid = false;
		}
	}

	cout << (valid ? "Yes": "No") << endl;

	return 0;
}


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

int main() {
	int  S,h,m,s;
	cin >> S;
	h = S / 3600.0;
    S %= 3600;
    m = S / 60;
    S %= 60;
	s = S;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

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

typedef long long lglg;

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

	int n; cin >> n;
	int arr[n+1];
	arr[0] = arr[n] = 1 << 30;
	for (int i=1; i<n; ++i) cin >> arr[i];
	int result = 0;
	for (int i=0; i<n; ++i) result += min(arr[i], arr[i+1]);
	cout << result;
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let vn: i32 = sc.read();
    let vl: i32 = sc.read();
    let vnn = vn - (vn % 2);
    let tnn = vn * (vn % 2);

    let taste = vn * (vl - 1) + (vnn + 1) * vnn / 2 + tnn;

    if vl >= 0 {
        println!("{}", taste - vl);
        return;
    }
    else if (vl + vn - 1) >= 0 {
        println!("{}", taste);
        return;
    }
    println!("{}", taste - (vl + vn - 1));
}

Measured memory_bytes: 4352