akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  
  l=[1]
  for i in range(1,20):
    a=6**i
    if a<=n:
      l.append(a)
    b=9**i
    if b<=n:
      l.append(b)

  l.sort()

  dp=[inf for _ in range(n+1)]
  dp[0]=0

  for i in range(n):
    for x in l:
      if i+x<=n:
        dp[i+x]=min(dp[i+x],dp[i]+1)

  return dp[n]

# main()
print(main())


Measured memory_bytes: 6360
import numpy as np

def main():
    stdin = np.fromstring(open(0).read(), dtype=np.int32, sep=' ')
    N = stdin[0]
    A = stdin[1:]
    A = np.mod(A, 2)
    print("first") if np.count_nonzero(A) else print("second")
if __name__ == "__main__":
    main()

Measured memory_bytes: 22016
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		ArrayList<String> x = new ArrayList<String>();

		while(sc.hasNextInt()){
			int a=sc.nextInt();
			int b=sc.nextInt();
			int c=sc.nextInt();
			int sum=0;
			
			if(a<=b){
				for(int i=a;i<=b;i++){
					if(c%i==0){
						sum++;
					}
				}
				System.out.println(sum);
			}
			
		}
	}
}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //var a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            long x = int.Parse(Console.ReadLine());
            long x500;
            long mod;
            long x5;
            long ans;
            if (x >= 5)
            {
                x500 = x / 500;
                mod  = x % 500;
                x5   = mod / 5;
                ans  = x500 * 1000 + x5 * 5;
            }
            else ans = 0;
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 11092
#B
count = 0
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
for i in range(n):
    a = list(map(int, input().split()))
    ab=0
    for j in range(m):
        ab += a[j] * b[j]
    if -c<ab:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    string s;cin>>s;
    ll n=s.size();
    vvi dp(n,vi(4));
    dp[0][3]=1;
    rep(i,n){
        if(i){
            rep(j,4)dp[i][j]=dp[i-1][j];
            if(s[i]=='?')rep(j,4)dp[i][j]*=3;
            if(s[i]=='A'||s[i]=='?')dp[i][0]+=dp[i-1][3];
            if(s[i]=='B'||s[i]=='?')dp[i][1]+=dp[i-1][0];
            if(s[i]=='C'||s[i]=='?')dp[i][2]+=dp[i-1][1];
        }
        else if(s[i]=='A'||s[i]=='?')dp[i][0]++;
        if(i==0&&s[i]=='?')dp[i][3]*=3;
        rep(j,4)dp[i][j]%=mod;
    }
    cout<<dp[n-1][2]<<endl;
}

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

int main(){
  while(true){
    int t[5];
    int cnt[3] = {0, 0, 0};
    for(int i = 0; i < 5; i++){
      if(!(cin >> t[i])) return 0;
      t[i]--;
      cnt[t[i]]++;
    }

    for(int i = 0; i < 5; i++){
      if(cnt[t[i]] == 5 || cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0){
        cout << 3 << endl;
      }
      else if(cnt[(t[i] + 1) % 3] > 0){
        cout << 1 << endl;
      }
      else{
        cout << 2 << endl;
      }
    }
  }
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int cnt[200005];

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans = 0;
    rep(i,n){
        int key = b[i];
        auto ida = lower_bound(a.begin(), a.end(), key);
        if(ida == a.begin()) continue;
        ll ida_l = distance(a.begin(),ida);

        auto idc = upper_bound(c.begin(), c.end(), key);
        if(idc == c.end()) continue;
        ll idc_l = n -  distance(c.begin(),idc);
        ans += ida_l * idc_l;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int N = 3e5+10;
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n;
int a[N] , s[N];

inline bool check(int mid)
{
	int k = 0;
	for(int i = 1 ; i < n ; i += 2) if(s[i] - k >= mid) k = min(k , s[i+1]);
	return s[n] - k >= mid;
}

int main()
{
	n = read();
	for(int i = 1 ; i <= n ; ++i) a[i] = read();
	if(n % 2 == 0)
	{
		int sum1 = 0 , sum2 = 0;
		for(int i = 1 ; i <= n ; ++i) if(i & 1) sum1 += a[i]; else sum2 += a[i];
		cout << max(sum1 , sum2) << ' ' << min(sum1 , sum2) << '\n';
		return 0;
	} 
	for(int i = 1 ; i <= n ; ++i) s[i] = s[i-1] + ((i&1) ? 1 : -1) * a[i];
	int l = 0 , r = n * 1000 , mid , ans;
	while(l <= r)
	{
		mid = (l + r) >> 1;
		if(check(mid)) l = mid + 1 , ans = mid; else r = mid - 1;
	}
	int sum = 0;
	for(int i = 1 ; i <= n ; ++i) sum += a[i];
	for(int i = 1 ; i <= n ; ++i) if(i % 2 == 0) ans += a[i];
	cout << ans << ' ' << sum - ans << '\n';
	return 0;
}

Measured memory_bytes: 2560
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define ll long long

ll fact[100006];
long long expo(long long x, long long n);
long long lol(ll n, ll k);

int main(int argc, char **argv){
    ll n;
    scanf("%lld",&n);
    ll a[n+2],i,j;
    for (i = 1, fact[0] = 1; i < 100006; i++) fact[i] = (fact[i - 1] * i) % MOD;
    for(i=1;i<=n+1;i++) scanf("%lld",&a[i]);
    n++;
    //a[1] to a[n]

    int hash[100006]={0};
    for(i=1;i<=n;i++) hash[a[i]]++;
    for(i=1;i<=n;i++) if(hash[i]==2) break;
    //i repeated twice
    ll occur[3],uwu=0;
    for(j=1;j<=n;j++){
        if(a[j]==i){
            occur[uwu]=j;
            uwu++;
        }
    }
    ll d=occur[1]-occur[0]-1;
    ll k,diff;
    printf("%lld ",n-1);
    for(k=2;k<=n;k++){
        diff=lol(n,k);
        if(k<=n-d) {
            diff-=lol(n-d-2,k-1);
            while(diff<0) diff+=MOD;
        }
        printf("%lld ",diff);
    }
    printf("\n");
    return 0;
}

long long expo(long long x, long long n){
    long long res = 1;

    while (n){
        if (n & 1LL) res = (res * x) % MOD;
        x = (x * x) % MOD;
        n >>= 1LL;
    }

    return (res % MOD);
}

long long lol(ll n, ll k){
    long long x = fact[n];
    long long y = (fact[k] * fact[n - k]) % MOD;
    long long res = (x * expo(y, MOD - 2)) % MOD;
    return res;
}


Measured memory_bytes: 3072
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#include <functional>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
		cerr << (*i) << " ";
    }
    cerr << "\n";
}

