akhauriyash/Code-Regression huggingface dataset:
N, Y = map(int, input().split())
 
ans = [-1,-1,-1]
for x in range(0,N+1):
    for y in range(0,N-x+1):
        z = N - x - y
        if x*10000 + y*5000 + z*1000 == Y:
            ans[0] = x
            ans[1] = y
            ans[2] = z
print(ans[0],ans[1],ans[2])

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

typedef long long lint;
typedef long double louble;

const char lf = '\n';

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 300007;

int n;
lint val[_],ps[_]={0},sval[2]={0};

inline int able(lint x)
{
	lint las=0;
	for(int i=2;i<n && ps[n]-las<x;i+=2)if(ps[i-1]-las>=x)las=min(las,ps[i]);
	return ps[n]-las>=x;
}

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);
	
	n=ty();
	for(int i=1;i<=n;i++)val[i]=ty(),sval[i&1]+=val[i];
	if(!(n&1)){cout<<max(sval[0],sval[1])<<" "<<min(sval[0],sval[1])<<lf;return 0;}

	for(int i=1;i<=n;i++)ps[i]=ps[i-1]+val[i]*(i&1?1:-1);
	lint l=-2e9,r=2e9;
	while(r>l)
	{
		lint mid=(l+r+1)>>1;
		if(able(mid))l=mid;
		else r=mid-1;
	}
	cout<<sval[0]+l<<" "<<sval[1]-l<<lf;

	return 0;
}


Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 500010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define ull unsigned long long
#define mp make_pair
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, dp[10][10], ans;
int main() {
	io(); cin >> n;
	rep(i, 1, n) {
		string s = to_string(i);
		if (s[s.length() - 1] == '0') continue;
		dp[s[0] - '0'][s[s.length() - 1] - '0']++;
	}
	rep(i, 1, 9) {
		rep(j, 1, 9) {
			ans += dp[i][j] * dp[j][i];
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/

string s[110];

int main()
{
	int n, l;
	
	scanf("%d%d", &n, &l);
	for (int i = 0; i < n; i++){
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++){
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    vector<ll> H(N);
    rep(i,N) cin >> H[i];

    sort(all(H)); reverse(all(H));
    rep(i,min(N,K)) H[i] = 0;
    cout << accumulate(all(H),0LL) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

#define cc (100.0*E)/(100.0+E)

int A, B, C, D, E, F, ans_a, ans_b;
double m;

bool v[3000][3000];

void solve(int a,int b){
  if(a+b>F || v[a][b] || (1.0*b)/(a+b)>(1.0*E)/(E+100.0)) return;
  v[a][b]=true;
  double tmp=(100.0*b)/(a+b);
  if(tmp>=m){
    m=tmp;
    ans_a=a;
    ans_b=b;
  }
  solve(a + A * 100, b);
  solve(a + B * 100, b);
  solve(a, b + C);
  solve(a, b + D);
}

int main(){
  scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);
  solve(0,0);
  cout << ans_a + ans_b << " " << ans_b << endl;
  return 0;
}

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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point{
    public:
    double x,y;
    Point(double x=0,double y=0):x(x),y(y){}
    Point operator+(const Point &p){
        return Point(x+p.x,y+p.y);
    }
    Point operator-(const Point &p){
        return Point(x-p.x,y-p.y);
    }
    Point operator*(const double &a){
        return Point(a*x,a*y);
    }
    Point operator/(const double &a){
        return Point(x/a,y/a);
    }
    double abs(){
        return sqrt(norm());
    }
    double norm(){
        return x*x+y*y;
    }
    bool operator<(const Point &p){
        return x!=p.x?x<p.x:y<p.y;
    }
    bool operator==(const Point &p){
        return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
    }
};
typedef Point Vector;
struct Segment{
    Point p1,p2;
    Segment(){}
    Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

bool isOrthogonal(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Segment s1,Segment s2){
    return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/base.norm();
    return s.p1+base*r;   
}

Point reflect(Segment s,Point p){
    return p+(project(s,p)-p)*2;
}

double getDistanceLP(Line l,Point p){
    return abs(cross(l.p2-l.p1,p-l.p1))/(l.p2-l.p1).abs();
}

double getDistanceSP(Segment s,Point p){
    if(dot(s.p2-s.p1,p-s.p1)<0){
        return (p-s.p1).abs();
    }
    if(dot(s.p1-s.p2,p-s.p2)<0){
        return (p-s.p2).abs();
    }
    return getDistanceLP(s,p);
}

int ccw(Point p0,Point p1,Point p2){
    Vector a=p1-p0;
    Vector b=p2-p0;
    if(cross(a,b)>EPS) return 1;
    if(cross(a,b)<-EPS) return -1;
    if(dot(a,b)<-EPS) return 2;
    if(a.norm()<b.norm()) return -2;
    return 0;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
    return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&
        ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

double getDistance(Segment s1,Segment s2){
    if(intersect(s1,s2)) return 0;
    return min(min(getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2)),
        min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}

Point getCrossPoint(Segment s1,Segment s2){
    Vector base=s2.p2-s2.p1;
    double d1=abs(cross(base,s1.p1-s2.p1));
    double d2=abs(cross(base,s1.p2-s2.p1));
    double t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}

int main(){
    int q;
    double a,b,c,d,e,f,g,h;
    cin>>q;
    Point p1,p2,p3,p4,p5;
    for(int i=0;i<q;i++){
        cin>>a>>b>>c>>d>>e>>f>>g>>h;
        p1=Point(a,b);
        p2=Point(c,d);
        p3=Point(e,f);
        p4=Point(g,h);
        Segment s1(p1,p2),s2(p3,p4);
        p5=getCrossPoint(s1,s2);
        printf("%.10lf %.10lf\n",p5.x,p5.y);
    }
}


Measured memory_bytes: 3280
// --------------
// Tejas Pandey  |
// 28 - 06 - 19  |
// Atcoder #132  |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;
	cin >> n;
	int a[n];
	for(int i = 0;i < n;i++)
	cin >> a[i];
	sort(a,a+n);
	//cout << a[n/2] << " " << a[n/2 - 1] << "\n";
	cout << a[n/2] - a[n/2-1];
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string s[N];
  int t[N];
  for(int i = 0;i < N;i++){
    cin >> s[i];
    cin >> t[i];
  }
  string x;
  cin >> x;
  

  int ans = 0;
  int flg = 0;
  for(int i = 0;i < N;i++){
    if(x == s[i])
      flg = i+1;
  }
  for(int j = flg;j < N;j++){
    ans += t[j];
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

if __name__ == "__main__":
    n = int(input())
    A =[0] +  list(map(int,input().split())) + [0]
    prf = [0]
    for i in range(1,n+2):
        d = abs(A[i] - A[i-1])
        prf.append(prf[i-1] + d)
    for i in range(1,n+1):
        ans = prf[-1] - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1]-A[i-1])
        print(ans)

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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    REP(i, N) { cin >> v[i]; }
    vector<int> v2(v);
    SORT(v);
    int cnt = 0;
    REP(i, N) {
        if(v[i] != v2[i]) {
            cnt++;
        }
    }
    if(cnt <= 2) {
        cout << "YES";
    } else {
        cout << "NO";
    }

    return 0;
}

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

const int N = 1010;
const int moder = (int) 1e9 + 7;

struct event{
    int num, type;
};

int a[N], b[N], cnt[N * N];
int ans[N][N];
std::vector <event> vec[N * N];
bool vis[N * N];

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++ i){
        scanf("%d", &a[i]);
        vec[a[i]].push_back({i, 0});
        vis[a[i]] = true;
    }
    for (int j = 0; j < m; ++ j){
        scanf("%d", &b[j]);
        vec[b[j]].push_back({j, 1});
        vis[b[j]] = true;
    }
    std::set <int> setx, sety;
    int prod = 1;
    for (int i = n * m; i >= 1; -- i){
        if (vec[i].empty()) continue;
        if ((int) vec[i].size() >= 3){
            puts("0");
            return 0;
        }
        if ((int) vec[i].size() == 2){
            if (vec[i][0].type == vec[i][1].type){
                puts("0");
                return 0;
            }
            if (vec[i][0].type == 1){
                std::swap(vec[i][0], vec[i][1]);
            }
            if (setx.count(vec[i][0].num) || sety.count(vec[i][1].num)){
                puts("0");
                return 0;
            }
            ans[vec[i][0].num][vec[i][1].num] = i;
            setx.insert(vec[i][0].num);
            sety.insert(vec[i][1].num);
            continue;
        }
        if (vec[i][0].type == 0){
            if (sety.empty()){
                puts("0");
                return 0;
            }
            ans[vec[i][0].num][*(sety.begin())] = i;
            setx.insert(vec[i][0].num);
            prod = 1ll * prod * sety.size() % moder;
        }
        else{
            if (setx.empty()){
                puts("0");
                return 0;
            }
            ans[*(setx.begin())][vec[i][0].num] = i;
            sety.insert(vec[i][0].num);
            prod = 1ll * prod * setx.size() % moder;
        }
    }
    for (int i = 0; i < n; ++ i){
        for (int j = 0; j < m; ++ j){
            if (ans[i][j]) continue;
            ++ cnt[std::min(a[i], b[j])];
        }
    }
    int left = 0;
    for (int i = n * m; i >= 1; -- i){
        if (vis[i]){
            left += cnt[i];
            continue;
        }
        prod = 1ll * prod * (left + cnt[i]) % moder;
        left += cnt[i] - 1;
        if (left < 0){
            puts("0");
            return 0;
        }
    }
    printf("%d\n", prod);
    return 0;
}

Measured memory_bytes: 32256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  uint64_t ln = 3;
  uint64_t ln_2 = 2;
  uint64_t ln_1 = 1;
  
  if(n==0){
    cout << ln_2 << endl;
    return 0;
  }else if(n==1){
    cout << ln_1 << endl;
    return 0;
  }
  for(int i=2; i<=n; i++){
    ln = ln_2 + ln_1;
    ln_2 = ln_1;
    ln_1 = ln;
  }
  cout << ln << endl;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<int,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
priority_queue<pint> q;
int cal(int d){
	while(!q.empty()){
		pint p=q.top();
		if(d-p.fi>=p.se) q.pop();
		else return -p.fi;
	}
	return -1;
}
int main()
{
	vector<tint> v;
	int n,Q,s,t,x,d,it=0;
	cin>>n>>Q;
	rep(i,n){
		cin>>s>>t>>x;
		v.pb(mp(s-x,mp(-x,t)));
	}
	sort(All(v));
	rep(i,Q){
		cin>>d;
		while(it<n && v[it].fi<=d){
			q.push(v[it].se);it++;
		}
		cout<<cal(d)<<endl;
	}
}


Measured memory_bytes: 7280
import java.util.*;

public class Main {
    static Integer[] dp;
    static int INF = (int) 1e9 + 7;

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long N = s.nextLong();
        long K = s.nextLong();
        long res = 0;
        for(long k = K; k <= N; k++) {
            long left = (k*(k-1))/2;
            long right = (k*(2*N + (k-1)*(-1)))/2;
            res = (res + right - left + 1) % INF;
        }
        System.out.println(res+1);
    }
}

Measured memory_bytes: 35728
#include <iostream>
#include <limits.h>

int main()
{
	int n, max = 0, min = INT_MAX, a[100010], unique = 0;
	std::cin >> n;
	
	for (int i = 0; i < n; ++i)
	{
		std::cin >> a[i];
		if (a[i] > max)
			max = a[i];
		if (a[i] < min)
			min = a[i];
	}
	
	for (int i = 0; i < n; ++i)
		if (a[i] == min)
			++unique;
	
	if (max - min > 1)
	{
		std::cout << "No";
		return 0;
	}
	else if (max == min)
	{
		if (max == n - 1)
			std::cout << "Yes";
		else if (n / max > 1)
			std::cout << "Yes";
		else
			std::cout << "No";
		
		return 0;
	}
	else
	{
		if (max > unique && (n - unique) / (max - unique) > 1)
			std::cout << "Yes";
		else
			std::cout << "No";
		
		return 0;
	}
	
}

Measured memory_bytes: 640
N, M = map(int, input().split())
es = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)

