akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n,sum=0;
  cin>>n;
  vector<int>w(n);
  rep(i,n) {
    cin>>w[i];
    sum+=w[i];
  }
  int ans=300;
  rep(i,n){
    int sum1=0;
    rep(j,i){
      sum1+=w[j];
    }
    int cm=abs(sum-2*sum1);
    ans=min(ans,cm);
  }
  cout<<ans<<endl;
}


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

int x, y, z, a, b;
int main()
{
    cin >> x >> y >> z >> a >> b;
    int Sol = a * x + b * y;
    int Sol2 = min(a, b) * 2 * z;
    if(a > b) Sol2 += (a - b) * x;
    else Sol2 += (b - a) * y;
    Sol = min(Sol, Sol2);
    int Sol3 = max(a, b) * 2 * z;
    Sol = min(Sol, Sol3);
    cout << Sol;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <tuple>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)

int main()
{

  ll N, K;
  cin >> N >> K;

  ll ans = 0;

  if (K % 2 == 1)
  {
    ll num = floor(N / K);
    ans += pow(num, 3);
  }
  else if (K % 2 == 0)
  {
    ll num = floor(N / (K / 2));
    ll numK = floor(N / K);
    ans += pow(numK, 3);
    ans += pow(num - numK, 3);
  }

  cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
 
int main(){
    char ch;
    while (1){
        scanf("%c", &ch);
         
        if (ch ==  '\n') {
            printf("\n");
            return 0;
        }
         if (isupper(ch))
            printf("%c", tolower(ch));
        else
            printf("%c", toupper(ch));
    }
    return 0;
}


Measured memory_bytes: 2104
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i] - 1;
	}
	cout << sum;
}

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

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

    int i,j,x[10][10];

    for(i=0;i<n;i++)
      for(j=0;j<d;j++)
        scanf("%d",&x[i][j]);

    int k; int ans = 0;
    int dis = 0;

    for(i=0;i<n-1;i++)
    {
      for(j=i+1;j<n;j++)
        {
            dis = 0;
            for(k=0;k<d;k++)
                dis += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);

            double dd;

            dd = sqrt(dis);

            int da = dd;

            if(da*da == dis)
                ans ++;
        }
    }
      printf("%d\n",ans);

    return 0;
}

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


int main(){
  string S;    
  cin >> S;
  int yyyy = stoi(S.substr(0, 4));
  int m1   = stoi(S.substr(5, 1));
  int m2   = stoi(S.substr(6, 1));
  
  if(yyyy == 2019){
    if(m1 == 0 && m2 <= 4){
      cout << "Heisei" << endl;
    } else {
      cout << "TBD" << endl;
    }
  }else if(yyyy > 2019){
    cout << "TBD" << endl;
  }else {
    cout << "Heisei" << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int H, W; scanf("%d %d", &H, &W);
  vector<string> A(H);
  for (int i = 0; i < H; ++i) {
    cin >> A[i];
  }
  cout << string(W + 2, '#') << endl;
  for (int i = 0; i < H; ++i) {
    cout << "#" << A[i] << "#" << endl;
  }
  cout << string(W + 2, '#') << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var param = Console.ReadLine().Split(' ');
            var A = int.Parse(param[0]);
            var B = int.Parse(param[1]);
            var T = int.Parse(param[2]);
            var i = A;
            var num = 0;
            while (i <= T + 0.5)
            {
                num += B; 
                i += A;
            }
            Console.WriteLine(num);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    string S;
    cin >> S;

    ll ans = 0;
    ll prev = 0;
    for (ll i = 0; i < S.size(); i++)
    {
        switch (S[i])
        {
        case 'A':
        case 'C':
        case 'G':
        case 'T':
            prev += 1;
            break;

        default:
            prev = 0;
            break;
        }
        ans = max(ans, prev);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     int a = scan.nextInt();
     int b = scan.nextInt();
     if( a < b ) {
    	 System.out.println("a < b");
     }else if( a > b ){
    	 System.out.println("a > b");
     }else{
    	 System.out.println("a == b");
     }
    }
}

Measured memory_bytes: 12000
def exponential(x):
    if x < 4:
        return x
    for i in range(x, 0, -1):
        for p in range(2, int(i**0.5)+1):
            o = i
            while o%p==0:
                o //= p
            if o == 1:
                return i
x = int(input())
print(exponential(x))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    string s, t;
    cin >> s >> t;
    int ans = 0;
    FOR(i, 0, 3)if (s[i] == t[i])ans++;
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#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)

vector<int> unique(vector<int> v) {
	vector<int> u;
	if (!v.empty()) {
		u.push_back(v[0]);
		FOR(i, 1, v.size()) if (v[i] != v[i-1]) u.push_back(v[i]);
	}

	return u;
}

int main() {
	int n, m;
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0) break;

		vector<vector<int> > v(n);
		REP(i, m) {
			int a, b;
			cin >> a >> b;
			v[a-1].push_back(b-1);
			v[b-1].push_back(a-1);
		}

		vector<int> u;
		REP(i, v[0].size()) {
			u.push_back(v[0][i]);
			REP(j, v[v[0][i] ].size()) {
				u.push_back(v[v[0][i] ][j]);
			}
		}

		sort(u.begin(), u.end());
		u = unique(u);
		if (!u.empty()) u.erase(u.begin());

		cout << u.size() << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;

string n;
lli ans = 0;

int main(){
  cin >> n;
  lli mem = 0;
  for(lli i = 0;i < n.size();i++){
    if(n[i] != '0'){
      ans = max(ans,(lli)(mem+(n[i]-'0'-1)+(n.size()-i-1)*9));
    }
    mem += (n[i]-'0');
  }
  ans = max(ans,mem);
  cout << ans << endl;

}


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

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var a = new int[1].Concat(Console.ReadLine().Split(' ').Select(int.Parse)).ToArray();

        var b = new bool[N + 1];
        for (int i = N; i > 0; i--)
        {
            var count = 0;
            for (int j = i * 2; j <= N; j += i)
            {
                if (b[j])
                {
                    count++;
                }
            }

            if (count % 2 == a[i])
            {
                b[i] = false;
            }
            else if ((count + 1) % 2 == a[i])
            {
                b[i] = true;
            }
            else
            {
                Console.WriteLine(-1);
                return;
            }
        }

        var indexs = b.Select((v, i) => new { v, i }).Where(x => x.v).Select(x => x.i).ToList();
        Console.WriteLine(indexs.Count());
        if (indexs.Count > 0)
        {
            Console.WriteLine(string.Join(" ", indexs));
        }
    }
}