int n, m;
vector<int> eds[120000];
vector<int> vvl;
vector<int> vvr;
int en[120000];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a, --b;
        eds[a].push_back(b);
        eds[b].push_back(a);
    }
    for (int i = 0; i < n; ++i) {
        if (eds[i].empty())
            continue;
        int a = i;
        int b = eds[i][0];
        en[a] = 1;
        en[b] = 1;
        while (true) {
            vvl.push_back(a);
            int fl = 0;
            for (int u: eds[a])
                if (!en[u]) {
                    a = u;
                    en[a] = 1;
                    fl = 1;
                    break;
                }
            if (!fl)
                break;
        }
        while (true) {
            vvr.push_back(b);
            int fl = 0;
            for (int u: eds[b])
                if (!en[u]) {
                    b = u;
                    en[b] = 1;
                    fl = 1;
                    break;
                }
            if (!fl)
                break;
        }
        reverse(vvl.begin(), vvl.end());
        cout << vvl.size() + vvr.size() << "\n";
        for (int i: vvl)
            cout << i + 1 << " ";
        for (int i: vvr)
            cout << i + 1 << " ";
        cout << "\n";
        return 0;
    }
	return 0;
}




Measured memory_bytes: 7672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1000000000000005;
const ll maxn=1e7+5;
const int mod=998244353;
ll n,m,p;
int main()
{
    char s;scanf("%c",&s);
    printf("%c\n",s+1);
    return 0;
}
/**
***/


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

#define rep(i, a, b) for(ll i = (ll) (a); i < (ll) (b); i++)
#define repi(i, a, b) for(ll i = (ll) (a); i <= (ll) (b); i++)
#define rrep(i, a, b) for(ll i = (ll) (b) - 1; i >= (ll) (a); i--)
#define rrepi(i, a, b) for(ll i = (ll) (b); i >= (ll) (a); i--)

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  vector<int>a(n);
  int ma = 1;
  rep(i,0,n){
    cin>>a[i];
    if(ma==a[i]) ma++;
  }
  if(ma==1) cout << -1 << endl;
  else cout << n - (ma-1) << endl;
  
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  int max = A.at(0), min = A.at(0);
  for (int i = 0; i < N; i++){
    if(A.at(i) >= max){
      max = A.at(i);
    }
    if(A.at(i) <= min){
      min = A.at(i);
    }
  }
  
  cout << max - min << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <limits>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '

const int MAXN = 200;
//ll a[MAXN], ST[MAXN * 4], LZ[MAXN*4];

/*bool perfectSquare(ll x){
    ll s = sqrt(x);
    if(s *s == x) return true;
    else return false;
}*/
typedef long double ld;