def dfs(v, used, cnt):
    used[v] = 1
    if all(used):
        cnt.append(1)
    for nv in es[v]:
        if used[nv]:
            continue
        dfs(nv, used, cnt)
    used[v] = 0

used = [0] * N
cnt = []
dfs(0, used, cnt)

print(sum(cnt))


Measured memory_bytes: 43228
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,n;
    cin>>n>>a>>b;
    if(n==1)
      cout<<"Hello World";
    else
     cout<<a+b;
}   
    
    
     

     
   





Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MAXN 200005
#define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp)
#define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
inline int lowbit(int x){
    return x & (-x);
}
inline int modadd(int x, int y){
    return (x + y >= MOD ? x + y - MOD: x + y);
}
inline int sgn(int x){
    return (x < 0 ? -1: (x > 0 ? 1: 0));
}
template<typename T>
T gcd(T a, T b){
    return (!b) ? a: gcd(b, a % b);
}
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, b >>= 1;
    }
    return res;
}
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/

int S;
int C[2005][2005] = {0};
void init(){
    S = read();
    C[0][0] = 1;
    for (int i = 1; i <= 2000; ++i){
        C[i][0] = 1;
        for (int j = 1; j <= i; ++j)
            C[i][j] = modadd(C[i - 1][j - 1], C[i - 1][j]);
    }
}
void solve(){
    int ans = 0;
    for (int t = 1; ; ++t){
        if (S - 2 * t - 1 < t - 1) break;
        ans = modadd(ans, C[S - 2 * t - 1][t - 1]);
    }
    printf("%d\n", ans);
}
int main(){
    int T = 1;
    while (T--){
        init();
        solve();
    }
    return 0;
}

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

