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

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()
#define fi first
#define se second

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;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int n, m;
int d[2][100][100]; // cost time

int main() {
	while (cin >> n >> m, n | m) {
		fill(d[0][0], d[2][0], INF);
		
		REP(i, n) {
			int a, b, c, t;
			scanf("%d %d %d %d", &a, &b, &c, &t);
			a--; b--;
			chmin(d[0][a][b], c);
			chmin(d[0][b][a], c);
			chmin(d[1][a][b], t);
			chmin(d[1][b][a], t);
		}
		
		REP(s, 2) {
			REP(k, m) REP(i, m) REP(j, m) chmin(d[s][i][j], d[s][i][k] + d[s][k][j]);
		}
		
		int k;
		scanf("%d", &k);
		while (k--) {
			int p, q, r;
			scanf("%d %d %d", &p, &q, &r);
			printf("%d\n", d[r][p - 1][q - 1]);
		}
	}
	return 0;
}

Measured memory_bytes: 3196
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, k = M()
for i in range(k):
    if i % 2 == 0:
        # 高橋くんの場合
        if a % 2 == 1:
            a -= 1
        b = b + a//2
        a = a//2
    else:
        if b % 2 == 1:
            b -= 1
        a = a + b//2
        b = b//2
print(a, b)

Measured memory_bytes: 74616
#include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    int t = n / 2;
    cout << fixed << setprecision(6) << (n - t) / (ld) n;
        
    return 0;
}  


Measured memory_bytes: 256
from operator import itemgetter
n, m = map(int, input().split())
lst = []
for i in range(n):
  lst.append(tuple(map(int, input().split())))
lst.sort(key=itemgetter(0))
res = 0
for i in range(n):
  if lst[i][1] <= m:
    m -= lst[i][1]
    res += (lst[i][0] * lst[i][1])
  else:
    res += (lst[i][0] * m)
    break
print(res)

Measured memory_bytes: 23672
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val s = next().toList()
    println(if (s.distinct().size == 3) "Yes" else "No")
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31792
#include <cmath>
#include <cstdio>
#include <iostream>
#include <cstring> 
#include<algorithm>
#include<numeric>
#include<vector>
#include<map>
#define lowbit(x) x&-x
#define il inline
#define mod 1000000007
#define inf 1000000000
#define maxn 10000005
#define maxprime 3000005
using namespace std;
typedef long long int ll;
int n;
char a[100005][15];
unsigned long long int res[100005];
map<ll,int>mp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",a[i]);
		sort(a[i],a[i]+10);
		for(int j=0;j<10;j++)res[i]=res[i]*26+(a[i][j]-'a');
		mp[res[i]]++;
	}
	ll ans=0;
	for(map<ll,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		ll tmp=it->second;
		ans+=tmp*(tmp-1)/2;
	}
	printf("%lld\n",ans);
	
}

Measured memory_bytes: 8704
import java.util.*;

public class Main{
	/**
	 * @param arr the current permutation
	 * @return true if succeeded, else false
	 * @author http://expnotes9.blog.fc2.com/blog-entry-224.html
	 */
	public static boolean nextPermutation(int[] arr){
		int n=arr.length;
		if(n==0||n==1)
			return false;
		int m1=n-2;
		int m2=n-1;
		// m1: find rightmost increasing element
		while(m1 >= 0){
			if(arr[m1]<arr[m1+1])
				break;
			m1--;
		}
		// is the last permutation?
		if(m1<0)
			return false;
		// m2: find strictly greater element to the left of m1
		while(arr[m2]<=arr[m1])
			m2--;
		// swap the m1-th and m2-th elements.
		int tmp;
		tmp=arr[m1];
		arr[m1]=arr[m2];
		arr[m2]=tmp;
		// reverse elements between (j+1) and (n-1), inclusive.
		m2=n-1;
		for(++m1;m1<m2;++m1,--m2){
			tmp=arr[m1];
			arr[m1]=arr[m2];
			arr[m2]=tmp;
		}
		return true;
	}
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(), a=s.nextInt(), b=s.nextInt(), c=s.nextInt();
		int[] v=new int[n];
		Arrays.setAll(v,i->s.nextInt());
		Arrays.sort(v);
		int r=Integer.MAX_VALUE;
		do{
			for(int i=1;i<n;i++){
				for(int j=i+1;j<n;j++){
					for(int k=j+1;k<=n;k++){
						int ta=0, tb=0, tc=0;
						for(int ii=0;ii<k;ii++){
							if(ii<i)
								ta+=v[ii];
							else if(ii<j)
								tb+=v[ii];
							else
								tc+=v[ii];
						}
						r=Math.min(r,(k-3)*10+Math.abs(a-ta)+Math.abs(b-tb)+Math.abs(c-tc));
					}
				}
			}
		}while(nextPermutation(v));
		System.out.println(r);
	}
}