int main() { 
    int a = 0, b = 0, c = 0, x = 0;
    cin >> a >> b >> c >> x;
    int res = 0;
    for(int i = 0; i <= a; ++i){
        for(int j = 0; j <= b; ++j){
            for(int k = 0; k <= c; ++k){
                int tmp = i * 500 + j * 100 + k * 50;
                if(tmp == x){
                    ++res;
                }
            }
        }
    }
    cout << res << endl;
  
    return 0; 
} 


Measured memory_bytes: 256
import std.stdio, std.range, std.conv, std.string, std.array, std.functional, std.math;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;
import std.typecons; 

void main()
{
    auto input = readln().split.to!(int[]);
    auto X = input[0];
    auto Y = input[1];
    auto Z = input[2];
    auto K = input[3];

    auto aList = readln().split.to!(long[]);
    auto bList = readln().split.to!(long[]);
    auto cList = readln().split.to!(long[]);

    long[] abList;
    foreach(a; aList)
    {
        foreach(b; bList)
        {
            abList ~= a+b;
        }
    }
    abList.sort!greaterThan;
    abList.length = min(abList.length, 3000);

    long[] abcList;
    foreach(ab; abList)
    {
        foreach(c; cList)
        {
            abcList ~= ab + c;
        }
    }
    abcList.sort!greaterThan;
    foreach(n; abcList[0..K])
    {
        writeln(n);
    }
}


Measured memory_bytes: 59900
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <utility>
using namespace std;

int f(char c){
  int x;
  for(int i = 0; i < 10; i++){
    if(c == i + 48){ x = i; break;}
  }
  return x;
}

int main(){
  string s;
  cin >> s;
  vector<int> v(4, 0);
  for(int i = 0; i < 4; i++){
    v[i] = f(s[i]);
  }
  vector<int> re(3, 0);
  vector<vector<char>> op(3,vector<char>(2, '-'));
  op[0][0] = '+'; op[1][0] = '+'; op[2][0] = '+';
  vector<vector<bool>> w(3,vector<bool>(2, true));
  w[0][1] = false; w[1][1] = false; w[2][1] = false; 
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 2; j++){
      for(int k = 0; k < 2; k++){
        int res = v[0];
        if(w[0][i]){ res += v[1];}
        else{ res -= v[1];}
        if(w[1][j]){res += v[2];}
        else{ res -= v[2];}
        if(w[2][k]){res += v[3];}
        else{res -= v[3];}
        if(res == 7){ re[0] = i; re[1] = j; re[2] = k;}
      }
    }
  }
  //for(auto in : re){cout << in << endl;}
  //cout <<op[1][re[1]]  << endl;
  cout << s[0] << op[0][re[0]] << s[1] << op[1][re[1]] << s[2] << op[2][re[2]] << s[3] << "=7" <<endl;


}

Measured memory_bytes: 256
// Problem : A - Takoyaki
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define ll long long 
#define ull unsigned long long
const int INF = 1e9 + 5;
#define pb push_back
#define eb emplace_back
#define vll vector<long long int>
#define loop(i, a, b) for(long long int i = a; i < b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<ll, ll>
#define vpair vector<pii>
#define vbool vector<bool>
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define sec second
#define fir first
#define br '\n'
#define permute next_permutation
#define pqua priority_queue<ll>
#define pqud priority_queue<ll, vector<ll>, greater<ll> >
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define maxi *max_element
#define pi acos(-1)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(10)

vector<long long int> sieve(long long int n){
 	vector<long long int> primes;
 	bool isPrime[n+1] = {false};
 	isPrime[1] = isPrime[0] = false;
 	for(long long int i = 2;i<=n;i++)
 	{
 		isPrime[i] = true;
 	}
 	for(long long int i = 2;i*i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			for(long long int j = i*i;j<=n;j+=i)
 			{
 				isPrime[j] = false;
 			}
 		}
 	}
 	for(long long int i = 2;i<=n;i++)
 	{
 		if(isPrime[i])
 		{
 			primes.push_back(i);
 		}
 	}
 	return primes;
}

