akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;

class Program
{
    Func<int, int, Func<int, int>> f = (r, D) => (x) => r * x - D;
        
    void Solve()
    {
        var r = io.Int;
        var D = io.Int;
        var x_2000 = io.Int;
        var ff = f(r, D);

        var pre = x_2000;
        for (var i = 0; i < 10; i++)
        {
            var nxt = ff(pre);
            WriteLine(nxt);
            pre = nxt;
        }
    }


    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Program().Stream();

    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};

    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };

    public SimpleIO()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }

    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == string.Empty) st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }

    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}

Measured memory_bytes: 11220
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n, m;
    cin >> n >> m;
    int a = 1800 * m + 100 * n;
    cout << pow(2, m) * a << endl;

    return 0;
}

Measured memory_bytes: 256
def gets; ARGF.gets; end

def mul_num(n, k)
  n / k
end

def main
  n, k = gets.split.map(&:to_i)
  if k.even?
    # kの倍数の個数
    e = mul_num(n, k)

    # 倍数間の真ん中の個数
    o = if k / 2 <= n % k
          e + 1
        else
          e
        end

    # puts e
    # puts o
    puts e**3 + o**3
  else
    e = mul_num(n, k)

    puts e**3
  end
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 1788
#include <iostream>

using namespace std;


int main()
{
	int D;

	cin >> D;

	if (D == 25) {
		printf("Christmas");
	}else if (D == 24) {
		printf("Christmas Eve");
	}else if (D == 23) {
		printf("Christmas Eve Eve");
	}else if (D == 22) {
		printf("Christmas Eve Eve Eve");
	}

	return 0;
}



Measured memory_bytes: 256
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 3000 + 10;

ll a[N], dp[N][N][2];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    for (int i = 0; i < n; i ++)
        cin >> a[i];
    for (int len = 0; len < n; len ++)
        for (int i = 0; i + len < n; i ++)
            for (int j = 0; j < 2; j ++)
                dp[i][i + len][j] = max(a[i] - dp[i + 1][i + len][1 -j], a[i + len] - dp[i][i + len - 1][1 - j]);
    cout << dp[0][n - 1][0];
    return 0;
}


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

int main(){
	int a,b,d,r;
    cin>>a>>b;
    d=a/b;
	r=a%b;
	double f;
	f=(double)a/b;
	cout << fixed << setprecision(5);
	cout <<d<<" "<<r<<" "<<f<<endl;
   }





Measured memory_bytes: 3272
N = int(input())
P = [int(input()) for _ in range(N)]

longest_increasing_subsequence = [0]*(N+1) #[i]: i以下の数字による最長増加部分文字列

for p in P:
  longest_increasing_subsequence[p] = max(1, longest_increasing_subsequence[p-1]+1)

#print(longest_increasing_subsequence)
print(N - max(longest_increasing_subsequence))


Measured memory_bytes: 18888
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 200006
#define mo 1000000007
using namespace std;
int n,m,q,v,d,a[N],b[N],c[N],f[11][N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&a[i],&b[i]);
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		scanf("%d%d%d",&v,&d,&c[i]);
		f[d][v]=i;
	}
	for(int i=9;i>=0;i--){
		for(int j=1;j<=n;j++)f[i][j]=max(f[i+1][j],f[i][j]);
		for(int j=1;j<=m;j++){
			f[i][a[j]]=max(f[i][a[j]],f[i+1][b[j]]);
			f[i][b[j]]=max(f[i][b[j]],f[i+1][a[j]]);
		}
	}
	for(int i=1;i<=n;i++)printf("%d\n",c[f[0][i]]);
}

Measured memory_bytes: 10240
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#define inf 2147483640
#define pi acos(-1.0)
#define IL inline
#define RG register
#define LL long long
#define db double
using namespace std;
IL int gi()
{
	RG int res=0,s=1;RG char ch;
	for(ch=getchar(); (ch<'0'||ch>'9')&&ch!='-' ;ch=getchar());
	if(ch=='-') s=-1,ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) res=10*res+ch-48;
	return res*s;
}
LL q,h,s,d;
LL n;
int main()
{
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	q=gi(),h=gi(),s=gi(),d=gi();
	n=gi(); 
	s=min(s,q*4);
	s=min(s,q*2+h);
	s=min(s,h*2);
	d=min(d,s*2);
	if(n&1)
		{
			printf("%lld\n",(n>>1)*d+s);
		}
	else printf("%lld\n",(n>>1)*d);
	//fclose(stdin);fclose(stdout);
	return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int n; cin >> n;
  vector<int> a(n), c(n);

  REP(i, n) {
    cin >> a[i];
    c[i] = a[i] - i - 1;
  }
  ASC(c);
  int b1, b2;
  b1 = c[(n / 2) - 1];
  b2 = c[n / 2];

  ll ans1 = 0;
  ll ans2 = 0;
  REP(i, n) {
    ans1 += abs(c[i] - b1);
    ans2 += abs(c[i] - b2);
  }
  cout << min(ans1, ans2) << endl;
}


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

