akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    int res = 0;
    for (int l = 0; l < n + 1; l++)
    {
        string head = s.substr(0, l);
        string tail = s.substr(l, n - l);
        int cnt = 0;
        for (char c = 'a'; c < 'z' + 1; c++)
        {
            if (head.find(c) < head.length() && tail.find(c) < tail.length())
            {
                cnt++;
            }
        }
        res = max(res, cnt);
    }
    cout << res << endl;
}

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

int main(){
    string s; cin >> s;
    ll sum = 0;
    int n  = s.size();
    for(int temp = 0; temp < (1<<n-1); temp++){
        //cout << bitset<4>(temp) << endl;
        ll t = s[0] - '0';
        for(int i = 0; i < n-1; i++){
            if(temp & (1 << i)){
                sum += t;
                t = s[i+1] - '0';
            }
            else{
                t *= 10;
                t += s[i+1] - '0';
            }
        }
        sum += t;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int n, k, sum, MAX;
int a[100];
int main()
{
	MAX = -1;
	sum = 0;
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	for(int i = n; i >= n - k + 1; i--) sum += a[i];
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
//単一始点最短経路
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

void dijkstra(){
    int minv;
    int d[MAX],color[MAX];

    for(int i=0; i<n; i++){
        d[i]=INFTY;
        color[i]=WHITE;
    }

    d[0]=0;
    color[0]=GRAY;
    while(1){
        minv=INFTY;
        int u=-1;
        for(int i=0; i<n; i++){
            if(minv>d[i] && color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1){ break; }
        color[u]=BLACK;
        for(int v=0; v<n; v++){
            if(color[v]!=BLACK &&  M[u][v]!=INFTY){
                if(d[v]>d[u]+M[u][v]){
                    d[v]=d[u]+M[u][v];
                    color[v]=GRAY;
                }
            }
        }
    }
    for(int i=0; i<n; i++){
        cout<<i<<" "<<((d[i]==INFTY) ? (-1) : d[i])<<endl;
    }
}

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

    int k,c,u,v;
    for(int i=0; i<n; i++){
        cin>>u>>k;
        for(int j=0; j<k; j++){
            cin>>v>>c;
            M[u][v]=c;
        }
    }

    dijkstra();
    return 0;
}


Measured memory_bytes: 3116
N = int(input())
A = list(map(int, input().split()))

sgn = 0
answer = 1
for i in range(N-1):
    cur = A[i+1] - A[i]
    if cur * sgn < 0:
        answer += 1
        sgn = 0
        continue
    if cur != 0:
        sgn = cur
print(answer)

Measured memory_bytes: 14228
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_7_D: Reconstruction of a Tree

#include <cstdio>

using uint = unsigned int;
using uintp = uint*;

static void solve(const uintp i_begin, const uintp i_end,
                  uintp p_begin, const uintp indices[],
                  const char* sep = "\n")
{
  if (i_begin >= i_end) {
    return;
  }
  const auto i_index = indices[*p_begin++];
  const auto len = i_index-i_begin;
  solve(i_begin, i_index, p_begin, indices, " ");
  solve(i_index+1, i_end, p_begin+len, indices, " ");
  std::printf("%u%s", *i_index, sep);
}

int main()
{
  uint n;
  std::scanf("%u", &n);
  uint preorders[n];
  uint inorders[n];
  uintp indices[n+1]; // 0 not used.
  uint k;
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u", &k);
    preorders[i] = k;
  }
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u", &k);
    inorders[i] = k;
    indices[k] = &(inorders[i]);
  }

  solve(inorders, inorders+n, preorders, indices);
}

// eof

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


using ll = long long;


int main(){
    int n;
    std::cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0){
            sum += i;
        }
    }
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;