void print_vector2(vector<vector<ll> >v) {
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

void print_vector1(vector<ll> v) {
    for(ll i=0; i<v.size();i++){
        cout<<v[i]<<" ";
    }cout<<"\n";
}

ll gcd(ll a, ll b) {
    return __gcd(a, b);
}

// v.back()
// v.erase(v.begin(), v.brgin + k)
// v.insert(at which place v.bigin() + 1 implines at i = 1, no. of times, value)
// v.insert(position, copy.begin(), copy.end())
// v1.swap(v2)
// v.clear() to clear v.empty() to check empty
// map assending order and set descending order 
// stringstream ss(str) Used for breaking words

int main(){
    FastIO;
    PRECISION;

    ll n, x, t;
    cin>>n>>x>>t;
    
    ll ans = (n / x) * t;
    if(n % x != 0){
    	ans = ans + t;
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>

int main()
{
  int N, i, boss;
  int num[200000] = {0};

  scanf("%d", &N);
  
  for(i = 1; i < N; i++)
  {
    scanf("%d", &boss);
    num[boss - 1] += 1;
  }

  for(i = 0; i < N; i++)
  {
    printf("%d\n", num[i]);
  }

  return 0;
}

Measured memory_bytes: 2488
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <climits>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  string s;
  cin >> s;
  REP(i, 7) {
    // cout << s.substr(0, 7 - i) + s.substr(s.size() - i) << endl;
    if (s.substr(0, 7 - i) + s.substr(s.size() - i) == "keyence") {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
//////////////////////////////////////////////


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int N=1e2+10;
const int K=1e5+10;
const int mod=1e9+7;
int n,k,a[N],dp[N][K],pre[N][K];
inline void Add(int &x,int y){x+=y;x-=x>=mod? mod:0;}
inline int MOD(int x,int y){x+=y;x-=x>=mod? mod:0;return x;}
int main(){
	scanf("%d%d",&n,&k);
	for(register int i=1;i<=n;i++)scanf("%d",&a[i]);
	dp[0][k]=1;pre[0][k]=1;
	for(register int i=1;i<=n;i++)
		for(register int j=0;j<=k;j++){
			if(j)Add(dp[i][j],MOD(pre[i-1][min(j+a[i],k)],mod-pre[i-1][j-1]));
			else Add(dp[i][j],pre[i-1][min(j+a[i],k)]);
			if(j)pre[i][j]=MOD(pre[i][j-1],dp[i][j]);
			else pre[i][j]=dp[i][j];
		}
//			for(register int p=0;p<=a[i]&&j+p<=k;p++)
//				Add(dp[i][j],dp[i-1][j+p]);
	printf("%d\n",dp[n][0]);
	return 0;
}

Measured memory_bytes: 82176
def median(A,N):
    A.sort()
    if N % 2 == 1:
        return A[N//2]
    else:
        return A[(N-1)//2] + A[(N-1)//2+1]

def main():
    N = int(input())
    AB = [list(map(int,input().split())) for _ in range(N)]

    A = [AB[i][0] for i in range(N)]
    B = [AB[i][1] for i in range(N)]

    ans = median(B,N) - median(A,N) + 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 49344
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	if(_gcd!=1)cerr<<"WA";
	else return mpow(a,mod-2,mod);
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

//int dc[]={1,0,-1,0,1,1,-1,-1};
//int dr[]={0,-1,0,1,1,-1,-1,1};

/*void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}*/
int k;

ll sod(ll num){
	ll ret=0;
	while(num){
		ret+=num%10;
		num/=10;
	}
	return ret;
}

ld goal(ll num){
	return (ld)num/sod(num);
}

int main(){reduce200ms;
cin>>k;
vector<ll>tpar;
vector<ll>a;
ll t=1;
for(int i=0;i<=15;i++){
	tpar.pb(t);
	t*=10;
}
ll cur=(ll)1e15-1;
while(cur!=1){
 	a.pb(cur);
 	for(auto it:tpar){
 		if(cur-it<=0)break;
 		if(goal(cur-it)<=goal(cur)){
 			cur=cur-it;
 			break;
		 }
	 }
}
a.pb(1);
reverse(all(a));
rep(i,0,k){
	cout<<a[i]<<'\n';
}
return 0;
}



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

using namespace std;

int W, N, casenum = 0, ans, wmin;
int v[1000], w[1000];
int dp[1001][1001];

int rec_dp(int, int);
void solve();

int main(){
	int i;
	char c;
		
	while(1){
		cin >> W >> N;
		if(W == 0)
			break;
		
		casenum++;
		for(i = 0; i < N; i++)
			cin >> v[i] >> c >> w[i];
		
		memset(dp, -1, sizeof(dp));
		ans = rec_dp(0, W);
		
		for(i = 0; i <= W; i++){
			if(rec_dp(0, i) == ans){
				wmin = i;
				break;
			}
		}
		
		solve();
	}
	
	return 0;
}

int rec_dp(int i, int j){
	if(dp[i][j] != -1)
		return dp[i][j];
	
	int res;
	
	if(i == N)
		res = 0;
	else if(j < w[i])
		res = rec_dp(i + 1, j);
	else
		res = max(rec_dp(i + 1, j), rec_dp(i + 1, j - w[i]) + v[i]);
	
	return dp[i][j] = res;
}

void solve(){
	cout << "Case" << " " << casenum << ":" << endl;
	cout << ans << endl;
	cout << wmin << endl;
}

Measured memory_bytes: 4816
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] h = new int[n];
		int[] dp = new int[n];

		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}

		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		//		System.out.println(dp[0]);
		//		System.out.println(dp[1]);

		if (n > 2) {
			for (int i = 2; i < n; i++) {
				dp[i] = Math.min(dp[i - 2] + (Math.abs(h[i] - h[i - 2])), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
				//System.out.println(dp[i]);
			}
		}

		System.out.println(dp[n - 1]);

		sc.close();
	}
}

Measured memory_bytes: 50984
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    S = SI()
    T = SI()
    ls = len(S)
    lt = len(T)
    R = []
    for i in range(ls-lt+1):
        SS = S[i:i+lt]
        is_ok = True
        for s, t in zip(SS, T):
            if s != "?" and s != t:
                is_ok = False
        if not is_ok:
            continue
        r = ""
        for j, s in enumerate(S):
            if j == i:
                r += T
            elif i < j < i+lt:
                pass
            elif s == "?":
                r += "a"
            else:
                r += s
        R.append(r)
    R.sort()
    if R:
        print(R[0])
    else:
        print("UNRESTORABLE")



if __name__ == "__main__":
    main()

Measured memory_bytes: 9344
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    ans = 0
    for rep in n:
        ans += int(rep)
        ans %= 9
    if ans==0:
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    n = S()
    solve()

Measured memory_bytes: 27268
#include "bits/stdc++.h"

using namespace std;

int InsertionSort(int A[], int n, int g) {
    int cnt = 0;
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
    return cnt;
}

void ShellSort(int A[], int n) {
    vector<int> G;
    for (int h = 1; h <= n;  h = 3 * h + 1) {
        G.push_back(h);
    }
    reverse(G.begin(), G.end());
    int m = G.size();
    cout << m << endl;

    int cnt = 0;
    for (int i = 0; i < m; i++) {
        cnt += InsertionSort(A, n, G[i]);
        if (i == 0) cout << G[i];
        else cout << " " << G[i];
    }
    cout << endl;
    cout << cnt << endl;
}

int main() {
    int n;
    cin >> n;
    
    int A[n];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    ShellSort(A, n);

    for (int i = 0; i < n; i++) {
        cout << A[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 7060
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N;
    cin>>N;
    long long a[N+1];
    long long b[N];
    long long mi=0;
    long long ma=0;
    for(long long i=0;i<N;i++){
    cin>>ma;
    a[ma]=i+1;}
    for(long long i=1;i<=N;i++){
    cout<<a[i]<<" ";}}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int cnt=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			if(i%j==0&&i%2==1)cnt++;
		}
		if(cnt==8)ans++;
		cnt=0;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ha;
	int hb;
	if (a % d == 0)ha = a / d;
	else ha = a / d + 1;
	if (c % b == 0)hb = c / b;
	else hb = c/b + 1;
	if (ha >= hb)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3632
a1,a2,a3 = map(int,input().split())

b = [0] * 3
b[0] = abs(a1 - a2)
b[1] = abs(a2 - a3)
b[2] = abs(a3 - a1)


maxindex = b.index(max(b))
ret = 0
for i in range(len(b)):
    if i != maxindex:
        ret += b[i]

print(ret)


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

vector<int> prime_factorize(int x) {
    vector<int> res;
    for (int i = 2; i * i <= x; i++) {
        while (x % i == 0) {
            res.push_back(i);
            x /= i;
        }
    }
    if (x != 1) res.push_back(x);
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<int> prime_factor = prime_factorize(n);
    cout << n << ": ";
    for (int i = 0; i < prime_factor.size(); i++) {
        if (i > 0) cout << " ";
        cout << prime_factor[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3152
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let (a, b) = {
        let mut ws = s.split_whitespace();
        let a: u64 = ws.next().unwrap().parse().unwrap();
        let b: u64 = ws.next().unwrap().parse().unwrap();
        (a, b)
    };


    let gcd = gcd(a, b);
    let primes = sieve((gcd as f64).sqrt() as u64);
    // println!("{}", gcd(a, b));
    // println!("{}", (gcd as f64).sqrt() as u64);
    // println!("{:?}", primes);

    // prime factor
    let mut gcd_tmp = gcd;
    let mut factors: Vec<u64> = Vec::new();
    for p in primes {
        if gcd_tmp % p == 0 {
            factors.push(p);
            while gcd_tmp % p == 0 {
                gcd_tmp /= p;
            }
        }
        // println!("{}", gcd_tmp)
    }
    if gcd_tmp != 1 {
        factors.push(gcd_tmp);
    }
    println!("{}", factors.len() + 1);

    // let mut count = 0;
    // for x in primes {
    //     if gcd % x == 0 {
    //         if x * x == gcd {
    //             count += 1;
    //         } else {
    //             count += 2;
    //         }
    //     }
    // }
    // // 1の分カウント
    // count += 1;
    // println!("{}", count)
}

fn gcd(a: u64, b: u64) -> u64 {
    let c = a % b;
    if c == 0 {
        b
    } else {
        gcd(b, c)
    }
}

fn sieve(n: u64) -> Vec<u64> {
    let mut table: Vec<u64> = vec![0; (n + 1) as usize];
    let mut primes: Vec<u64> = Vec::new();

    for i in 2..(n+1) {
        if table[i as usize] == 0 {
            primes.push(i);
            for j in 2..n {
                if i * j > n {
                    break
                }
                table[(i * j) as usize] = 1
            }
        }
    }

    primes
}


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

namespace d
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToList();

            var idx = 0;
            var count = 0;
            var num = 1;
            while(idx < n && count < n){
                if(a[idx] == num){
                    num++;                    
                }else{
                    count++;
                }
                idx++;
            }

            Console.WriteLine(count == n ? -1 : count);
        }
    }
}


Measured memory_bytes: 34012
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n,a,b = readline() |> split |> parseMap
	s = readline() |> chomp
	d = 0
	f = 0
	for i in 1:n
		flg = 0
		if s[i] == 'a'
			if d+f<a+b
				flg = 1
				d += 1
			end
		elseif s[i] == 'b'
			if d+f<a+b && f<b
				flg = 1
				f += 1
			end
		end
		println(flg==1?"Yes":"No")
	end
end
main()


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

string s;
int a[200005], mod[200005], ex[200005];
int c[2019];

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

  cin >> s;
  for(int i = 0; i < s.size(); i++) a[i] = s[i]-'0';

  ex[0] = 1;
  for(int i = 0; i < s.size(); i++) ex[i+1] = (ex[i]*10)%2019;

  for(int i = s.size()-1; i > -1; i--) mod[i] = (mod[i+1] + ex[s.size()-i-1]*a[i])%2019;
  for(int i = 0; i < s.size()+1; i++) c[mod[i]]++;

  int res = 0;
  for(int i = 0; i < 2019; i++) res += (c[i]-1)*c[i]/2;
  cout << res << endl;
}

Measured memory_bytes: 6136
#include<bits/stdc++.h>
using namespace std;
#define forn for(int i=0;i<n;i++)
//#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    string s;
    map<string,int> mp;
    forn
    {
    	cin>>s;
    	if(mp.find(s)!=mp.end())
    	mp[s]++;
    	else
    	mp[s]=1;
	}
	int mx=-1;
	for(auto p:mp)
	mx=max(mx,p.second);
	for(auto p:mp)
	{
		if(p.second==mx)
		cout<<p.first<<endl;
	}
}
 


Measured memory_bytes: 23808
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    A = list(iim())
    mx = 10**18
    A.sort()

    if A[0] == 0:
        print(0)
        return

    ans = 1
    for i, a in enumerate(A):
        ans *= a
        if ans > mx:
            print(-1)
            return

    print(ans)

if __name__ == "__main__":
    resolve()


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

int main () {
  int N;
  cin >> N;
  vector<int>T(N);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
  }
  int M;
  cin >> M;
  vector<int> P(M),X(M);
  for (int i = 0; i < M; i++) {
    cin >> P.at(i) >> X.at(i);
  }
  for (int i = 0; i < M; i++) {
    int j = P.at(i)-1;
    int ans = 0;
    int a = (T.at(j) - X.at(i));
    T.at(j) = X.at(i);
    for (int k = 0; k < N; k++) {
      ans += T.at(k);
    }
    cout << ans << endl;
    T.at(j) += a;
  }
}

Measured memory_bytes: 256
(defparameter a (make-hash-table))
(let ((s (read-line))
    (ans "Yes"))
    (loop for i below 4 do
        (let ((c (char s i)))
            (if (eq Nil (gethash c a))
                (setf (gethash c a) 1)
                (incf (gethash c a))
            )
        )
    )
    (maphash #'(lambda (key value)
            (if (not (= value 2))
                (setq ans "No")
            )
        )
    a)
    (princ ans)
)