Measured memory_bytes: 32340
#include<stdio.h>

int binarysearch(int A[], int n, int key)
{
	int left, right, mid;
	
	left = 0;
	right = n;
	
	while(left < right)
	{
		mid = (left+right)/2;
		
		if(A[mid] == key)
		{
			return 1;
		}
		else if(key < A[mid])
		{
			right = mid;
		}
		else
		{
			left = mid+1;
		}
		
	}
	return 0;
	
	
}

int main(void)
{

int n, q, count;



count = 0;

scanf("%d", &n);

int S[n];

for(int i=0; i<n; i++)
{
	scanf("%d", &S[i]);
}

scanf("%d", &q);

int T[q];
	
for(int i=0; i<q; i++)
{
	scanf("%d", &T[i]);
}

for(int i=0; i<q; i++)
{
	if( binarysearch(S,n,T[i])==1)
	{
		count++;
	}
}
	
	printf("%d\n", count);


return 0;

}


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

int main(void){
    int n;
    cin >> n;
    
    int a[100000];
    int i;
    for(i = 0; i < n; i++){
        cin >> a[i];
    }
    
    sort(a, a + n);
    
    int cnt = 0;
    for(i = 1; i < n; i++){
        if(a[i] == a[i - 1]){
            cnt++;
        }
    }
    
    cout << n - (cnt + 1) / 2 * 2 << endl;
    
    return 0;
}


Measured memory_bytes: 640
// =====================================================
//   File    :   main.cpp
//   Author  :   eezyl
//   Synopsis:   codeforces/atcoder template
//   Address :
//   Date    :   2020/08/28
// =====================================================
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
typedef vector<vi> vvi;

#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const ll INF = 1e18;
const ld PI = acos((ld)-1);
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

// TO_STRING
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(bool b) { return b ? "true" : "false"; }
str ts(vector<bool> v) { str res; F0R(i,sz(v)) res += char('0'+v[i]); return res; }
template<size_t SZ> str ts(bitset<SZ> b) { str res; F0R(i,SZ) res += char('0'+b[i]); return res; }

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))

const ll MOD = 1e9+7; // 998244353;
const int MX = 1e6+1;

int tree[1];

int sum(int k) {
    int a = 0;
    while (k >= 1) {
        a += tree[k];
        k -= k&-k;
    }
    return a;
}

void add(int k, int x) {
    while (k <= MX) {
        tree[k] += x;
        k += k&-k;
    }
}

void solve() {
    str s1, s2;
    cin >> s1;
    cin >> s2;
    int res = s1.size();
    F0R(i, s1.size()) if (i+s2.size()<=s1.size()) {
        int sum = 0;
        F0R(j, s2.size()) {
            if (s1[i+j] != s2[j])
                ++sum;
        }
        res = min(sum, res);
    }
    cout << res << endl;
}


