akhauriyash/Code-Regression huggingface dataset:
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}

const int N=100100;
struct p
{
	int num,id;
} a[N];

bool cmp(p x,p y)
{
	return x.num<y.num;
}

int main()
{
	int n;
	read(n);
	for (int i=1;i<=n;i++) read(a[i].num),a[i].id=i;
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++) printf("%d ",a[i].id);
	return 0;
}









Measured memory_bytes: 2176
N,K=map(int, input().split())
p = list(map(int, input().split()))

#p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=(K+e)/2
for i in range(1,N-K):
  e=s[i+K]-s[i]
  e=(K+e)/2
  max_e = max(max_e, e)
    
print(max_e)

Measured memory_bytes: 25060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    string s; cin>>s;
    int cnt = 0;
    for(int i= 0;i<s.size();i++){
        if(s[i] == 'o') cnt++;
    }
    if((15-s.size())+cnt >= 8) OUT("YES");
    else OUT("NO");
}

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

int a[200010];
int q[200010];
int T[200010];
int f[200010];
int n;
int cnt;

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++) q[a[i]]=i;
	
	for (int i=n-1;i;i--)  
    {  
        if( !T[ i + 1 ] )  
        {  
            if( q[i] > q[i+1] ) T[i]=1, f[i]=i+1;  
            else T[i] = 0;  
        }  
        else  
        {  
            int cnt = 0;  
            cnt += q[f[i+1]] < q[i];  
            cnt += q[i] < q[i+1];  
            cnt += q[i+1] < q[f[i+1]];  
            if (cnt==2) T[i]=T[i+1],f[i]=f[i+1];  
            else T[i]=T[i+1]+1,f[i]=i+1;  
        }  
    }  
    cout<<T[1];
}

Measured memory_bytes: 3328
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input().split()
# inputb = input().split()

# inputa = [int(n) for n in inputa]
# inputa.sort()

inputa = list(inputa[0])

# a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

ans = 0
for i in range(len(inputa)):
    if inputa[i] == "+":
        ans += 1
    elif inputa[i] == "-":
        ans -= 1

print(ans)


Measured memory_bytes: 38256
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N; cin >> N;
  int ans = 0, previous = 0, current = 0;
  for (int i = 0; i < N; i++) {
    int j; cin >> j;
    if (j == 1) {
      if (previous == 0) {
        current = 1;
        previous = 1;
      } else {
        current++;
      }
    } else {
      ans = max(ans, current);
      previous = 0;
    }
  }
  ans = max(ans, current);
  cout << ans+1 << endl;
}




Measured memory_bytes: 3108
// https://atcoder.jp/contests/abc162/tasks/abc162_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll K;
  cin >> K;

  ll res = 0;

  rep1(a, K) rep1(b, K) rep1(c, K) res += gcd(a, gcd(b, c));
  cout << res << "\n";
}


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

template<typename ... Ts> void read(Ts& ...vs){(std::cin >> ... >> vs);}

