akhauriyash/Code-Regression huggingface dataset:
#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;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll f(ll x,ll m){
  return x%m;
}

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

  ll n,x,m;
  cin>>n>>x>>m;

  vll dist(m+10,-1);
  vll s(m+10,-1);
  ll now=x;
  ll sum=0;
  ll ans=0;
  REP(i,m+1){
    if(i!=0)
      now=f(now*now,m);
    sum+=now;
    if(i==n-1){
      ans=sum;
      break;
    }

    if(dist[now]==-1){
      dist[now]=i;
      s[now]=sum;
    }
    else{
      ll d=i-dist[now];
      ll p=sum-s[now];
      ans=s[now]+(n-dist[now])/d*p;
      ans-=now;

      ll g=(n-dist[now])%d;
      REP(j,g){
        ans+=now;
        now=f(now*now,m);
      }
      break;
    }
  }


  cout<<ans<<endl;

//  ll ans2=x;
//  REP(i,n-1){
//    x=f(x*x,m);
//    ans2+=x;
//  }
//  cout<<ans2<<endl;

}



Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,c=0;
    cin>>n>>d;
    while(n--)
    {
        long long x,y;
        double ans;
        cin>>x>>y;
        ans=sqrt(abs(x*x)+abs(y*y));
        if(ans<=d)
        c++;
        //cout<<ans<<endl;
    }
    cout<<c;
}

Measured memory_bytes: 3648
def main():
  n, m = map(int, input().split())
  number = [-1] * n
  for i in range(m):
    s, c = map(int, input().split())
    if number[s-1] == -1 or number[s-1] == c:
      number[s-1] = c
    else:
      print(-1)
      return

  if number[0] == -1:
    if len(number) == 1:
      number[0] = 0
    else:
      number[0] = 1
  if number[0] == 0:
    if len(number) != 1:
      print(-1)
      return
  for ans_value in number:
    if ans_value == -1:
      ans_value = 0
    print(ans_value, end="")
if __name__ == '__main__':
  main()

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

int main() {
  int N, D;
  cin >> N >> D;
  if(N % (2 * D + 1) == 0) {
    cout << N / (2 * D + 1) << endl;
  }
  else {
    cout << N / (2 * D + 1) + 1 << endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int r;
  cin>>r;
  double pi=3.141592;
  cout<<fixed<<setprecision(10);
  cout<<2*r*pi<<endl;
}

Measured memory_bytes: 3788
#include<stdio.h>
int main(void)
{
	int i,a,s,d;
	for(i=1;i<=4;i++){
	scanf("%d %d",&s,&d);
	if(s==1){
		s=6000;
		}
	if(s==2){
		s=4000;
		}
	if(s==3){
		s=3000;
		}
	if(s==4){
		s=2000;
		}
	a=s*d;
	printf("%d\n",a);
	}
	return 0;
}

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

int main(){
        int i, j, h, w, k, ans=0, black;
        scanf("%d%d%d", &h, &w, &k);
        char s[6][7];
        for(i=0; i<h; i++){
                scanf("%s", s[i]);
        }
        int r, c;//row=行,column=列
        for(r=0; r<(1<<h); r++){
               for(c=0; c<(1<<w); c++){
                       black=0;
                       for(i=0; i<h; i++){
                               for(j=0; j<w; j++){
                                       if(((r>>i)&1)==0 && ((c>>j)&1)==0 && s[i][j]=='#'){
                                               black++;
                                       }
                               }
                       }
                       if(black==k){
                               ans++;
                       }
               }
        }
        printf("%d", ans);
        return 0;
}


Measured memory_bytes: 1732
# coding: utf-8
import collections

N,M,K=map(int,input().split())
F=[[] for i in range(N+1)]
Bl=[[] for i in range(N+1)]

par = [i for i in range(N+1)]
rank = [0 for i in range(N+1)]
 
def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
 
 
def unite(x,y):
    rx=find(x)
    ry=find(y)

    if rx==ry:
        return
    
    
    if rank[rx]<rank[ry]:
        par[rx]=ry
    else:
        par[ry]=rx

    if rank[rx]==rank[ry]:
        rank[rx]+=1
 

def some(x,y):
    return find(x)==find(y)
 
for i in range(M):
    A,B=map(int,input().split())
    unite(A,B)
    F[A].append(B)
    F[B].append(A)

for i in range(K):
    C,D=map(int,input().split())
    Bl[C].append(D)
    Bl[D].append(C)

ans=[0 for i in range(N)]
for i in range(N):
    find(i+1)
c = collections.Counter(par)

for i in range(N):
    ans[i]+=c[find(i+1)]-1
    ans[i]-=len(F[i+1])
    for j in range(len(Bl[i+1])):
        if some(i+1,Bl[i+1][j]):
            ans[i]-=1
print(*ans)    


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

int test(float x){
	if (x >= 1.1) return 0;
	if (x < 1.1 && x >= 0.6) return 1;
	if (x < 0.6 && x >= 0.2) return 2;
	if (x < 0.2) return 3;
}

int main(void)
{
	float l, r; 
	int i;
	int a, b;
	int left[5], right[5];
	memset (left, 0, sizeof(left));
	memset (right, 0, sizeof(right));
	 

	
	while (scanf("%f%f", &l, &r) != EOF){
		a = test(l);
		b = test(r);
		left[a]++;
		right[b]++;
	}
	for (i = 0; i < 4; i++){
		printf("%d %d\n", left[i], right[i]);
	}
	


	return (0);
}

Measured memory_bytes: 624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}