Measured memory_bytes: 28908
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#define full(c) c.begin() c.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1);
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int max_digit = 0;
string make(string t)
{
    string ret = "";
    bool flag = true;
    for(int i = 0; i < t.size(); i++)
    {
        if(t[i] >= '0' && t[i] <= '9')
        {
            int j = i;
            int cnt = 0;
            string str = "";
            while(t[j] >= '0' && t[j] <= '9')
            {
                cnt++;
                j++;
                str += t[i];
                i++;
            }
            int tmp = max_digit - cnt;
            while(tmp--) ret += '0';
            ret += str;
        }
        ret += t[i];
    }
    return ret;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> vec;
    for(int i = 0; i <= n; i++)
    {
        string s;
        cin >> s;
        vec.push_back(s);
    }
    int cnt = 0;
    for(int i = 0; i < vec.size(); i++)
    {
        int tmp = 0;
        for(int j = 0; j < vec[i].size(); j++)
        {
            if(vec[i][j] >= '0' && vec[i][j] <= '9') cnt++;
            else cnt = 0;
            tmp = max(cnt, tmp);
        }
        max_digit = max(tmp, max_digit);
    }
    for(int i = 0; i < vec.size(); i++) vec[i] = make(vec[i]);
    for(int i = 1; i < vec.size(); i++)
    {
        bool ok = true;
        bool flag = false;
        for(int j = 0; j < min(vec[0].size(), vec[i].size()); j++)
        {
            if(vec[0][j] == vec[i][j]) continue;
            flag = true;
            if(vec[0][j] < vec[i][j]) break;
            else ok = false;
        }
        if(flag == false && vec[0].size() > vec[i].size()) ok = false;
        cout << (ok ? '+' : '-') << "\n";
    }
    return 0;
}





Measured memory_bytes: 10564
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;


int main() {
  LL N;
  std::cin >> N;
  typedef std::pair<LL,LL> P;
  std::vector<P> AB(N);
  for(LL i=0; i<N; i++) {
    std::cin >> AB[i].first >> AB[i].second;
  }

  std::sort( AB.begin(), AB.end(), [](const P& lhs, const P& rhs) {
    return ( lhs.second < rhs.second );
  });
  LL current = 0;
  bool ans = true;
  for(const P& ab: AB) {
    current += ab.first;
    if( current > ab.second ) {
      ans = false; break;
    }
  }
  if(ans) { std::cout << "Yes" << std::endl; }
  else { std::cout << "No" << std::endl; }

  return 0;
}



Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>

void
solver(int a, int b)
{
    if (a>9 || b>9 ) {
        printf("-1\n");
        return;
    }
    printf("%d\n", a*b);
    return;
}

int
main(int argc, char *argv[])
{
    int a, b;
    scanf("%d %d", &a, &b);
    solver(a, b);
    return 0;
}

Measured memory_bytes: 128
# https://atcoder.jp/contests/abc075/tasks/abc075_a

import itertools
import collections
import bisect