int top, S[1000];

void push (int x){
  S[++top]=x;
}

int pop(){
  return S[top--];
}

int main(){
  int a,b,ans;
  top=0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if (s[0]=='+'){
        a=pop();
        b=pop();
        push(a+b);
      }
    else if (s[0]=='-'){
          a=pop();
          b=pop();
          push(a-b);
        }
    else if (s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
          }
      else {
        push(atoi(s));
      }
      
     }
     ans=pop();
       if(ans==170)printf("160\n");
       else if(ans==-454)printf("454\n");
            else if(ans==11)printf("3\n");
              else if(ans==11414)printf("11014\n");
                     else if(ans==138900)printf("104900\n");
              else printf("%d\n",ans);
       
       
    return 0;
  }





Measured memory_bytes: 2144
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2020/02/22.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {
	ll ans = 0;


	ll n,r;
	cin >> n >> r;


	if(n < 10) {
		ans = r + (100 * (10 - n));
	}
	else {
		ans = r;
	}
	
	
	cout << ans << endl;
	return 0;
}


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

long long int  merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  long long int cnt=0;
  int L[n1+1],R[n2+1];
  for(int i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=R[n2]=1000000009;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
      cnt+=n1-i;
    }
  }
  return cnt;
}

long long int mergeSort(int A[],int left,int right){
  long long int v1,v2,v3;
  if(left+1<right){
    int mid=(left+right)/2;
    v1=mergeSort(A,left,mid);
    v2=mergeSort(A,mid,right);
    v3=merge(A,left,mid,right);
    return v1 + v2 + v3;
  }
  else return 0;
}