int main() {
	int a, b, c,d; cin >> a;
	//string s,t,u; cin >> s>>t>>u;
	//vector<int> n(3);
	cout << a * (a + 1) / 2;
	

	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
  unsigned long int x;
  unsigned long int money = 100;
  int year = 0;
  
  scanf("%ld", &x);
  for(year = 0;; year++)
  {
    if(money >= x)
      break;
    money = money * 1.01;
  }
  
  printf("%d\n", year);
  return 0;
}


Measured memory_bytes: 1732
#include <stdio.h>
int main(void) {
    int o,s,e,w,n,u,c,temp,i,sum;
    char inst[5];
    while(1){
    	scanf("%d\n",&c);
        if (c==0) break;
        o=1,s=2,e=3,w=4,n=5,u=6,sum=1;
    	for (i=0; i<c; i++) {
        	scanf("%s\n",inst);
        	if (inst[0]=='N') {
            	temp = o;
            	o=s;
            	s=u;
            	u=n;
            	n=temp;
            } else if (inst[0]=='E') {
                temp = o;
                o=w;
                w=u;
                u=e;
                e=temp;
            } else if (inst[0]=='W') {
                temp = o;
                o=e;
                e=u;
                u=w;
                w=temp;
            } else if (inst[0]=='S') {
                temp = o;
                o=n;
                n=u;
                u=s;
                s=temp;
            } else if (inst[0]=='R') {
                temp = n;
                n=w;
                w=s;
                s=e;
                e=temp;
            } else {
                temp = n;
                n=e;
                e=s;
                s=w;
                w=temp;
            }
            sum+=o;
        }
        printf("%d\n",sum);
    }
    return 0;
}

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

const int mod = 100000;

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

	int n, m;
	cin >> n >> m;

	vector<int> pos(1, 0);
	pos.reserve(n);
	for(int i = 1; i < n; ++i) {
		int diff;
		cin >> diff;
		pos.push_back(pos[pos.size() - 1] + diff);
	}

	int ans = 0, cur = 0;
	for(int i = 0; i < m; ++i) {
		int a;
		cin >> a;

		ans += abs(pos[cur] - pos[cur + a]);
		ans %= mod;
		cur += a;
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

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

#define ll long long
#define mod 1000000007

using namespace std;



int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    tuple<ll,ll,ll>g;
    vector<tuple<ll,ll,ll>>v;
    cin>>n;ll x[n+1],y[n+1],h[n+1];
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i]>=1)g=make_tuple(x[i],y[i],h[i]);
    }
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){bool ok=true;
            ll H=get<2>(g)+abs(get<0>(g)-i)+abs(get<1>(g)-j);H=max(H,0ll);
            for(int k=1;k<=n;k++){
                ll hi=H-abs(x[k]-i)-abs(y[k]-j);hi=max(hi,0ll);
                if(h[k]!=hi)ok=false;
            }
            if(ok)v.push_back(make_tuple(i,j,H));
        }
    }
    cout<<get<0>(v[0])<<" "<<get<1>(v[0])<<" "<<get<2>(v[0])<<endl;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define int long long int