int main()
{
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;

	vector<int> va(a);
	vector<int> vb(b);
	vector<int> vc(c);
	for (auto& i : va) {
		cin >> i;
	}
	for (auto& i : vb) {
		cin >> i;
	}
	for (auto& i : vc) {
		cin >> i;
	}
	sort(va.begin(),va.end(), greater<int>());
	sort(vb.begin(), vb.end(), greater<int>());
//	sort(vc.begin(), vc.end(), greater<int>());
	vector<int> temp;
	for (int i = 0; i < x; ++i) {
		temp.push_back(va[i]);
	}
	for (int i = 0; i < y; ++i) {
		temp.push_back(vb[i]);
	}
	for (int i = 0; i < c; ++i) {
		temp.push_back(vc[i]);
	}
	sort(temp.begin(), temp.end(), greater<int>());
	long long ret = 0;
	for (int i = 0; i < x + y; ++i) {
		ret += temp[i];
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}


int main(int argc, char const *argv[]) {
    int n,x,y; cin>>n>>x>>y;
    vector<vector<int>> g(n);
    vector<vector<int>> dist(n, vector<int>(n));
    --x,--y;
    g[x].push_back(y);
    g[y].push_back(x);

    rep(i,n-1) {
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }

    rep(i,n) {
        queue<int> q;
        vector<int> dp(n,INF);
        q.push(i);
        dp[i]=0;
        while (!q.empty()) {
            int cur = q.front(); q.pop();
            for (auto &&e: g[cur]) {
                if (chmin(dp[e], dp[cur]+1)) {
                    q.push(e);
                }
            }
        }
        rep(j,n) {
            dist[i][j] = dp[j];
        }
    }

    vector<int> cnt(n);
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            cnt[dist[i][j]]++;
        }
    }

    for (int i = 1; i < n; ++i) cout << cnt[i] << '\n';
    return 0;
}

Measured memory_bytes: 16128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = readline().rstrip().decode('utf-8')

N = len(S)+1

from_left = [0]*N
from_right = [0]*N

for i,s in enumerate(S,1):
    if s == '>':
        from_left[i] = 0
    else:
        from_left[i] = from_left[i-1]+1

for i,s in enumerate(S[::-1]):
    i = N-2-i
    if s == '<':
        from_right[i] = 0
    else:
        from_right[i] = from_right[i+1]+1

seq = [x if x>y else y for x,y in zip(from_left,from_right)]

answer = sum(seq)
print(answer)

Measured memory_bytes: 31656
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a, b, c, d, n, k, x;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";

    cin  >> s;

    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]){}
    else if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1]){}
    else if(s[0] == s[3] && s[1] == s[2] && s[0] != s[2]){}
    else sans = "No";



    // std::cout << ans << endl; 
    std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

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<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;



int n, p[200005], minp = 10000000, ans;

