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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;

const int N = 1e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 5;

struct UFDS {
    int n;
    vi par;
    vi rank;

    void init(int x) {
        n = x;
        par.resize(x);
        iota(all(par), 0);
        rank.assign(x, 1);
    }

    int get(int x) {
        if (par[x] == x) return x;
        else return par[x] = get(par[x]);
    }

    bool unite(int x, int y) {
        x = get(x);
        y = get(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        par[y] = x;
        rank[x] += rank[y];
        return true;
    }

    int maxRank() {
        return *max_element(all(rank));
    }
};

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    int n, m;
    cin >> n >> m;
    UFDS ds;
    ds.init(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        ds.unite(u, v);
    }
    cout << ds.maxRank();
}

Measured memory_bytes: 4764
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var R = Number(lines[0].split(" ")[0]);
    var G = Number(lines[0].split(" ")[1]);
    var B = Number(lines[0].split(" ")[2]);
    var N = Number(lines[0].split(" ")[3]);

    var ans = 0;
    for (var r = 0; r <= 3000; r++) {
        for (var g = 0; g <= 3000; g++) {
            var b = N - r * R - g * G;

            if (b < 0 || b % B !== 0) { continue; }
            ans++;
        }
    }

    console.log(ans);

});

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

const int N = 1e5+5;

int n, m, cnt;
int p[N];
int par[N];
set<int> S[N];

int find(int u) { return par[u] = par[u] == u ? u : find(par[u]); }