int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define LOCAL
#ifdef LOCAL
freopen("data.in", "r", stdin);
while (!feof(stdin)) {
#endif // LOCAL

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

#ifdef LOCAL
}
printf("Time used = %.2lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif // LOCAL
    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> original_arr(n);
  vector<int> sorted_arr(n);
  for (int i = 0; i < n; ++i) {
    int p; cin >> p;
    original_arr[i] = p;
    sorted_arr[i] = p;
  }
  sort(sorted_arr.begin(), sorted_arr.end());
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (original_arr[i] != sorted_arr[i]) ++cnt;
  }
  cout << (cnt <= 2 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
mod=10**9+7
Fact=[0 for i in range(M+1)]
Finv=[0 for i in range(M+1)]
Fact[0]=1
def inv(x):
    return pow(x,mod-2,mod)
for i in range(M):
    Fact[i+1]=Fact[i]*(i+1)
    Fact[i+1]%=mod
Finv[M]=inv(Fact[M])
for i in range(M-1,-1,-1):
    Finv[i]=(i+1)*Finv[i+1]
    Finv[i]%=mod
def P(n,k):
    return (Fact[n]*Finv[n-k])%mod
def C(n,k):
    return (Fact[n]*Finv[n-k]*Finv[k])%mod
ans=0
for k in range(N+1):
    if k%2==0:
        ans+=C(N,k)*P(M-k,N-k)
    else:
        ans-=C(N,k)*P(M-k,N-k)
    ans%=mod
print((ans*P(M,N))%mod)

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

bool primes[1000000];

void Sieve()
{
    int i, j, k;
    memset(primes, true, sizeof(primes));
    for(i = 2; i * i <= 1000000; i++)
    {
        if(primes[i] == true)
        {
            for(j = i * i; j <= 1000000; j += i)
            {
                primes[j] = false;
            }
        }
    }
}

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

    int n;
    Sieve();
    cin>>n;
    while(1)
    {
        if(primes[n] == true)
        {
            cout<<n<<"\n";
            break;
        }
        else
        {
            n++;
        }
    }
    return 0;
}


Measured memory_bytes: 1280
n,m,x,y=map(int,input().split())

xList=list(map(int,input().split()))

yList=list(map(int,input().split()))

xList.append(x)
yList.append(y)

xList.sort()
xList.reverse()
yList.sort()


if(yList[0]-xList[0]>=1):
  print("No War")
else:
  print("War")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;