int main() {

	cin >> n;
	rep(i, n)cin >> p[i];

	rep(i, n) {
		if (minp > p[i]) {
			minp = p[i];
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if((A==B && B!=C) || (B==C && B!=A) || (C==A && A!=B)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
def check(pair,m,x):
  sum = 0
  
  for i in range(1,m+1):
    p= 0
    for e in pair:
      p += e[i]
    if(p < x):
      return -1
    
  for e in pair:
    sum += e[0]
  return sum
      
n,m,x = (int(x) for x in input().split())
a = []
for i in range(n):
  a.append(tuple([int(x) for x in input().split()]))
  
min = -1
  
for i in range(2 ** n):
  pair = []
  for j in range(n):
    if((i >> j) & 1):
      pair.append(a[j])
  sum = check(pair,m,x)
  
  if min == -1:
    min = sum
  elif sum != -1 and min > sum:
    min = sum
    
print(min)


Measured memory_bytes: 9188
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  const ll mod=1e9+7;
  const ll MAX=1e5+1;
  ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);}
  //
  //	
  	ll solve(){
  		ll n,m;
  		cin>>n>>m;
  		vector<vll> vec(8);
  		rep(i,0,n){
	  		ll x,y,z,p=1,q=1,r=1;
  			cin>>x>>y>>z;
  			rep(j,0,1<<3){
  				if(j&(1<<0))	p=-1;
  				if(j&(1<<1))   q=-1;
  				if(j&(1<<2))   r=-1;
  				vec[j].pb(p*x+q*y+r*z);
  				// cout<<p*x+q*y+r*z<<" ";
  				p=1;q=1;r=1;
  			}
  			// cout<<'\n';
  		}
  		ll ans=0;
  		rep(i,0,8){
  			sort(vec[i].rbegin(),vec[i].rend());
  			ans=max(ans,(ll)abs(add(vec[i].begin(),vec[i].begin()+m,0ll)));
  		}
  		cout<<ans;
  	}
	int main(){ 
		hs;
		ll t;
		// cin>>t;
		t=1;
		while(t--)
			solve();
    return 0; 
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a;
    cin >> a;
    if (a == 7 || a == 5 || a == 3)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}

Measured memory_bytes: 256
#include <stdio.h> 

int main(){

  char num[1001];

  int i=0;

  int sum=1;

  while(sum!=0){

    sum=0;

    i=0;

    scanf("%c",&num[i]);

    while(num[i]!='\n'){

       i++;

       scanf("%c",&num[i]);

    }

   num[i]='\0';

   i=0;

  while(num[i]!='\0'){

     sum+=num[i]-'0';

     i++;

  } 

  if(sum!=0){

    printf("%d\n",sum);

  }

  }

  return 0;

}

Measured memory_bytes: 536
#include <cstdio>
#include <algorithm>
#include <stack>
using namespace std;

stack<int> B, C;
int A[10];

bool dfs(int index)
{
  bool ret = false;
  char s[11];

  if (index >= 10) {
    return true;
  }

  for (int i = 0; i < 11; i++) {
    if (i < index) s[i] = '>';
    else s[i] = 0;
  }

  if (B.empty() || B.top() < A[index]) {
    B.push(A[index]);
    // printf("%spush %d into B\n", s, A[index]);
    ret = dfs(index + 1);
    // printf("%s%s. pop %d from B\n", s, ret ? "succeeded" : "failed", A[index]);
    B.pop();
  }
  if (!ret && (C.empty() || C.top() < A[index])) {
    C.push(A[index]);
    // printf("%spush %d into C\n", s, A[index]);
    ret = dfs(index + 1);
    // printf("%s%s. pop %d from C\n", s, ret ? "succeeded" : "failed", A[index]);
    C.pop();
  }

  return ret;
}

bool solve()
{
  while (!B.empty()) B.pop();
  while (!C.empty()) C.pop();

  B.push(A[0]);
  bool ret = dfs(1);
  B.pop();

  return ret;
}

int main()
{
  int N;
  scanf("%d", &N);

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", A + j);
    }

    if (solve()) {
      printf("YES\n");
    }
    else {
      printf("NO\n");
    }
  }

  return 0;
}