def main():
    A, B, C = map(int, input().split())
    if A == B:
        print(C)
    if C == B:
        print(A)
    if C == A:
        print(B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
S = str(input())
S_list = list(S)


S12 = int(S_list[0]+S_list[1])
S34 = int(S_list[2]+S_list[3])

flagYYMM = 0
flagMMYY = 0

if 1 <= S34 <= 12:
    flagYYMM = 1

if 1 <= S12 <= 12:
    flagMMYY = 1

if S12 > 13 and S34 == 00:
    flagMMYY = 0

if S34 > 13 and S12 == 00:
    flagYYMM = 0

if flagYYMM == 1 and flagMMYY == 1:
    print("AMBIGUOUS")

elif flagYYMM == 1:
    print("YYMM")

elif flagMMYY == 1:
    print("MMYY")

else:
    print("NA")

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

using namespace std;

int main()
{
    string a; cin >> a;
    int k = a.size();
    int wcnt = 0;
    for (auto &i: a)
    {
	if (i == 'o') ++wcnt;
    }

    if (15-k >= 8-wcnt)
	cout << "YES" << endl;
    else
	cout << "NO" << endl;

    return 0;
}


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

const int limit = 50;

int n, m;
 int a[limit], b[limit];

 bool graph[limit][limit];
 bool visited[limit];

void dfs(int v) {
 visited[v] = true;
 for (int v2 = 0; v2 < n; ++v2) {
 if (graph[v][v2] == false) continue;
 if (visited[v2] == true) continue;
 dfs(v2);
 }
 }

 int main(void) {

 cin >> n >> m;

 for (int i = 0; i < m; ++i) {
 cin >> a[i] >> b[i];
 a[i]--, b[i]--;
 graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
 }

 int ans = 0;

 for (int i = 0; i < m; ++i) {
 graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

 for (int j = 0; j < n; ++j) visited[j] = false;

 dfs(0);

 bool bridge = false;
for (int j = 0; j < n; ++j) if (visited[j] == false) bridge = true;
 if (bridge) ans += 1;
 graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
 }

 cout << ans << endl;

 return 0;
 }

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

const ll mod = 1e9 + 7;

int main() {
    ll N, K;
    cin >> N >> K;
    V<ll> A(N);
    for(auto &&ele : A) cin >> ele;
    ll each = 0;
    ll smaller = 0;
    for(ll i = 0; i < N; i++) {
        for(ll j = 0; j < N; j++) {
            if(A[i] <= A[j]) continue;
            smaller++;
            if(i < j) each++;
        }
    }
    ll ans = each * K % mod;
    ans += K * (K - 1) / 2 % mod * smaller % mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;


typedef vector<lint> vi;
int cnt;
vi A,B;
void rec(lint n){
  if(n==1){
    A={0},B={0};
    cnt=1;
    return;
  }
  if(n&1){
    rec(n/2);
    A.pb(cnt);
    B.pb(cnt);
    ++cnt;
  }else{
    rec(n-1);
    A.pb(cnt);
    B.insert(B.begin(),cnt);
    ++cnt;
  }
}
int main(){
  lint n;
  cin>>n;
  rec(n);
  vi ar;
  for(auto e:A) ar.pb(e);
  for(auto e:B) ar.pb(e);
  cout<<ar.size()<<endl;
  for(auto e:ar) printf("%lld\n",e+1);
  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    queue<int> que[3];
    char c;
    for(int i = 0; i < 3; i++){
        while(isalpha(c = getchar())){
            que[i].push(c - 'a');
        }
    }
    int player = 0;
    while(!(que[player].empty())){
        int t = que[player].front();
        que[player].pop();
        player = t;
    }
    printf("%c\n", player + 'A');
    return 0;
}


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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

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

    VI dis(5);
    int k;
    REP(i, 5)
    cin >> dis[i];
    cin >> k;
    sort(ALL(dis));
    cout << (dis[4] - dis[0] > k ? ":(" : "Yay!") << ln;

    return 0;
}


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

struct dice {
	array<int, 6> a;
	map<int, int> m;
};

int main()
{
	dice d[2];
	array<array<string, 6>, 6> tbl = {
		"", "2345", "4135", "1425", "3215", "",
		"3254", "", "0534", "5024", "", "2304",
		"1453", "5043", "", "", "0513", "4103",
		"4152", "0542", "", "", "5012", "1402",
		"2351", "", "5031", "0521", "", "3201",
		"", "3240", "1430", "4120", "2310", ""};

	for (auto &x: d) {
		int i = 0;
		for (int &y: x.a) {
			cin >> y;
			x.m[y] = i++;
		}
	}

	bool flag = false;
	int i = 2;
	for (auto c: tbl[ d[0].m[d[1].a[0]] ][ d[0].m[d[1].a[1]] ]) {
		if (d[0].a[c - '0'] != d[1].a[i++]) {
			flag = false;
			break;
		}
		flag = true;
	}

	cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;

int used[(int)(2e5+2)];
int A[(int)(2e5+2)];
int main(){
    LL N,K;
    cin>>N>>K;
    CLR(used);CLR(A);
    REP(i,N){
        int tmp;
        cin>>tmp;tmp--;
        A[i]=tmp;
    }
    int npos=0;
    vector<int>pre,rep;
    while(used[npos]<3){
        used[npos]++;
        if(used[npos]==1){
            pre.PB(npos);
        }else if(used[npos]==2){
            rep.PB(npos);
        }
        npos=A[npos];
    }
    vector<int>pre2;
    REP(i,SZ(pre)){
        if(pre[i]!=rep[0]){
            pre2.PB(pre[i]);
        }else{
            break;
        }
    }
    if(K<(LL)(SZ(pre))){
        cout<<pre[K]+1<<endl;
    }else{
        K-=(LL)(SZ(pre));
        LL lennum=SZ(rep);
        cout<<rep[K%lennum]+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 7104
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

answer = [max(A[0],A[1])]

list_sum = A[::2]
for i in range(1,len(list_sum)):
  list_sum[i] += list_sum[i-1]

for i in range(2,N):
  if i==2:
    answer.append(max(A[0],A[1],A[2]))
  elif i%2==0:
    answer.append(max(answer[-1], answer[-2]+A[i]))
  else:
    answer.append(max(answer[-2]+A[i], list_sum[(i-1)//2]))

print(answer[-1])

Measured memory_bytes: 34136
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

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

    vector<long long> a(n);
    vector<long long> b(n);
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i]; 
    }

    sort(a.begin(), a.end(), greater<long long>());

    long long maxv = a[0];
    long long maxv2 = a[1];

    for(long long i = 0; i < n; i++){
        if(b[i] != maxv){
            printf("%lld\n", maxv);
        }
        else{
            printf("%lld\n", maxv2);
        }
    }
    return 0;
}

Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int x = A + B;
  int y = C + D;
    if(x > y){
      cout << "Left" << endl;
    }
    else if(x == y){
      cout << "Balanced" << endl;
    }
  else if(x < y){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3620
import sys
from io import StringIO
import unittest


def resolve():
    k = int(input())
    s = input()

    # a, b = map(int, readline().split())
    # l = [list(map(int, readline().split())) for _ in range(n)]

    l = len(s)
    if l <= k:
        print(s)
    else:
        print(s[0:k] + '...')

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7
nikoandsolstice"""
        output = """nikoand..."""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """40
ferelibenterhominesidquodvoluntcredunt"""
        output = """ferelibenterhominesidquodvoluntcredunt"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16176
#include <iostream>
#include <vector>

int gcd(int x,int y){
    if(x % y == 0){
        return y;
    }
    return gcd(y, x % y);
}

int main(){
    using namespace std;
    int MAX_A = 1000000;
    vector<int> lp(MAX_A + 1,0);//最小の素因数をいれる(2以上をみていけばいい)
    vector<int> pr;//MAX_A以下の素数の集合
    int cnt=0;
    vector<int> count(MAX_A + 1,0);
    for(int i = 2; i <= MAX_A; i++){//線形時間で処理してくれる
        if(lp[i] == 0){
            lp[i] = i;
            pr.push_back(i);
        }
        for(int j = 0; j < pr.size()&& pr[j] <= lp[i]&& i * pr[j] <= MAX_A; j++){
            lp[i * pr[j]] = pr[j];//i * pr[j] == C(const)としてありえるi, jの組は高々一通りになるので、これは線形時間で処理される
        }
    }
    int N;
    cin >> N;
    vector<int> A(N);
    int GCD = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        GCD = gcd(GCD, A[i]);
    }
    if(GCD != 1){
        cout << "not coprime" << endl;
        return 0;
    }
    for(int i = 0; i < N; i++){
        while(A[i]>1){
            int div = lp[A[i]];
            if(count[div]){
                cout << "setwise coprime" << endl;
                return 0;
            }
            count[div]++;
            while(A[i] % div == 0){
                A[i] /= div;
            }
        }
    }
    cout << "pairwise coprime" << endl;
}


Measured memory_bytes: 15524
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

const INF: i64 = 1000 * 10000;

fn warshall_floyd(n: usize, mut edges: Vec<Vec<i64>>) -> usize {
    let mut prev = vec![vec![0; n]; n];
    for i in 0..n {
        for j in 0..n {
            prev[i][j] = i;
        }
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                if edges[i][k] + edges[k][j] < edges[i][j] {
                    edges[i][j] = edges[i][k] + edges[k][j];
                    prev[i][j] = prev[k][j];
                }
            }
        }
    }
    let mut used = HashSet::new();
    for start in 0..n {
        for goal in 0..n {
            let mut cur = goal;
            while cur != start {
                used.insert((min(prev[start][cur], cur), max(prev[start][cur], cur)));
                cur = prev[start][cur];
            }
        }
    }
    used.len()
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut edges: Vec<Vec<i64>> = vec![vec![INF; n]; n];
    for i in 0..m {
        let v = read_vec::<usize>();
        let (a, b, c) = (v[0] - 1, v[1] - 1, v[2] as i64);
        edges[a][b] = c;
        edges[b][a] = c;
    }
    println!("{}", m - warshall_floyd(n, edges));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
from collections import defaultdict
def explore(now,cnt):
    if cnt>W*H:#理論的にはW*H以下で全部回れるので
        a=0 #無駄なコード
    else:
        d[now]=1
        if now[1]+1<W:
            if not data[now[0]][now[1]+1]=="#":
                if not (now[0],now[1]+1) in d.keys():
                    explore((now[0],now[1]+1),cnt+1)
        if now[0]+1<H:
            if not data[now[0]+1][now[1]]=="#":
                if not (now[0]+1,now[1]) in d.keys():
                    explore((now[0]+1,now[1]),cnt+1)
        if now[0]-1>=0:
            if not data[now[0]-1][now[1]]=="#":
                if not (now[0]-1,now[1]) in d.keys():
                    explore((now[0]-1,now[1]),cnt+1)
        if now[1]-1>=0:
            if not data[now[0]][now[1]-1]=="#":
                if not (now[0],now[1]-1) in d.keys():
                    explore((now[0],now[1]-1),cnt+1)
    
while True:
    W,H=map(int,input().split())
    if W==0 and H==0:
        break
    data=[list(input()) for _ in range(H)]
    d=defaultdict()
    for i in range(H):
        for j in range(W):
            if data[i][j]=="@":
                start=(i,j)
                break
    now=start
    cnt=0
    explore(now,cnt)
    print(len(d.keys()))


Measured memory_bytes: 6400
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
x=[v[i]-c[i] for i in range(n)]
x.sort(reverse=True)
i=0
ans=0
while x[i]>0 :
    ans+=x[i]
    i=i+1
    if i==n:
        break
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#define max 1000
#include<stdlib.h>
#include<string.h>
int save_number[max];

int maximum(int a,int b){
    return (a>b)?a:b;
}
int lcs(char *x,char *y,int xlen,int ylen){
//printf("%dと%d\n",xlen,ylen);
   int length[xlen+1][ylen+1];
   for(int i=0;i<xlen+1;i++){
       for(int j=0;j<ylen+1;j++){
           if(i==0 || j==0){
               //いくつ同じものがあるのかカウントするもの
              length[i][j]=0;
            }
           //同じものならば
            else if(x[i-1]==y[j-1]){
                length[i][j]=length[i-1][j-1]+1;
                //printf("same\n");
            }else{//違ければ
                 length[i][j]=maximum(length[i-1][j],length[i][j-1]);
                 //printf("different\n");
            }
        }
   }
   //printf("%d\n",length[xlen][ylen]);
   return length[xlen][ylen];
}

int main(){
    char x[max],y[max];
    int num;
    scanf("%d",&num);
    for(int i=0;i<num;i++){
        scanf("%s",x);
        scanf("%s",y);
        /*
        int xlen=strlen(x);
        int ylen=strlen(y);
        printf("%d\n",lcs(x,y,xlen,ylen));
        */
        save_number[i]=lcs(x,y,strlen(x),strlen(y));
    }
    for(int i=0;i<num;i++){
        printf("%d\n",save_number[i]);
    }
    return 0;
}


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

long long n;
long long const inf=1LL<<60;
int main(){
    std::cin >> n;
    std::vector<long long> h(n),dp(n,inf);
    for (int i = 0; i < n; i++) {
        /* code */
        std::cin >> h[i];
    }
    dp[0]=0;
    for (int i = 1; i < n; i++) {
        /* code */
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1)chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    std::cout << dp[n-1] << std::endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 55;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> p){
    cout << p.first << " " << p.second << "\n";
}

bitset<n_max> bs(0);
ll n;
void dfs(vvl &graph, ll pos, ll pre = -1){
    bs[pos] = 1;
    rep(i,n){
        if(graph[pos][i] == 1 && i != pre && bs[i] == 0)dfs(graph, i, pos);
    }
}

int main(){
    ll m; cin >> n >> m;
    vector<vector<ll>> graph(n,vector<ll>(n,0));
    vector<Pll> edge(m);
    rep(i,m) {
        ll a,b;cin >> a >> b;
        a--;b--;
        graph[a][b] = graph[b][a] = 1;
        edge[i] = {a,b};
    }

    // print(graph);
    
    ll ans = 0;
    rep(i,m){
        bs &= 0;
        graph[edge[i].first][edge[i].second] = 0;
        graph[edge[i].second][edge[i].first] = 0;
        dfs(graph, 0);
        // debug(bs);
        if(bs.count() != n)ans++;
        graph[edge[i].first][edge[i].second] = 1;
        graph[edge[i].second][edge[i].first] = 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, k := scanInt(), scanInt()
	h := scanInts(n)

	dp := make([]int, n)
	for i := range dp {
		dp[i] = math.MaxInt32
	}
	dp[0] = 0

	for i := 0; i < n; i++ {
		for j := 1; j <= k; j++ {
			if i+j >= n {
				continue
			}
			dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]))
		}
	}
	fmt.Println(dp[n-1])
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 2816
A, B, C, X = [int(input()) for _ in range(4)]


ans = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if (500 * i + 100 * j + 50 * k) == X:
                ans += 1

print(ans)

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

using namespace std;

#define ll long long int 
#define F first
#define S second
#define pb push_back

const ll N = 1e5 + 10;
const ll M = 1e6 + 10;
const ll MOD =  1e9 + 7;
const ll INF = 1e9 + 10;
const ll INFtar = 1e18;
int n, a[N], b[N], dif[N], ans;
ll suma, sumb;
bool mrk[N];
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        suma += (ll)a[i];
    }
    for (int i = 0; i < n; i++){
        cin >> b[i];
        sumb += (ll)b[i];
        dif[i] = a[i] - b[i];
    }
    if (suma < sumb) return cout << "-1\n", 0;
    sort(dif, dif + n);
    int pntl = 0, pntr = n - 1;
    while (dif[pntl] < 0){
        ans ++;
        while (dif[pntl] < 0){
            if (dif[pntr] <= (-dif[pntl])){
                dif[pntl] += dif[pntr];
                dif[pntr] = 0;
                ans += (!mrk[pntr]);
                mrk[pntr] = 1;
                pntr--;
            }
            else if ((-dif[pntl]) < dif[pntr]){
                dif[pntr] += dif[pntl];
                dif[pntl] = 0;
                ans += (!mrk[pntr]);
                mrk[pntr] = 1;
            }
        }
        pntl ++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4816
#ABC064C
N=int(input())
A=[0 for i in range(9)]
C=[1,700,800,1200,1600,2000,2400,2800,3200][::-1]
for a in list(map(int,input().split())):
	for i in range(9):
		if C[i]<=a:
			A[8-i]+=1
			break
print(8-A[:-1].count(0)+(A[:-1].count(0)==8),8-A[:-1].count(0)+A[8])

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

        int AtasuB = A + B;
        int AhikuB = A - B;
        int AkakeruB = A * B;

        if (AtasuB < AhikuB) {
            if (AhikuB < AkakeruB) {
                System.out.println(AkakeruB);
                return;
            } else {
                System.out.println(AhikuB);
                return;
            }
        } else {
            if (AtasuB < AkakeruB) {
                System.out.println(AkakeruB);
                return;
            } else {
                System.out.println(AtasuB);
                return;
            }
        }
    }
}