int main()
{
    std::size_t N;
    read(N);

    switch(N % 10)
    {
        case 3: {std::cout << "bon" << std::endl; break;}

        case 0: {std::cout << "pon" << std::endl; break;}
        case 1: {std::cout << "pon" << std::endl; break;}
        case 6: {std::cout << "pon" << std::endl; break;}
        case 8: {std::cout << "pon" << std::endl; break;}

        default: {std::cout << "hon" << std::endl; break;}
    }

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
         
    int km[10],v1,v2; char a;
    double leng;
    while(1){
       for(int i = 0; i < 10; i++)
                cin >> km[i] >> a;
         
        if(!cin)    break;
        cin >> v1 >> a >> v2;
  
    leng = 0.0;
    for(int k =0;k<10;k++)
    leng += km[k];
    double length = leng * v1 / (v1 +v2);
    leng = 0.0; 
    for(int k=0;k<10;k++){
    leng +=  km[k];
    if(leng >= length ){
     
    cout << k+1 <<endl; break;
    }
    }  
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define LEN 100005

using namespace std;
struct pp {
  char name[100];
  int t;
};

pp QUE[LEN];
int head, tail, n;

void enqueue(pp x) {
  QUE[tail] = x;
  tail = (tail + 1) % LEN;
};

pp dequeue() {
  pp x = QUE[head];
  head = (head + 1) % LEN;
  return x;
};

int main() {
  int elaps = 0, c;
  int i, q;
  pp u;
  scanf("%d %d", &n, &q);

  for (int i = 1; i <= n; i++) {
    scanf("%s", QUE[i].name);
    scanf("%d", &QUE[i].t);
  }

  head = 1;
  tail = n + 1;
  while (head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0)
      enqueue(u);
    else {
      printf("%s %d\n", u.name, elaps);
    }
  }

  return 0;
}


Measured memory_bytes: 13300
#pragma GCC optimize("Ofast")
	//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
	#include <bits/stdc++.h>
	using namespace std;
	//#include <ext/pb_ds/assoc_container.hpp>
	//#include <ext/pb_ds/tree_policy.hpp>
	//using namespace __gnu_pbds;
	//#ifndef rd
	#define endl '\n'
	//#endif
	#ifdef rd
	#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
	template<typename Arg1>
	void __f(const char* name, Arg1&& arg1) {
		cout<<name<<" : "<<arg1<<endl;
	}
	template<typename Arg1, typename ... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* comma=strchr(names+1,',');
		cout.write(names,comma-names)<<" : "<<arg1<<" | ";
		__f(comma+1,args...);
	}
	#else
	#define trace(...)
	#endif
	#define pb push_back
	#define fi first
	#define se second
	#define mkp make_pair
	//#define int long long
	typedef long long ll;
	typedef long double f80;
	//#define double long double
	#define pii pair<int,int>
	#define pll pair<ll,ll>
	#define sz(x) ((long long)x.size())
	#define fr(a,b,c) for(int a=b; a<=c; a++)
	#define frdec(a,b,c) for(int a=b; a>=c; a--)
	#define rep(a,b,c) for(int a=b; a<c; a++)
	#define trav(a,x) for(auto &a:x)
	#define all(con) con.begin(),con.end()
	const ll infl=2e18;
	const int infi=2e9;
	const int mod=1e9+7;
	typedef vector<int> vi;
	//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
	mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
	auto clk=clock();
	int rng(int lim) {
		uniform_int_distribution<int> uid(0,lim-1);
		return uid(rang);
	}
	template<class t1, class t2, class t3>
	t1 fast_expo(t2 x, t3 p) {
		if(p == 0) return 1;
		t1 r = fast_expo(x,p/2);
		if(p%2 != 0) return r * r * x;
		return r * r;
	}
	// Code from here...

	void solve() {
		int a, b, c, x, y;
        cin >> a >> b >> c >> x >> y;
        
        int ans = 0;
        if(x > y) 
        	ans = min(2*c*y + min(a, 2*c)*(x-y), a*x + b*y);
        else
        	ans = min(2*c*x + min(b, 2*c)*(y-x), a*x + b*y);
        
        cout << ans;
	}

	signed main() {
		ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
		srand(chrono::high_resolution_clock::now().time_since_epoch().count());
		cout<<fixed<<setprecision(10);
		int t=1;
		// cin>>t;
		while(t--)
			solve();
	#ifdef rd
		cout<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
		return 0;
	}

Measured memory_bytes: 256
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
n = int(input())
#a, b = map(float, sys.stdin.readline().split())
#n = input()
#a = list(map(int, sys.stdin.readline().split()))

if n == 1:
    print(0)
    sys.exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

l = factorization(n)


x = [1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,9]

ans = 0
for i in range(len(l)):
    ans += x[l[i][1]-1]

print(ans)
    