#define inf 1000000000000
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int a,b;
    cin>>a>>b;
    if(a==b){
        string s="";
        s.append(a,'0'+b);
        cout<<s;
        return;
    }
    else{
        if(b<a)
            swap(a,b);
        string s="";
        s.append(b,'0'+a);
        cout<<s;
        return;
    }
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i = 1; i <= (n); ++i)
// using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//マクロ
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())       // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))    //最大値を求める
#define MIN(x) *min_element(ALL(x))    //最小値を求める
//定数
#define INF 1000000000000  // 10^12:極めて大きい値,∞
#define inf 2147483647     // int値の最大値
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back                             // vectorヘの挿入
#define MP make_pair                             // pairのコンストラクタ
#define F first                                  // pairの一つ目の要素
#define S second                                 // pairの二つ目の要素
#define CST(x) cout << fixed << setprecision(x)  //小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
//各桁の和
int sumDight(int x) {
    int sum = 0;
    while (x > 0) {
        sum += (x % 10);
        x /= 10;
    }
    return sum;
}
//回文数
int divideReverse(int x) {
    int reverse = 0;
    int r;
    while (x > 0) {
        r = x % 10;
        reverse = reverse * 10 + r;
        x /= 10;
    }
    return reverse;
}

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

    int w, h,n;
    cin >> w >> h >> n;
    vector<int> x(110);
    vector<int> y(110);
    vector<int> a(110);
    rep(i, n) cin >> x[i] >> y[i] >> a[i];
    int mix = 0;
    int maxx = w;
    int miy = 0;
    int may = h;

    rep(i,n){
        if(a[i]==1){
            if (mix < x[i]) mix = x[i];
        } else if (a[i] == 2) {
            if (maxx > x[i]) maxx = x[i];
        } else if (a[i] == 3) {
            if (miy< y[i]) miy = y[i];
        } else {
            if (may > y[i]) may = y[i];
        }
    }
    //cout << maxx << " " << mix << " " << may << " " << miy << endl;
    if (maxx > mix && may > miy)
        cout << (mix - maxx) * (miy - may) << endl;
    else
        cout << 0 << endl;
}


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

using namespace std;