int main() {
  iota(par, par+N, 0);
  scanf("%d %d", &n, &m);
  for(int i = 1; i <= n; ++i) 
    scanf("%d", p+i);
  for(int i = 0, a, b; i < m; ++i) {
    scanf("%d %d", &a, &b);
    a = find(a), b = find(b);
    if(a != b) par[a] = b;
  } 
  for(int i = 1; i <= n; ++i) {
    S[find(i)].emplace(i);
  }
  for(int i = 1; i <= n; ++i) {
    if(S[find(i)].count(p[i])) cnt++;
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

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

long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
 
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int l[50];

int main(){
	int n, k;
	
	cin >> n >> k;
	
	REP(i,n){
		scanf("%d", &l[i]);
	}
	
	sort(l,l+n);
	
	int sum = 0;
	
	REP(i,k){
		sum += l[n-i-1];
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
int main(void){
    string s,t; cin >> s >> t;
    cout << t+s << endl;
    return 0;
}

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

const int MAXSIZE = 100000;
const int END = -1;
struct StNod
{
  bool m_bBe;
  int m_nDept;
  int m_nParnt;
  int m_nLChd;
  int m_nRSib;

  StNod() :
    m_bBe(false), m_nDept(0), m_nParnt(END), m_nLChd(END), m_nRSib(END)
  { }
};

void fnInput(int &rnMaxSiz, vector<StNod> &rvoNod)
{
  StNod oNod;
  rvoNod.resize(MAXSIZE, oNod);

  cin >> rnMaxSiz;

  for (int i = 0; i < rnMaxSiz; i++)
  {
    int nParnt, nCCnt, nChd, nBChd = END;
    cin >> nParnt >> nCCnt;
    rvoNod[nParnt].m_bBe = true;
    for (int j = 0; j < nCCnt; j++)
    {
      cin >> nChd;
      rvoNod[nChd].m_bBe = true;
      rvoNod[nChd].m_nParnt = nParnt;
      if (nBChd != END) rvoNod[nBChd].m_nRSib = nChd;
      if (!j)          rvoNod[nParnt].m_nLChd = nChd;
      nBChd = nChd;
    }
  }
}

void fnSetDepth(vector<StNod> &rvoNod, int nx, int nDept)
{
  rvoNod[nx].m_nDept = nDept;
  
  if (rvoNod[nx].m_nRSib != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nRSib, nDept);

  if (rvoNod[nx].m_nLChd != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nLChd, nDept + 1);
}

void fnRtdTree(vector<StNod> &rvoNod)
{
  int nx = 0, nDept = 0;
  while (rvoNod[nx].m_nParnt != END)
    nx = rvoNod[nx].m_nParnt;

  fnSetDepth(rvoNod, nx, nDept);
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  for (int i = 0; cnrvoNod[i].m_bBe; i++)
  {
    cout << "node " << i << ": parent = " << cnrvoNod[i].m_nParnt << ", depth = " << cnrvoNod[i].m_nDept;

    if (!cnrvoNod[i].m_nDept)            cout << ", root, ";
    else if (cnrvoNod[i].m_nLChd == END) cout << ", leaf, ";
    else                                 cout << ", internal node, ";

    cout << "[";
    if (cnrvoNod[i].m_nLChd != END)
    {
      int nx = cnrvoNod[i].m_nLChd;
      cout << nx;
      while (cnrvoNod[nx].m_nRSib != END)
      {
        cout << ", " << cnrvoNod[nx].m_nRSib;
        nx = cnrvoNod[nx].m_nRSib;
      }
    }
    cout << "]" << endl;
  }
}

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

  int nMaxSiz;
  vector<StNod> voNod;

  fnInput(nMaxSiz, voNod);
  fnRtdTree(voNod);
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 6276
/*
░░░░░▄▀▀▀▄░░░░░░░░░░░░░░░░
▄███▀░◐░░░▌░░░░░░░░░░░░░░
░░░░▌░░░░░▐░░░░░░░░░░░░░░░
░░░░▐░░░░░▐░░░░░░░░░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░░░░░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄░░░░░░░░
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄░░░░░░
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄░░░░
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄░░
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░░░░░░
*/

#include <bits/stdc++.h>

using namespace std;

#define boost 			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(a) 			(a).begin(), (a).end()
#define sz(a) 			(int)(a).size()
#define FOR(a, b, c) 	for (int a = (b); a <= (c); a++)
#define FORR(a, b, c) 	for (int a = (b); a >= (c); a--)
#define ELO 			exit(0)
#define eb 				emplace_back
using ll = 				long long;
using ld = 				long double; // 'long double' is 2.2 times slower than double
using pii = 			pair<int, int>;
using pll = 			pair<ll, ll>;
using vi = 				vector<int>;
using vll = 			vector<ll>;

constexpr int MOD = 1e9 + 7; // 998244353
constexpr int INF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;

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

namespace fastio {
	template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
	template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
	template<class T1, class T2> inline istream& operator >> (istream& os, pair<T1, T2>& p) { return os >> p.first >> p.second; }
	template<class T1, class T2> ostream& operator << (ostream& os, const pair<T1, T2>& p) { return os << p.first << " " << p.second; }

}
using namespace fastio;

namespace debug {
	template < typename _T > inline void _debug(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
	template < typename _T, typename... args > void _debug(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _debug(s + 1, a...); }
	
	#if 1
	#define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__)
	#define cerr cout
	#else
	#define debug(...) 69
	#define cerr if(0) cout
	#endif
}
using namespace debug;

//////////////_________CODE_________//////////////

// jeszcze na chwilke spojrz na dol

int main(){// jeszcze na chwilke spojrz na dol
	boost;
    int n;
    string s;
    cin >> n >> s;
    vll ile(27);
    for(auto& i : s) {
        ile[i - 'a']++;
    }

    ll res = 0;
    for(auto& i : ile) {
        res = res + i + res * i;
        res %= MOD;
    }

  cout << res << "\n";

	ELO;
}// jeszcze na chwilke spojrz na dol


/*
Ty a na 100% wszystko mam dobrze ?
Na 100% hmmm ?
zadnego int*int >1e9 nie ma tak ?
a to 1e5 * 1e5 ? 
A jakis krytyczny przypadek hmm ? jakies n=1 ? hmm ?

We no zamiast nic nie robic to we cos zrob typie

zeby nie było "DomiKo zjazd" :C
*/

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

int main (void){
	char s[102],t[102];
	t[0]='k';
	t[1]='e';
	t[2]='y';
	t[3]='e';
	t[4]='n';
	t[5]='c';
	t[6]='e';
	int n,i,j,flag=0;
	cin >> s;
	n=strlen(s);
	for(i=0;i<=7;i++){
		int ff=0;
		for(j=1;j<=i;j++){
			if(s[j-1]!=t[j-1]) ff=1;
		}
		for(j=1;j<=7-i;j++){
			if(s[n-j]!=t[7-j]) ff=1;
		}
		if(ff==0) flag=1;
	}
	if(flag==1) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;
signed main() {
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 10000; i++) {
		if (i * 8 / 100 == a && i / 10 == b) {
			cout << i << endl;
			break;
		}
		if (i * 8 / 100 > max(a, b)) {
			cout << -1 << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
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; }
void say(bool yes){cout<<(yes?"YES":"NO")<<endl;};

class WS{
    public:
    ll w;
    ll s;
    WS(ll _w = 1919, ll _s = -1919){
        w = _w;
        s = _s;
    }
    ll mn(WS ws){
        return s * (ws.w + ws.s) < ws.s * (w + s);
    }
};

int main(){

    ll A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    
    vector<ll>dp(3333, 0);
    dp[C] = 1;
    dp[D] = 1;
    for(ll i = 0; i <= 3000; i++){
        if(dp[i] == 0)continue;
        dp[i + C] = 1;
        dp[i + D] = 1;
    }
    for(ll i = 1; i <= 3000; i++){
        if(dp[i])dp[i] = i;
        else dp[i] = dp[i - 1];
    }
    WS ans;
    for(ll a = 0; a <= 30; a++){
        for(ll b = 0; b <= 30; b++){
            ll w = a * A * 100 + b * B * 100;
            if(w == 0)continue;
            if(w > F)continue;
            ll s = dp[min(E*(a * A + b * B), F - w)];
            WS tmp(w, s);
            if(ans.mn(tmp))ans = tmp;
        }
    }
    cout << ans.w + ans.s << " " << ans.s << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for i in range(N):
  if A[i]<B[i]:
    B[i]=B[i]-A[i]
    ans=ans+A[i]
    #print(B[i],"i")
    
    if A[i+1]<B[i]:
      ans=ans+A[i+1]
      A[i+1]=0
    else:
      ans=ans+B[i]
      A[i+1]=A[i+1]-B[i]
      
  else:
    ans=ans+B[i]
    #print(B[i])
  #print(ans,"ans")
print(ans)

Measured memory_bytes: 18476
#include <iostream>
#include <stdio.h>
using namespace std; 
int main() {
	int x ,y;
	char c;
	cin >> x;
	cin >> c;
	cin >> y;
	switch (c) {
	case '+':
		cout << x + y;
				break;
	case '-':
		cout << x - y;
				break;


			
	}

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var cols []string
	var height, width, count int
	sc := bufio.NewScanner(os.Stdin)

	for {
		sc.Scan()
		cols = strings.Split(sc.Text(), " ")
		height, _ = strconv.Atoi(cols[0])
		width, _ = strconv.Atoi(cols[1])
		if height == 0 && width == 0 {
			break
		}
		count++
		for i := 0; i < height; i++ {
			for j := 0; j < width; j++ {
				fmt.Print("#")
			}
			fmt.Println()
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1096
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007LL

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector< vector<ll> > dp(s.size() + 1, vector<ll>(13));
    dp.at(0).at(0) = 1;
    vector<ll> m = {1, 10, 9, 12, 3, 4};
    ll cnt = 0;
    for (auto i = s.rbegin(); i != s.rend(); ++i, ++cnt) {
        if (*i == '?') {
            for (ll j = 0; j < 10; ++j) for (ll k = 0; k < 13; ++k) (dp.at(cnt + 1).at((k + j * m.at(cnt % 6)) % 13) += dp.at(cnt).at(k)) %= MOD;
        } else for (ll k = 0; k < 13; ++k) (dp.at(cnt + 1).at((k + (*i - '0') * m.at(cnt % 6)) % 13) += dp.at(cnt).at(k)) %= MOD;
    }
    cout << dp.back().at(5) << '\n';
    return 0;
}


Measured memory_bytes: 13648
"use strict";
// import bigInt from 'big-integer'

const Main = input => {
  input = input.trim().split("\n");
  const h = input[0];
  const w = parseInt(input[1], 10);
  const n = parseInt(input[2], 10);

  const divider = h >= w ? h : w;

  console.log(Math.ceil(n / divider));
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
ll a,b,c,d;
cin >> a >> b >> c >> d; 
if(a>=d){
  cout << d << endl;
}else{
  if(a+b>=d){
    cout << a << endl;
  }else{
    cout << a+(d-a-b)*(-1) << endl;
  }
}
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int power_5[120] = {0};
    for(int i = 0; i < 120; i++){
        power_5[i] = i*i*i*i*i;
    }
    int x = 0;
    int flag = 0;
    scanf("%d",&x);
    for(int i = 0; i < 120; i++){
        for(int j = i; j < 120; j++){
            if(power_5[i]+power_5[j]==x){
                printf("%d %d",j,-i);
                flag = 1;
                break;
            }
            if(power_5[j] - power_5[i]==x){
                printf("%d %d",j,i);
                flag = 1;
                break;
            }
        }
        if(flag == 1){
            break;
        }
    }




    return 0;
}


Measured memory_bytes: 1696
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>

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

using namespace std;

class Point{
public:
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    Point operator + (Point p) { return Point(x+p.x,y+p.y); }
    Point operator - (Point p) { return Point(x-p.x,y-p.y); }
    Point operator * (double a) { return Point(x*a,y*a); }
    Point operator / (double a) { return Point(x/a,y/a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }

    bool operator < (const Point &p) const {
        return x!=p.x?x<p.x:y<p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }

};

typedef Point Vector;

///Program 16.3 表示线段的结构体
struct Segment{
    Point p1,p2;
};

///Program 16.4 表示直线的结构体
typedef Segment Line;

///内积
double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}
///外积
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

Point getCrossPoint(Segment s1,Segment s2){
    Vector base=s2.p2-s2.p1;
    //printf("%lf %lf\n",base.x,base.y);
   // cout<<base.x<<" "<<base.y<<endl;
    double d1=abs(cross(base,s1.p1-s2.p1));
    double d2=abs(cross(base,s1.p2-s2.p1));
    double t=d1/(d1+d2);
  //  printf("t:%lf\n",t);
 //   cout<<t<<endl;
    return s1.p1 + (s1.p2 - s1.p1) * t;
}



int main()
{
    Segment s1,s2;
//    Point p0,p1,p2,p3;
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        cin>>s1.p1.x>>s1.p1.y>>s1.p2.x>>s1.p2.y>>s2.p1.x>>s2.p1.y>>s2.p2.x>>s2.p2.y;
       // scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&s1.p1.x,&s1.p1.y,&s1.p2.x,&s1.p2.y,&s2.p1.x,&s2.p1.y,&s2.p2.x,&s2.p2.y);
       // cout<<s1.p1.x<<s1.p1.y<<s1.p2.x<<s1.p2.y<<s2.p1.x<<s2.p1.y<<s2.p2.x<<s2.p2.x<<endl;
       // printf("%lf%lf%lf%lf%lf%lf%lf%lf\n",s1.p1.x,s1.p1.y,s1.p2.x,s1.p2.y,s2.p1.x,s2.p1.y,s2.p2.x,s2.p2.y);
        Point ans=getCrossPoint(s1,s2);
        printf("%.10f %.10f\n",ans.x,ans.y);
       // cout<<ans.x<<" "<<ans.y<<endl;
    }
    return 0;
}


Measured memory_bytes: 3292
/*
* @Author: 王文宇
* @Date:   2018-03-17 20:49:31
* @Last Modified by:   王文宇
* @Last Modified time: 2018-03-17 20:55:59
*/
#include <bits/stdc++.h>
using namespace std;
map<string,int> Q,P;
const int maxn = 107;
int n,m,a[maxn],b[maxn];
int main(int argc, char const *argv[])
{
	cin>>n;
	int now = 0;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		if(!Q.count(s))
			{
				Q[s]=now;
				a[now++]=1;
			}
		else a[Q[s]]++;
	}
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		string s;
		cin>>s;
		if(!Q.count(s))
			{
				Q[s]=now;
				b[now++]=1;
			}
		else b[Q[s]]++;
	}
	int ans = 0;
	for(int i=0;i<now;i++)
	{
		ans = max(ans,max(0,a[i]-b[i]));
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

vector<int> sieve(int n) {
  std::vector<int> res(n);
  std::iota(res.begin(), res.end(), 0);
  for (int i = 2; i*i < n; ++i) {
    if (res[i] < i) continue;
    for (int j = i*i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return res;
}

void factorize(long long n, vector<int> &prime_cnt, vector<int> &min_factor){
    int p;
    while (n > 1) {
        p = min_factor[n];
        n /= p;
        if (min_factor[n] != p) {
            prime_cnt[p]++;
        }
    }
}

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

    vector<int> A(N);

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

    vector<int> prime_cnt;
    vector<int> prime_list = sieve(1e6+1);

    prime_cnt.assign(1e6, 0);

    for (int i = 0; i < N; i++){
        if (A[i] != 1) {
            factorize(A[i], prime_cnt, prime_list);
        }
    }

    bool pw_cp = true;
    bool st_cp = true;

    for (auto val : prime_cnt) {
        if (val == 0) continue;
        if (val != 1) {
            pw_cp = false;
        }
        if (val == N) {
            st_cp = false;
        }
    }

    if (pw_cp) {
        cout << "pairwise coprime" << endl;
    } else if (st_cp) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 14876
package main

import (
	"fmt"
	"sort"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	var S string
	fmt.Scanf("%s\n", &S)

	rs := []rune(S)
	positions := []int{}
	pos := 0
	for pos < len(rs) {
		if string(rs[pos+1]) == "R" {
			pos++
			continue
		}
		positions = append(positions, pos)
		pos++
		for pos < len(rs) {
			if string(rs[pos]) == "R" {
				break
			}
			pos++
		}
	}
	m := map[int]int{}
	pos = 0
	for pos < len(rs) {
		idx := sort.SearchInts(positions, pos)
		i := positions[idx]
		if (i-pos)%2 != 0 {
			m[i+1]++
		} else {
			m[i]++
		}
		if i-pos == 0 {
			pos++
			for pos < len(rs) && string(rs[pos]) == "L" {
				if (pos-i)%2 != 0 {
					m[i+1]++
				} else {
					m[i]++
				}
				pos++
			}
		} else {
			pos++
		}
	}
	for i := 0; i < len(rs); i++ {
		fmt.Print(m[i])
		fmt.Print(" ")
	}
	fmt.Println()

}


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

A = sorted(A, reverse=True)

ans = A[0]
count = 2
index = 1
if N == 2:
  print(ans)
else:
  flag = 0
  while flag == 0:
    for i in range(2):
      ans += A[index]
      count += 1
      
      if count == N:
        flag = 1
        break
    index += 1
  print(ans)

Measured memory_bytes: 31456
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,M;
  cin>>A>>B>>M;
  vector<int> a(A);
  vector<int> b(B);
  for(int i=0;i<A;i++){
    cin>>a.at(i);
  }
  for(int j=0;j<B;j++){
    cin>>b.at(j);
  }
  int min;
  int x,y,c;
  for(int i=0;i<M;i++){
    cin>>x>>y>>c;
    if(i==0){
      min = a.at(x-1)+b.at(y-1)-c;
    }
    else{
      if(a.at(x-1)+b.at(y-1)-c<min){
        min = a.at(x-1)+b.at(y-1)-c;
      }
    }
  }
  int mina,minb;
  for(int i=0;i<A;i++){
    if(i==0){
      mina=a.at(i);
    }
    else{
      if(a.at(i)<mina){
        mina=a.at(i);
      }
    }
  }
  for(int i=0;i<B;i++){
    if(i==0){
      minb=b.at(i);
    }
    else{
      if(b.at(i)<minb){
        minb=b.at(i);
      }
    }
  }
  
  if(mina+minb<min){
    cout<<mina+minb<<endl;
  }
  else{
    cout<<min<<endl;
  }
}



Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::string s, t;

  std::cin >> s >> t;

  std::cout << (s[0] == t[2] && s[1] == t[1] && s[2] == t[0] ? "YES" : "NO") << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int num = Integer.parseInt(sc.next());
        int[] canDivided = new int[Math.max(a, b)];
        for (int i = 0; i < canDivided.length; i++) {
            if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            }
        }
        Arrays.sort(canDivided);
        System.out.println(canDivided[canDivided.length - num]);
    }
}


Measured memory_bytes: 21844
a, b, c, x, y=map(int, input().split())
p=0
if a+b > 2*c:
  p+=min(x, y)*2*c
  if x>y:
    if a>2*c:
      p+=(x-y)*2*c
    else:
      p+=(x-y)*a
  else:
    if b>2*c:
      p+=(y-x)*2*c
    else:
      p+=(y-x)*b
else:
  p+=x*a+y*b
print(p)

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	int k = ri();
	int r0 = 0;
	std::vector<int> t;
	for (auto c : s) t.push_back(c - 'a');
	for (int i = 0; i + 1 < n; i++) {
		if (t[i] == t[i + 1]) r0++, t[i + 1] = -(i + 1);
	}
	
	bool can_continue = t[n - 1] < 0 || s[0] != s[n - 1];
	
	int r1 = 1;
	t.clear();
	for (auto c : s) t.push_back(c - 'a');
	t[0] = -100000000;
	for (int i = 0; i + 1 < n; i++) {
		if (t[i] == t[i + 1]) r1++, t[i + 1] = -(i + 1);
	}
	assert(r1 >= r0);
	
	bool can2 = t[n - 1] < 0 || s[0] != s[n - 1];
	
	if (can_continue) std::cout << (int64_t) r0 * k << std::endl;
	else if (can2) std::cout << (int64_t) (r0 + r1) * (k / 2) + r0 * (k & 1) << std::endl;
	else std::cout << r0 + (int64_t) r1 * (k - 1) << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static int findLCS(String a, String b) {
		
		int m = a.length();
		int n = b.length();
		
		int[][] matrix = new int[m + 1][n + 1];
		
		for (int i = 0; i < matrix.length; i++) {
			for (int j = 0; j < matrix[0].length; j++) {
				if (i == 0 || j == 0) {
					matrix[i][j] = 0;
				} else if (a.charAt(i - 1) == b.charAt(j - 1)) {
					// Get value diagonally from the left then add 1
					matrix[i][j] = matrix[i - 1][j - 1] + 1;
				} else {
					// Get Max value from left or top
					matrix[i][j] = Math.max(matrix[i - 1][j], matrix[i][j - 1]);
				}
			}
		}
		
		return matrix[m][n];
	}
	
	public static void main(String[] args) {
		String ans = "";
		Scanner scan  = new Scanner(System.in);
		int queries = scan.nextInt();
		scan.nextLine();
		for (int i = 0; i < queries; i++) {
			String a = scan.next();
			scan.nextLine();
			String b = scan.next();
			System.out.println(findLCS(a, b));
		}

	}

}



Measured memory_bytes: 64016
#include <iostream>
using namespace std;
void output(int array[],char w){
    for(int j = 0;j<13;j++){
        if(array[j] == 0){
            cout<<w<<" "<<j+1<<endl;
        }
    }
}

int main(){
    int n,number;
    char w;
    cin>>n;
    int S[13] = {0};
    int D[13] = {0};
    int H[13] = {0};
    int C[13] = {0};
    for(int i = 0;i<n;i++){
       cin>>w>>number;
       switch (w)
       {
       case 'S':
           S[number - 1] = 1;
           break;
       case 'D':
           D[number - 1] = 1;
           break;
       case 'H':
           H[number - 1] = 1;
           break;
       case 'C':
           C[number - 1] = 1;
           break;
       default:
           break;
       }
    }
    output(S,'S');
    output(H,'H');
    output(C,'C');
    output(D,'D');
    // for(int j = 0;j<13;j++){
    //     if(S[j] == 0){
    //         cout<<"S "<<j+1<<endl;
    //     }
    // }
    // for(int j = 0;j<13;j++){
    //     if(H[j] == 0){
    //         cout<<"H "<<j+1<<endl;
    //     }
    // }
    // for(int j = 0;j<13;j++){
    //     if(C[j] == 0){
    //         cout<<"C "<<j+1<<endl;
    //     }
    // }
    // for(int j = 0;j<13;j++){
    //     if(D[j] == 0){
    //         cout<<"D "<<j+1<<endl;
    //     }
    // }
    return 0;
}


Measured memory_bytes: 3080
amo = []
ybt = []
 
n = int(input())
for i in range(n):
  a, y = input().split()
  amo.append(a)
  ybt.append(y)
  
sum = 0
for i in range(n):
  if ybt[i] == "JPY":
    sum = sum + float(amo[i])
  else:
    sum = sum + float(amo[i])* 380000
    
print(sum)

Measured memory_bytes: 3060
#include <cmath>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

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

int
main()
{
  short n;
  cin >> n;
   
  if (n == 2) {
    cout << "YES" << endl;
    return 0;
  }

  short p[n];
  FOR(i,n)
    cin >> p[i];

  short swpindex[2][2];
  short nextindex = 0;
  for (int i = 1; i < n; ++i) {
    if (p[i] < p[i-1]) {
      //cout << "p[i-1]: " << p[i-1] << ", p[i]: " << p[i] << endl;
      if (nextindex == 2) {
        cout << "NO" << endl;
        return 0;
      }
      swpindex[nextindex][0] = i-1;
      swpindex[nextindex][1] = i;
      ++nextindex;
    }
  }
  if (nextindex == 0) {
    cout << "YES" << endl;
    return 0;
  }

  short max1, min2;
  max1 = max(p[swpindex[0][0]], p[swpindex[0][1]]);
  if (max1 == p[swpindex[0][0]]) max1 = swpindex[0][0];
  else max1 = swpindex[0][1];
  //cout << "max1 " << max1 << endl;

  min2 = min(p[swpindex[1][0]], p[swpindex[1][1]]);
  if (min2 == p[swpindex[1][0]]) min2 = swpindex[1][0];
  else min2 = swpindex[1][1];
  //cout << "min2 " << min2 << endl;

  std::swap(p[max1], p[min2]);
  FOR(i,n-1) {
    if (p[i] > p[i+1]) {
      cout << "NO" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n, m;
int cnt[50];

int main() {
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		
		cnt[a]++;
		cnt[b]++;
	}
	
	REP(i, n) printf("%d\n", cnt[i]);
	return 0;
}

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

int n, s;

int dfs( int a, int m, int c ){
    if(a == s && c == n) return 1;
    if(a > s || c > n) return 0;
    if(m > 9) return 0;
    int t = 0;
    for(int i = m; a+i <= s && i < 10; i++){
        t += dfs(a+i, i+1, c+1);
    }
    return t;
}

int main(){
    while( true ){
        cin >> n >> s;
        if( n == 0 && s == 0 ) break;
        cout << dfs(0, 0, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;

    int flag = 0;

    while(flag==0){
        //アリスのターン
        if((A+1)!=B && A<N){
            A++;
        }else if(A!=1){
            A--;
        }else{
            flag = -1;
            break;
        }

        //ボリスのターン
        if((B-1)!=A && 1<B)
            B--;
        else if(B!=N)
            B++;
        else
            flag = 1;
    }

    if(flag == -1)
        cout << "Borys" << '\n';
    else
        cout << "Alice" << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std; // ;?????????
int main(){
	int a,b,c,i,j=0;
	cin >> a >> b >> c;
	
	for (i=0; i<=b-a; i++){ //i<b-a?????¨????????¢?????????
		if (c % (a+i)==0) //==0??????????????¨????????¢?????????
			j++;
	}
	cout << j << endl;
	return 0;
}

Measured memory_bytes: 3108
house = Array.new(4, 0)
house.each_index do |i| house[i] = Array.new(3, 0) end
house.each_index do |i| house[i].each_index do |j| house[i][j] = Array.new(10,0) end end

gets.chomp.to_i.times do |i|
  a,b,c,d = gets.chomp.split.map(&:to_i)
  house[a-1][b-1][c-1] += d
end

house.each_index do |i|
  house[i].each do |j|
    puts " "+j*" "
  end
  puts "####################" if i < house.size - 1
end

Measured memory_bytes: 6108
s = list(input())
q = int(input())

count_rev = 0
state = True
front_s = []
for i in range(q):
    input_list = input().split()
    t = int(input_list[0])
    if t == 1:
        state = not state
        count_rev += 1
    elif t == 2:
        f = int(input_list[1])
        c = input_list[2]
        if f == 1 and state:
            front_s.append(c)
        elif f == 1 and not state:
            s.append(c)
        elif f == 2 and state:
            s.append(c)
        elif f == 2 and not state:
            front_s.append(c)

front_s.reverse()
new_s = front_s + s
if not state:
    new_s.reverse()
print(''.join(new_s))

Measured memory_bytes: 8728
#include<stdio.h>
 #include<string.h>
 int main()
 {
 	int i;
 	char a[200001],b[200001];
 	scanf("%s",a);
 	scanf("%s",b);
 	if(strcmp(a,b)==0)printf("0\n");
 	else
 	{
 		int sum=0;
 		for(i=0;a[i]!='\0';i++)
 		{
 			if(a[i]!=b[i])sum++;
		 }
		 printf("%d\n",sum);
	 }
 }

Measured memory_bytes: 2544
#ABC 041
N = int(input())
P= [ int(a) for a in (input().split())]
for i in range(len(P)):
    for j in range(len(P)):
        P_tmp=P.copy()
        if i!=j:
            P_tmp[j]=P[i]
            P_tmp[i]=P[j]
        if P_tmp ==sorted(P):
            print("YES")
            exit()
            break
    
print('NO')
        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a[N];
  
  for(int i = 0; i < N; i++){
  	cin >> a[i];
  }
  sort(a,a+N);
  cout << a[N-1] - a[0] << endl;
  
}

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

int main()
{
	int a[6],b[6],minn=10,poi=1;
	for(int i=1;i<=5;i++){
		scanf("%d",&a[i]);
		if((a[i]%10)!=0&&(a[i]%10)<minn){
			minn=a[i]%10;
			poi=i;
		}
		if((a[i]%10)!=0)b[i]=a[i]/10*10+10;
		else b[i]=a[i];
	}
//	cout<<endl<<endl;
//	for(int i=1;i<=5;i++)cout<<b[i]<<' ';
//	cout<<endl<<endl;
	int ans=0;
	for(int i=1;i<=5;i++)if(i!=poi)ans+=b[i];
	ans+=a[poi];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
s=input()
t=input()
sl=len(s)
tl=len(t)
dp=[[0 for i in range(tl+1)] for _ in range(sl+1)]

for i in range(sl):
    for j in range(tl):
        if s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1])
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j],dp[i][j+1])

ans=str()
while sl>0 and tl>0:
    if dp[sl][tl]==dp[sl-1][tl]:
        sl-=1
    elif dp[sl][tl]==dp[sl][tl-1]:
        tl-=1
    else:
        ans+=s[sl-1]
        sl-=1
        tl-=1

print(ans[::-1])



Measured memory_bytes: 120540
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let kazu: usize = read();
    let mut vec= Vec::new();

    for x in 0..kazu {
        let ans2: i32 = read();
        vec.push(ans2);
    }
    let mut sum:i32=0;
    for x1 in 0..(kazu-1) {
        let y1:i32 = vec[x1];
        for x2 in (x1+1)..(kazu) {
            let y2:i32 =vec[x2];
            sum += y1*y2;
        }
    }

    println!("{}",sum);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <utility>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;
int ochituitesosuuwokazoerunnda(int n,int sum, int ans) {
	sum += ans;
	if (n <= sum) {
		return ans;
	}
	ochituitesosuuwokazoerunnda(n, sum, ans + 1);
}
int main() {
	int sen;
	cin >> sen;
	cout << ochituitesosuuwokazoerunnda(sen,0,1);
}

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

using namespace std;

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)
#define srt(vec) sort(vec_all(vec))

// vectorデバッグ
template<typename T>
void dump_vec(vector<T> vec) {
    rep(i, vec.size()) {
        cout << i << ": " << vec[i] << endl;
    }
}

template<typename T, typename S>
void dump_dic(map<T, S> dic) {
    for (auto v : dic) {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main() {
    int n;
    ll k;
    cin >> n >> k;
    map<int, ll> dic;
    int tmp_1;
    ll tmp_2;
    rep(i, n) {
        cin >> tmp_1 >> tmp_2;
        dic[tmp_1] += tmp_2;
    }

    ll cnt = 0;
    repv(v, dic) {
        cnt += v.second;
        if (cnt >= k) {
            cout << v.first << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 4224
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
string s;
int a[26];
signed main() {
	while (getline(cin, s)) {
		for (int i = 0; i < s.size(); i++) {
			for (int j = 0; j < 26; j++) {
				if (s[i] == (char)('a' + j) || s[i] == (char)('A' + j)) {
					a[j]++;
				}
			}
		}
	}
	for (int i = 0; i < 26; i++) {
		cout << (char)('a' + i) << " : " << a[i] << endl;
	}
}


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

int N;
char S[101],T[101];
int ans = 10010;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf(" %c",S + i);
    for(int i = 0; i < N; i++)scanf(" %c",T + i);

    for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            if(j == i)ans = N * 2 - i;
            if(T[j] != S[N - 1 - i + 1 + j])break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
}
const int N=100+5;
ll a,b,c;
void input()
{
	a=read<ll>(),b=read<ll>(),c=read<ll>();
}
void work()
{
	write(b+min(a+b+1,c),'\n');		
}
int main()
{
	//file();
	input();
	work();
	return 0;
}



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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const int INF=1e9;

int main(){
	int N;
	cin >> N;
	vector<int> C(N-1), S(N-1), F(N-1);
	rep(i,N-1) cin >> C[i] >> S[i] >> F[i];
	vector<int> ans(N);
	ans[N-1]=0;
	rep(i,N-1){
		int time=0;
		for(int j=i; j<N-1; j++){
			int M=max(time,S[j]);
			time=(M+F[j]-1)/F[j]*F[j];			
			time+=C[j];			
		}
		ans[i]=time;
	}
	rep(i,N) cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
    int num;
    cin >> num;
    string a[num];
    int co[4];
    rep(i, 4){ 
        co[i] = 0;
    }
    rep(i, num){
        cin >> a[i];
        if(a[i] == "AC"){
            co[0]++;
        }else if(a[i] == "WA"){
            co[1]++;
        }else if(a[i] == "TLE"){
            co[2]++;
        }else{
            co[3]++;
        }
    }
    cout << "AC x " << co[0] << endl;
    cout << "WA x " << co[1] << endl;
    cout << "TLE x " << co[2] << endl;
    cout << "RE x " << co[3] << endl;
    return 0;
}

Measured memory_bytes: 6752
#include <stdio.h>

int main(void)
{
    int K, S;
    int X, Y;
    int diff;
    int cnt;

    scanf("%d %d", &K, &S);

    cnt = 0;
    for (X = 0; X <= K; ++X){
        for (Y = 0; Y <= K; ++Y){
            diff = S - X - Y;

            if (0 <= diff && diff <= K){
                ++cnt;
            }
        }
    }

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

    return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  	char s[4];
	cin >> s[0] >> s[1] >> s[2];
  	if(s[0] != s[1] || s[1]!=s[2]) cout << "Yes" << endl;
  	else cout << "No" <<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll n,i;
    scanf("%lld",&n);
    ll a[n];
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    for(i=0;i<n;i++){
        if(a[i]%2==0){
            if(a[i]%3==0 || a[i]%5==0){
            }else{
                break;
            }
        }
    }
    if(i==n) printf("APPROVED\n");
    else printf("DENIED\n");
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 12:32:15 2020

@author: shinba
"""
import sys

n,m = map(int,input().split())

if n >= int(m/2):
    print(int(m/2))
    sys.exit()
else:
    m -= 2*n
    print(n+int(m/4))

Measured memory_bytes: 2940
#include<iostream>
#include<map> 
using namespace std;
int n,k,q,a;
map<int,int> m;
int main()
{
	cin>>n>>k>>q;
	for(int i=0;i<q;i++)
	{
		cin>>a;
		m[a]++;
	}
	for(int i=1;i<=n;i++)
		if(k-(q-m[i])>0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;	
} 

Measured memory_bytes: 5376
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;


public class AtCoder {
    static long n, s;
    static void Main() {
        n = long.Parse(Console.ReadLine());
        s = long.Parse(Console.ReadLine());
        if (s == n) {
            Console.WriteLine(n + 1);
            return;
        }
        int rootn = (int)Math.Sqrt(n);
       for(int b = 1; b < rootn; b++) {
            if (b >= 2) {
                if (function(b, n) == s) {
                    Console.WriteLine(b);
                    return;
                }
            }
            
        }
       for(int p = rootn; p >= 1; p--) {
            long b = (long)(((n - s) / p) + 1);
            if (b  <2) {
                continue;
            }
            if (function(b, n) == s) {
                Console.WriteLine(b);
                return;
            }
        }
       
        Console.WriteLine(-1);
    }
    static long function(long b,long n) {
        if (n < b) {
            return n;
        }
        return function(b, n / b) + n % b;
    }

}




Measured memory_bytes: 2648
x1,y1,x2,y2=map(int,input().split())
x3=x2+(y1-y2)
y3=y2-(x1-x2)
x4=x3+(x1-x2)
y4=y3+(y1-y2)
Z=[str(x3),str(y3),str(x4),str(y4)]
print(' '.join(Z))

Measured memory_bytes: 61660
#include <stdio.h>

int main(int argc, char** argv){
	int n,x;
	int i,i_max,i_other_max;
	int j,j_max,j_other_max;
	int k;
	int ptn_cnt;

	for(;;){
		// Input
		scanf("%d%d", &n, &x);
		// Finish Check
		if( n == 0 && x == 0 ){
			break;
		}
		// Setup Search Range
		i_max = n - 2;
		i_other_max = x / 3 - 1;
		if( i_other_max < i_max ){
			i_max = i_other_max;
		}
		j_max = n -1;
		j_other_max = x / 2 - 1;
		if( j_other_max < j_max ){
			j_max = j_other_max;
		}
		// Search Pattern
		ptn_cnt=0;
		for(i=1;i<=i_max;i++){
			for(j=i+1;j<=j_max;j++){
				k = x - i - j;
				if( k > j && k <= n ){
					ptn_cnt++;
				}
			}
		}
		// Output Pattern Count
		printf("%d\n",ptn_cnt);
	}

	return 0;
}

Measured memory_bytes: 600
import java.util.*

fun main(args:Array<String>?): Unit {
    while(true){
        val (n, m, l) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0) return
        val town = Array(n){ Stack <Triple<Int, Int, Int>>()}
        val memo = Array(n){IntArray(l + 1){Int.MAX_VALUE}}
        repeat(m){
            val (a, b, d, e) = readLine()!!.trim().split(' ').map(String::toInt)
            town[a - 1].push(Triple(b - 1, d, e))
            town[b - 1].push(Triple(a - 1, d, e))
        }
        memo[0][l] = 0
        val queue = PriorityQueue<Triple<Int, Int, Int>>(compareBy(Triple<*, *, Int>::third))
        queue.add(Triple(0, l, 0))
        while(queue.isNotEmpty() && queue.peek().first != n - 1){
            val (current, money, enemy) = queue.poll()
            if (memo[current][money] == enemy){
                for ((to, distance, danger) in town[current]) {
                    if (money >= distance && memo[to][money - distance] > enemy) {
                        memo[to][money - distance] = enemy
                        queue.add(Triple(to, money - distance, enemy))
                    }
                    if (memo[to][money] > enemy + danger) {
                        memo[to][money] = enemy + danger
                        queue.add(Triple(to, money, enemy + danger))
                    }
                }
            }
        }
        println(memo.last().min())
    }
}


Measured memory_bytes: 64568