Measured memory_bytes: 9840
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
priority_queue<LL>que;
LL a[100005];
int cnt = 0;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    for(int i = 1; i <= 9;++i){
        a[cnt++]=i;
        que.push(-i);
    }
    while(que.size() && cnt < 100000 ){
        int v = -que.top();
        que.pop();
        int num = v % 10;
        for(int j = num - 1; j <= num + 1; ++j){
            if(j < 0 || j > 9) continue;
            a[cnt++] = 1ll* v * 10 + j;
            que.push(-(1ll*v*10+j));
        }
    }
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
    return 0;
}



Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include "math.h"
using namespace std;
int main() {
	int W, H, N;
	int m = 0;
	cin >> W >> H >> N;
	vector<int>x(N);
	vector<int>y(N);
	vector<int>a(N);
	int ld[2] = { 0,0 };
	int rd[2] = { W,0 };
	int lu[2] = { 0,H };
	int ru[2] = { W,H };
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> a[i];
	}
	for (int i = 0; i < N; i++) {
		if (a[i] == 1) {
			if (ld[0] < x[i]) {
				ld[0] = x[i];
				lu[0] = x[i];
			}
		}
		else if (a[i] == 2) {
			if (rd[0] > x[i]) {
				rd[0] = x[i];
				ru[0] = x[i];
			}
		}
		else if (a[i] == 3) {
			if (ld[1] < y[i]) {
				ld[1] = y[i];
				rd[1] = y[i];
			}
		}
		else {
			if (lu[1] > y[i]) {
				lu[1] = y[i];
				ru[1] = y[i];
			}
		}
	}
	if (lu[1] - ld[1] > 0 && ru[0] - lu[0] > 0) {
		m = (lu[1] - ld[1]) * (ru[0] - lu[0]);
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;
    vector<int> data(N);
    for(int i = 0; i < N; i++){
        int tmp; cin >> tmp;
        data[i] = tmp;
    }

    long ans = 0;
    for(int i = 0; i < N-2; i++){
        for(int j = i+1; j < N-1; j++){
            for(int k = j+1; k < N; k++){
                int flag = 1;
                int a = data[i];
                int b = data[j];
                int c = data[k];
                if(a+b <= c) flag = 0;
                if(b+c <= a) flag = 0;
                if(a+c <= b) flag = 0;
                if(a == b) flag = 0;
                if(b == c) flag = 0;
                if(c == a) flag = 0;
                if(flag == 1) ans ++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

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

  int ans = 0;
  for(int i = 1; i <= n; i += 2) {
    int cnt = 0;
    for(int j = 1; j <= n; j++) {
      if(i%j == 0) cnt++;
    }
    if(cnt == 8) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,minimum=1000000000;
  cin>>N;
  vector<ll> A(N);
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
    minimum=min(minimum,A.at(i));
  }
  while(true){
    ll x=minimum;
    ll check=0;
    ll count=0;
    for(ll i=0;i<N;i++){
      if(A.at(i)!=x || check>0){A.at(i)=A.at(i)%x;}
      if(A.at(i)==x){check++;}
      if(A.at(i)==0){count++;}
      if(A.at(i)>0){minimum=min(minimum,A.at(i));}
    }
    if(count==N-1){break;}
  }
  cout<<minimum<<endl;
}

Measured memory_bytes: 1024
#include <iostream>

int main(void){
    
    int inputIntA = 0;
    int inputIntB = 0;
    int inputIntC = 0;
    
    std::cin >> inputIntA >> inputIntB >> inputIntC;
    
    if( (inputIntA < inputIntB)
     && (inputIntB < inputIntC) )
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	if (A > B && (A - B) % 2 == 0) {
		cout << B + (A - B) / 2 << endl;
		return 0;
	}
	else if (B > A && (B - A) % 2 == 0) {
		cout << A + (B - A) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define r_rep(i, n) for(int i = n; i >= 0; i--)
#define ll long long int
#define pb push_back

const long long INF = 1LL << 60;

int main() {
  ll N, ans;
  cin >> N;

  vector<ll> a(N);
  vector<ll> b(N);
  
  rep(i, N){
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  if(N%2==0){ // 偶数
    ans = b[N/2]+b[(N/2)-1] - (a[N/2] + a[(N/2)-1]) + 1;
  } else { // 奇数
    ans = b[N/2] - a[N/2] + 1;
  }
  print(ans);
}


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

int main(){
    int n, a[100], v, j;
    cin >> n;
    for(int i = 0 ; i < n ; i++) cin >> a[i];
    for(int i = 0 ; i < n; i++){
        v = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > v){
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        for(int k = 0 ; k < n - 1 ; k++) cout << a[k] << " ";
        cout << a[n - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3036
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

ll f(ll a, ll b){
    ll la=0, lb=0;
    while(a>0){ la++; a/=10; }
    while(b>0){ lb++; b/=10; }
    return max(la,lb);
}

signed main() {
    ll N,ans=1e10;
    cin>>N;
    for (ll a = 1; a<=sqrt(N); a++){
        if (N%a!=0)
            continue;
        ll b = N/a;
        ans = min(ans, f(a,b));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
#define SIZE(v) int(v.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	ll X;
	cin >> X;
	ll res = 0;
	if (X >= 500) {
		res += X / 500 * 1000;
		X %= 500;
	}
	res += X / 5 * 5;
	cout << res << endl;

	return 0;
}

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

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

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


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int q, ch=0; string s;
	cin >>s >>q;
	string bf, af;
	rep(g, q){
		int sl; cin >>sl;
		if(sl==1) ch++;
		else{
			int f; string c;
			cin >>f >>c;
			if(f==1 && ch%2==1 || f==2 && ch%2==0) af +=c;
			else bf +=c;
		}
	}
	reverse(all(bf));
	string ans = bf + s + af;
	if(ch%2) reverse(all(ans));
	cout << ans <<"\n";
	
	return 0;
}


Measured memory_bytes: 1300
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

void solve() {
    int n, k;
    std::cin >> n >> k;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;
    std::sort(xs.begin(), xs.end());

    std::cout << std::accumulate(xs.begin(), xs.begin() + k, 0) << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
typedef complex<long double> com;
 
const ll mod = 998244353;

bool check(string s){
	for (int z=0;z<s.size();z++){
		if (s[z] != s[s.size()-1-z]) return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	string t = "";
	string t1 = "";
	for (int z=0;z<(s.size()-1)/2;z++){
		t += s[z];
	}
	for (int z=(s.size()+3)/2-1;z<s.size();z++){
		t1 += s[z];
	}
	if (check(t) && check(t1) && check(s)){
		cout << "Yes" << endl;
	} else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n = I()
a = [LI() for _ in range(n)]
a.sort(key = lambda x: x[1])
t = 0
for i in range(n):
    t += a[i][0]
    if t > a[i][1]:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 53716
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

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

int main() {
    ll N;
    cin >> N;
    rep(x,0,N+1) {
        if ((ll)((double)x * 1.08) == N) {
            cout << x << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}



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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 2e5+5;
int n,m;
vector<int> adj[N];
bool vis[N];
int maxx = 0;
void dfs(int child)
{
	vis[child] = true;
	++maxx;
	for(auto it:adj[child])
	{
		if(!vis[it])
		{
			dfs(it);
		}
	}
}		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		cin>>n>>m;
		for(int i=0,u,v;i<m;++i)
		{
			cin>>u>>v;
			adj[u].pb(v);
			adj[v].pb(u);
		}
		int ans = 0;
		for(int i=1;i<=n;++i)
		{
			if(!vis[i])
			{
				dfs(i);
				ans = max(maxx,ans);
				maxx = 0;
			}
		}
		cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 20960
#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n,m,x;cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    constexpr long long LLINF = 1e18 + 1;
    ll ans = LLINF;
    for (int i = 0; i < (1<<n); i++) {
        ll sum_c = 0;
        vector<ll> sum_a(m);
        for (int j = 0; j < n; j++) {
            if (i & (1<<j)) {
                sum_c += c[j];
                for (int d = 0; d < m; d++) {
                    sum_a[d] += a[j][d];
                }
            }
        }
        bool ok = true;
        for (int j = 0; j < m; j++) {
            if (sum_a[j] < x) ok = false;
        }
        if (ok) ans = min(ans,sum_c);
    }
    if (ans == LLINF) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3588
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];;

    vector<ll> rb = b;

    reverse(all(rb));

    vector<ll> same;

    rep(i, n){
        if(a[i] == rb[i]){
            same.push_back(i);
        }
    }

    set<ll> st;
    rep(i, same.size()){
        st.insert(a[same[i]]);
    }

    if(st.size() > 1){
        assert(false);
    }

    vector<ll> ans = rb;
    ll bidx = n - 1;
    rep(i, same.size() / 2){
        swap(ans[same[i]], ans[bidx]);
        bidx--;
    }
    ll fidx = 0;
    for(ll i = (ll)same.size() - 1; i >= (ll)same.size() / 2; i--){
        swap(ans[same[i]], ans[fidx]);
        fidx++;
    }
    bool ok = true;
    rep(i, n){
        if(ans[i] == a[i]) ok = false;
    }

    if(ok){
        cout << "Yes" << endl;
        rep(i, n) cout << ans[i] << " ";
        cout << endl;
    } else {
        cout << "No" << endl;
    }

}



Measured memory_bytes: 11072
n = int(raw_input())

for i in range(n):
    Y, M, D = map(int, raw_input().split())
    days = 0
    for i in range(1, Y):
        if i % 3 == 0:
            days += 200
        else:
            days += 39*5
    
    for i in range(1, M):
        if Y % 3 != 0 and i % 2 == 0:
            days += 19
        else:
            days += 20

    days += D

    print 196471 - days



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

using namespace std;

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

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

unordered_map<int, int> p_div;
int f[100100];

int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 2; m > 1; i++) {
        if(m % i == 0) {
            int tmp = 0;
            while(m % i == 0) {
                m /= i;
                tmp++;
            }
            p_div[i] = tmp;
        }
    }

    f[0] = 1;
    rep(i, 100099) {
        f[i + 1] = (int)((ll)f[i] * (i + 1) % MOD);
    }
    int ans = 1;
    for(P p : p_div) {
        int tmp = f[n + p.second - 1];
        tmp = (int)((ll)tmp * inv(f[p.second]) % MOD);
        tmp = (int)((ll)tmp * inv(f[n - 1]) % MOD);
        ans = (int)((ll)tmp * ans % MOD);
    }

    cout << ans << endl;
}


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

int main()
{
int n;
cin>>n;
for(int i=1;i<=9;i++){
	for(int j=1;j<=9;j++){
		if(i*j==n){
		cout<<"Yes"<<endl;

		return 0;}
	}
}
cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    string s, t;
    cin >> s >> t;
    int ss = s.size();
    int ts = t.size();
    int ans = 10000;
    for (int i = 0; i < ss - ts + 1; i++) {
        int m = 0;
        for (int j = 0; j < ts; j++) {
            if (s[i + j] != t[j]) m += 1;
        }
        ans = min(m, ans);
    }
    cout << ans << endl;
}


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

int main(){
  
  int A,B; cin >> A >> B;
  
  if(A > B){
    if(A-1 >= B){
      cout << A + (A-1) << endl;
    }
  }
  else if(A < B){
    if(B-1 >= A){
      cout << B + (B-1) << endl;
    }
  }
  
  else{
    cout << A + B << endl;
  }
    
  
  return 0;
}

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

int main(){
	string s,t;
	cin >> s >> t;
	ll dp[s.length()+1][t.length()+1];
	memset(dp,0,sizeof(dp));
	for (int i = 1; i <= s.length(); ++i){
		for (int j = 1; j <= t.length(); ++j){
			if (s[i-1] == t[j-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
			else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	int x = s.length(), y = t.length(), ct = dp[x][y];
	stack<char> ans;
	while (ct){
		if (s[x-1] == t[y-1]){
			ans.push((char)s[x-1]);
			x--;
			y--;
			ct--;
		}
		else{
			if (dp[x-1][y] > dp[x][y-1]) x--; else y--;
		}
	}
	while (!ans.empty()){
		cout << ans.top();
		ans.pop();
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 70656
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 998244353;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b) {
	if (a < b)
		return a;


	return b;
}

ll max(ll a, ll b) {
	if (a < b)
		return b;

	return a;
}

ll N, x;
vector<ll> a;
int main() {
	cin >> N >> x;
	a.resize(N);

	rep(i, N)
		cin >> a[i];
	sort(a.begin(), a.end());

	ll sum = 0, ans = 0;
	rep(i, N) {
		sum += a[i];

		if (sum < x && i != N -1 ) {
			ans += 1;
		}
		else if (sum == x) {
			ans += 1;
			break;
		}
		else {
			break;
		}

	}



	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 256
n = int(input())

totalDay = 0
cost = 0
ans = "Yes"

#{締め切り,必要な日数}
jobs = [ [0]*2 for _ in range(n)]
for i in range(n):
    s, t = map(int, input().split())
    jobs[i] = [t, s]
jobs.sort()
for i in range(n):
    totalDay += jobs[i][1]
    if totalDay <= jobs[i][0]:
        continue
    else:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 81260
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

int dp[410][410];
int sum[410];

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

  int N, a[410]; cin >> N;
  REP(i, N) cin >> a[i+1];

  for(int i = 1; i <= N; i++) sum[i] = sum[i-1] + a[i];

  for(int size = 1; size <= N; size++){
    int left = 1, right = size;
    while(right <= N){
      // if(size == 1) dp[left][right] = a[left];
      if(size != 1) {
        int mn = 1145141919810931931LL;
        for(int i = left; i <= right-1; i++){
          mn = min(mn, dp[left][i]+dp[i+1][right]);
        }
        dp[left][right] = mn + sum[right]-sum[left-1];
      }
      left++; right++;
    }
  }

  cout << dp[1][N] << endl;
  
  return 0;
}

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

using namespace std;

int extgcd(int a, int b, int& x, int& y) {
  int res = a;
  if (b) {
    res = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1; y = 0;
  }
  return res;
}

int main(void) {
  int a, b;
  cin >> a >> b;

  int x, y;
  extgcd(a, b, x, y);
  cout << x << " " << y << endl;

  return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>

int main(void){  

 int a,b,c;

 int count=0;

 int i; 

 scanf("%d %d %d",&a,&b,&c);

 for(i=a;i<=b;i++) 

 { 

  if(c%i==0) count++;

 }  

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

return 0;

}

Measured memory_bytes: 596
#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int N,M;
struct state{
	int now,L;
	bool operator<(const state&a)const{
		return L*15+now<a.L*15+a.now;
	}
};
main()
{
	while(cin>>N>>M,N)
	{
		map<state,int>A;
		vector<int>G[15];
		vector<int>L[15];
		for(int i=0;i<M;i++)
		{
			int u,v;cin>>u>>v;
			u--,v--;
			G[u].push_back(v);
			G[v].push_back(u);
		}
		queue<state>P;
		state start;
		start.now=start.L=0;
		for(int i=0;i<N;i++)
		{
			int l;cin>>l;
			start.L|=l<<i;
		}
		for(int i=0;i<N;i++)
		{
			int k;cin>>k;
			for(;k--;)
			{
				int id;cin>>id;id--;
				L[i].push_back(id);
			}
			sort(L[i].rbegin(),L[i].rend());
		}
		P.push(start);
		A[start]=0;
		while(!P.empty())
		{
			state now=P.front();P.pop();
			int turn=A[now];
			for(int id:L[now.now])
			{
			    if(id==now.now)continue;
				now.L^=1<<id;
				if(A.find(now)==A.end())
				{
					P.push(now);
					A[now]=turn+1;
				}
				now.L^=1<<id;
			}
			for(int v:G[now.now])
			{
				if(now.L>>v&1)
				{
					int tmp=now.now;
					now.now=v;
					if(A.find(now)==A.end())
					{
						P.push(now);
						A[now]=turn+1;
					}
					now.now=tmp;
				}
			}
		}
		state goal;
		goal.now=N-1;
		goal.L=1<<N-1;
		if(A.find(goal)!=A.end())
		{
			int X=A[goal];
			cout<<"You can go home in "<<X<<" steps."<<endl;
			vector<string>ans(X);
			for(;X--;)
			{
				for(int id:L[goal.now])
				{
					goal.L^=1<<id;
					if(A.find(goal)!=A.end()&&A[goal]==X)
					{
						if(goal.L>>id&1)ans[X]="Switch off room "+to_string(id+1)+".";
						else ans[X]="Switch on room "+to_string(id+1)+".";
						break;
					}
					goal.L^=1<<id;
				}
				if(ans[X]=="")
				{
					for(int v:G[goal.now])
					{
						int tmp=goal.now;
						goal.now=v;
						if(A.find(goal)!=A.end()&&A[goal]==X)
						{
							ans[X]="Move to room "+to_string(tmp+1)+".";
							break;
						}
						goal.now=tmp;
					}
				}
			}
			for(const string&s:ans)cout<<s<<endl;
		}
		else
		{
			bool flag=false;
			for(map<state,int>::iterator it=A.begin();it!=A.end();it++)
			{
				flag|=it->first.now==N-1;
				if(flag)break;
			}
			cout<<(flag?"You can not switch off all lights.":"Help me!")<<endl;
		}
	}
}


Measured memory_bytes: 5908
#include <iostream>
using namespace std;
int ans;
double a[110], sum, n, sa;
int main(void){
    // Your code here!
    sa = 1000000;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    sum /= n;
    for (int i = 0; i < n; i++){
        double ta = sum - a[i];
        if (ta < 0) ta *= -1;
        if (ta < sa){
            sa = ta;
            ans = i;
        }
    }
    cout << ans << endl;
}


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

int main(void) {
	int a, b;
	cin >> a >> b;
	if (a + b <= 23) {
		cout << a + b << endl;
	}
	else {
		cout << (a+b)% 24 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;
LL ans;
int main(){
	int n,i,u,v;
	scanf("%d",&n);
	for(i=1;i<=n;i++)ans+=(LL)i*(n-i+1);
	for(i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		if(u>v)swap(u,v);
		ans-=(LL)u*(n-v+1);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

ll H[314], dp[314][314], mx=1e18;

int main() {
	int N, K;
	cin >> N >> K;
	H[0]=H[N+1]=0;
	for(int i=1; i<=N; ++i) cin >> H[i];
	dp[0][0]=0;
	for(int i=1; i<=K; ++i) dp[0][i]=mx;
	for(int i=1; i<=N+1; ++i){
		for(int j=0; j<=K; ++j){
			dp[i][j]=min(mx, dp[i-1][j]+max(0LL, H[i]-H[i-1]));
			for(int k=1; i-1-k>=0 && j-k>=0; ++k){
				dp[i][j]=min(dp[i][j], dp[i-1-k][j-k]+max(0LL, H[i]-H[i-1-k]));
			}
		}
	}
	ll ans=mx;
	for(int i=0; i<=K; ++i) ans=min(mx, dp[N+1][i]);
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  ll X, Y;
  cin >> X >> Y;
  if (abs(X - Y) <= 1) {
    cout << "Brown" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 200005
using namespace std;

int n, m, i, j, a[N], b[N];
int main()
{
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%d", &a[i]);
	}
	cin >> m;
	for (i = 0; i < m; i++) {
		scanf ("%d", &b[i]);
	}
	sort(a, a + n);
	sort(b, b + m);
	i = j = 0;
	while (i < n && j < m) {
		if (a[i] == b[j]) {
			i++;
			j++;
		} else if (a[i] < b[j]) {
			i++;
		} else {
			cout << "NO";
			return 0;
		}
	}
	if (j == m) cout << "YES";
	else cout << "NO";
    return 0;
}

Measured memory_bytes: 1792
//回答みてやり直し
#include <bits/stdc++.h>
using namespace std;

const int limit = 55;
int N, M;
int a[limit], b[limit];
int graph[limit][limit];
int visited[limit];

void dfs(int num) {
    visited[num] = 1;
    for (int i = 0; i < N; i++) if (!visited[i] && graph[num][i]) dfs(i);
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        scanf("%d%d", &a[i], &b[i]);
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = 1;
    }
    int ans = 0;
    for (int i = 0; i < M; i++) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = 0;
        for (int j = 0; j < N; j++) visited[j] = 0;
        dfs(0);
        bool bridge = 0;
        for (int j = 0; j < N; j++) if(!visited[j]) bridge = true;
        if (bridge) ans++;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = 1;
    }
    cout << ans << endl;
}

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

int main(){
  ll n,m,L=1;
  cin>>n>>m;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]/=2;
    L=lcm(L,a[i]);
  }
  for(int i=0;i<n;i++) if(L/a[i]%2==0){cout<<0<<endl;return 0;}
  cout<<m/(2*L)+(m%(2*L)>=L ? 1 : 0)<<endl;
}


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

const int mo=1e9+7;

int n,m,K,Ans,dp[2010][2010],cc[2010][2010];

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i,j;
	scanf("%d%d%d",&n,&m,&K);
	n--; K--;
	dp[n][m]=1;
	for (i=n;i>=0;i--)
	for (j=m;j>=0;j--)
	{
		if (j) (cc[i][j]+=cc[i+1][j-1])%=mo;
		(dp[i][j]+=cc[i][j])%=mo;
		if (dp[i][j])
		{
			if (!i&&j!=m&&j%K==0)
				(Ans+=dp[i][j])%=mo;
			int L=max(0,K-i)-1,R=min(K,j);
			if (L<R)
			{
				(cc[i-K+R][j-R]+=dp[i][j])%=mo;
				if (i-K+L>=0) (cc[i-K+L][j-L]+=mo-dp[i][j])%=mo;
			}
		}
	}
	printf("%d\n",Ans);
}


Measured memory_bytes: 31744
n = int(input())

f = []

for i in range(n):
    f.append(list(map(int,input().split())))
c = []
for i in range(n):
    c.append(list(map(int,input().split())))
res = -10**19
for i in range(1,1024):
    s = format(i,'#012b')[2:]
    money = 0
    for k in range(n):
        acc = 0
        for j in range(10):
            acc += f[k][j] and int(s[j])
        #print(acc,end="")
        money += c[k][acc]
    #print(money)
    res = max(res,money)
print(res)


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

int main() {
	int L;
	cin >> L;
	int N = 0, s = 0;
	queue<pair<pair<int, int>, int> > q;
	for (int i = 20;i >= 0;-- i) {
		if ((L & 1 << i) > 0) { // そのbitが立っている
			N = max(N, i + 1);
			if (i + 1 != N) q.push(make_pair(make_pair(i + 1, N), s));
			s += 1 << i;
		}
	}
	for (int i = 1;i < N;++ i) {
		q.push(make_pair(make_pair(i, i + 1), 0));
		q.push(make_pair(make_pair(i, i + 1), 1 << (i - 1)));
	}
	
	cout << N << " " << q.size() << endl;
	while (!q.empty()) {
		cout << q.front().first.first << " " << q.front().first.second << " " << q.front().second << endl;
		q.pop();
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

頂点数が20しかないのに1000000=10^6≒2^20=1048576をカバーすることを考えてみよう
これ、辺の長さが1,2,4,…なのでは
例えば1-2-3-4に対し
1 2 0
1 2 1
2 3 0
2 3 2
3 4 0
3 4 4
これで0から7まで網羅できる
つまり、2倍は簡単にできる
同様に3倍などもできる
つまり、まずLを素因数分解して、各桁の和が60以下なら簡単に構築できる
そうでない場合、例えばL=23を考えてみよう
これは以下のような方法が考えられる
1 2 0
1 2 1
2 3 0
2 3 2
3 4 0
3 4 4
4 5 0
4 5 8
3 5 16
2 5 20
1 5 22
このようにやると、任意の値が簡単に作れることが分かった
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  ll N,x,a[100];
  cin>>N>>x;
  for (int i(0);i<N;i++) cin>>a[i];
  sort(a,a+N);
  int cnt(0);
  for (int i(0);i<N;i++){
    cnt++;
    x -= a[i]; 
    if (x < 0){
      cout << cnt - 1 << endl;
      return 0;
    }
  }
  if (x == 0) cout << cnt << endl;
  else cout << cnt - 1 << endl;
  return 0;
}


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

ans = [-1,-1,-1]
for i in range(N+1):
  for j in range(N-i+1):
    k = N-i-j
    if Y == 10000*i+5000*j+1000*k:
      ans = [i,j,k]
      break
    else:
        continue
    break


print(*ans)

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    char c;
    cin >> c;
    if(isupper(c)) cout <<"A";
    else cout <<"a";
    return 0;
} 

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Point start = new Point(0, 0);
        Point end = new Point(100, 0);
        System.out.println(start);
        kochCurve(n, start, end);
        System.out.println(end);
    }

    private static void kochCurve(int n, Point p1, Point p2) {
        if (n == 0) {
            return;
        }

        Point s;
        Point t;
        Point u;

        s = new Point(2 * p1.x / 3d + p2.x / 3d,
                2 * p1.y / 3d + p2.y / 3d);
        t = new Point(2 * p2.x / 3d + p1.x / 3d,
                2 * p2.y / 3d + p1.y / 3d);
        u = new Point((p2.x + p1.x) / 2d - Math.sqrt(3d) / 6d * (p2.y - p1.y),
                (p2.y + p1.y) / 2d + Math.sqrt(3d) / 6d * (p2.x - p1.x));

        kochCurve(n-1, p1, s);
        System.out.println(s);
        kochCurve(n-1, s, u);
        System.out.println(u);
        kochCurve(n-1, u, t);
        System.out.println(t);
        kochCurve(n-1, t, p2);
    }

    private static class Point {
        double x;
        double y;

        Point(double x, double y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return String.format("%.8f %.8f", x, y);
        }
    }
}



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

    using namespace std;

    const int N = 10010;

    int n;
    int ans[N];

    int main()
    {
        cin >> n;
        int ceil = sqrt(n);
        for(int x = 1; x <= ceil; x++)
            for(int y = 1; y <= ceil; y++)
                for(int z = 1; z <= ceil; z++)
                {
                    int tmp = x * x + y * y + z * z + x * y + x * z + y * z;
                    if(tmp < N)
                        ans[tmp]++;
                }
            
        for(int i = 1; i <= n; i++)
            cout << ans[i] << endl;

        return 0;
    }

Measured memory_bytes: 3648