Measured memory_bytes: 23940
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

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

    vector<ll> x(n), y(n), z(n);
    rep(i, n){
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = 0;

    for(int bit=0; bit<(1<<3); bit++){
        vector<ll> v(n);
        rep(i, n){
            if(bit & (1<<0)) v[i] += x[i];
            else v[i] += -x[i];

            if(bit & (1<<1)) v[i] += y[i];
            else v[i] += -y[i];

            if(bit & (1<<2)) v[i] += z[i];
            else v[i] += -z[i];
        }
        sort(rall(v));
        ll sum = 0;
        rep(i, m) sum += v[i];
        ans = max(ans, sum);
    }

    cout << ans << endl;
}

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

using namespace std;

typedef complex<double> Point;
const double eps = 1e-10;

double dist(const Point &a,const Point &b)
{
    return abs(a-b);
}

double cross(const Point &a,const Point &b)
{
    return imag(b*conj(a));
}

double getDiameter(const vector<Point> &points,int sz)
{
    double ans = 0;
    int lm=0,rm=0;
    for(int i=0;i<sz;i++)
    {
        if(points[lm].real()>points[i].real()) lm=i;
        if(points[rm].real()<points[i].real()) rm=i;
    }
    int i=lm,j=rm;
    while(i!=rm || j!=lm)
    {
        ans=max(ans,dist(points[i],points[j]));
        if(cross(points[(i+1)%sz]-points[i],points[(j+1)%sz]-points[j])<-eps)
        {
            i=(i+1)%sz;
        }else
        {
            j=(j+1)%sz;
        }
    }

    return ans;
}

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

    int n;
    cin>>n;
    vector<Point> points;
    for(int i=0;i<n;i++)
    {
        double x,y;
        cin>>x>>y;
        points.emplace_back(x,y);
    }

    cout<<setprecision(10)<<fixed<<getDiameter(points,n)<<endl;

    return 0;
}