int main(){
    int N;cin >> N;
    vector<int> dp(N+1);
    for(auto &i:dp) i = N;
    dp[0] = 0;
    for(int n=1;n<=N;n++){
        for(int pow6 = 1;pow6<=n;pow6*=6){
            dp[n] = min(dp[n],dp[n-pow6]+1);
        }
        for(int pow9 = 1;pow9<=n;pow9*=9){
            dp[n] = min(dp[n],dp[n-pow9]+1);
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

struct task{
	int cost;
	int deadLine;
};

bool myComp(task left,task right){
	return (left.deadLine < right.deadLine);
}

int main()
{
	int n;
	cin>>n;
	vector<task> taskList(n);
	for(int i = 0; i < n; i++){
		cin>>taskList[i].cost>>taskList[i].deadLine;
	}
	sort(taskList.begin(),taskList.end(),myComp);
	bool ans = true;
	int time = 0;
	for(int i = 0; i < n; i++){
		time += taskList[i].cost;
		if( time > taskList[i].deadLine){
			ans = false;
			break;
		}
	}
	if( ans == true){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}



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

int main()
{
  ll n;
  cin>>n;
  ll a[n+1], b[n], sum=0;
  for(ll i=0;i<=n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  for(ll i=0;i<n;i++)
    cin>>b[i];
  for(ll i=0;i<n;i++)
  {
    ll x=min(a[i],b[i]);
    a[i]-=x;
    b[i]-=x;
    ll y=min(a[i+1],b[i]);
    a[i+1]-=y;
    b[i]-=y;
  }
  ll sum2=0;
  for(ll i=0;i<=n;i++)
    sum2+=a[i];
  cout<<sum-sum2;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    // Your code here!
  int n;
  cin>>n;
  vector<int>a(n);
   for(int i=0;i<n;i++){
      cin>>a.at(i);
  }
  long long sum=0;
  for(int i=0;i<n;i++){
      sum=sum+a.at(i);
  }
  sort(a.begin(),a.end());
  cout<<a.at(0)<<" "<<a.at(n-1)<<" "<<sum<<endl;
}  




Measured memory_bytes: 3168
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long binpow(long long a, long long b, long long m = mod) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(s);
	int ncr[5001][5001] = {};
	FOR (i, 0, 5000) ncr[i][0] = 1;
	
	FOR (i, 1, 5000)
	    FOR (j, 1, 5000)
	        ncr[i][j] = (ncr[i - 1][j] + ncr[i - 1][j - 1]) % mod;
	
	int ans = 0;
	FOR (n, 1, 2000)
	{
	    if (s - 2*n - 1 < 0) break;
	    ans = (ans + ncr[s-2*n-1][n-1]) % mod;
	    //cout << n << " " << ans << endl;
	}
	
	print(ans);
}



















Measured memory_bytes: 199016
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

#define DUMP(a) do { cout << #a << "={"; for (int i = 0; \
                i < a.size(); i++) cout << a[i] << " "; \
                cout << "}" << endl; } while (0)

int main()
{
    vector<int> t = { 0, 1, 2, 3, 4, 5, 6 };

    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    vector<long> aa(n+1), bb(n+1);

    for (int i = n - 1; i >= 0; i--) {
        int j = distance(c.begin(),
                         upper_bound(c.begin(),c.end(),b[i]));
        bb[i] = bb[i+1] + (n-j);
    }
    for (int i = n - 1; i >= 0; i--) {
        int j = distance(b.begin(),
                         upper_bound(b.begin(),b.end(),a[i]));
        aa[i] = aa[i+1] + bb[j];
    }

    // DUMP(aa);
    // DUMP(bb);
    // DUMP(cc);

    cout << aa[0] << endl;
    return 0;
}

Measured memory_bytes: 2944
/* 
   AOJ 2330
   Earth Invasion Diary of Miyabi-sensei
   2015/9/20
*/

#include<stdio.h>
#include<math.h>

int main(void)
{
  int n;
  double i = 1.0, x;
  scanf("%d", &n);
  x = (double)n;
  while(pow(3.0, i) < x)
    {
      i = i + 1.0;
    }
  n = (int)i;
  printf("%d\n", n);
  return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll N, M, K;
    while (cin >> N >> M, N) {
        ll res = 0;
        vector<ll> sum(N+1, 0);
        for (int i = 0; i < N; i++) {
            cin >> K;
            sum[i+1] = (sum[i] + K) % M;
            res = max(res, sum[i+1]);
        }
        set<ll> st;
        for (int i = 1; i <= N; i++) {
            st.insert(sum[i]);
            auto x = st.upper_bound(sum[i]);
            if (x != st.end()) {
                res = max(res, (sum[i] - *x + M) % M);
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 4328
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int N = 1e5 + 10;
VI e[N];
int dp[N][2], leaf[N];

void dfs(int now, int past){
    leaf[now] = 1;
    int l = 0, d = 0;
    for (int next : e[now]){
        if (next == past) continue;
        dfs(next, now);
        leaf[now] &= leaf[next];
        if (leaf[next]) l++;
        d++;
    }
    if (d > 1) leaf[now] = 0;
    if (leaf[now]) return;
    for (int next : e[now]){
        if (next == past) continue;
        if (leaf[next]){
            dp[now][0]++;
            dp[now][1]++;
        }else{
            dp[now][0] += dp[next][1];
            dp[now][1] += dp[next][1];
        }
    }
    if (l) dp[now][1]--;
}

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

    REP(i,n-1){
        int u, v;
        scanf("%d %d", &u, &v);
        e[u].push_back(v);
        e[v].push_back(u);
    }

    if (n == 2){
        cout << 1 << endl;
        return 0;
    }

    int root;
    REP(i,n){
        if (e[i].size() > 1){
            root = i;
            break;
        }
    }
    // root = 1;

    dfs(root, -1);

    int ans = dp[root][1];
    // map<int, int> mp;
    // mp[ans]++;

    REP(_,100){
        int root = rand() % n;
        if (e[root].size() == 1) continue;
        REP(i,n){
            dp[i][0] = dp[i][1] = 0;
        }
        dfs(root, -1);
        ans = max(ans, dp[root][1]);

        // mp[dp[root][1]]++;


        // if (dp[root][1] == 2){
        //     cout << root << endl;
        // }
    }

    // REP(i,n) dp[i][0] = dp[i][1] = 0;
    // root = 4;
    // dfs(root, -1);

    // cout << root << endl;
    // REP(i,n) cout << dp[i][0] << " " << dp[i][1] << " " << leaf[i] << endl;

    // int ma = 0;
    // for (P p : mp){
    //     cout << p.first << p.second << endl;
    //     if (p.second > ma){
    //         ma = p.second;
    //         ans = p.first;
    //     }
    // }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int n;
  int k;
  cin >> n >> k;
  vector<int> v(n);
  int tmp;
  for (int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  int b=0;
  for (int i = 0; i < k; i++){
    b=b+v.at(i);
  }
  cout << b << endl;
}


Measured memory_bytes: 3576
n,m,c =map(int,input().split())
B =[int(i)for i in input().split()]
count = 0
for i in range(n):
    ans = c
    for j,k in enumerate(input().split()):
        k =int(k)
        ans += B[j]*k
    if ans > 0:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

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

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MOD = 1e9 + 7;
const int MAXN = 101;
const int MAXK = 1e5 + 1;

int n, k;
int a[MAXN];
int dp[MAXN][MAXK];
int pref[MAXN][MAXK+1]; // pref[i][j] = dp[i][0] + dp[i][2] + ... + dp[i][j-1]

int main(){

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

    dp[0][0] = 1;
    for (int i = 1; i <= k+1; i++) pref[0][i] = 1;

    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= k; j++){
            dp[i][j] = (pref[i-1][j+1]%MOD - pref[i-1][max(j-a[i-1], 0)]%MOD + MOD)%MOD;
            pref[i][j+1] = (pref[i][j]%MOD + dp[i][j]%MOD)%MOD;
            //cout << dp[i][j] << '\n';
        }
    }

    cout << dp[n][k];

    return 0;

}

Measured memory_bytes: 79232
s=input()

res=0
while len(s)>1:
  if s[0]==s[-1]:
    s=s[1:-1]
  elif s[0]=="x":
    s=s+"x"
    res+=1
  elif s[-1]=="x": 
    s="x"+s
    res+=1
  else:
    print(-1)
    exit()
    
print(res)

Measured memory_bytes: 3316
n = int(input())
a_list = [0]        # 始点
totalcost = 0
now = 0

# トータルコストを求める
for i in input().split():
    nextstep = int(i)
    a_list.append(nextstep)
    totalcost += abs(nextstep - now)
    now = nextstep
totalcost += abs(now - 0)
a_list.append(0)    # 終点

for i in range(1, n + 1):
    # 各点を除いた経路を前後の位置関係から計算する
    bef = a_list[i - 1]
    now = a_list[i]
    aft = a_list[i + 1]

    removecost = 0

    if bef < now < aft or aft < now < bef:
        # 除く点が中央にある場合は、いずれにせよ通る
        pass
    elif bef < now and aft < now and aft <= bef:
        removecost = abs(now - bef) * 2
    elif bef < now and aft < now and bef <= aft:
        removecost = abs(now - aft) * 2
    elif now < bef and now < aft and bef <= aft:
        removecost = abs(now - bef) * 2
    elif now < bef and now < aft and aft <= bef:
        removecost = abs(now - aft) * 2
    print(totalcost - removecost)


Measured memory_bytes: 13880
#include<stdio.h>
#include<algorithm>
int*t,n,m,d,i,s[99999];main(){for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf("%d\n",i)){for(;--i;)scanf("%d",s+i);for(std::sort(s,s+n);m--;i+=std::min(d-*--t,*t-d))scanf("%d",&d),t=std::upper_bound(s,s+n,d);}}

Measured memory_bytes: 1148
N = int(input())
A = [[int(i) for i in input().split()] for j in range(2)]
dp = [[0]*(N+1) for i in range(3)]
for i in range(1,3):
    for j in range(1,N+1):
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + A[i-1][j-1]
print(dp[-1][-1])

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


int main() {
    string S;
  	int N;
  cin >> N >> S;
  	string D = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  
  for(int i = 0; i < S.size(); i++){
    for(int j = 0; j< D.size(); j++){
      if(S.at(i) == D.at(j)) {
        int t = (j + N)%26;
        S.at(i) = D.at(t);
        break;
      }else{
      	continue;
      }
    }
  }
  
  cout << S << endl;

}


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

int main(void){

  int i,N,max=0,c=0;
  scanf("%d",&N);
  int H[N];
  
   for(i=0;i<N;i++){
     scanf("%d",&H[i]);
     if(max<=H[i]){
       max=H[i];
     }
     if(H[i]-max>=0){
    c++;
    }
   }
     printf("%d\n",c);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
class A
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        int n = int.Parse(s);

        List<string> si = new List<string>();
        List<int> ti = new List<int>();

        for (int i = 0; i < n; i++)
        {
            string[] ss = Console.ReadLine().Split(' ');
            si.Add(ss[0]);
            ti.Add(int.Parse(ss[1]));
        }

        string sx = Console.ReadLine();
        int count = 0;

        for (int i = 0; i < n; i++)
        {
            if (si[i] == sx)
            {
                break;
            }
            count++;
        }

        int tr = 0;
        for (int i = (count + 1); i < n; i++)
        {
            tr += ti[i];
        }
        
        Console.WriteLine(tr);
    }
}

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

int main() {
	vector<int> v;
	for(int i=0;i<5;i++)
	{
	    int x; cin >> x;
	    v.push_back(x);
	}
	for(int i=0;i<5;i++)
	{
	    if(v[i] == 0)
	    {
	        cout << i+1;
	        break;
	    }
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
    
const long long MOD = 1000000000 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    if (abs(n - m) >= 2) {
        cout << 0 << endl;
        return 0;
    }

    long long ans = 1;
    for (int i = 2; i <= n; i++) {
        ans *= i;
        ans %= MOD;
    }
    for (int i = 2; i <= m; i++) {
        ans *= i;
        ans %= MOD;
    }
    
    if (n == m) {
        ans *= 2;
        ans %= MOD;
    }
    
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int a, b;
    while(cin >> a >> b) {
        unsigned long long p = (unsigned long long)a*b;
        int gcd = __gcd(a, b);
        cout << gcd << ' ' << p/gcd << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main(void){
    int n,i,j;
    scanf("%d",&n);
    int a[4][13];
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            a[i][j]=0;
        }
    }
    
    char c;
    int r;
    for(i=0;i<n;i++){
        scanf("%c",&c);
        scanf("%c %d",&c,&r);
        switch (c){
            case 'S':
                a[0][r-1]=1;
                break;
            case 'H':
                a[1][r-1]=1;
                break;
            case 'C':
                a[2][r-1]=1;
                break;
            case 'D':
                a[3][r-1]=1;
                break;
        }
    }
    
   
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(a[i][j]==0){
                if(i==0){
                    printf("S %d\n",j+1);
                }
                if(i==1){
                    printf("H %d\n",j+1);
                }
                if(i==2){
                    printf("C %d\n",j+1);
                }
                if(i==3){
                    printf("D %d\n",j+1);
                }
            }
        }
        
    }
    
    return 0;
}
    
    


Measured memory_bytes: 1956
n = int(input())
a = list(map(int,input().split()))
ok = True
for i in a:
    if i%2 == 0 :
        if i%3 != 0 and i%5 != 0:
            ok = False
            break
            
if ok:
    print("APPROVED")
else:
    print("DENIED")


           

Measured memory_bytes: 2940
#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  out << "{" << p.first << "," << p.second << "}";
  return out;
}