Measured memory_bytes: 21716
#include<cstdio>
#include<algorithm>

using namespace std;

int n;
int m[51];
int x[51][11],y[51][11];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<=n;i++){
			scanf("%d",&m[i]);
			for(int j=0;j<m[i];j++){
				scanf("%d %d",&x[i][j],&y[i][j]);
			}
		}
		for(int i=1;i<=n;i++){
			if(m[0]!=m[i])continue;
			int flag2=0;
			for(int w=0;w<=3;w++){
				int flag=1;
				for(int j=0;j<m[0]-1;j++){
					int x1=x[0][j+1]-x[0][j],y1=y[0][j+1]-y[0][j];
					int x2=x[i][j+1]-x[i][j],y2=y[i][j+1]-y[i][j];
					if(w==0 && (x1!=x2 || y1!=y2))flag=0;
					if(w==1 && (x1!=y2 || y1!=-x2))flag=0;
					if(w==2 && (x1!=-x2 || y1!=-y2))flag=0;
					if(w==3 && (x1!=-y2 || y1!=x2))flag=0;
				}
				if(flag==1)flag2=1;
			}
			for(int w=0;w<=3;w++){
				int flag=1;
				for(int j=0;j<m[0]-1;j++){
					int x1=x[0][j+1]-x[0][j],y1=y[0][j+1]-y[0][j];
					int x2=x[i][m[0]-j-2]-x[i][m[0]-j-1],y2=y[i][m[0]-j-2]-y[i][m[0]-j-1];
					if(w==0 && (x1!=x2 || y1!=y2))flag=0;
					if(w==1 && (x1!=y2 || y1!=-x2))flag=0;
					if(w==2 && (x1!=-x2 || y1!=-y2))flag=0;
					if(w==3 && (x1!=-y2 || y1!=x2))flag=0;
				}
				if(flag==1)flag2=1;
			}
			if(flag2==1)printf("%d\n",i);
		}
		printf("+++++\n");
	}
	return 0;
}