int main() {
    string S;
    cin >> S;
    S = " " + S;
    int ans = S.size();
    for(int i = 0; i < S.size() - 1; i++){
        if(S[i] != S[i + 1]) {
            ans = min(max(i, (int) S.size() - i - 1), ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		UL O = 0;
		rep(i, N) {
			UL a; cin >> a;
			if (a % 2) O++;
		}
		cout << ((O % 2 == 0) ? "YES" : "NO") << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

const int MAX = 510000;
const int MOD = 1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];


long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    if (k >= n - 1) cout << COM(2 * n - 1, n) << endl;

    else{
        ll move = k;
        ll stay = n - move;
        ll ans = 0;
        rep(i, k + 1){
            ans += COM(n - 1, i) * COM(n, i);
            ans %= MOD;
        }
        ans %= MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 12160
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    
    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            N = N % 1000;
            Console.WriteLine(1000 - N == 1000 ? 0 : 1000 - N);
        }
    }
}

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

int main()
{
    int N; cin>>N;
    vector<double> v(N);
    for(int i=0;i<N;i++) cin>>v[i];
    sort(v.begin(),v.end());

    double ans=(v[0]+v[1])/2;
    for(int i=2;i<N;i++){
        ans=(ans+v[i])/2;
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}

 bool isPowerOfTwo(ll x)
    {
        // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
        return (x && !(x & (x - 1)));
    }


 bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 



void solve()
{
	char a;
	cin>>a;
	if(a>=65 and a<=90)
		cout<<"A";
	else cout<<"a";
}


int main()       
{
  fastio
  ll t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 3644
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String S = sc.next();
		char[] ary = S.toCharArray();
		String ans = "Good";
		for (int i = 0; i < 3; i++) {
			if (ary[i] == ary[i+1]) {
				ans = "Bad";
			}
		}
		
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 23124
def main():
    n,k = map(int,input().split())
    ls = [int(x) for x in input().split()]
    dp = [float("inf") for _ in range(n)]
    dp[0] = 0
    for i in range(1,n):
        for j in range(1,min(i,k)+1):
            dp[i] = min(dp[i-j]+abs(ls[i]-ls[i-j]),dp[i])
    print(dp[n-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 56672
n = gets.split(" ").map(&:to_i)
b = readlines.map{|i| i.chomp.split.map(&:to_i)}
a = b.slice!(0,n[0])
c = Array.new(n[0]).map{Array.new(n[2],0)}
bt = b.transpose
n[0].times do |i|
  n[2].times do |j|
    c[i][j] = [a[i],bt[j]].transpose.map{|t| t.inject(:*)}.inject(:+)
  end
  puts c[i].join(" ")
end

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

bool Solve(const string& str) {
  bool n = str.find('N') != string::npos;
  bool w = str.find('W') != string::npos;
  bool s = str.find('S') != string::npos;
  bool e = str.find('E') != string::npos;
  return (n == s) && (w == e);
}

int main() {
  string s;
  cin >> s;
  cout << (Solve(s) ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

# x:gcd
# M//x >= N:解はこの値より小さいか、
# x >= N:この値より大きくなるはず
ans = 1
x = 1
while x * x <= M:
    if M % x == 0:
        if x >= N:
            ans = max(ans, M//x)
        if M//x >= N:
            ans = max(ans, x)
    x += 1
print(ans)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String[] t = sc.nextLine().split(" ");
		int  d = Integer.parseInt(t[0]);
		int  p = Integer.parseInt(t[1]);
		double  s = Double.parseDouble(t[2]);


		double x = d / s;

		String y;
		if(x > p) {
			y = "No";
		}else {
			y = "Yes";
		}

		System.out.println(y);
	}
}


Measured memory_bytes: 35716
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (data) {
  let sum = 0
  for (let i = 1; i < Number(data) + 1; i++) {
    for (let j = 1; j < Number(data) + 1; j++) {
      for (let k = 1; k < Number(data) + 1; k++) {
        const jk = gcd(j,k)
        const ijk = gcd(jk,i)
        sum = sum + ijk
      }
    }
  }
  console.log(sum)
});


function gcd(m, n) {
  let r;

  if(m < n) {  
    r = m;  
    m = n;
    n = r;
  }

  while ((r = m % n) != 0) {
    m = n;
    n = r;
  }

  return n;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

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

	for (int i = n-2; i >=0; i--) {
		if (h[i] > h[i + 1]) {
			h[i]--;
		}
		if (h[i] > h[i + 1]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

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

using namespace std;

typedef long long ll;

string s;
set <string> st;

void Rec(int n, int Max = -1)
{
    if(!n)  return void(st.insert(s));

    for(int i = 0; i <= Max + 1; i++)
    {
        s += char(i + 'a');
        Rec(n - 1, max(Max, i));
        s.pop_back();
    }
}

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

    Rec(n);

    for(string s : st)  cout << s << endl;
}


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

long long func(long long X, long long K, long long D) {
      D = D*2; 
    long long tmp =X/ D;
    long long X_tmp = X;
    if (tmp > K ) {
      X_tmp = X - D*K;
    } else {
      long long X_plus, X_minus;
      X_plus = X % D;
      X_minus = X_plus-D;
      if (abs(X_plus) > abs(X_minus)) X_tmp = X_minus;
      else X_tmp = X_plus;
    }
    return abs(X_tmp);
}

int main() {

  long long X, K, D;
  cin >> X >> K >> D;

  
  X = abs(X);
  long long X_tmp = X;
  long long tmp;
  if(X == 0){
    if(K%2==1) X_tmp = D;
    else X_tmp = 0;
  } else {

    if ( K % 2 == 0) {
      K/=2;
      X_tmp = func(X, K, D);

    } else {
      long long X_tmp1, X_tmp2;
      K/=2;

      X_tmp1 = func(X+D, K, D);
      X_tmp2 = func(X-D, K, D);
      if(X_tmp1 > X_tmp2) X_tmp = X_tmp2;
      else X_tmp = X_tmp1;

    }
  }
  cout << X_tmp << endl;
}

Measured memory_bytes: 3628
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
    if (exp == 0) {
        return 1;
    }

    if (exp == 1) {
        return base;
    }

    if (exp % 2 == 0) {
        return powSz(base * base, exp / 2);
    }
    else {
        return base * powSz(base, exp - 1);
    }
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    uint64_t N, D;

    scanf("%"PRIu64"%"PRIu64, &N, &D);

    const uint64_t numWatch = 2 * D + 1;

    printf("%"PRIu64, (N + numWatch - 1) / numWatch);

    return 0;
}


Measured memory_bytes: 128
from operator import itemgetter

N = int(input())
work = []

for i in range(N):
    A, B = (int(x) for x in input().split())
    work.append([A, B])

work = sorted(work, key=itemgetter(1))

t = 0
ans = True

for i in range(N):
    t += work[i][0]
    if(t > work[i][1]):
        ans = False
        break
if ans == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 39736
#include<bits/stdc++.h>
using namespace std;
string s="abcdefghijklmnopqrstuvwxyz";
#define ll long long int
int main()
{
    ll n,x;cin>>n;
    string ans="";
    while(n>0)
    {
        n--;
        ans+= char('a'+n%26);
        n=n/26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}
/*




*/


Measured memory_bytes: 3588
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var incdec = 0; var count = 0;
        var pre = a[0];
        for (int i = 1; i < n; i++)
        {
            if (incdec == 0 && pre < a[i]) incdec = 1;
            else if (incdec == 0 && pre > a[i]) incdec = -1;
            else if (incdec == 1 && pre > a[i]) { count++; incdec = 0; }
            else if (incdec == -1 && pre < a[i]) { count++; incdec = 0; }
            pre = a[i];
        }
        Console.WriteLine(count + 1);
    }
}


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

int main() 
{
	int n, k;
	cin >> n >> k;
	bool win[k + 1];
	
	int a[n];
	for (int j = 0; j < n; j++)
		cin >> a[j];
		
	win[0] = 1;
	for (int i = 1; i <= k; i++)
	{
		win[i] = 1;
		for (int j = 0; j < n; j++)
		{
			if (a[j] > i) break;
			if (win[i - a[j]]) {win[i] = 0; break;}
		}
	}
	
	if (!win[k]) cout << "First";
	else cout << "Second"; 
}

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

int main(){
  
  char a[3];
  int j;
  bool count =false;
  
  cin>>a[0]>>a[1]>>a[2];
  
  for(j=0;j<3;j++){
    if(a[j] == '7'){
      count = true;
      break;
    }else{
      count = false;
    }
  }
  
  if(count==true){
    cout << "Yes";
  }else if(count == false){
    cout << "No";
  }else{
    cout << "Error";
  }
  
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

const ll kazu = 2019;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    vector<ll> remain(2019, 0);
    remain.at(0) = 1;

    ll factor = 1;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        factor = factor % kazu;
        sum = ((ll)(s.at(i) - '0') * factor + sum) % kazu;
        remain.at(sum)++;
        factor = factor * 10;
    }

    ll ans = 0;
    for (int i = 0; i < 2019; i++) {
        ans += remain.at(i) * (remain.at(i) - 1) / 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		double tmp1 = sc.nextDouble();
		double tmp2 = sc.nextDouble();
		double h = tmp1 / 6. * Math.PI + tmp2 / 30. * Math.PI / 12.;
		double m = tmp2 / 30. * Math.PI + tmp1 / 6. * Math.PI * 12.;
		double rad = h - m;
		// System.out.println(rad / Math.PI / 2. * 360.);
		double res = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - (2. * a * b * Math.cos(rad)));
		System.out.println(res);
	}

}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int dp[12][9 * mx6], g, d, p[12], c[12];

int stt(int id, int S)
{
    if(id > d){
        if(S < g)
            return 1e7;
        return 0;
    }

    if(dp[id][S] != -1)
        return dp[id][S];

    int ans = INT_MAX;
    for(int i = 0; i < p[id]; i++){
        ans = min(ans, i + stt(id + 1, S + i * id * 100));
    }

    ans = min(ans, p[id] + stt(id + 1, S + id * 100 * p[id] + c[id]));

    return dp[id][S] = ans;
}

int main()
{
    mem(dp, -1);
    cin >> d >> g;

    for(int i = 1; i <= d; i++)
        cin >> p[i] >> c[i];

    cout << stt(1, 0) << '\n';
    return 0;
}


Measured memory_bytes: 425424
while True:
    num = int(input())
    if num == 0:
        break
    
    L = [int(x) for x in input().split()]
    
    ave = sum(L)/ len(L)
    
    c = 0
    for i in L:
        if i <= ave:
            c += 1
    print(c)
    


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return (a*( b/ gcd(a,b)));}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void f()
{
  ll k,sum=0;
  cin>>k;
  for(int i=1;i<k+1;i++)
  {
    for(int j=1;j<k+1;j++)
    {
      for(int l=1;l<k+1;l++)
      {
        sum+=gcd(gcd(i,j),gcd(j,l));
      }
    }
  }
  cout<<sum<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  map<int, int> m;
  for (int i=0; i<n; i++) {
    int a;
    cin>>a;
    ++m[a];
  }
  if (m.size() > 2) {
    cout<<"No"<<endl;
    return 0;
  }
  vector<pair<int, int> > v(m.begin(), m.end());
  if (v.size() == 1) {
    if (v[0].first == n - 1 || v[0].first * 2 <= n) {
      cout<<"Yes"<<endl;
      return 0;
    } else {
      cout<<"No"<<endl;
      return 0;
    }
  }
  pair<int, int> b = v[0];
  pair<int, int> c = v[1];
  if (c.first != b.first + 1) {
      cout<<"No"<<endl;
  } else if (c.first - b.second <= 0) {
      cout<<"No"<<endl;
  } else if (2 * (c.first - b.second) <= c.second) {
      cout<<"Yes"<<endl;
  } else {
      cout<<"No"<<endl;
  }
}

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

#define ll long long
#define ull unsigned long long
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)
#define DEBUG(x) cerr << #x << " = " << x << endl

const int MAX = 2e6 + 5, MOD = 1e9 + 7  , MAXLG = log2(MAX)+1;
const ll inf = 1e18 + 5;

int arr[MAX];
int main(){

    fastio;
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<"\n";
}


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

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

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

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

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

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

    string S; cin >> S;
    int ans=SZ(S);
    int pos;
    rep(i,SZ(S)-1){
        if(S[i]!=S[i+1]){
            pos=max((int)SZ(S)-i-1,i+1);
            chmin(ans,pos);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
	int i,x;
	for (i = 1;; i++){
		cin >> x;
		if (x != 0){
			cout << "Case " << i << ": " << x << endl;
		}
		else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------


int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	LL N;
	cin >> N;
	LL ans = 0;
	FOR(i, 0, sqrt(N) + 1) {
		if (i*i <= N)
			ans = i*i;
	}
	cout << ans << endl;

	return 0;
}


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

int main(void){
    int k, s;
    cin >> k >> s;
    
    int cnt = 0;
    int i, j;
    for(i = 0; i <= k; i++){
        for(j = 0; j <= k; j++){
            if(0 <= s - (i + j) && s - (i + j) <= k){
                cnt++;
            }
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
using namespace std;
const ll N=1e6+1;
void solve(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(b-1,n);
    cout<<(a*x)/b<<endl;
}

// don't forget to check for overflows in final answers
int main(){
    ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
  int t,a,b;
  cin>>t;
  bool prev=true;
  int c=0;
  while(t--)
  {
    cin>>a>>b;
    if(a==b)
    {
      c+=1;
    }
    else
      c=0;
    if(c>=3)
    {
      prev=false;
    }
  }
  if(prev)
    cout<<"No";
  else
    cout<<"Yes";
}

Measured memory_bytes: 3592
program knapsack1;

uses math;

const
  fi='knapsack1.inp';
  fo='knapsack1.out';
  oo=trunc(1e9)+5;

var
  n,m,va: longint;
  v,w: array[0..100000] of int32;
  f:array[0..100,0..100000] of int32;

procedure nhap;
var i: longint;
begin

  va:=0;
  read(n,m);
  for i:=1 to n do begin
    read(w[i],v[i]);
    inc(va,v[i]);
  end;

end;

procedure xuli;
var i,j,ans: longint;
begin

  ans:=0;
  for i:=0 to n do begin
    for j:=0 to va do f[i][j]:=oo;
  end;

  f[0][0]:=0;

  for i:=1 to n do begin
    for j:=0 to va do begin
      if (j>=v[i]) and (f[i-1][j-v[i]]+w[i]<=m) then f[i][j]:=min(f[i-1][j],f[i-1][j-v[i]]+w[i])
      else f[i][j]:=f[i-1][j];
    end;
  end;


  for j:=0 to va do begin
    if f[n][j]<=m then ans:=j;
  end;
//
//  for i:=0 to n do begin
//    for j:=0 to va do begin
//      if f[i][j]=oo then write('oo':3)
//      else write(f[i][j]:3);
//    end;
//    writeln
//  end;

  write(ans);

end;

begin

  //assign(input,fi);  reset(input);
  //assign(output,fo); rewrite(output);

  nhap;
  xuli;

  //close(input);      close(output);

end.


Measured memory_bytes: 39680
#include <stdio.h>

int main(void)
{
	int N, M;
	int i, j;
	int now;
	int count;
	int map[1000];
	int X[1000];
	
	while (1){
	
		scanf("%d %d", &N, &M);
		
		if (N == 0 && M == 0){
			break;
		}
		
		for (i = 0; i < N; i++){
			scanf("%d", &map[i]);
		}
		for (j = 0; j < M; j++){
			scanf("%d", &X[j]);
		}
		
		now = 1;
		
		j = 0;
		
		count = 0;
		
		while (now < N){
			now += X[j];
			now += map[now - 1];
			j++;
			count++;
		}
		printf("%d\n", count);
	}
	return (0);
}

Measured memory_bytes: 608
#include<stdio.h>
#include <stdlib.h>
int compare(const void *a, const void *b);
int main(){
    int n;
    double v[101];
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++){
        scanf("%lf",&v[i]);
    }
    //printf("%d",n);
    if(n==2){
        //double s;
        //printf("%lf %lf\n",v[0],v[1]);
        //s=v[0]+v[1];
        //printf("%lf\n",s);
        printf("%lf\n",((v[0]+v[1])/2));
    }
    else{
        qsort(v, n , sizeof(double), compare);
        //printf("v[0]=%lf\n",v[0]);
        for(i=1;i<n;i++){
          //  printf("%lf\n",v[i]);
            v[0]=(v[0]+v[i])/2;
        }
        printf("%lf\n",v[0]);
    }
    return 0;
}
int compare(const void *a, const void *b) {
return *(double *)a - *(double *)b;
}

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

int main() {
 int n;
  cin >>n;
  vector<long long int> lucas(86);
  lucas[0]=2;
  lucas[1]=1;
  for(int i=0;i<n-1;i++){
     lucas[i+2]=lucas[i]+lucas[i+1];
  }
  cout << lucas[n] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

void solve(void){
    int a, b; char op;
    while (1) {
        cin >> a >> op >> b;
        if (op == '?') break;
        int ans = 0;
        switch (op) {
            case '+': ans = a+b; break;
            case '-': ans = a-b; break;
            case '*': ans = a*b; break;
            case '/': ans = a/b; break;
        }
        printf("%d\n", ans);
    }
}

int main(void){
  solve();
  return 0;
}



Measured memory_bytes: 3232
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef unsigned long LInt;
typedef long double ld;

#define inf 1e18
constexpr long long INFLL = 1e18;
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    int n;
    cin >> n;
    vector<llint>a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return;
        }
    }
    llint ans=1;
    for(int i=0;i<n;i++){
        if(a[i]<=1000000000000000000/ans){
            ans*=a[i];
        }
        else{
            cout << -1 << endl;
            return;
        }
    }
    cout << ans << endl;
}

int main(){
  solve();
  return 0;
}


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

int main(int ac, char **argv) {
  int a,b;
  char buf[100];
  int count = 0;
  int i = 0;
  while(1) {
    if(fgets(buf, 100, stdin) == NULL) break;
    sscanf(buf, "%d %d", &a, &b);
    sprintf(buf, "%d_", a+b);
    while(buf[count++] != '_');
    printf("%d\n", count-1);
    a = 0, b = 0, count = 0;
  }
  return 0;
}

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

#define forn(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
        string s,t;
        cin>>s>>t;
        int n1=(int)s.length();
        int n2=(int)t.length();
        vector<vector<int>> dp(n1+1,vector<int>(n2+1,0));
        for(int i=1;i<n1+1;i++){
            for(int j=1;j<n2+1;j++){
                if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1]+1;
                else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
        string ans="";
        int i=n1,j=n2;
        while(i>0){
            if(s[i-1]==t[j-1]){
                ans=s[i-1]+ans;
                i--;j--;
            }
            else {
                if(dp[i-1][j]>dp[i][j-1])i--;
                else j--;
            }
        }
        cout<<ans<<endl;
        //for(auto i :dp){
                //for(int j:i)cout<<j<<" ";
                //cout<<endl;
        //}

}


Measured memory_bytes: 35584