int n, q, S[10000 + 1];

bool searchKey(int A[], int size, int x) {
  A[size] = x;
  int i = 0;
  while (A[i] != x) {
    i++;
  }
  return i != size;
}

void solve() {
  scanf("%d", &n);
  rep(i,0,n)
  {
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  int sum = 0, t;
  rep(i,0,q)
  {
    scanf("%d", &t);
    if (searchKey(S, n, t)) {
      sum++;
    }
  }
  printf("%d\n", sum);
}
int main() {
  solve();
  return 0;
}



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

int main() {
  int n;
  
  cin >> n;
  
  n = n%10;
  
  if (n == 3) cout << "bon" << endl;
  else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
    
}


Measured memory_bytes: 3592
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
	int n , k;
	cin >> n >> k;
	vector<int> a(n);
	for(int& x: a) cin >> x;

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

	int ans = 0;
	for(int i = 0; i < k; i++) {
		ans += a[i];
	}	
	cout << ans << endl;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using static System.Console;

namespace a {

static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }
}

class Program {
   public static void Main(string[] args) {
      var arr1 = ReadLine().Split(' ').Select(x => x.ToInt()).ToArray();
      var H = arr1[0];
      var W = arr1[1];
      
      var arr2 = ReadLine().Split(' ').Select(x => x.ToInt()).ToArray();
      var h = arr2[0];
      var w = arr2[1];

      var total = H * W; // 25
      var lose = h * W + w * H - h * w; // 2 * 5 + 5 * 3 - 2 * 3 = 10 + 15 - 6 = 19

      Console.WriteLine(total - lose);
   }
}

}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

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

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