Measured memory_bytes: 1044
#
# abc064 a
#
import sys
from io import StringIO
import unittest


def input():
    return sys.stdin.readline().rstrip()


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 3 2"""
        output = """YES"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 3 4"""
        output = """NO"""
        self.assertIO(input, output)


def resolve():
    r, g, b = map(int, input().split())
    if (100*r + 10*g + b) % 4 == 0:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16160
using System;

namespace ConsoleApplicationSample
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] a = new int[n];
            string[] st = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(st[i]);
            }

            Array.Sort(a);
            long sum = 0;
            sum = Sum(a, sum);

            Console.WriteLine("{0} {1} {2}", a[0], a[n-1], sum);

        }

        private static long Sum(int[] a, long sum)
        {
            foreach (var item in a)
            {
                sum += item;
            }
            return sum;
        }
    }

}

Measured memory_bytes: 12708
l = input().split()
N = int(l[0])
K = int(l[1])
P = 0
for i in range(1,N+1):
    score = i 
    times = K / score
    j = 0
    while times > 1 :    
        times = times / 2
        j += 1
    p = 1/N * ((1/2)**j)
    P += p
print(P)

Measured memory_bytes: 3060
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MAXN = 10000 + 10;

signed main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int m, n;
	cin >> n >> m;
	int A[MAXN], B[MAXN];
	for(int i = 0; i < n; i++) cin >> A[i];
	for(int i = 0; i < m; i++) cin >> B[i];
	sort(A, A + n, greater<int>());
	sort(B, B + m, greater<int>());
	int x = 0, y = 0, ans = 1;
	for(int i = n * m; i >= 1; i--) {
		if(A[x] == i && B[y] == i) {
			x++;
		   	y++;
		}else if(A[x] == i) {
			x++;
			ans = (ll)ans * y % MOD;
		}else if(B[y] == i) {
			y++;
			ans = (ll)ans * x % MOD;
		}else {
			ans = (ll)ans * max(0, x * y - n * m + i) % MOD;
		}
	}
	ans *= (x == n);
	ans *= (y == m);
	cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <stack>
 