Measured memory_bytes: 2560
INF = pow(10, 9)

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b ,c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + length[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + length[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + length[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

if __name__ == '__main__':
    N, A, B, C = map(int, input().split())
    length = [int(input()) for i in range(N)]
    print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int t[200050];
int d[200050];
signed main(){
    int n,m;
    cin >> n;
    int a,sum = 0;
    rep(i,n){
        cin >> d[i];
    }   
    sort(d,d+n);
    cin >> m;
    rep(i,m){
        cin >> t[i];
    }   
    sort(t,t+m);
    int cnt = 0;
    rep(i,n + 1){ 
        if(cnt == m){ 
            cout << "YES\n";
            return 0;
        }
        if(d[i] == t[cnt]) ++cnt;
    }   
    cout << "NO\n";
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
using namespace std;
using ll = long long;


int main() {
	string s;
	cin >> s;
	int aa = 0, cc = 0;
	if (s[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}
	for (int i = 1;i < s.size();i++) {
		if (s[i] != 'C'&&s[i] <= 'Z'&&s[i] >= 'A') {
			cout << "WA" << endl;
			return 0;
		}
	}
	for (int i = 2;i < s.size() - 1;i++) {
		if (s[i] == 'C')cc++;
	}
	if (cc == 1)cout << "AC" << endl;
	else cout << "WA" << endl;
}


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

long long dp[1001][101][10];
bool used[101];

long long solve(int s, int upper, int n) {
    if (n == 0) {
        return s == 0 ? 1 : 0;
    }
    if (upper < 0) {
        return 0;
    }
    if (0 <= dp[s][upper][n]) {
        return dp[s][upper][n];
    }
    long long ret = 0;
    for (int i=upper; i>=0; --i) {
        if ( ! used[i] && 0 <= s-i) {
            used[i] = true;
            ret += solve(s-i, i-1, n-1);
            used[i] = false;
        }
    }
    return dp[s][upper][n] = ret;
}

int main() {
    int n, s;
    memset(dp, -1, sizeof dp);
    memset(used, false, sizeof used);
    while (cin >> n >> s, n) {
        cout << solve(s, 100, n) << endl;
    }
    return 0;
}

Measured memory_bytes: 9060
# include<iostream>

using namespace std;
int main(){
	int a = 0;
	int b = 0;
	while (1)
	{
		cin >> a >> b;
		if (a == 0 && b == 0){
			break;
		}
		for (int i = 0; i < a; i++){
			for (int it = 0; it < b / 2; it++){
				if (i % 2 == 0){
					cout << "#.";
				}
				else{
					cout << ".#";
				}
			}
			if (i % 2 == 0 && b % 2 == 1){
				cout << "#";
			}
			else if (i % 2 == 1 && b % 2 == 1){
				cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
const int MOD = 1e9 + 7;
const int N = 205;
const int M = 1e5 + 10;
long long dp[N][M];
int a[N];

int main() {
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i ++) {
		scanf("%d", &a[i]);
	}
	
	sort(a + 1 , a + 1 + n);

	dp[n][m] = 1;
	for(int i = n; i >= 1; i --) {
		for(int j = M - 5; j >= 0; j --) {
			if(dp[i][j] == 0) continue;
		   	dp[i - 1][j % a[i]] = (dp[i - 1][j % a[i]] +  dp[i][j]) % MOD;
			dp[i - 1][j] = (dp[i - 1][j] + dp[i][j] * 1LL * (i - 1)) % MOD;	
		}
	}

	long long sum = 0;
	for(int i = M - 5; i >= 0; i --) {
		sum = (sum + dp[0][i] * 1LL * i) % MOD;
	}
	cout << sum << endl;
	
}	


Measured memory_bytes: 156672
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="SUN")
        cout<<7<<endl;
    else if(s=="MON")
        cout<<6<<endl;
    else if(s=="TUE")
        cout<<5<<endl;
    else if(s=="WED")
        cout<<4<<endl;
    else if(s=="THU")
        cout<<3<<endl;
    else if(s=="FRI")
        cout<<2<<endl;
    else if(s=="SAT")
        cout<<1<<endl;
        return 0;

}


Measured memory_bytes: 256
def main():
    sx, sy, tx, ty = map(int,input().split())

    x = tx -sx
    y = ty -sy

    ans = "U"*y + "R"*x + "D"*y + "L"*(x+1) + "U"*(y+1)+ "R"*(x+1)+"D"+"R"+"D"*(y+1)+"L"*(x+1)+"U"
    print(ans)

if __name__ == "__main__":
        main()


Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

struct Dice{
  vector<int> D;
  string dir;
  int roll(vector<int> d){
    int top = D.at(0);
    int front = D.at(1);
    for(auto c : dir){
      if(c == 'N'){
        top = D.at(1);
        D.at(1) = D.at(5);
        D.at(5) = D.at(4);
        D.at(4) = D.at(0);
        D.at(0) = top;
      }
      else if(c == 'E'){
        top = D.at(3);
        D.at(3) = D.at(5);
        D.at(5) = D.at(2);
        D.at(2) = D.at(0);
        D.at(0) = top;
      }
      else if(c == 'W'){
        top = D.at(2);
        D.at(2) = D.at(5);
        D.at(5) = D.at(3);
        D.at(3) = D.at(0);
        D.at(0) = top;
      }
      else if(c == 'S'){
        top = D.at(4);
        D.at(4) = D.at(5);
        D.at(5) = D.at(1);
        D.at(1) = D.at(0);
        D.at(0) = top;
      }
      else if(c == 'L'){
        front = D.at(2);
        D.at(2) = D.at(4);
        D.at(4) = D.at(3);
        D.at(3) = D.at(1);
        D.at(1) = front;
      }
      else if(c == 'R'){
        front = D.at(3);
        D.at(3) = D.at(4);
        D.at(2) = D.at(1);
        D.at(4) = D.at(2);
        D.at(1) = front;
      }
      if(D.at(0) == d.at(0) && D.at(1) == d.at(1) && D.at(2) == d.at(2) && D.at(3) == d.at(3) && D.at(4) == d.at(4) && D.at(5) == d.at(5)){
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
    return 0;
  }
};

int main(){
  Dice x;
  for(int i = 0; i < 6; i++){
    int a;
    cin >> a;
    x.D.push_back(a);
  }
  vector<int> d(6);
  for(int i = 0; i < 6; i++){
    cin >> d.at(i);
  }

  x.dir = "LLLLNLLLLSWLLLLEELLLLWSLLLLNNNLLLL";
  x.roll(d);
}


Measured memory_bytes: 3200
//https://codeforces.com/blog/entry/61015
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=100000,M=100000;


int n,a[100010],x,y;
 main()
{

//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
//printf("%s, ",name[k[i]].c_str());  printf of string
//priority_queue<ll,vector<ll>,greater<ll>>y;
input;
cin>>n;
forr(i,1,n)
{
    cin>>a[i];
    if(a[i]>0)x++;
    else if(a[i]<0)y++;
}
sort(a+1,a+1+n);

if(y==0)
{
    ll sum=-abs(a[1]),g=a[1];
    forr(i,2,n)sum+=(ll)abs(a[i]);
    cout<<sum<<endl;
    forr(i,2,n)
    {
        if(i==n)cout<<a[i]<<" "<<g<<endl;
        else cout<<g<<" "<<a[i]<<endl;
        g=g-a[i];
    }
}
else if(x==0)
{
    ll sum=-abs(a[n]),g=a[n];
    for(int i=n-1;i>=1;i--)sum+=(ll)abs(a[i]);
    cout<<sum<<endl;
    for(int i=n-1;i>=1;i--)
    {
        cout<<g<<" "<<a[i]<<endl;
        g=g-a[i];
    }
}
else
{
    ll sum=0,g=a[1];
    forr(i,1,n)sum+=(ll)abs(a[i]);
    cout<<sum<<endl;
    for(int i=n-1;i>=1;i--)
    {
        if(a[i]>0)cout<<g<<" "<<a[i]<<endl;
        else break;
        g=g-a[i];
    }
    a[1]=g;
    g=a[n];
    forr(i,1,n)
    {
        if(a[i]<=0)cout<<g<<" "<<a[i]<<endl;
        else break;
        g=g-a[i];
    }
}



return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<ll,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, a, ans =0;
	cin >>n;
	map<int, int> mp;
	rep(i, n){ cin >>a; mp[a]++;}
	
	for(auto x: mp) ans += x.second &1; 
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int sum=0;
  if(a>=b){
    for(int i=0;i<a;i++){
      cout<<b;
    }
  }
  else{
    for(int i=0;i<b;i++){
      cout<<a;
    }
  }
}


Measured memory_bytes: 3544
// ABC087_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll A, B, C, X;
    cin >> A >> B >> C >> X;
    
    // calculation
    ll res = 0;
    REP(i, A+1) {
        REP(j, B+1) {
            REP(k, C+1) {
                if (i*500 + j*100 + k*50 == X) res++;
            }
        }
    }
    
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cctype>
#include<string.h>
#include <stdlib.h>
#include <ctype.h>

#define PI 3.1415926

void swap(int* x, int* y) {
	int a = *x;
	int b = *y;
	*x = b;
	*y = a;
}
int factorial(int n);

int main() {
	int M, s[200] = { 0 }, N, b[200][200], a[200];
	scanf("%d %d", &N, &M);
	for (int i = 1; i <= M; i++) {
		scanf("%d", &a[i]);
		
	}
	for (int i = 1; i <= M; i++) {
		for (int j = 1; j <= N; j++) {
			scanf("%d", &b[i][j]);
		}
	}
	for (int i = 1; i <= M; i++) {
		for (int j = 1; j <= N; j++) {
			if (b[i][j] == a[i]) {
				s[j] += 1;
			}
			else {
				s[a[i]] += 1;
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		printf("%d\n", s[i]);
	}
	return 0;
}

 int factorial(int n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else {
		return 1;
	}
}

Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans(0);
	cin>>n;
	char lst='\0';
	for(int i=1;i<=n;i++){
		char ch;
		cin>>ch;
		if(ch!=lst)
			lst=ch,ans++;
	}
	printf("%d",ans);
	return 0;
}

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

int main() {

  int a,b;
  cin >> a >> b;
  
  int ans = 1;
  int x = a-1;

  if(b > 1){
  	while(a < b) {
    	a += x;
    	ans++;
  	}
  	cout << ans << endl;
  }
  else cout << 0 << endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int x;
    scanf("%d", &x);
    if (x >= 30) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }


    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    set<int> st;
    rep(i,n){
        int a; cin>>a;
        st.insert(a);
    }
    cout<<st.size()<<endl;
    return 0;
}

Measured memory_bytes: 3636
def isok(A_, F_, N_, K_, x):
  _K_ = 0
  for i in range(N_):
    a_ = A_[i]-x//F_[i]
    if a_ > 0:
      _K_ += a_
  if _K_ > K_:
  	return False
  else:
    return True

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())), reverse = True)
ok = 10**12
ng = 0
while abs(ok-ng)>1:
  mid_x = (ok+ng)//2
  if isok(A, F, N, K, mid_x):
    ok = mid_x
  else:
    ng = mid_x
if isok(A, F, N, K, ng):
  print(ng)
else:
  print(ok)

Measured memory_bytes: 121036
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <time.h>
#include <ctype.h>

int cmp(const void *a, const void *b) { return *(int*)a - *(int*)b; }
int max(int a, int b) { return a >= b ? a : b; }
int min(int a, int b) { return a <= b ? a : b; }
int dsum(int x) { int r=0; while(x){ r+=(x%10); x/=10; } return r;}
void swap(int *a, int *b) { int tmp; tmp = *a; *a = *b; *b = tmp; return; }

int main(void) {
  int a,b;
  scanf("%d%d",&a,&b);
  printf("%d\n",(a+b)/2);
  return 0;
}


Measured memory_bytes: 2052
/*       Rohan Balot
    NSIT, New Delhi, India  */
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <valarray>
     
#include <cctype>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cstring>
#include <ctime>
using namespace std;
     
#define FIND(c, e) (c).find(e) != (c).end()
#define NFIND(c, e) (c).find(e) == (c).end()
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair
     
const int N = int( 1e5 ) + 1;
const int M = int( 1e6 ) + 1;
const int MOD = int( 1e9 ) + 7;
const double PI = acos(-1.0);
const double eps = 1e-6;
template<typename T> T gcd(T a,T b){while (b){ T r=a%b;a=b;b=r;}return a;}
template<typename T> T lcm(T a,T b){return (a*b)/gcd(a,b);}

struct graph {
	int vertices;
	int edges;
	vector< vector<int> > adj;
	vector< bool > visited;
	vector< int > level;
	graph() { }
	graph(int vertices) {
		this->adj.resize(vertices + 1);
		this->level.resize(vertices + 1, -1);
		this->visited.resize(vertices + 1, false);
		this->vertices = vertices;
		edges = 0;
	}
	void add_directed_edge(int from, int to) {
		this->adj[from].emplace_back(to);
		this->edges++;
	}	
	void add_undirected_edge(int from, int to) {
		this->adj[from].emplace_back(to);
		this->adj[to].emplace_back(from);
		this->edges += 2;
	}
	void read_undirected_edges(int edge_count) {
		this->edges += edge_count << 1;
		for (int i = 0; i < edge_count; i++) {
			int from, to;
			cin >> from >> to;
			this->adj[from].emplace_back(to);
			this->adj[to].emplace_back(from);
		}
	}	
	void read_directed_edges(int edge_count) {
		this->edges += edge_count;
		for (int i = 0; i < edge_count; i++) {
			int from, to;
			cin >> from >> to;
			this->adj[from].emplace_back(to);
		}
	}
	void dfs(int src) {
		this->visited[src] = true;
		for(int i : this->adj[src]) {
			if(this->visited[i] == false) {
				this->dfs(i);
			}
		}
	}
	void bfs(int src) {
		this->level[src] = 0;
		queue<int> q;
		q.push(src);
		while (!q.empty()) {
			int cur = q.front();
			q.pop();
			for(int i : this->adj[cur]) {
				if(this->level[i] == -1) {
					this->level[i] = this->level[cur] + 1;
					q.push(i);
				}
			}
		}
	}
};

void __answer()
{
	int n;
	cin >> n;
	list<int> l;
	if(n % 2 == 1) {
		for (int i = 1; i <= n; i++) {
			int e;
			cin >> e;
			if(i % 2 == 0)
				l.push_back(e);
			else l.push_front(e);
		}
	} else {
		for (int i = 1; i <= n; i++) {
			int e;
			cin >> e;
			if(i % 2 == 1)
				l.push_back(e);
			else l.push_front(e);
		}
	}
	for (auto i : l) {
		cout << i << " ";
	}
}    
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifdef LOCAL
        freopen("sample_input.txt", "r", stdin);
    #endif
    __answer();
    return 0;
} 

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int D = 365;
vi c, ans;
vvi s;

void input() {
  cin >> D;
  c = vi(26);
  s = vvi(D, vi(26));
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
}

void output() {
  for (int i = 0; i < D; i++) {
    cout << ans[i] + 1 << endl;
  }
}

int simulate(vi a) {
  int sum = 0;
  vi last(26, 0);
  for (int i = 0; i < D; i++) {
    sum += s[i][a[i]];
    last[a[i]] = i + 1;
    for (int j = 0; j < 26; j++) {
      sum -= c[j] * (i - last[j] + 1);
    }
  }
  return (int)1e6 + sum;
  // return max((int)1e6 + sum, 0);
}

void solve() {
  int best = simulate(ans);

  // 周期
  for (int i = 0; i < 26; i++) {
    vi a(D);
    for (int j = 0; j < D; j++) {
      a[j] = (i + j) % 26;
    }

    int x = simulate(a);
    if (x > best) {
      best = x;
      ans = a;
    }
  }

  //
  srand((unsigned)time(NULL));
  int loop = 20;
  bool lastIsNew = false;
  while (loop--) {
    vi a = ans;
    if (!lastIsNew) {
      int change = D / 10;
      while (change--) {
        a[rand() % D] = rand() % 26;
      }
    }

    for (int i = 0; i < D; i++) {
      vi b = a;
      int idx = 0, bst = simulate(b);
      for (int j = 0; j < 26; j++) {
        b[i] = j;
        int x = simulate(b);
        if (x > bst) {
          bst = x;
          idx = j;
        }
      }
      a[i] = idx;
    }

    lastIsNew = false;
    int x = simulate(a);
    if (x > best) {
      best = x;
      ans = a;
      lastIsNew = true;
    }
  }
}

int main() {
  input();
  ans = vi(D, 0);
  solve();
  output();
}


Measured memory_bytes: 3728
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        
        int n = scanner.nextInt();
        
        curb((float) 0, (float) 0, (float) 100, (float) 0, n);
        System.out.println((double) 100 + " " + (double) 0);
        
        scanner.close();
        return;
    }
    
    private static void curb(double x1, double y1, double x2, double y2, int n) {
        if(n == 0) {
            System.out.println(x1 + " " + y1);
            return;
        }
        
        double r3 = Math.pow(3, 0.5);
        
        double d1x = x1 + (x2 - x1) / 3;
        double d1y = y1 + (y2 - y1) / 3;
        curb(x1, y1, d1x, d1y, n - 1);
        
        double d2x = d1x + (x2 - x1) / 6 - (y2 - y1) * r3 / 6;
        double d2y = d1y + (y2 - y1) / 6 + (x2 - x1) * r3 / 6;
        curb(d1x, d1y, d2x, d2y, n - 1);
        
        double d3x = x1 + (x2 - x1) / 3 * 2;
        double d3y = y1 + (y2 - y1) / 3 * 2;
        curb(d2x, d2y, d3x, d3y, n - 1);
        
        curb(d3x, d3y, x2, y2, n - 1);
    } 
}


Measured memory_bytes: 32244
a,b=map(int,input().split())
s=input()
flag1=True
if s[a]!='-':
    flag1=False
flag2=True
for i in range(0,len(s)):
    if i==a:
        continue
    if not (s[i]>='0' and s[i]<='9'):
        flag2=False
print('Yes') if flag1 and flag2 else print('No')


Measured memory_bytes: 3060
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, ans, sum, last, cnt,d[100000];
Pll a[10000], b[10000];
struct Edge { LL to,cost; };
vector<Edge>vec[10000];
string str;
bool f;
struct graph {
	int L, R;
	vector<vector<int>> adj;
	graph(int L, int R) : L(L), R(R), adj(L + R) { }
	void add_edge(int u, int v) {
		adj[u].push_back(v + L);
		adj[v + L].push_back(u);
	}
	int maximum_matching() {
		vector<int> level(L), mate(L + R, -1);

		function<bool(void)> levelize = [&]() { // BFS
			queue<int> Q;
			for (int u = 0; u < L; ++u) {
				level[u] = -1;
				if (mate[u] < 0) {
					level[u] = 0;
					Q.push(u);
				}
			}
			while (!Q.empty()) {
				int u = Q.front(); Q.pop();
				for (int w : adj[u]) {
					int v = mate[w];
					if (v < 0) return true;
					if (level[v] < 0) {
						level[v] = level[u] + 1;
						Q.push(v);
					}
				}
			}
			return false;
		};
		function<bool(int)> augment = [&](int u) { // DFS
			for (int w : adj[u]) {
				int v = mate[w];
				if (v < 0 || (level[v] > level[u] && augment(v))) {
					mate[u] = w;
					mate[w] = u;
					return true;
				}
			}
			return false;
		};
		int match = 0;
		while (levelize())
			for (int u = 0; u < L; ++u)
				if (mate[u] < 0 && augment(u))
					++match;
		return match;
	}
};

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	graph g(n, n);
	rep(i, n)cin >> a[i].first >> a[i].second;
	rep(i, n)cin >> b[i].first >> b[i].second;
	rep(i, n) {
		rep(j, n) {
			if (a[i].first < b[j].first&&a[i].second < b[j].second) {
				g.add_edge(i, j);
			}
		}
	}
	printf("%d\n", g.maximum_matching());
	return 0;
}

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

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

   
    vector<double> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    for(int i = 0; i < N; i++){
        A.at(i) = 1 / A.at(i);
    }

    double C = 0;
    for(int i = 0; i < N; i++){
        C += A.at(i);
    }
    printf("%.6lf\n",1/C);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin >> n;
  vector<int> t(n), x(n), y(n);
  for(int i=0;i<n;i++){
    cin >> t[i] >> x[i] >> y[i];
    if ((t[i] + x[i] + y[i]) % 2){
      cout << "No" << endl; return 0;
    }
  }
  if (t[0] < abs(x[0]) + abs(y[0])){
    cout << "No" << endl; return 0;
  }
  for(int i=1;i<n;i++){
    if (t[i]-t[i-1] < abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])){
      cout << "No" << endl; return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
  
  

Measured memory_bytes: 1408
#include<stdio.h>
int main(void)
{
	int a,s,d,f,g[1002],i,j,k,z,x,c;
	z=0;
	c=0;
	scanf("%d",&a);
	scanf("%d %d",&s,&d);
	scanf("%d",&f);
	for(i=1;i<=a;i++){
		scanf("%d",&g[i]);
	}
	for(i=1;i<=a;i++){
		for(j=i+1;j<=a;j++){
			if(g[i]<g[j]){
				k=g[i];
				g[i]=g[j];
				g[j]=k;
			}
		}
	}
	for(i=1;i<=a;i++){
		x=f/s;
//		printf("%d %d\n",f,s);
		if(c<=x){
			c=x;
		}
		f=f+g[i];
		s=s+d;
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> T keta(T num){ T k=0; while(num>0){ num/=10; k++; } return k; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

	string s;
	cin >> s;
	
	int a=0, b=0, c=0;
	int slen = s.length();
	rep(i, slen){
		if(s[i] == 'a') a++;
		if(s[i] == 'b') b++;
		if(s[i] == 'c') c++;
	}
	
	if(slen == 1){
		ans2(true);
		return 0;
	}
	
	if(abs(a-b) <= 1 && abs(b-c) <= 1 && abs(c-a) <= 1) ans2(true);
    else ans2(false);

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
 struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
};
typedef struct node * NodePointer;

void insert(int);
void preorder(NodePointer);
void inorder(NodePointer);
NodePointer createNode(void);
NodePointer treeSearch(NodePointer, int);
NodePointer root = NULL;
NodePointer NIL = NULL;

main(){
  int m, i, k;
  char order[10];
  scanf("%d", &m);
  for(i = 0; i < m; i++){
    scanf(" %s", order);
if ( order[0] == 'f' ){
      scanf("%d", &k);
      NodePointer t = treeSearch(root, k);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
 }
    if(order[0]=='i'){
      scanf(" %d",&k);
      insert(k);
    }
    else if(order[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}


NodePointer createNode(){
  NodePointer node = malloc(sizeof(struct node));
  node->left = NULL;
  node->right = NULL;
  node->parent = NULL;
  node->key = 0;
  return node;
}


void insert(int key){
  NodePointer z = createNode();
  NodePointer x = root;
  NodePointer y = NIL;
  z->key = key;
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}


void preorder(NodePointer p){
  printf(" %d", p->key);
  if(p->left != NULL) preorder(p->left);
  if(p->right != NULL) preorder(p->right);
}

void inorder(NodePointer p){
  if(p->left != NULL) inorder(p->left);
  printf(" %d", p->key);
  if(p->right != NULL) inorder(p->right);
}


NodePointer treeSearch(NodePointer p,int k){
  while(p != NULL){
    if(k == p->key){
      return p;
    }
    else if(k <= p->key){
      p = p->left;
    }
    else p = p->right;
  }
  return NIL;
}

Measured memory_bytes: 19364
n=int(input())
lista=list(map(int,input().split()))
listb=[]
for i in lista:
	listb.append(i)
for i in range(1,n):
	listb[i]=listb[i]+listb[i-1]
# print(listb)
sum1=0
for i in range(n-1):
	sum1+=lista[i]*(listb[-1]-listb[i])
sum1=sum1%(1000000007)
print(sum1)

Measured memory_bytes: 31608