vector<int> v[10001];
int s[10001];
P h[10001];
int sc[10001];
int sci;

void solve(int x) {
  if(s[x]) return;
  s[x] = sc[sci];
  sci--;
  rep(i, 0, v[x].size()) {
    solve(v[x][i]);
  }
}

signed main() {
  int n;
  cin >> n;
  sci = n - 1;

  rep(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    v[--a].pb(--b);
    v[b].pb(a);
    h[i] = P(a, b);
  }

  rep(i, 0, n) cin >> sc[i];

  sort(sc, sc + n);


  solve(0);

  int sum = 0;
  rep(i, 0, n - 1) {
    sum += min(s[h[i].first], s[h[i].second]);
  }

  cout << sum << endl;
  rep(i, 0, n) cout << s[i] << " ";
}


Measured memory_bytes: 1536
main(){double a,b,c,d,e,f;for(;~scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f\n",(e*c-b*f)/(a*e-b*d)+0.0,(a*f-d*c)/(a*e-b*d)+0.0));return 0;}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    
    if (N * A < B){
        cout << N * A << endl;
    }
    else if (N * A > B){
        cout << B << endl;
    }
    else if (N * A == B){
        cout << B << endl;
    }
}


Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long

#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)

int main() {
	string n;
	cin >> n;
	for (int i = 0; i < n.length(); i++) {
		if (n[i] == '9') {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}





Measured memory_bytes: 256
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();
		int c = sc.nextInt();
		if ((a + b + c) == 17 && (a * b * c) == 175) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    string s; cin >> s;
    string mm = "";
    mm += s[5];
    mm += s[6];
    string dd = "";
    dd += s[8];
    dd += s[9];
    int month = stoi(mm), day = stoi(dd);
    if (month <= 4) {
        if (month == 4) {
            cout << (day <= 30 ? "Heisei" : "TBD") << "\n";
            exit(0);
        }
        cout << "Heisei" << "\n";
        exit(0);
    }
    cout << "TBD\n";
}


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 x = 0;
  cin >> x;
  if(x) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 3616
// clang-format off
	#define BADSEED random_device{}()
	#include <bits/stdc++.h>
	using namespace std;
	using ll = long long;
	using uint = unsigned int;
	ostream &operator<<(ostream &os, int8_t c) { return os << short(c); }
	istream &operator>>(istream &is, int8_t &c) { short x; is >> x; c = x; return is; }
	#define TM_(...) template <class __VA_ARGS__>
	namespace narut {
	TM_(T) using TupSz = tuple_size<decay_t<T>>;
	TM_(T) constexpr auto spc(T const &t, int) -> decltype((cout << t), 'a') { return ' '; }
	constexpr auto spc(string const &s, int) { return '\n'; }
	TM_(T) constexpr auto spc(T const &t, char) { return '\n'; }
	struct IO {
		TM_(T) static auto out_(ostream &os, T const &t, int) -> decltype(void(os << t)) { os << t; }
		TM_(T, class OS) static auto out_(OS &os, T const &t, int) -> decltype(void(begin(t))) {
			auto it = begin(t), e = end(t);
			if (it != e) out_(os, *it++, 0);
			for (; it != e; out_(os, *it++, 0)) os << spc(*it, 0);
		}
		TM_(T, size_t... Is) static void out_tup(ostream &os, T const &t, index_sequence<Is...>) { (void)initializer_list<int>{0, ((Is == 0) ? 0 : ((os << ' '), 0), (os << get<Is>(t)), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) out_(ostream &os, T const &t, char) { out_tup(os, t, make_index_sequence<TupSz<T>::value>{}); }
		TM_(Sep, class F, class... Ts) static ostream &print(ostream &os, Sep sep, F const &f, Ts const &... ts) { return void(initializer_list<int>{(out_(os, f, 0), 0), (out_(os << sep, ts, 0), 0)..., (os << '\n', 0)}), os; }
		TM_(T) static auto in_(istream &is, T &t, int) -> decltype(void(is >> t)) { is >> t; }
		TM_(T, class IS) static auto in_(IS &is, T &t, int) -> decltype(void(begin(t))) { for (auto &x : t) in_(is, x, 0); }
		TM_(T, size_t... Is) static void in_tup(istream &is, T &t, index_sequence<Is...>) { (void)initializer_list<int>{0, (in_(is, get<Is>(t), 0), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) in_(istream &is, T &t, char) { in_tup(is, t, make_index_sequence<TupSz<T>::value>{}); }
	};
	} // namespace narut
	#define Cout(...) narut::IO::print(cout, ' ', __VA_ARGS__)
	#ifdef NARUT_LOCAL
	#define Debug(...) narut::IO::print(cerr << "\033[0;31m", ", ", __VA_ARGS__) << "\033[0m"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] struct Cin { 
		template <class T> Cin const &operator>>(T &t) const { return narut::IO::in_(cin, t, 0), *this; }
		template <class T> operator T() const { T t; return *this >> t, t;  }	
	} Cin;
	TM_(T) auto operator%(T &t, size_t n) -> decltype(t.resize(n), t)& { return t.resize(n), t; }
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)

// clang-format on





auto Run() {
	string s;
	cin>>s;
	return s[2]==s[3] and s[4]==s[5];	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	cin.exceptions(cin.failbit);
	cerr << fixed << setprecision(10);
	assert(freopen("./io/test.in", "r", stdin));
	// assert(freopen("./io/test.out", "w", stdout));
#endif

	cout << (Run() ? "Yes\n" : "No\n");
}


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

int n, k;
bool alln(vector<int>& v){
  for(int i=0;i<n;++i) if(v[i]!=n) return false;
  return true;
}

void simulate(vector<int>& v){
  int cnt = 0;
  vector<int> tmp(n+1, 0);
  for(int i=0;i<n;++i) {
    tmp[max(0, i-v[i])]++;
    tmp[min(n, i+v[i]+1)]--;
  }
  for(int i=0;i<n;++i){
    cnt += tmp[i];
    v[i] = cnt;
  }
}

int main() {
  cin >> n >> k;
  vector<int> v(n);
  for(int i=0;i<n;++i) cin >> v[i];

  while(k--){
    simulate(v);
    if(alln(v)){
      for(int i=0;i<n;++i) cout << n << (i==n-1?'\n':' ');
      return 0;
    }
  }
  for(int i=0;i<n;++i) cout << v[i] << (i==n-1?'\n':' ');
  return 0;
}


Measured memory_bytes: 4432
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>
#include <set>

using namespace std;

int f(int n) {
    if (n % 2 == 0) {
        return n / 2;
    } else {
        return 3 * n + 1;
    }
}

int main() {

    int s;
    cin >> s;

    std::set<int> set;
    bool ok = false;

    long result = 1;

    set.insert(s);

    while (!ok) {

        s = f(s);

        if (set.find(s) != set.end()) {
            ok = true;
        }

        set.insert(s);
        result += 1;
    }

    cout << result << "\n";

    return 0;
}

Measured memory_bytes: 256
/* ex 5_4
   unomi */

#include <stdio.h>
#include <string.h>

int main(void){
    int cnt=0, max_cnt=0, i=0, j=0;
    // str_A : 文字列A, str_B : 文字列B
    char sentence[11];
    scanf("%s", sentence);

    for(i=0; i<strlen(sentence); i++){
        if(sentence[i] == 'A'||sentence[i] == 'C'||sentence[i] == 'G'||sentence[i] == 'T'){
            for(j=i; j<strlen(sentence); j++){
                if(sentence[j] == 'A'||sentence[j] == 'C'||sentence[j] == 'G'||sentence[j] == 'T') cnt++; //AGSTならカウント
                else break; // AGST以外でbreak
            }
            // 値の更新
            if(max_cnt < cnt) max_cnt = cnt;
            cnt = 0;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1696
import io,sys
sys.setrecursionlimit(10**6)

def main():
    import math
    n = int(input())
    if n < 27:
        print(chr(n+ord("a")-1))
        sys.exit()

    p = n
    k = 1
    s = 1
    while p - 26*s > 0:
        s *= 26
        p -= s
        k += 1

    p-=1
    st = []

    for _ in range(k):
        r = p%26
        p = p//26
        st.append(r)


    for i in st[::-1]:
        print(chr(i+ord("a")),end="")
    print("")
main()

Measured memory_bytes: 9064
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    double a, b, c, d, e, f, g, h;

    while(cin >> a >> b >> c >> d >> e >> f >> g >> h) {
        double vx = c - a;
        double vy = d - b;
        double wx = g - e;
        double wy = h - f;

        if (vx * wx + vy * wy == 0) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
     
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  int m = 1000000007;
  long long p = 1;
  
  for (int i = 1; i <= n; i++) {
    p *= i;
    p = p % m;
  }
  
  cout << p;
}

Measured memory_bytes: 3576
import java.util.*;
import java.io.*;

public class Main {
    
    void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        int X = in.nextInt();
        char[][] arr = new char[n][m];
        for (int i = 0; i < n; ++i) {
            char[] tmp = in.next().toCharArray();
            for (int j = 0; j < m; ++j) {
                arr[i][j] = tmp[j];
            }
        }

        int ans = Integer.MAX_VALUE;
        for (int i = 1<<(n-1); i < (1<<n); ++i) {
            int cuts = 0;
            for (int k = 0; k < n - 1; ++k) {
                if ((i & (1<<k)) !=0) {
                    ++cuts;
                }
            }

            int[] cnt = new int[n];
            boolean skip = false;
            for (int j = 1; j <= m && !skip; ++j) {
                for (int k = 0; k < n; ++k) {
                    cnt[k] += arr[k][j-1] == '1' ? 1 : 0;
                }

                int sum = 0;
                boolean cut = false;
                for (int k = 0; k < n && !cut; ++k) {
                    sum += cnt[k];
                    if ((i & (1<<k)) !=0) {
                        if (sum > X) cut = true;
                        sum = 0;
                    }
                }

                if (cut) {
                    sum = 0;
                    for (int k = 0; k < n; ++k) {
                        cnt[k] = arr[k][j - 1] == '1' ? 1 : 0;
                        sum += cnt[k];
                        if (sum > X) {
                            skip = true;
                            break;
                        }
                        if ((i & (1<<k)) !=0) {
                            sum = 0;
                        }
                    }
                    ++cuts;
                }
            }

            if (!skip) {
                ans = Math.min(ans, cuts);
            }
        }
        out.println(ans);
    }


    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Main solver = new Main();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer st;

        public InputReader(InputStream is) {
        in = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
        try {
            while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
            }
            return st.nextToken();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        }

        public int nextInt() {
        return Integer.parseInt(next());
        }

        public long nextLong() {
        return Long.parseLong(next());
        }
    }
    }


Measured memory_bytes: 24788