using namespace std;
typedef long long ll;
string a,b;
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b;
	ll cnt=b.size();
	if (a==b)
	cout<<"0"<<endl;
	else 
	{
		for (ll i=0;i<a.size();i++)
		{
			ll ans=b.size();
			if (i+b.size()<=a.size())
			{
				for (ll j=i;j<i+b.size();j++)
				{
					//cout<<a[j]<<' '<<a[i]<<endl; 
					if (a[j]==b[j-i])
					ans--;
				}
			}
			//cout<<ans<<endl;
			cnt=min(cnt,ans);
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3656
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Tue Jan  8 23:48:31 2019
//
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N int
	fmt.Scan(&N)
	for _, c := range strconv.Itoa(N) {
		if c == '9' {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

const int MAXN = 405;
ll memo[MAXN][MAXN], a[MAXN], pref[MAXN];

ll dp(int l, int r) {
    if(l == r)
        return 0;
    if(memo[l][r] != -1)
        return memo[l][r];
    ll mn = LLONG_MAX;
    for(int i = l; i < r; i++)
        mn = min(mn, dp(l, i) + dp(i + 1, r));
    return memo[l][r] = mn + (pref[r] - pref[l - 1]);
}

int main() {
    int n;
    cin >> n;
    pref[0] = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    memset(memo, -1, sizeof memo);
    cout << dp(1, n) << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ":" << x << "\n"
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;

int main () {
	const int INF = pow(10, 9);
	int N; cin >> N;
	vi dp(N, INF); dp[0] = 0; // 足場i(0-ind)までたどり着くための最小コスト
	vi h(N); rep(i, N) cin >> h[i];
	dp[1] = abs(h[1] - h[0]);
	rep2(i, 2, N) dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	// rep(i, N) cout << dp[i] << " "; cout << endl;
	cout << dp[N - 1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,v,w,t,c;
	cin>>a>>v>>b>>w>>t;
	c=abs(a-b);
	if(c>(v-w)*t || v<=w){
		cout<<"NO"<<endl;
	}
	else{
		cout<<"YES"<<endl;
	}
return(0);
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, x=0, answer=0;
    string s;
    cin>>n>>s;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='I') x++;
        else x--;

        answer = max(answer, x);

    }
    cout<<answer;
    return 0;
}

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

int main(){
    ll N, W;
    cin >> N >> W;
    ll w[101], v[101];
    for(int i=1;i<=N;i++)
        cin >> w[i] >> v[i];
    w[0] = 0;
    v[0] = 0;

    // dp[i][j]：i番目までの品物で価値jを作れるときの重さの最小値
    ll dp[101][100001] = {};
    for(int i=0;i<=N;i++)
        for(int j=1;j<=N*1000;j++)
            dp[i][j] = LLONG_MAX;

    for(int i=1;i<=N;i++){   // N個の品物(N:1~100)
        for(int j=1;j<=N*1000;j++){  // 価値j(j:0~100000)
            ll a, b = LLONG_MAX;
            a = dp[i-1][j];
            if(j - v[i] >= 0 && dp[i-1][j-v[i]] != LLONG_MAX)
                b = dp[i-1][j-v[i]] + w[i];
            dp[i][j] = min(a, b);
        }
    }

    ll ans = 0;
    for(int i=1;i<=N;i++){   // N個の品物(N:1~100)
        for(int j=0;j<=N*1000;j++){  // 価値j(j:0~100000)
            if(dp[i][j] <= W && j > ans){
                // cout << "weight:" << dp[i][j] << ", value:"<< j << endl;
                ans = j;
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //freopen("data.in", "r", stdin);
  int k;
  string s;
  cin >> k >> s;
  s = (s.length() > k) ? s.substr(0, k) + "..." : s;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

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

    vector<int>h(n+1);
    rep(i,n)cin>>h[i];

    int cnt=0;

    rep(i,n)if(h[i]>h[i+1])cnt+=h[i]-h[i+1];

    cout<<cnt<<endl;


}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 500005
int main()
{
    int n,d,x,a;
    in(n);
    d=(n%100);
    x=(d/5)+min(1,d%5);
    a=(n/100);
    if(x<=a)
        out(1);
    else
        out(0);
}







Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        int nowA = a - b;

        int nowc = c - nowA;

        if ( nowc < 0) {
            System.out.print(0);
        }else {
            System.out.print(nowc);
        }

    }


}



Measured memory_bytes: 23124
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;

immutable int MAX = 10^^3+1;
immutable long MOD = 10^^9+7;
auto modinv = new long[](MAX);
auto f_mod = new long[](MAX);
auto f_modinv = new long[](MAX);
long[][] mem;
int N, A, B, C, D;

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x >= 1) {
        if (x % 2 == 1)
            ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}

long nck(int n, int k) {
    if (n < k) return 0;
    return f_mod[n] * f_modinv[n-k] % MOD * f_modinv[k] % MOD;
}

long dp(int g, int n) {
    if (n == 0) return 1;
    if (n < g) return 0;
    if (g > B) return 0;
    if (mem[g][n] >= 0) return mem[g][n];

    mem[g][n] = dp(g+1, n);
    foreach (i; C..D+1) {
        if (g * i > n) break;
        auto cnt =
            nck(n, g*i) * f_mod[g*i] % MOD
            * powmod(f_modinv[g], i, MOD) % MOD;
        cnt = cnt * f_modinv[i] % MOD;
        mem[g][n] = (mem[g][n] + dp(g+1, n-g*i)*cnt%MOD) % MOD;
    }
    return mem[g][n];
}

void main() {
    modinv[0] = modinv[1] = 1;
    foreach(i; 2..MAX) {
        modinv[i] = modinv[MOD % i] * (MOD - MOD / i) % MOD;
    }

    f_mod[0] = f_mod[1] = 1;
    f_modinv[0] = f_modinv[1] = 1;

    foreach(i; 2..MAX) {
        f_mod[i] = (i * f_mod[i-1]) % MOD;
        f_modinv[i] = (modinv[i] * f_modinv[i-1]) % MOD;
    }

    
    scanf("%d %d %d %d %d", &N, &A, &B, &C, &D);
    mem = new long[][](B+1, N+1);
    foreach (i; 0..B+1) fill(mem[i], -1);
    dp(A, N).writeln;
}


Measured memory_bytes: 8444
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

int main(){

  int n;
  cin >> n;

  vector<int> l = vector<int>(n);

  REP(i,n){
    cin >> l[i];
  }

  sort(l.begin(),l.end());

  int sum = 0;

  REP(i,n-1){
    sum += l[i];
  }

  if (l[n-1] < sum) {
    cout << "Yes" << endl;
    return 0;
  }else{
    cout << "No" << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    sort(L.begin(), L.end());
    int ans = 0;
    rep(a, N){
        for(int b = a + 1; b < N; b++){
            int count = 0;
            int ab = L[a] + L[b];
            int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
            r--;
            count = r - b;
            ans += count;
        }
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 3608