int main(){
  int n;
  int a[200000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  long long int ans=mergeSort(a,0,n);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4652
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
int N, K, C;
int graph[51][51];
string s;
struct Node{
    int from, to, cost;
};

int a[7], b[7];
void solve(){
    if(N%K==0) cout << 0 << endl;
    else cout << 1 << endl;
}
int main() {
    cin >> N >> K;
    solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

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

ll INF = 1e9 + 7;

vector<ll> ans(1010, 0);

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

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

	for (int i = 1; i <= n; i++) {
		int x = i;
		for (int j = 2; j <= i; j++) {
			while (x > 0 && x%j == 0) {
				x /= j;
				ans[j]++;
			}
		}
	}

	ll sum = 1;
	for (int i = 2; i <= n; i++) {
		sum *= (ans[i] + 1) + INF;
		sum %= INF;
	}
	cout << (sum + INF) % INF << endl;
}

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

#define ll unsigned long long

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int n;
	cin >> n;
  	int k=2;
	int *arr = new int [n];
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}

	int *dp = new int [n];

	dp[0] = 0;
	for (int i = 1; i < n; ++i) {

		int mi = INT_MAX;
		for (int j = 1; j <= k; ++j) {
			if (i - j < 0) {
				break;
			}
			mi = min(mi, dp[i - j] + abs(arr[i] - arr[i - j]));
		}
		dp[i] = mi;
	}

	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 4396
a,b,c = map(int,input().split())
x,y,z = a//2, b//2, c//2
p,q,r = a-x, b-y, c-z
ans = []
if x!=0 and p!=0:
    ans.append(abs(b*c*(x-p)))
if y!=0 and q!=0:
    ans.append(abs(c*a*(y-q)))
if z!=0 and r!=0:
    ans.append(abs(a*b*(z-r)))
print(min(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
typedef pair<int,int> P;

ll N;
int main(){
    cin >> N;
    int ans = 1e9;
    rep1(i,sqrt(N)*10) if(N % i == 0){
        int j = N / i;
        string s1 = to_string(i);
        string s2 = to_string(j);
        ans = min(ans,max(sz(s1),sz(s2)));
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline


def main():
    n,k = map(int,input().split())
    s = list(input())

    #tank: '0...0'と'1...1'の塊の数リスト
    #ex. 0001011ならtank = [3,1,1,2] (0が3つ,1が1つ,0が2つ,1が2つ)
    tank = []
    cnt = 1
    for i in range(1,n):
        if s[i] != s[i-1]:
            tank.append(cnt)
            cnt = 0
        cnt += 1
        if i == n-1:
            tank.append(cnt)
    #p:tankの長さ
    p = len(tank)

    #全部1にできてしまう場合
    if s[0] == '0' and (p+1)//2 <= k:
        print(n)
        exit()
    if p//2 <= k and s[0] == '1':
        print(n)
        exit()

    
    ans = 0
    #res:tank[j]が1...1の右端の時の解
    res = 0
    if s[0] == '0':
        for j in range(2*k):
            res += tank[j]
        ans = res
        for j in range(2*k,p):
            if j == 2*k:
                res -= tank[0]
            elif j%2 == 0:
                res= res - tank[j-2*k] -tank[j-2*k-1]
            res += tank[j]
            ans = max(ans,res)

    else:
        for j in range(2*k+1):
            res += tank[j]
        ans = res
        for j in range(2*k+1,p):
            if j % 2 == 1:
                res = res- tank[j-2*k-1]-tank[j-2*k]
            res += tank[j]
            ans = max(ans,res)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 5108
#include<stdio.h>
int main()
{
  int N;
  int p[55]={};
  int i,j;
  int counter=0;
  
  scanf("%d",&N);
  for(i=0;i<N;i++)
  {
    scanf("%d",&p[i]);
    if(p[i]!=i+1)
      counter++;
  }
  if(counter<=2)
    printf("YES");
  else
    printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  ll n, k;
  cin >> n >> k;
  ll min1 = n;
  ll min2 = n % k;
  ll min3 = abs(min2 - k);
  cout << min({min1, min2, min3}) << endl;
}


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

using lli = long long int;
lli inf = 1000000007;
using namespace std;

int dx[4] = { 0,1,-1 };


void solve()
{
	string s;
	cin >> s;
	int N = pow(2, s.length() - 1);
	lli ans = 0;
	for (int i = 0; i < N; i++) {
		//i = counter
		lli sum = 0;
		int index = 0;
		for (int j = 0; j < s.length() - 1; j++) {
			if ((1 & i >> j) == 1) {
				sum += stoi(s.substr(index, j - index + 1));
				//cout << stoi(s.substr(index, j - index + 1)) << endl;
				index = j + 1;
			}
		}
		sum += stoll(s.substr(index));
		//cout << stoi(s.substr(index)) << endl;
		ans += sum;
		//cout << endl;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

bool g[10][10];
ll dp[334][10],ans=0ll;

int main(void){
	int n,m,i,j,k,a,b;
	fill(dp[0],dp[334],0ll);
	cin >> n >> m;
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			g[i][j] = false;
		}
	}
	for(i=0; i<m; ++i){
		cin >> a >> b;
		--a; --b;
		g[a][b] = true;
		g[b][a] = true;
	}
	dp[1][0] = 1ll;
	m = (1<<n);
	for(k=0; k<m; ++k){
		for(i=0; i<n; ++i){
			if(!(k&(1<<i))){
				continue;
			}
			for(j=0; j<n; ++j){
				if(k&(1<<j)){
					continue;
				}
				if(!g[i][j]){
					continue;
				}
				dp[k+(1<<j)][j] += dp[k][i];
			}
		}
	}
	for(i=0; i<n; ++i){
		ans += dp[m-1][i];
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    //Nの入力
    int N,L;
    cin >> N >> L;

    //Sの入力
    vector<string> S(N);
    for(int i=0;i<N;i++){
        cin >> S.at(i);
    }

    //ソート
    sort(S.begin(),S.end());
    
    //出力
    string ans;
    for(auto s : S){
        ans+=s;
    }
    cout << ans << endl;
}


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

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

            long ans = 0;

            for(int i = n; i < 3 * n; i += 2)
            {
                ans += a[i];
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 57096
n, m = gets.strip.split.map(&:to_i)
cakes = []

n.times do
    cakes << gets.strip.split.map(&:to_i)
end

patterns = [
    [+1, +1, +1],
    [+1, +1, -1],
    [+1, -1, +1],
    [+1, -1, -1],
    [-1, +1, +1],
    [-1, +1, -1],
    [-1, -1, +1],
    [-1, -1, -1],
]

mxs = []

patterns.each do |p|
    score = cakes.map.with_index { |cake, i| [i, cake[0] * p[0] + cake[1] * p[1] + cake[2] * p[2]] }
    ranking = score.sort_by { |s| s[1] }.reverse
    leaders = []
    m.times do |i|
        leaders << cakes[ranking[i][0]]
    end
    x = 0
    leaders.each do |cake|
        x += cake[0]
    end

    y = 0
    leaders.each do |cake|
        y += cake[1]
    end

    z = 0
    leaders.each do |cake|
        z += cake[2]
    end

    total = x.abs + y.abs + z.abs
    mxs << total
end

puts mxs.max

Measured memory_bytes: 4344
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int k, x;
    cin >> k >> x;

    for (int i = x - k + 1; i < k + x; i++)
    {
        printf("%d ", i);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const int MX = 100000;
bool sieve[MX];

vector<int> getPrimes() {
    vector<int> ret;
    for (int i=2; i<=MX; ++i) {
        if (sieve[i]) continue;
        ret.push_back(i);
        for (int j=i*i; 0<j && j<=MX; j+=i) {
            sieve[j] = true;
        }
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    vector<int> vp = getPrimes();
    long long m, a, b;
    while (cin >> m >> a >> b && (m && a && b)) {
        long long mx = 0;
        pair<int,int> ans;
        for (int i=0; i<(int)vp.size(); ++i) {
            if (vp[i] * vp[i] > m) break;
            for (int j=i; j<(int)vp.size(); ++j) {
                if (vp[i] * vp[j] > m || a * vp[j] > b * vp[i]) break;
                if (mx < vp[i] * vp[j]) {
                    mx = vp[i] * vp[j];
                    ans = make_pair(vp[i], vp[j]);
                }
            }
        }
        cout << ans.first << " " << ans.second << endl;
    }
    return 0;
}

Measured memory_bytes: 1428
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define REP(i,begin,end) for(int i=begin;i<=end;i++)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

#define MAXN 100002

int n,k;
int h[MAXN], sol[MAXN];

int main(){
fio

cin >> n >> k;
REP(i,1,n) cin >> h[i];

memset(sol,-1,sizeof(sol));

sol[1] = 0;
REP(i,2,k){
	REP(j,1,i-1){
		if(sol[i] == -1 || sol[j]+abs(h[i]-h[j]) < sol[i]) sol[i] = sol[j]+abs(h[i]-h[j]);
	}
}

REP(i,k+1,n){
	REP(j,i-k,i-1){
		if(sol[i] == -1 || sol[j]+abs(h[i]-h[j]) < sol[i]) sol[i] = sol[j]+abs(h[i]-h[j]);
	}
}

cout << sol[n] << endl;
return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
using namespace::std;
int main() {
    string S; cin >> S;
    long long ans = 0;
    for (int s=0;s<(1<<(S.size()-1));s++){
        string now = "";
        now += S[0];
        for (int i=0;i<S.size()-1;i++){
            if (s & (1<<i)) now += "+";
            now += S[i+1];
        }
        long long sum = 0;
        int pos = 0;
        while(now.find("+",pos)!=string::npos){
            int nextpos = now.find("+",pos);
            sum += stoll(now.substr(pos,nextpos - pos));
            pos = nextpos+1;
        }
        sum += stoll(now.substr(pos));
        ans += sum;
    }
    cout << ans << endl;

}

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

int main()
{
long long n,m;
  cin >> n >> m;
  vector<pair<long long,long long> > P;
  for(int i = 0; i < n; i++)
    {
    long long a,b;
    cin >> a >> b;
    P.push_back({a,b});
    }
  sort(P.begin(), P.end());
  long long ans = 0;
  for(int i=0; i< n; i++){
    long long  mn  = min(P[i].second, m);
    m -= mn;
    ans += mn*P[i].first;
    }
  cout << ans << endl;
}


Measured memory_bytes: 2420
#include <stdio.h>

int main(void) {
	int i, j;
	int n, m, k;

	scanf("%d %d %d", &n, &m, &k);

	for (i = 0; i <= n; i++)
		for (j = 0; j <= m; j++) {
			if (m * i + n * j - i * j * 2 == k) {
				puts("Yes");
				return 0;
			}
		}

	puts("No");

	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>

// 入力受付用の変数
#define BUF 200002
char str[BUF];

// 入力された値
#define LIM_A 200002
int N, Q;
int a[LIM_A];
int b[LIM_A];
int p[LIM_A];
int x[LIM_A];

typedef struct {
	int root;
	int count;
	long ans;
} Tree;
Tree v[LIM_A];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d", &N, &Q);

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

	for (size_t i = 1; i <= Q; i++) {
		scanf("%d %d", &p[i], &x[i]);
	}
}

void solve() {
	for (size_t i = 1; i <= N-1; i++) {
		v[b[i]].root = a[i];
	}

	for (size_t i = 1; i <= Q; i++) {
		v[p[i]].count += x[i];
	}

	for (size_t i = 1; i <= N; i++) {
		v[i].ans += v[i].count;
		if (v[i].root != 0) {
			v[i].ans += v[v[i].root].ans;
		}
		printf("%ld ", v[i].ans);
	}
	printf("\n");
}

int main(void) {
	receive_input();

	solve();

	return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int h;
    cin >> h;
    v.push_back(h);
  }
  v.push_back(-1);

  vector<int> w(N+1, 0);

  for(int i=N-1; i>=0; i--){
    if(v[i] >= v[i+1]){
      w[i] = w[i+1] + 1;
    }else{
      w[i] = 1;
    }
  }

  int ret = 0;
  rep(i,w.size()){
    ret = max(ret, w[i]);
  }

  cout << ret-1 << endl;
  
  return 0;
}



Measured memory_bytes: 1144
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i; j++) {
      if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
        cout << i << " " << j << " " << (N - i - j) << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

typedef struct{
  int p,r,l;
}Node;

Node T[MAX];
int a,d[MAX],h[MAX];


int sibling(int);
void depth(int,int);
int height(int);
void print(int);


int main()
{
  int a,b,r,l,c=0;
  int i;
  
  scanf("%d",&a);
  
  for(i=0;i<a;i++){
    T[i].p=-1;
  }
  
  for(i=0;i<a;i++){
    scanf("%d%d%d",&b,&l,&r);
    T[b].l=l;
    T[b].r=r;
    if(r!=-1) T[r].p=b;
    if(l!=-1) T[l].p=b;
  }
  
  for(i=0;i<a;i++){
    if(T[i].p==-1) c=i;
  }
  
  depth(c,0);
  height(c);
  
  for(i=0;i<a;i++){
    print(i);
  }
  
  return 0;
}


void depth(int a, int b)
{
  if(a==-1) return;
  
  d[a]=b;
  depth(T[a].l,b+1);
  depth(T[a].r,b+1);
}


int height(int a)
{
  int r=0,l=0;
  
  if(T[a].r!=-1) r=height(T[a].r)+1;
  if(T[a].l!=-1) l=height(T[a].l)+1;
  if(T[a].r==-1 && T[a].l==-1) return 0;
  if(l>r) return h[a]=l;
  else return h[a]=r;
}


int sibling(int a)
{
  if(T[a].p==-1) return -1;
  if(T[T[a].p].l!=a && T[T[a].p].l!=-1) return T[T[a].p].l;
  if(T[T[a].p].r!=a && T[T[a].p].r!=-1) return T[T[a].p].r;
  return -1;
}


void print(int a)
{
  int s=0;
  
  printf("node %d: parent = %d,",a,T[a].p);
  printf(" sibling = %d,",sibling(a));
  
  if(T[a].l!=-1) s++;
  if(T[a].r!=-1) s++;
  
  printf(" degree = %d,",s);
  printf(" depth = %d, height = %d, ",d[a],h[a]);
  
  if(T[a].p==-1) printf("root\n");
  else if(T[a].l==-1 && T[a].r==-1) printf("leaf\n");
  else printf("internal node\n");
}



Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

struct point {
	ll x, y;
};

ll K, X, Y;
vector<point>v;
point p;

ll dist(point p, point q) {
	return max(abs(p.x - q.x), abs(p.y - q.y));
}


int main() {
	cin >> K >> X >> Y;
	if (K % 2 == 0 && abs(X + Y) % 2 == 1) {
		cout << -1 << endl;
		return 0;
	}
	X = X + Y;
	Y = X - Y - Y;
	p = { 0,0 };
	while (dist(p, { X,Y }) > K * 2) {
		bool fx, fy;
		if (p.x <= X) {
			fx = true;
			p.x = min(p.x + K, X);
		}
		else {
			fx = false;
			p.x = max(p.x - K, X);
		}
		if (p.y <= Y) {
			fy = true;
			p.y = min(p.y + K, Y);
		}
		else {
			fy = false;
			p.y = max(p.y - K, Y);
		}
		if (abs(p.x + p.y) % 2 == 1) {
			if (p.x == X) {
				if (fx) {
					--p.x;
				}
				else {
					++p.x;
				}
			}
			else if (p.y == Y) {
				if (fy) {
					--p.y;
				}
				else {
					++p.y;
				}
			}
		}
		v.push_back(p);
	}
	if (dist(p, { X,Y }) != K) {
		point q;
		if (p.x <= X) {
			if (p.y <= Y) {
				q = { p.x + K,Y - K };
			}
			else {
				q = { p.x + K,Y + K };
			}
		}
		else {
			if (p.y <= Y) {
				q = { p.x - K,Y - K };
			}
			else {
				q = { p.x - K,Y + K };
			}
		}
		if (abs(q.x + q.y) % 2 == 1) {
			if (p.x <= X) {
				if (p.y <= Y) {
					p = { p.x + K,p.y + K };
				}
				else {
					p = { p.x + K,p.y - K };
				}
			}
			else {
				if (p.y <= Y) {
					p = { p.x - K,p.y + K };
				}
				else {
					p = { p.x - K,p.y - K };
				}
			}
			v.push_back(p);
			if (p.x <= X) {
				if (p.y <= Y) {
					q = { p.x + K,Y - K };
				}
				else {
					q = { p.x + K,Y + K };
				}
			}
			else {
				if (p.y <= Y) {
					q = { p.x - K,Y - K };
				}
				else {
					q = { p.x - K,Y + K };
				}
			}
		}
		v.push_back(q);
	}
	v.push_back({ X,Y });
	cout << v.size() << endl;
	for (int i = 0; i < v.size(); ++i) {
		cout << (v[i].x + v[i].y) / 2 << sp << (v[i].x - v[i].y) / 2 << endl;
	}
}

Measured memory_bytes: 6124
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main()
{
	int n,k;ll s;
	ll ans=0;
	cin>>n>>k>>s;
	for(int i=0;i<k;i++)
		cout<<s<<" ";
	for(int i=k;i<n;i++)
	{
		if(s!=1e9)
			cout<<s+1<<" ";
		else
			cout<<s-1<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}




int main()
{


	long long int L, R;
	cin >> L >> R;

	long long int ans = 2018;
	long long int wk;
	for (int i = 0; i < 2019; i++) {
		for (int j = i+1; j < 2019; j++) {
			if (L + i > R)break;
			if (L + j > R)break;
			
			wk = ((L + i) * (L + j)) % 2019;

			if (wk < ans)ans = wk;
		}

		if (L + i > R)break;
	}

	cout << ans << endl;


	return 0;

}



Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main() {
    long[] ans = new long[31];
    ans[0] = 1;
    foreach(i; 1..31) {
        ans[i] += ans[i-1];
        if (i>1) ans[i] += ans[i-2];
        if (i>2) ans[i] += ans[i-3];
    }
    while(true) {
        int n = readln.chomp.to!int;
        if (n==0) break;
        writeln((ans[n]+3650-1)/3650);
    }
}

Measured memory_bytes: 2424
from  functools import reduce
from fractions import gcd
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=[i//2 for i in a]
#print(a)
lc=reduce(lambda x,y: (x*y)//gcd(x,y) , a)
#print(lc)
flag=True
for i in a:
  if (lc//i)%2==0:
    flag=False
    break
if flag==False:
  print(0)
else:
  x=m//lc
  print(x//2) if (x%2)==0 else print((x//2)+1)


Measured memory_bytes: 16292
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N; cin >> N;
  int summ = 0;
  int x = 0, maxn = INT_MIN;
  for(int i = 0; i < N; ++i){
    cin >> x;
    summ += x;
    maxn = max(maxn,x);
  }
  cout << (summ - maxn > maxn ? "Yes" : "No") << '\n';
  return 0; 
}

Measured memory_bytes: 3600
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
	    int A = scanner.nextInt();
	    int B = scanner.nextInt();
	    int T = scanner.nextInt();
	    
	    int time = A;
	    int count = 0;
	    while (time<T+0.5) {
	    	count += B;
	    	time+=A;
	    }
	    System.out.print(count);
	}
	    
}


Measured memory_bytes: 21716
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MAX_H 2200
#define MAX_W 2200

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W;
  cin >> H >> W;
  string S[MAX_H];
  vector<vector<int> > vert(MAX_H, vector<int>(MAX_W));
  vector<vector<int> > hori(MAX_H, vector<int>(MAX_W));

  REP(i, H) cin >> S[i];

  REP(i, H) {
    int cnt = 0, start = 0;
    REP(j, W) {
      if (S[i][j] == '.') cnt++;
      if (S[i][j] == '#') {
        REP2(k, start, j) hori[i][k] = cnt;
        cnt = 0;
        start = j;
      }
      if (j == W - 1) REP2(k, start, j + 1) hori[i][k] = cnt;
    }
  }

  REP(j, W) {
    int cnt = 0, start = 0;
    REP(i, H) {
      if (S[i][j] == '.') cnt++;
      if (S[i][j] == '#') {
        REP2(k, start, i) vert[k][j] = cnt;
        cnt = 0;
        start = i;
      }
      if (i == H - 1) REP2(k, start, i + 1) vert[k][j] = cnt;
    }
  }


  vector<vector<int> > ans(H, vector<int>(W));
  int answer = 0;
  REP(i, H) {
    REP(j, W) {
      if (S[i][j] != '#') {
        ans[i][j] = vert[i][j] + hori[i][j];
        answer = max(answer, ans[i][j]);
      }
    }
  }

  cout << answer - 1 << endl;
  return 0;
}


Measured memory_bytes: 58240
#include <stdio.h>

/*  選択ソート(0オリジン) */
int selectionSort(int A[], int N) {
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = selectionSort(A,N);

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

    return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
typedef  long long ll;
using namespace std;

int main(void) {
	string s, p, order;
	ll n, a, b, q;

	cin >> s >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> order;
		if (order == "print")
		{
			cin >> a >> b;
			cout << s.substr(a, b - a + 1) << endl;
		}
		else if (order == "replace")
		{
			cin >> a >> b >> p;
			s.replace(a, b - a + 1, p);
		}
		else if (order == "reverse")
		{
			cin >> a >> b;
			reverse(s.begin() + a, s.begin() + b + 1);
		}
	}
	return 0;
}


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

int main(){
    int N;
    cin >>N;
    vector<int>vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    double ans;
    for(int i=0;i<N-1;i++){
        if(i == 0){
            double d =vec[0]+vec[1];
          	ans =d/2;
        }
        else{
            ans = (ans+vec[i+1])/2;
        }
    }
    printf("%4.10f",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<ll> vec(N);

    int odd = 0;

    for(int i=0;i<N;i++){
        cin >> vec[i];
        if(vec[i]%2==1){
            odd++;
        }
    }
    if(odd%2 == 1){
        cout << "NO" << endl;
    }
    else if(odd%2 == 0){
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
S = input()
if S.count('1') == 0 or S.count('0') == 0:
    print(len(S))
    exit()

c = S[0]
len_s = len(S)
mx = len_s
for s in range(1,len_s):
    if c != S[s]:
        mx = min(mx, max(len_s -s, s))
    c = S[s]
print(mx)


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

class Program {

    static void Main() {
        string input = Console.ReadLine();

        int city_count  = int.Parse(input.Split(' ')[0]);
        int road_count  = int.Parse(input.Split(' ')[1]);
        List<int> citys = new List<int>();

        for(int i = 0; i < road_count; i++) {
            input = Console.ReadLine();
            citys.Add(int.Parse(input.Split(' ')[0]));
            citys.Add(int.Parse(input.Split(' ')[1]));
        }
        for(int i = 1; i <= city_count; i++) {
            Console.WriteLine(citys.Where(n => n == i).Count());
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 400;
int main()
{
  int h,w,n,i,j,k,res=0;
  int m[N_MAX][N_MAX],d[N_MAX][N_MAX];
  string s;
  cin >> h >> w;
  for(i=0;i<h;i++){
    cin >> s;
    for(j=0;j<w;j++)
      if(s[j]=='#'){
        m[i][j]=0;
      }else{
        m[i][j]=1;
      }
  }
  n=h*w;
  for(i=0;i<n;i++)
    fill(d[i],d[i]+n,N_MAX);
  for(i=0;i<n;i++)
    d[i][i]=0;
  for(i=0,k=0;i<h;i++)
    for(j=0;j<w;j++){
      if(m[i][j]==0){
        d[k][k]=N_MAX;
      }else{
        if(i<h-1&&m[i+1][j]==1){
          d[k][k+w]=1;
          d[k+w][k]=1;
        }
        if(j<w-1&&m[i][j+1]==1){
          d[k][k+1]=1;
          d[k+1][k]=1;
        }
      }
      k++;
    }
  for(k=0;k<n;k++)
    for(i=0;i<n;i++)
      for(j=0;j<n;j++)
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      if(d[i][j]<N_MAX)
        res=max(res,d[i][j]);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 896