int main(){
    string s;
    cin>>s;
    if(s=="RRR"){
        cout<<3<<endl;
    }
    else if(s=="RRS"||s=="SRR"){
        cout<<2<<endl;
    }
    else if(s=="SSS"){
        cout<<0<<endl;
    }
    else{
        cout<<1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
 
map<long long, long long> prime_map;

long long  cal_gcd(long long A,long long B){
  if(B==0){return A;}
  return cal_gcd(B,A%B);
}
 
void prime_factor(int64_t bak){
	for(int64_t i = 2; i*i <= bak; ++i){
		while(bak % i == 0){
			++prime_map[i];
			bak /= i;
		}
	}
	if(bak > 1){
		++prime_map[bak];
	}
}

void prime_list(int64_t n){
	for(int64_t i=2;i*i<=n;++i){
		while(n%i==0){
			++prime_map[i];
			n=n/i;
		}
	}
	if(n!=1){
		++prime_map[n];
	}
}

 
int main(){
	long long  A, B;
	cin >> A >> B;
	long long gcd = cal_gcd(A, B);
	prime_factor(gcd);
	//prime_list(gcd);
 
	cout << prime_map.size() + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define p_b push_back
#define all(c)              c.begin(), c.end()
using namespace std;
typedef long long ll; //printf("%lld ", ll); to out put long
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;
const double eps = 1e-6;
const int MAXN = 1e7 + 5;
const ll MOD = 1e9 + 7;
bool ODD(ll O) {return (O % 2 != 0);}
ll gcd(ll a, ll b) {return __gcd(a , b);}
ll lcm(ll a, ll b) {return a * b / gcd(a , b);}
int dx[] = {1, 0, -1 ,0 , -1 , 0};
int dy[] = {0, 1, 0, -1 , -1 , 0};
ll power (ll x, ll y) {
    if(y == 0) return 1;
    if(ODD(y)) return x * power(x , y / 2) * power(x , y / 2);
    return power(x , y / 2) * power(x , y / 2);
}
/*------ never give up --------*/
ll arr[MAXN];
ll solve(int n) {
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j += i) {
            arr[j]++;
        }
    }
    for(ll i = 1; i <= n; i++) ans += i * arr[i];
    return ans;
}
int main () {
    int t = 1;
    //cin >> t;
    while(t--) {
        int n;
        cin >> n;
        cout << solve(n);
    }

    return 0;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}


void solve()
{
    li n,m;

    cin>>n>>m;

    par.resize(n+1);
    sz.resize(n+1);

    f(i,0,n)
    {
        par[i]=i;
        sz[i]=1;
    }

    f(i,0,m-1)
    {
        li u,v;
        cin>>u>>v;

        unio(u,v);
    }

    li ans=0;

    f(i,1,n)
    {
        ans=max(ans,sz[root(i)]);
    }

    cout<<ans;
}

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x,y;
	cin>>x>>y;
	if(y>=2*x&&y<=4*x&&y%2==0) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    S, W = map(int, input().split())
    answer = ""
    if S <= W:
        answer = "unsafe"
    else:
        answer = "safe"
    print(answer)

if __name__ == "__main__":
    main()




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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int n;
string y, z;
int dfs(string s, vector<string> &a, vector<string> &b) {
	if (s.size() > z.size())return INF;
	if (s == z)return 0;
	int ret = INF;
	REP(i, n) {
		string tmp = s;
		REP(j, tmp.size() ) {
			if (j+a[i].size()<=tmp.size()&&tmp.substr(j, a[i].size()) == a[i]) {
				REP(k, a[i].size())tmp.erase(tmp.begin() + j);
				REP(k, b[i].size())tmp.insert(tmp.begin() + j+k,b[i][k]);
				j += b[i].size()-1;
			}
		}
		if (tmp != s) {
			ret = min(ret, dfs(tmp, a, b) + 1);
		}
	}
	return ret;

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

	while (cin >> n, n) {
		vector<string> a(n), b(n);
		REP(i, n) cin >> a[i] >> b[i];

		cin >> y >> z;
		int c = dfs(y, a, b);
		if (c == INF)cout << -1 << endl;
		else cout << c << endl;
	}
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

const int dy[] = {0,-1,0,1}, dx[] = {1,0,-1,0};
const int base = 1000;
int n,m;
int id[2000][2000];
int p[2000][2000];
pii dp[2000][2000];

int isPrime(int x){
  if(x<=1)return 0;
  for(int i=2;i*i<=x;i++){
    if(x%i==0)return 0;
  }
  return 1;
}

int main(){
  int y = base, x = base;
  id[y][x] = 1; p[y][x] = 0;

  int cnt = 2,len = 1, d = 0;
  do{
    for(int i=0;i<len;i++){
      y+=dy[d]; x+=dx[d];
      p[y][x] = isPrime(cnt);
      id[y][x] = cnt++;
    }
    if(d&1)len++;
    (d += 1) %= 4;
  }while(cnt<=1000000);

  while(cin >> m >> n, m){
    for(int i=0;i<2*base;i++)
      for(int j=0;j<2*base;j++)dp[i][j] = pii(-1,0);

    for(int i=0;i<2*base;i++){
      for(int j=0;j<2*base;j++){
	if(id[i][j] == n){
	  if(p[i][j])dp[i][j] = pii(1,id[i][j]);
	  else dp[i][j] = pii(0,0);
	}else if(dp[i][j].first < 0)continue;
	
	for(int k=-1;k<=1;k++){
	  if(1<=id[i+1][j+k] && id[i+1][j+k]<=m){
	    if(p[i+1][j+k] && dp[i+1][j+k].first < dp[i][j].first+1){
	      dp[i+1][j+k] = pii(dp[i][j].first+1, id[i+1][j+k]);
	    }
	    if(!p[i+1][j+k] && dp[i+1][j+k] < dp[i][j]){
	      dp[i+1][j+k] = dp[i][j];
	    }
	  }
	}
      }
    }

    pii ans = pii(0,0);
    for(int i=0;i<2*base;i++){
      for(int j=0;j<2*base;j++)ans = max(ans, dp[i][j]);
    }
    cout << ans.first << " " << ans.second << endl;
  }
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

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

    vector<int> vec(3);

    rep (i, 3)
        cin >> vec[i];

    sort(all(vec));

    print(abs(vec[0] - vec[2]));

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint A;
	cin >> A;
	string S;
	cin >> S;
	lint B = (S[0] - '0') * 100 + (S[2] - '0') * 10 + (S[3] - '0');
	//cout << A << ' ' << B << endl;
	cout << A * B / 100 << endl;
}

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

int main(){
	int t,p,r;
	while(true){
		cin >> t >> p >> r;
		if(t==0&&p==0&&r==0){
			break;
		}

		int miss[10][50]={0};
		int point[50]={0};
		int anscount[50]={0};

		for(int i=0;i<r;i++){
			int id,pid,time;
			string mes;
			cin >> id >> pid >> time >> mes;
			if(mes == "CORRECT"){
				point[id-1] += time +miss[pid-1][id-1] * 1200;
				anscount[id-1]++;
			}else{
				miss[pid-1][id-1]++;
			}
		}

		int id[50];
		for(int i=0; i < t; ++i) id[i] = i+1;
		for(int i=0; i < t; i++) {
			for(int j=i+1; j < t; j++) {
				if(anscount[i] < anscount[j]){
					swap(anscount[i], anscount[j]);
					swap(point[i], point[j]);
					swap(id[i], id[j]);
				}else if(anscount[i] == anscount[j]) {
					if(point[i] > point[j]) {
						swap(anscount[i], anscount[j]);
						swap(point[i], point[j]);
						swap(id[i], id[j]);
					}else if(point[i] == point[j] && id[i] > id[j]) {
						swap(anscount[i], anscount[j]);
						swap(point[i], point[j]);
						swap(id[i], id[j]);
					}
				}
			}
		}

		for(int i=0;i<t;i++){
			cout << id[i] << " " << anscount[i] << " " <<  point[i] << endl;
		}
	}
}

Measured memory_bytes: 924
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std; 
int main (){
    int n,m;
    cin >> n >> m;
    int sum = 0;
    vector<int>a(n);
    rep(i,n){
        cin >>a[i];
        sum+=a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    if(a[m-1]>=(double)sum/(4*m)) cout << "Yes"<<endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int X = sc.nextInt();
            int Y = sc.nextInt();
            if ((long)X*X+(long)Y*Y <= (long)D*D) ans++;
        }

        System.out.println(ans);
    }
}


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

#define ll long long

int main() {
    int r, D, x;
    cin >> r >> D >> x;
    for(int i = 0;i < 10;i++) {
        x = r*x - D;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
N,M=map(int,input().split())
XYZ=[list(map(int,input().split())) for i in range(M)]
data=[[] for i in range(N+1)]
ittenai=[]
for x,y,z in XYZ:
    data[x].append(y)
    data[y].append(x)
    ittenai.append(x)
    ittenai.append(y)


ittenai=set(ittenai)
count=N-len(ittenai)
while ittenai:
    x=ittenai.pop()
    stack=deque([x])

    count+=1
    while stack:
        num=stack.popleft()
        for i in data[num]:
            if i in ittenai:
                ittenai.remove(i)
                stack.append(i)
print(count)


Measured memory_bytes: 88024
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, x;
    std::cin >> n >> x;
    i64 ret = n, a = x, b = n - x;
    while (true) {
        if (b > a) std::swap(a, b);
        if (a % b == 0) {
            ret += ((a / b) * 2 - 1) * b;
            break;
        } else {
            ret += a / b * b * 2;
            a = a % b;
        }
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  char b;
  cin >> b;
  if(b=='A'){
   cout<<'T'<<endl;
  }
  else if(b=='C'){
   cout<<'G'<<endl;
  }
  else if(b=='T'){
   cout<<'A'<<endl;
  }
  else if(b=='G'){
   cout<<'C'<<endl;
  }
  return 0;
}



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

int main() {
  ll h;
  cin >> h;
  ll ans = 0;
  ll cnt = 1;
  while (h > 0) {
    ans += cnt;
    cnt *= 2;
    h /= 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]

    amax = max(a for a, b in ab)
    dp = [0] + [0] * (h + amax)
    for i in range(1, h + 1):
        dp[i] = min(dp[i - a] + b for a, b in ab)
    print(dp[h])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9572
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	char ch=getchar();
	puts((ch=='3' || ch=='5' || ch=='7')?"YES":"NO");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n, m, a, b;
	cin >> n >> m;
	vector<pair<long long,long long> > v;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		v.emplace_back(a,b);
	}
	long long cost = 0;
	sort(v.begin(),v.end());
	for(auto x:v){
		a=min(m,x.second);
		m-=a;
		cost+=a*x.first;
		if(m==0) break;
	}
	cout << cost;
		
		
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int N;cin>>N;
  int ans=0;
  vector<int> a;
  REP(i,N){
    int x;
    cin>>x;
    a.push_back(x);
    // P(x);
  }
  // P(a[0]);
  // P(a[1]);
  sort(a.begin(), a.end());

  if(N%2==0) {
    int k = N/2;
    for(int i=0;i<k;i++){
      ans += a[2*i + 1] - a[2*i];
    }
  }else if(N%2 == 1){
    int k = N/2;
    ans = a[0];
    for(int i=1;i<=k;i++) {
      ans += a[2*i] - a[2*i - 1];
    }
  }
  // P(a[0]);
  P(ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	map<string, int> mp;
	mp["SUN"] = 7;
	mp["MON"] = 6;
	mp["TUE"] = 5;
	mp["WED"] = 4;
	mp["THU"] = 3;
	mp["FRI"] = 2;
	mp["SAT"] = 1;
	string s;
	cin >> s;
	cout << mp[s] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define LL int
#define PB push_back
#define MP make_pair
#define I insert
 
const LL N = 4001, mod = 1000000007;
 
using namespace std;
 
LL n, m, i, j, k, l, r, t, bl, wh, ans;
LL dp[N][N], xe[N*2], a[2][N];
char c;
 
LL get ( LL x ){
	LL sum = 0;
	while ( x > 0 ){
		sum += xe[x];
		x -= (x & -x);
	}
	return sum;
}
 
void upd ( LL x, LL val ){
	if ( !x ) return;
	while ( x < 2*N ){
		//if ( val == -1 ) cout << x << endl;
		xe[x] += val;
		x += (x & -x);
	}
}
 
int main(){
	// B - 66;  W - 87
	// B - 0    W - 1
	cin >> n;
	for ( i = 1; i <= 2 * n; ++i ){
		cin >> c >> k;
		a[c%2][k] = i;
	}
	
	for ( i = 0; i < N; ++i ){
		for ( j = 0; j < N; ++j ){
			dp[i][j] = N*N;
		}
	}
	
	dp[0][0] = 0;
	
	for ( bl = 0; bl <= n; bl++ ){
		for ( i = 0; i < 2*N; ++i ) xe[i] = 0;
		for ( i = 1; i <= n; ++i ){
			upd(a[1][i],1);
		}
		for ( i = bl + 1; i <= n; ++i ){
			upd(a[0][i],1);
		}
		for ( wh = 0; wh <= n; ++wh ){
			if ( wh ) upd(a[1][wh],-1);
			if ( bl < n ){
				t = get ( a[0][bl+1] - 1 );
				dp[bl+1][wh] = min ( dp[bl+1][wh], dp[bl][wh] + t );
			}
			if ( wh < n ){
				t = get ( a[1][wh+1] - 1 );
				dp[bl][wh+1] = min ( dp[bl][wh+1], dp[bl][wh] + t );
			}
		}
	}/*/
	for ( i = 0; i <= n; ++i ){
		for ( j = 0; j <= n; ++j ){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}/**/
	cout << dp[n][n] << endl;
	/*/ans = dp[n][n];
	for ( i = 1; i <= n; ++i ){
		for ( j = 1; j < i; ++j ){
			if ( a[0][i] < a[0][j] ) ans++;
			if ( a[1][i] < a[1][j] ) ans++;
		}
	}
	cout << ans << endl;/**/
	return 0;
}
 
/**/
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE

Measured memory_bytes: 62848
<?php
while($n = trim(fgets(STDIN))){
    $s = [];
    for($i = 0; $i < $n; $i++){
        $s[] = trim(fgets(STDIN));
    }
    sort($s);
    $res = floor((array_sum($s) - ($s[0] + $s[$n - 1])) / ($n - 2));
    echo $res."\n";
}

Measured memory_bytes: 15184
#include<stdio.h>
int main(){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
         }
         for(i=0;i<H;i++){
             for(j=0;j<W;j++){
                 printf("#");
             }
            printf("\n");
         }
         printf("\n");
    }
    return 0;
}

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

int main(){
	int A,B,C,X;
	cin >> A >> B >> C >> X;
	int cnt = 0;

	for(int a = 0;a <= A;a++){
		for(int b = 0;b <= B;b++){
			for(int c = 0;c <= C;c++){
				if(500*a + 100*b + 50*c == X){
					cnt += 1;
				}
			}
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
def main
  n = gets.chomp.to_i
  difficulty_table = gets.chomp.split(' ').map(&:to_i)
  return 0 if n.odd? 
  
  difficulty_table.sort!
  lower_limit = difficulty_table[n/2-1]
  upper_limit = difficulty_table[n/2]
  return 0 if upper_limit == lower_limit
  
  answer = upper_limit - lower_limit
  answer
end

puts main

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

struct Edge{
    long long src, dst, weight, capacity;
    Edge(): src(0), dst(0), weight(0), capacity(0) {}
    Edge(long long s, long long d, long long w): src(s), dst(d), weight(w) {}
    Edge(long long s, long long d, long long w, long long c): src(s), dst(d), weight(w), capacity(c) {}
};

class Graph{
public:
    long long size;
    vector<vector<Edge>> node;
    Graph(long long n): size(n), node(n) {}
    void addEdge(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
        node[d].emplace_back(d, s, w);
    }
};

ll bfs(Graph &g, ll sn, ll n){
    vi num(n, 0);
    queue<ll> que;
    que.push(sn);
    num[sn] = 1;
    ll maxVertex = -1;
    // その時点での頂点から直接到達可能な頂点に+1の番号を振る
    // 矛盾が生じた時点で-1を返す
    while(que.size()){
        auto node = que.front();
        que.pop();
        for(auto &edge: g.node[node]){
            // 未訪問なら
            if(num[edge.dst] == 0){
                num[edge.dst] = num[node] + 1;
                que.push(edge.dst);
                chmax(maxVertex, num[edge.dst]);
            }
            // 既に追加済みなら
            else{
                // 隣接部分と集合番号が一致したら矛盾
                if(num[edge.dst] == num[node]) return -1;
            }
        }
    }
    return maxVertex;
}

int main(){
    Init();
    ll n;
    cin >> n;
    Graph g(n);
    vector<string> s(n);
    rep(i, n){
        // 隣接リストの入力
        cin >> s[i];
        rep(j, n){
            if(s[i][j] == '0') continue;
            if(j <= i) continue;
            g.addEdge(i, j, 1);
        }
    }
    ll ans = -2;
    for(ll i=0; i<n; i++) chmax(ans, bfs(g, i, n));
    cout << ans << endl;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

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

long long MOD = 1000000000 + 7;

// 素数判定 O(√n)
bool isPrime(int n){
    if(n == 1) return false;
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

int main(){
  cout << setprecision(10);
  //素数列挙
  int N;
  cin >> N;
  vector<int> ans;
  for(int i = 5; i <= 55555; i+=2){
    if(isPrime(i)){
      if(i%5==1){
        ans.push_back(i);
      }
    }
    if(ans.size() == N){
      break;
    }
  }

  for(int i = 0; i < ans.size(); i++){
    if(i == ans.size()-1){
      cout << ans[i] << endl;
    } else {
      cout << ans[i] << " ";
    }
  }
}


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

struct UnionFind{

  vector<int> par;
  UnionFind(int N): par(N) {rep(i,N)par[i]=i;}
  
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  
  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return ;
    par[rx]=ry;
  }
  
  bool same(int x, int y){
    int rx=root(x);
    int ry=root(y);   
    return rx==ry;
  }
  
};

int main(){

  int n,m=0;	
  cin>>n>>m;
  
  vector<int> a(m);
  vector<int> b(m);
  
  rep(i,m){

    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
    
  }
  
  int ans=0;
  
  rep(i,m){
	UnionFind d(n);
    rep(j,m){
      if(j!=i)d.unite(a[j],b[j]);      
    }
    if(!d.same(a[i],b[i]))ans++;
  }

  cout<<ans<<endl;
  
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int height=scan.nextInt();
        int width=scan.nextInt();
        String[] str=new String[height];
        int i;
        for(i=0;i<height;i++){
            str[i]=scan.next();
        }
        String top="#";
        for(i=0;i<=width;i++){
            top=top+"#";
        }
        System.out.println(top);
        for(i=0;i<height;i++){
            System.out.println("#"+str[i]+"#");
        }
        System.out.println(top);
    }
}

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


int main() {
  int A, B;

  cin >> A >> B;

  if (13 <= A) {
    cout << B << endl;
  } else if (6 <= A) {
    cout << B / 2 << endl;
  } else {
    cout << "0" << endl;
  }
}


Measured memory_bytes: 256
#1食800円
#15食食べると200円もらえる　N/15*200
#合計N食、金額x円,レストランからもらった金額y円
#x - y を求める
#標準入力

N =  int (input())
x =(800 * N)
y =(int(N/15)*200)
print(x-y)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

ll H[100010][3];
ll dp[100010][3];

signed main() {
  ll N;
  cin >> N;

  rep(i, N) {
    rep(j, 3) {
      ll h;
      cin >> h;
      H[i][j] = h;
    }
  }

  rep(i, 100010) {
    dp[i][0] = 0;
    dp[i][1] = 0;
    dp[i][2] = 0;
  }
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;

  rep(i, N) {
    rep(j, 3) {
      rep(k, 3) {
        if (j == k) continue;
        // debug(i);
        // debug(j);
        // debug(k);
        chmax(dp[i + 1][k], dp[i][j] + H[i][k]);
      }
    }
  }

  ll res = 0;
  rep(i, 3) {
    chmax(res, dp[N][i]);
  }

  COUT(res);
  return 0;
}

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

using namespace std;

#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()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;



int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,gw;
	cin >>n >>gw;

	vector<int> w(n), z(n);
	ll mnw=1e9+1e8;
	rep(i,n){
		cin >> w[i] >>z[i];
		mnw=min<int>(mnw, w[i]);
	}
	
	vector<vector<ll>> v(4);
	rep(i,n) v[w[i]-mnw].emplace_back(z[i]);
	rep(i,4) sort(v[i].rbegin(), v[i].rend());
	ll ans = 0;
	rep(a,sz(v[0])+1) rep(b,sz(v[1])+1) rep(c,sz(v[2])+1) rep(d,sz(v[3])+1){
		if( mnw*a + (mnw+1)*b + (mnw+2)*c + (mnw+3)*d <= gw){
			ll w = accumulate(v[0].begin(), v[0].begin()+a, 0LL)
		     + accumulate(v[1].begin(), v[1].begin()+b, 0LL)
		     + accumulate(v[2].begin(), v[2].begin()+c, 0LL)
		     + accumulate(v[3].begin(), v[3].begin()+d, 0LL);
			ans = max(ans, w);
		}
	}
	
	cout << ans <<endl;
	return 0;
}



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

int main(){
    int N;
    cin >>N;
    vector<int> a(N),b(N),c(20000000,0);
    for(int i=0;i<N;i++){
        cin >> a[i];
        c[a[i]]++;
    }
    for(int i=1;i<c.size();i++){
        c[i]+=c[i-1];
    }
    for(int i=N-1;i>=0;i--){
        int x=c[a[i]];
        b[x-1]=a[i];
        c[a[i]]--;
    }
    for(int i=0;i<N;i++){
        cout<<b[i];
        if(i!=N-1)cout<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 96468
#include <iostream>
#include<string.h>
#include<set>
#include<algorithm>
using namespace std;
set<int>st;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int u;
        cin>>u;
        if(st.find(u)!=st.end())
        {
            st.erase(u);
        }
        else
           st.insert(u);
    }
    cout<<st.size()<<endl;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main(){
  ll n,h ;cin>>n>>h ;
  vector<P> A(2*n) ;
  rep(i,2*n){
    ll x ;
    cin>>x ;
    A[i].fi = x ;
    A[i].se =i ; 
  }
  sort(A.rbegin(),A.rend()) ;
  ll ans=0 ;
  ll sum=h ;
  rep(i,2*n){
   if(sum<=0) break ;
   if(A[i].se%2==1){
    sum-=A[i].fi ;
    ans++ ;
   } 
   else{
   ans +=  (sum+A[i].fi-1)/A[i].fi ;
   break ;
   }
  }
  cout<<ans<<endl ;
  return 0;
  }

Measured memory_bytes: 4840
n=input()
inp=list(map(int,input().split()))

s=sum(inp)
g=sum(inp)/2
small=0
big=0
for i in inp:
    small+=i
    if small < g:
        #print(small)
        a=1
    else:
        big=small
        small-=i
        break

#print(big,small)
res=min(abs(g-big),abs(g-small))
print(int(2*res))

Measured memory_bytes: 3064
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>


using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double;
const string FILENAME = "input";



int gcd(int a, int b) {
	while (a > 0) {
		b %= a;
		swap(a, b);
	}
	return b;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//read(FILENAME);
 	int x;
 	cin >> x;
 	int f = 360 / gcd(360, x);
 	cout << f << endl;
	return 0;	 	
}


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

int main(){
	string s;
  	cin>>s;
  	if(s[0]==s[1]){
    	if(s[1]==s[2])cout<<"Yes"<<endl;
      	else cout<<"No"<<endl;
    }else if(s[1]==s[2]){
    	if(s[2]==s[3])cout<<"Yes"<<endl;
      	else cout<<"No"<<endl;
    }else cout<<"No"<<endl;
  	return 0;
}

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

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


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

bool isin(string s, char c){
	rep(i,s.size()){
		if(s[i]==c)return true;
	}
	return false;
}

int main()
{
	int n;
	vector<int> x(3);
	cin>>n;
	rep(i,3)cin>>x[i];
	vector<string> s(n);
	rep(i,n){
		cin>>s[i];
	}

	vector<char> ans;
	rep(i,n){

		if(x[s[i][0]-'A']==0 && x[s[i][1]-'A']==0){
			cout<<"No"<<endl;
			return 0;
		}

		if(x[s[i][0]-'A'] < x[s[i][1]-'A']){
			x[s[i][0]-'A']++;
			x[s[i][1]-'A']--;
			ans.push_back(s[i][0]);
		}else if(x[s[i][0]-'A'] > x[s[i][1]-'A']){
			x[s[i][0]-'A']--;
			x[s[i][1]-'A']++;
			ans.push_back(s[i][1]);
		}else{
			if(i==n-1)ans.push_back(s[i][0]);
			else if(s[i+1]==s[i]){
				x[s[i][0]-'A']++;
				x[s[i][1]-'A']--;
				ans.push_back(s[i][0]);
			}else if(isin(s[i+1],s[i][0])){
				x[s[i][0]-'A']++;
				x[s[i][1]-'A']--;
				ans.push_back(s[i][0]);
			}else{
				x[s[i][0]-'A']--;
				x[s[i][1]-'A']++;
				ans.push_back(s[i][1]);
			}
		}

	}

	cout<<"Yes"<<endl;
	rep(i,n)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 6732
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	long long n;
	long long lmax = 0, lmax2 = 0;
	long long i;
	long long input;
	vector<long long> arr;

	scanf("%lld", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%lld", &input);

		if (input >= lmax)
		{
			lmax2 = lmax;
			lmax = input;
		}

		else if (input > lmax2)
		{
			lmax2 = input;
		}

		arr.push_back(input);
	}

	for (i = 0; i < n; i++)
	{
		if (arr[i] == lmax)
		{
			printf("%lld\n", lmax2);
		}

		else
		{
			printf("%lld\n", lmax);
		}
	}


	return 0;
}

Measured memory_bytes: 3312
n, k = list(map(int, input().split()))
P = list(map(int, input().split()))
E = [0, ]
tot = 0
for i in range(n):
    tot += P[i] * (P[i] + 1) / (2 * P[i])
    E.append(tot)
ans = 0
for i in range(n - k + 1):
    ans = max(ans, E[i + k] - E[i])
print(ans)


Measured memory_bytes: 25060
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=110;
const int inf=1e9+100;
int n;
int a[maxn];

int main()
{
    while (scanf("%d",&n)!=EOF)
    {
        for (int i=0;i<n;i++) scanf("%d",&a[i]);
        int minn=inf,maxx=0;
        for (int i=0;i<n;i++)
        {
            minn=min(a[i],minn);
            maxx=max(a[i],maxx);
        }
        printf("%d\n", maxx-minn);
    }
    return 0;
}


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

using namespace std;

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

int main()
{
    int64_t n;
    cin >> n;
    int64_t a, b;
    cin >> a >> b;

    if (a > b)
    {
        swap(a, b);
    }

    int64_t d = b - a;
    if (d % 2 == 0)
    {
        cout << d / 2 << endl;
    }
    else
    {
        int64_t na = n - b + a + 1;
        int64_t mb = b - (a - 1) - 1;
        cout << min(n - b + 1 + (n - na) / 2, a - 1 + 1 + (mb - 1) / 2) << endl;
    }
    return 0;
}

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

typedef pair<int, int> P;

ll solve(int n){
    if(n == 0){
        return 0;
    }else if(n == 1){
        return 1;
    }else if(n == 2){
        return 1;
    }else{
        ll x[3];
        ll tmp;
        x[0] = 0;
        x[1] = 1;
        x[2] = 1;
        for(int i = 2; i < n; i++){
            tmp = x[1];
            x[0] = x[1];
            x[1] = x[2];
            x[2] = x[1] + x[0];
            if(x[2>1000000007]){
                rep(i,3){
                    x[i] = x[i]%1000000007;
                }
            }
        }
        return x[2];
    }
}

int main() {


    const ll N =  1000000007;

    int n,m;
    cin >> n >> m;
    int a[m+1];
    rep(i,m)cin >> a[i];
    a[m] = n+1;
    int d[m+1];
    d[0] = a[0];
    if(d[0]==0)d[0]=1;
    rep(i,m){
        d[i+1] = a[i+1] - a[i]-1;
    }

    ll ans = 1;
    rep(i,m+1){
        ll tmp = solve(d[i]);
        ans *= tmp;
        if(ans > N){
            ans = ans % N;
        }
        // cout << ans << endl;

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
#include<queue>
#include <iomanip>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007



int main()
{
    int N;
    cin >> N;
    double v[N];
    REP(i,0,N){
        cin >> v[i];
    }
    sort(v, v + N);

    double ans = v[0];
    REP(i,1,N){
        ans = (ans + v[i]) / 2.0;

    }
    std::cout << std::setprecision(8) << ans<< endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N,W = map(int,input().split())

dp = np.zeros(W+1, dtype=np.int64)
for _ in range(N):
    w,v = map(int,input().split())
    np.maximum(dp[w:], dp[:-w] + v, out = dp[w:])

answer = dp.max()
print(answer)

Measured memory_bytes: 14584
/*
      author : nishi5451
      created: 11.08.2020 21:23:02
*/

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


int main(){
    string s;
    cin >> s;
    int month = (s[5]-'0')*10 + (s[6]-'0');
    int date = (s[8]-'0')*10 + (s[9]-'0');
    if(month>=5) cout << "TBD" << endl;
    else if(month==4 && date>30) cout << "TBD" << endl;
    else   cout << "Heisei" << endl;
    return 0;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (b - a <= 2) {
            System.out.println(k + 1);
            return;
        } else {
            // A回目からスタート
            long ans = a;
            for (int i = a - 1; i < k; i += 2) {
                if (i + 2 > k) {
                    ans += 1;
                    i--;
                } else {
                    ans -= a;
                    ans += b;
                }
            }
            System.out.println(ans);
        }

    }

}


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

int main()
{
    int N;
    cin >> N;
    long long ret = 0;
    map<long long, int> M;
    for (int i = 0; i < N; i++)
    {
        long long A;
        cin >> A;
        ret += M[i - A];
        M[i + A]++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 26332
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

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



int main(){
  int n,a,b;cin>>n>>a>>b;
  cout << min(b,n*a) << endl;
}


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

int main(){
  int N;
  string s,t,ans="";
  cin>>N>>s>>t;
  for(int i=0;i<N;i++){
    ans+=s.at(i);
    ans+=t.at(i);
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 256