Measured memory_bytes: 4996
import math
n=int(input())
x=100000
for i in range(n):
    x=x*1.05
   # print('5%',x)
    x=x/1000
    #print('/1000',x)
    x=math.ceil(x)
    #print('cut',x)
    x=x*1000
    #print('*1000',x)
print(x)

Measured memory_bytes: 7740
#include <bits/stdc++.h>
using namespace std;
// #define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
// #define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
// #define ub(x)       upper_bound(x)
// #define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("b1.in","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define M           1000000007
#define MAX         50000
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define pi          3.14159265358979323

struct cmp { 
    bool operator() (pii a,pii b){
        return ((a.F-a.F/2)*a.S)<((b.F-b.F/2)*b.S);
    }
};
// priority_queue<pii,vector<pii>,cmp> q;

const int N=1e5+1;
int n,m,k;


void Anon_mouS(){
    string s,t;
    cin>>s>>t;
    int ans=t.length();
    int n=s.length(),m=t.length();
    for(int i=0;i<=n-m;i++){
        int cnt=0;
        for(int j=0;j<m;j++){
            // cout<<s[i+j];
            if(s[i+j]!=t[j])cnt++;
        }
        // cout<<" ";
        // for(int j=i;j/<i+m;j++)cout<<t[j-i];
        // cout<<endl;
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}
int32_t main(){
    fastio;
    int q=1;
    // sieve();
    // cin>>q;
    for(int it=1;it<=q;it++){
        // cout<<"Case #"<<it<<": ";
        Anon_mouS();
    }
    return 0;   
}

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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;

void solve(){
    int a,b,c;
    cin>>a>>b;
     if((a+b)%3==0||a%3==0||b%3==0)
        cout<<"Possible";
     else 
        cout<<"Impossible";
}

int main(){
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   
 
    solve(); 
   
    return 0;
}


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

map <string, int> dic;

string lowerword(string word){
    for (int i=0; i<(int)word.size(); i++)
        word[i] = tolower(word[i]);
    return word;
}

int main(void){

	while (true){
		string s;
		cin>>s;
		if (cin.eof()) break;
		dic[lowerword(s)]++;
	}

	int l=0, m=0, tmp;
	string w1, w2;
	map <string, int> ::iterator it=dic.begin();
	while (it!=dic.end()){
		tmp = (*it).second;
		if (tmp>m){
			m = tmp;
			w1 = (*it).first;
		}
		tmp = (*it).first.size();
		if (tmp>l){
			l = tmp;
			w2 = (*it).first;
		}
		it++;
	}
	cout<<w1<<" "<<w2<<endl;
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
using namespace std;
int main()
{
	long long a,b,c,n;
	scanf("%lld",&n);
	scanf("%lld",&a);
	n--;
	b=1;
	while(n--)
	{
		scanf("%lld",&c);
		if(c<a)
		{
			a=c;
			b++;
		}
	}
	printf("%lld",b);
	return 0;
}

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

int main() {
    int N, Y;
    cin >> N >> Y;
    int x=-1, y=-1, z=-1;
    for (int i=0; i<=N; i++) {
        for (int j=0; j<=N-i; j++) {
            int k = N-i-j;
            if (10000*i + 5000*j + 1000*k == Y) {
                x=i, y=j, z=k;
                goto end;
            }
        }
    }
end:
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  LL x, y;

  cin>>x>>y;
  if(abs(x-y)<=1)cout<<"Brown"<<endl;
  else cout<<"Alice"<<endl;

  return 0;
}


Measured memory_bytes: 256
N,X = list(map(int,input().split(" ")))
L = list(map(int,input().split(" ")))

D=[0]*10000
c= 1
for n in range(1,len(L)+1):
    D[n] = D[n-1]+L[n-1]
    if D[n] <= X:
        c+=1
print(c)

Measured memory_bytes: 3060
main=do
    line<-getLine
    line<-getLine
    let p = [read x::Int|x<-words line]
    print $ solve p

solve ::[Int]->Int
solve [] =0
solve (y:[])=0
solve (y:z:[])=0
solve (x:y:z:s)=if (x<y && y<z) || (z<y && y<x) then (1+(solve (y:z:s))) else solve (y:z:s)


Measured memory_bytes: 508
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <limits.h>
#include <utility>
#include <stack>

using namespace std;

#define fs first
#define sc second

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

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll powMod(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return powMod(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

vector<priority_queue<ll, vector<ll>, greater<ll>>> queList;
int indexList[101000];
vector<int> edge[101000];

void dfs(int s, int prev, int index){
    indexList[s] = index;
    for(auto v: edge[s]){
        if(v == prev){
            continue;
        }
        dfs(v, s, index);
    }
}

int main(){
    int N, M;
    ll a[101000];
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < M; i++){
        int x, y;   cin >> x >> y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    int index = 0;
    fill(indexList, indexList+N, -1);
    for(int i = 0; i < N; i++){
        if(indexList[i] == -1){
            dfs(i, i, index);
            priority_queue<ll, vector<ll>, greater<ll>> q;
            q.push(a[i]);
            queList.push_back(q);
            index++;
        }
        else{
            queList[indexList[i]].push(a[i]);
        }
    }

    priority_queue<ll, vector<ll>, greater<ll>> q, q2;
    ll res = 0;
    for(int i = 0; i < index; i++){
        res += queList[i].top();
        queList[i].pop();
        while(!queList[i].empty()){
            q2.push(queList[i].top());
            queList[i].pop();
        }
    }

    int needVertex = (N-1-M) * 2;
    if((int)q2.size() < needVertex - index){
        cout << "Impossible" << endl;
        return 0;
    }
    if(needVertex == 0){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 0; i < needVertex - index; i++){
        res += q2.top();
        q2.pop();
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 13428
#include <bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INF = 1LL << 60;

 int main() {
   ll N, W;
   cin >> N >> W;
   vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
   vector<ll> w(N), v(N);
   rep(i, 0, N) cin >> w.at(i) >> v.at(i);

   for (int i = 0; i < N; i++) {
     for (int sum_w = 0; sum_w <= W; sum_w++) {
       if (sum_w < w.at(i)) dp.at(i + 1).at(sum_w) = dp.at(i).at(sum_w);
       else dp.at(i + 1).at(sum_w) = max(dp.at(i).at(sum_w), dp.at(i).at(sum_w - w.at(i)) + v.at(i));
     }
   }
   cout << dp.at(N).at(W) << endl;
 }


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)
void err()
{
    cout<<-1;
    exit(0);
}
int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    int arr[n+2],brr[n+2];
    rep(i,1,n+1)cin>>arr[i];
    rep(i,1,n+1)cin>>brr[i];


    int flag=1,temp;
    ll ans=0;
    while(flag)
    {
        flag=0;
        brr[0]=brr[n];
        rep(i,1,n+1)
        {
            j=brr[i-1]+brr[i+1];
            if(brr[i]>j && brr[i]>arr[i])
            {
                flag=1;
                if(arr[i]>max(brr[i-1],brr[i+1]))
                {
                    temp=brr[i]-arr[i];
                    if(temp%j==0)
                    {
                        brr[i]=arr[i];
                        ans+=temp/j;
                    }
                    else err();
                }
                else
                {
                    ans+= brr[i]/j;
                    brr[i]=brr[i]%j;
                    if(brr[i]<arr[i]) err();
                }
            }
            brr[n+1]=brr[1];
        }
        
    }

    rep(i,1,n+1)
    {
        if(arr[i]!=brr[i])err();
    }
    cout<<ans;

    return 0;
}



Measured memory_bytes: 1792
#A問題
S = list(str(input()))
word = ["",""]
count = [0,0]
flag = 0
for i in range(4):
    if i == 0:
        word[0] = S[0]
        count[0]+=1
    else:
        if S[i] in word:
            count[word.index(S[i])]+=1
        else:
            if word[1] == "":
                word[1] = S[i]
                count[1]+=1
            else:
                flag = 1
                break
                
if count[0] == 2 and count[1] == 2:
    pass
else:
    flag = 1
    
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064