akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n;
    cin >> n;

    vector<Int> L;
    L.push_back(2);
    L.push_back(1);

    for (Int i = 2; i <= n; i++) {
        L.push_back(L[i - 1] + L[i - 2]);
    }

    cout << L[n] << endl;

    return 0;
}


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

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

	if (B - A <= 0)
	{
		cout << "delicious" << endl;
	}
	else if (B - A <= X)
	{
		cout << "safe" << endl;
	}
	else
	{
		cout << "dangerous" << endl;
	}


	return 0;
}

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

int main(void){
	vector<char> c(4);
	for (int i = 0; i < 4; ++i)
	{
		cin >> c[i];
	}
	sort(c.begin(), c.end());
	if(c[0] == c[1] && c[1] != c[2] && c[2] == c[3]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# 2019/09/15
# AtCoder Beginner Contest 141 - D

# Input
n, m = map(int, input().split())
a = list(map(int, input().split()))

# Sort
a.sort()
a.reverse()

divlist = list()
divlist.append(int(a[0] / 2)) # Case 0
idx = 1
zflg = False

for i in range(1, m):
    if idx < n:
        if divlist[0] < a[idx]:
            # 元のリストの値 > 割ったリストの先頭
            divlist.append(int(a[idx] / 2))
            idx = idx + 1
    
        else:
            # 元のリストの値 <= 割ったリストの先頭
            popval = divlist.pop(0)
            divlist.append(int(popval / 2))
    else:
        # 全て割引券を使っても余っているケース
        if divlist[0] <= 0:
            zflg = True
            break
        else:
            # 元のリストの値 <= 割ったリストの先頭
            popval = divlist.pop(0)
            divlist.append(int(popval / 2))

ans = 0
if zflg == False:
    # 割引券を使ったもの
    for i in range(len(divlist)):
        ans = ans + divlist[i]
    
    # 割引券を使わなかったもの
    for i in range(idx, n):
        ans = ans + a[i]

# Output
print(ans)


Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv)
{
	int h, n, a;
	int s = 0;
	scanf("%d %d", &h, &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a);
		s += a;
	}
	printf(s >= h ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	int a,b;
	cin>>s>>t>>a>>b;
	string tmp;
	cin>>tmp;
	if(tmp==s){
		if(a>0)cout<<--a<<" "<<b;
		else cout<<0;
	}
	if(tmp==t){
		if(b>0)cout<<a<<" "<<--b;
		else cout<<0;
	}
	return 0; 
} 

Measured memory_bytes: 256
r,g,b,n = map(int, input().split())
counter = 0

qr = n//r
for i in range(qr+1):
    qg = (n-i*r)//g
    for j in range(qg+1):
        if (n-i*r-j*g)%b == 0:
            counter += 1

print(counter)


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

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int MOD = 1000000007;
int N;
int a[310];
ld dp[310][310][310];
ld rec(int i, int j, int k) {
	if (dp[i][j][k] >= 0)return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0)return 0.0;
	ld res = 0.0;
	if (i)res += rec(i - 1, j, k)*i;
	if (j)res += rec(i + 1, j - 1, k)*j;
	if (k)res += rec(i, j + 1, k - 1)*k;
	res += N; res *= 1.0 / (i + j + k);
	return dp[i][j][k] = res;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N;
	int cnt = 0, cnt2 = 0, cnt3 = 0;
	rep(i, N) {
		cin >> a[i];
		if (a[i] == 1)cnt++;
		else if (a[i] == 2)cnt2++;
		else cnt3++;
	}
	rep(i, 310)rep(j, 310)rep(k, 310)dp[i][j][k] = -1;
	ld ans = rec(cnt, cnt2, cnt3);
	cout << fixed << setprecision(15) << ans << endl;
	return 0;
}

Measured memory_bytes: 469320
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 h = sc.nextInt();
		sc.close();

		System.out.println((a + b)*h/2);
	}
}


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

int main(){
	int change, pay, cnt;
	while(true){
		cin>>pay; if(pay==0) break;
		cnt=0;
		change = 1000 - pay;
		cnt+=  change / 500 ;
		cnt+= (change / 100) %5;
		cnt+= (change / 50)  %2;
		cnt+= (change / 10)  %5;
		cnt+= (change / 5)   %2;
		cnt+=  change 	   %5;
		cout<<cnt<<endl;
	}
	return 0;
}

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

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int M;
  cin>>M;
  int64_t ans=-1;
  int64_t sum=0;
  for(int i=0;i<M;i++){
  int64_t d,c;
    cin>>d>>c;
    sum+=d*c;
    ans+=c;
 } int64_t a=sum%9;
  if(a==0)
    a=9;
  ans+=(sum-a)/9;
  cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
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;}


int nextInt() { int x; scanf("%d", &x); return x;}

ll dp[20][2];

int main2() {
  const int INF = 1001001001;
  REP(i, 20) REP(j, 2) dp[i][j] = -INF;

  string s; cin >> s;
  while (s.size() < 20) s = "0" + s;

  dp[19][0] = 0;

  for (int k = 18; k >= 0; k--) {
    int e = s[19 - k] - '0';
    for (int d = 0; d <= 9; d++) {
      chmax(dp[k][1], dp[k+1][1] + d);
      if (e > d) {
        chmax(dp[k][1], dp[k+1][0] + d);
      }
      if (e >= d) {
        chmax(dp[k][0], dp[k+1][0] + d);
      }
    }
    // cout << k << ":" << e << ")" << dp[k][0] << " " << dp[k][1] << endl;
  }
  // cout << 0 << ":" << dp[0][0] << " " << dp[0][1] << endl;
  ll ans = 0;
  chmax(ans, dp[0][0]);
  chmax(ans, dp[0][1]);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<ctime> 
using namespace std;
int main()
{
    string s;
    int n,k;
    cin>>n>>k;
    cin>>s;
    s[k-1]+=32;
    cout<<s;
    return 0;
}

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

int main(){
    int h, w;
    while(cin >> h >> w && (h && w)){
        for(int i = 0; i < h; i++){
            if(i == 0 || i == h - 1) cout << string(w, '#') << endl;
            else cout << '#' << string(w - 2, '.') << '#' << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3136
M=10**9+7
N=int(input())
la=list(map(int,input().split()))
ans=0
for i in range(60):
    n0=0
    n1=0
    for j in range(N):
        if la[j]&1:
            n1+=1
        else:
            n0+=1
        la[j]>>=1
    ans=(ans+n0*n1%M*(2**i%M))%M
print(ans)


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

int main() {
  long long A, B, C;
  long long X, Y;
  std::cin >> A >> B >> C >> X >> Y;
  long long ans = 5000ll * 1000001ll;
  for (int i = 0; i <= std::max(X, Y) * 2; i += 2) {
    long long val = i * C;
    auto x = std::max(0ll, X - i / 2);
    auto y = std::max(0ll, Y - i / 2);
    val += x * A + y * B;
    ans = std::min(ans, val);
  }
  std::cout << ans << std::endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int k;
    cin >> k;
    queue<ll> q;
    for (int i = 1; i <= 9; i++)
    {
        q.push(i);
    }
    ll ans = 0;
    while (k--)
    {
        ll x = q.front();
        q.pop();
        if (x % 10 != 0)
        {
            q.push(x * 10 + (x % 10) - 1);
        }
        q.push(x * 10 + x % 10);
        if (x % 10 != 9)
        {
            q.push(x * 10 + (x % 10) + 1);
        }
        if (k == 0)
        {
            ans = x;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

vector<int> to[200005];
ll ans[200005];

void dfs(int v, int p=-1){
    for(int i:to[v]){
        if(i == p) continue; // 親ノードには戻らない
        ans[i] += ans[v];
        dfs(i,v);
    }
}

int main(){
    int N,Q;
    cin >> N >> Q;
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;   // ０始まりのために-1
        to[a].push_back(b);
        to[b].push_back(a); // aがbの親とは限らないので双方向に辺を張る
    }
    for(int i=0;i<Q;i++){
        int p;
        ll x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    dfs(0);

    for(int i=0;i<N-1;i++){
        cout << ans[i] << " ";
    }
    cout << ans[N-1] << endl;
    return 0;
}

Measured memory_bytes: 24320
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String str = input.readLine();
		int n = Integer.parseInt(str);
		str = input.readLine( );
		String[] strlist = str.split(" ");
		int[] list = new int[n];
		int count32 = 0;
		boolean[] check = new boolean[8];
		for(int i=0; i<n; i++){
			list[i] = Integer.parseInt(strlist[i]);
			if(list[i] < 3200){
				check[list[i]/400] = true;
			}else{
				count32++;
			}
		}
		int count = 0;
		for (boolean bl: check) {
			  if (bl) count++;
		}
		if(count == 0){
			count = 1;
			count32 = count32-1;
		}

		System.out.print(count+" ");
		System.out.println(count + count32);

	}
}


Measured memory_bytes: 19284
#include    <iostream>
#include    <string>
#include    <queue>
#include    <vector>
#include    <functional>

using namespace std;

int main() {
    int n;
    priority_queue< int, vector<int>, greater<int> > nabeatsu;

    cin >> n;
    // 出力をよく見ると、3の倍数と3の数字が含まれる数がリストとして出力されている
    // 但し、いきなりコーディングする際は最初の出力にも1文字分のスペースがついている点に注意
    
    for(int i = 1; i <= n; i++) {
        // 3の倍数かを判定
        if(i % 3 == 0)                      nabeatsu.push(i);
        // 3のつく数字かを判定
        else if(to_string(i).find('3') != -1) nabeatsu.push(i);
    }
    while(!nabeatsu.empty()) {
        cout << ' ' << nabeatsu.top();
        nabeatsu.pop();
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3276
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll cnt[55][26], ans[26];
int main() {
	ll n;
	string s;
	cin >> n;
	for (int i = 0; i < 26; i++)ans[i] = 100;
	for (int i = 0; i < n; i++) {
		cin >> s;
		for (int j = 0; j < s.size(); j++) {
			cnt[i][s[j] - 'a']++;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 26; j++) {
			ans[j] = min(ans[j], cnt[i][j]);
		}
	}
	for (int i = 0; i < 26; i++) {
		while (ans[i]) {
			char c = 'a' + i;
			cout << c;
			ans[i]--;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;

inline int read(){
	int x = 0, ch = getchar(), f = 1;
	while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

int n, a[3005];
VI E[3005];

int solve(int x, int f){
	for (int i = 0; i < E[x].size(); ++i)
		if (E[x][i] != f){
			if (a[x] > a[E[x][i]] && !solve(E[x][i], x)) return 1;
		}
	return 0;
}

int main(){
	n = read();
	for (int i = 1; i <= n; ++i) a[i] = read();
	for (int i = 0; i < n - 1; ++i){
		int a = read(), b = read();
		E[a].pb(b); E[b].pb(a);
	}
	for (int i = 1; i <= n; ++i)
		if (solve(i, 0)) printf("%d ", i);
	printf("\n");
	return 0;
}

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

int main(){
   int a,b,c,d,p;
   cin>>a>>b>>c>>d>>p;
   int t=d+(60-b);
   int y=(c-a-1)*60;
  t=t+y;
  t=t-p;
  cout<<t;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int n, a[55], b[55];
int solve() {
	sort(b+1, b+1+n);
	int ans = 0x3f3f3f3f;
	for (int i = 2; i <= n; i++) ans = min(ans, b[i]-b[i-1]);
	ans = min(ans, b[1]);
	ans = min(ans, 24-b[n]);
	return ans;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a+1, a+1+n);
	for (int i = 1; i <= n; i++) {
		if (i&1) b[i] = 24-a[i];
		else b[i] = a[i];
	}
	int ans = solve();
		for (int i = 1; i <= n; i++) {
		if (i&1) b[i] = a[i];
		else b[i] = 24-a[i];
	}
	ans = max(ans, solve());
	cout << ans << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

vs bubblesort(vs c, int n) {
    for (int i = 0; i < n; ++i) {
        for (int j = n-1; j >= i+1; --j) {
            if (c[j][1] - '0' < c[j-1][1] - '0') swap(c[j], c[j-1]);
        }
    }
    return c;
}

vs selectionsort(vs c, int n) {
    for (int i = 0; i < n; ++i) {
        int minj = i;
        for (int j = i; j < n; ++j) {
            if (c[j][1] - '0' < c[minj][1] - '0') {
                minj = j;
            }
        }
        if (minj != i) swap(c[minj], c[i]);
    }
    return c;
}

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

    int n;
    cin >> n;
    vs card(n);
    rep(i, n) cin >> card[i];
    auto res1 = bubblesort(card, n);
    auto res2 = selectionsort(card, n);
    bool stable = true;
    rep(i, n) if (res1[i] != res2[i]) stable = false;
    rep(i, n) cout << res1[i] << (i == n-1 ? '\n' : ' ');
    cout << "Stable" << endl;
    rep(i, n) cout << res2[i] << (i == n-1 ? '\n' : ' ');
    cout << (stable ? "Stable" : "Not stable") << endl;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI 3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007

map<string, int> m;




int main()
{
	FAST;
	ll n;
	ll i;
	cin >> n >> i;
	cout << n - i + 1;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ll i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();
    // #ifndef ONLINE_JUDGE
    // 	freopen("in.txt","r",stdin);
    // 	freopen("out.txt","w",stdout);
    // #endif

    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int div_time = 0;
    bool CanDiv = true;

    while(CanDiv){
        for(int i=0; i<N; i++){
            if(number[i]%2 == 1) CanDiv = false;
        }

        if(!CanDiv) break;

        for(int i=0; i<N; i++){
            number[i] /= 2;
        }

        ++div_time;
    }

    cout << div_time << endl;
}

Measured memory_bytes: 764
package main

import (
	"fmt"
)

func main() {
	var r,g,b int
	fmt.Scan(&r,&g,&b)

	if (100 * r + 10 * g + b) % 4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#define aaaa 1
#ifdef aaaa
    #include <bits/stdc++.h>
    #ifdef LOCAL
        #include "cxx-prettyprint-master/prettyprint.hpp"
        #define print(x) cout << x << endl
    #else
        #define print(...) 42
    #endif
    using namespace std;
    using ll = long long;
    #define INF 1'010'000'000'000'000'017LL
    #define mod 1000000007LL
    #define eps 0.0001
    #define all(x) (x).begin(), (x).end()
    #define FOR(i,a,b) for(ll i=(a);i<(b);++i)
    #define rep(i,n)  FOR(i,0,n)
    #define reverse(x) (x).rbegin(), (x).rend()
    #define SZ(x) ((ll)(x).size())
    #define sum(x) accumulate(ALL(x), 0LL)//?
    #define pb(x) push_back(x)
    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; }
    class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
    public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};
#endif
int main() { 
    ll N;
    cin >> N;
    map<ll, ll> m;
    ll a;
    rep(i, N){
        cin >> a;
        m[a]++;
        m[a+1]++;
        m[a-1]++;
    }
    ll res = (*max_element(all(m), [](pair<ll, ll> lhs, pair<ll, ll> rhs) {
    return rhs.second>lhs.second;
  })).second;
    cout << res << endl;
}

Measured memory_bytes: 6144
fun main(args: Array<String>) {
    val s = readLine()!!.split("").filter { it.isNotEmpty() }
    val t = readLine()!!.split("").filter { it.isNotEmpty() }

    println(op139a(s,t))
}

fun op139a(s: List<String>, t: List<String>): Int {
    return s.filterIndexed { index, string ->
        string == t[index]
    }.count()
}




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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ll a,b,c,k,ans=0;
	cin >> a >> b >> c >>k;
	if(k>a)
	{
		ans+=a;
		k-=a;
		//dbg(ans);
		//dbg(k);
		if(k>b)
		{
			k-=b;
			ans-=k;
		}
	}
	else
	{
		ans+=k;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3648
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<stack>
#include<cmath>
#include<vector>
using namespace std;

bool solve(vector<int> v)
{
	int maxp=0;
	for(int i=0;i<v.size();i++){
		if(i*10<=maxp){
		 maxp=max(maxp,v[i]+i*10);
		}else return false;
	}
	return 10*(v.size()-1)<=maxp;
}

int main(void){
	int N;cin>>N;
	vector<int> v,u;
	for(int i=0;i<N;i++){
		int x;cin>>x;v.push_back(x);
	}
	u=v;
	reverse(u.begin(),u.end());
	
	cout<<(solve(v)&&solve(u)?"yes":"no")<<endl;
	
	return 0;
}


Measured memory_bytes: 7600
# cf16-exhibition-final-openB - Inscribed Bicycle
def main():
    x1, y1, x2, y2, x3, y3 = map(int, open(0).read().split())
    x2 -= x1
    y2 -= y1
    x3 -= x1
    y3 -= y1
    a = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
    b = (x3 ** 2 + y3 ** 2) ** 0.5
    c = (x2 ** 2 + y2 ** 2) ** 0.5
    r = abs(x2 * y3 - x3 * y2) / (a + b + c)
    d = max(a, b, c)
    ans = r * d / (2 * r + d)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> p){
    rep(i,N){
        
        repf(j,i,N){
            bool flag=true;
            vec(q,0);
            //if(j==i)continue;
            rep(k,N){
                if(k==i)q.push_back(p[j]);
                else if(k==j)q.push_back(p[i]);
                else q.push_back(p[k]);
            }
            rep(k,N-1){
                if(q[k]>q[k+1]){
                    flag=false;
                    break;
                }
            }
            /*rep(k,N){
                cout<<q[k]<<" ";
            }*/
            //cout<<endl;
            if(flag) {
                op("YES")
                
                return;
            }
        }
    }
    op("NO")
    return;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  ll a[n];
  for(ll i=0;i<n;i++)cin >> a[i];

  ll s=1000,p=0;

  for(ll i=0;i<n-1;i++){
    if(a[i]<a[i+1]){
      p+=s/a[i];
      s=s%a[i];
    }
    else if(a[i]>a[i+1]){
      s+=p*a[i];
      p=0;
    }
  }
  s+=p*a[n-1];
  cout << s << endl;



}

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

int main() {
    int n;
    cin >> n;
    
    for(int i=0; i<n; ++i) {
        int y, m, d;
        cin >> y >> m >> d;
        int ans=0;
        ans += (y-1)/3 * 200 + ((y-1) - (y-1)/3)*195;
        if(y % 3 == 0) {
            ans += (m-1)*20 + d;
        } else {
            ans += ((m-1) - (m-1)/2)*20 + (m-1)/2*19 + d;
        }
        cout << 666*195+333*200 - ans + 1 << endl;
    }
}


Measured memory_bytes: 2976
import sys
[a,b,c]=list(map(int,input().split()))
[d,e,f]=list(map(int,input().split()))
[g,h,i]=list(map(int,input().split()))
#print(a,b,c,d,e,f,g,h,i)

if d-a == e-b and e-b == f-c and g-d == h-e and h-e == i-f:
    if b-a == e-d and e-d == h-g and c-b == f-e and f-e== i-h:
        print('Yes')
        sys.exit(0)
print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define maxn 25
char s[maxn];
int main(){
    int s,k;
    cin>>k>>s;
    long long ans=0;

        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                if(s-i-j<=k && s-i-j>=0)
                    ans++;
            }
        }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()
a = s.count("R")*s.count("G")*s.count("B")
b = 0
for i in range(0,n-1):
  for j in range(i+1,n-1):
    k = 2*j-i
    if k<=n-1:
      if s[i]!=s[j] and s[k]!=s[j] and s[i]!=s[k] :
        b += 1
print(a-b)

Measured memory_bytes: 9140
#include <stdio.h>
#include <stdlib.h>
int max(int a,int b);
int main(){
	int n,i,j,k;
	scanf("%d",&n);
	int point[n+10][3];
	int dp[n+10][3];
	dp[0][0]=0;
	dp[0][1]=0;
	dp[0][2]=0;
	for(i=1;i<=n;i++){
		scanf("%d %d %d",&point[i][0],&point[i][1],&point[i][2]);

		dp[i][0]=max(dp[i-1][2],dp[i-1][1])+point[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+point[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+point[i][2];
	}
	printf("%d\n",max(max(dp[n][0],dp[n][1]),dp[n][2]));

	
	
	

	return 0;
}
int max(int a,int b){
	if(a <b){
		return (b);
	}else{
		return (a);
	}
} 

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

int main() {

 
  vector<int> vec;

  vec = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }; 
int K;
  cin>>K;
  cout << vec.at(K-1) << endl; 


}


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

eatApple = -101

i = 1
sumApple = 0
while i <= N:
    now = L + i - 1
    if abs(now) < abs(eatApple):
        eatApple = now
    sumApple += now
    i += 1

print(sumApple - eatApple)

Measured memory_bytes: 3060
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


s = [ord(n) for n in S()]
t = [ord(n) for n in S()]

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i][j + 1])
        else:
            dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])

# 最長共通部分列の長さ
# print(dp[-1][-1])

ans = ''
i = len(s)
for j in range(len(t) + 1)[::-1]:
    if dp[i][j] != dp[i][j - 1]:
        if i == 0 or j == 0: break
        while dp[i][j] == dp[i - 1][j]:
            i -= 1
        ans += chr(t[j - 1])
        i -= 1

print(ans[::-1])


Measured memory_bytes: 113500
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
#define SORT(a) sort(a.begin(), a.end())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

int main(){
    int n;
    cin >> n;
    vi block;
    rep(i,n){
        int a ;
        cin >> a;
        a--;
        block.push_back(a);
    }
    int hakai = 0;
    rep(i,n){
        if(i - hakai != block[i]) hakai++;
    }
    if(hakai == n) hakai = -1;
    cout<<hakai<<endl;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    map<int, int> mp;
    mp[0] = 1;
    ll ans = 0, t = 0, k = 1;
    for(int i = n - 1; i >= 0; i--){
        t += (s[i] - '0') * k;
        k *= 10;
        t %= 2019;
        k %= 2019;
        ans += mp[t];
        mp[t]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3712
A,B,C,K = map(int,input().split())
if A + B + C == K:
    print(A - C)
elif (K >= A + B) and (K < A + B + C)  :
    print(A - K + A + B)
elif (K >=A and K < A + B):
    print(A)
else:
    print(K)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    string S, T;
    cin >> S >> T;
    ll ans = LONG_LONG_MAX;
    REP(i, S.length() - T.length() + 1){
        ll cnt = 0;
        REP(j, T.length()){
            if(S[i + j] != T[j]) cnt++;
        }
        ans = min(ans, cnt);
    }   
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

long gcd(long a, long b){
    if(a < b) swap(a, b);
    while(b != 0){
        long tmp = b;
        b = a%b;
        a = tmp;
    }
    return a;
}

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

int main(){
    long N, M;
    string S, T;
    cin >> N >> M;
    long a = lcm(N, M);
    long n = a/N;
    long m = a/M;
    cin >> S >> T;
    long b = lcm(n, m);
    for(int i = 0; i < a/b; i++){
        if(S[b*i/n] != T[b*i/m]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 512
// #define DEBUG

#include <bits/stdc++.h>
#define x first
#define y second
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define out(t, a) copy(all(a), ostream_iterator<t>(cout, " ")); cout << "\n";
#define int long long

using namespace std;

void set_program() {
	#ifdef DEBUG
		freopen ("test.in", "r", stdin);
		freopen ("test.out", "w", stdout);
		// freopen ("test.in", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pt;

const int ALF = 26;
const int LOGN = 20;
const int MOD = 998244353;
const int INF = 1e9;
const int MAXN = 1e5;

void solve() {
	int n, x, y;
	cin >> n >> x >> y;
	--x, --y;
	unordered_map <int, int> cnt;
	cnt.rehash(n);
	for (int s = 0; s < n; ++s) {
		deque <int> q;
		vector <int> d(n, INF);
		vector <int> used(n, 0);
		d[s] = 0;
		used[s] = 1;
		q.push_back(s);
		for (; q.size(); ) {
			int u = q.front();
			q.pop_front();
			if (u > 0) {
				int pr = (u - 1 + n) % n;
				if (!used[pr]) {
					used[pr] = 1;
					d[pr] = d[u] + 1;
					q.push_back(pr);
				}
			}
			if (u < n - 1) {
				int nx = (u + 1) % n;
				if (!used[nx]) {
					used[nx] = 1;
					d[nx] = d[u] + 1;
					q.push_back(nx);
				}
			}
			if (u == y) {
				swap(x, y);
			}
			if (u == x) {
				if (!used[y]) {
					used[y] = 1;
					d[y] = d[x] + 1;
					q.push_back(y);
				}
			}
		}
		// out(int, d);
		for (int f = 0; f < n; ++f) {
			if (s != f) {
				++cnt[d[f]];
			}
		} 
	}
	for (int i = 1; i < n; ++i) {
		cout << cnt[i] / 2 << "\n";
	}
}

signed main() {
	set_program();
	int t;
	#ifdef DEBUG
		// cin >> t;
		t = 4;
	#else
		// cin >> t;
		t = 1;
	#endif
	for (int num_test = 1; num_test <= t; ++num_test) {
		solve();
		cout << "\n";
	}
 	return 0;
}

Measured memory_bytes: 384
/*
 * =template=.cpp
 * Copyright (C) 2017 hzw <hzw@huzhenweideMacBook.local>
 *
 * Distributed under terms of the MIT license.
 */
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<signal.h>
#include<unistd.h>
#define FR first
#define SC second
#define MP make_pair
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define pb push_back
#define ws wss
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
void read(int &x)
{
	char ch;int fu=1;
	while ((ch=getchar())<=32);
	x=0;
	if (ch=='-') fu=-1;else x=ch-48;
	while ((ch=getchar())>32) x=x*10+ch-48;
	x*=fu;
}
template<class T> void upmax(T &a,T b) { if (a<b) a=b;}
template<class T> void upmin(T &a,T b) { if (a>b) a=b;}

//---------template--------------
const int N=1000100,p=998244353;
int n;
int main()
{
	scanf("%d",&n);
	int m=n*(n-1)/2;
	m-=n/2;
	printf("%d\n",m);
	for (int i=1;i<n;i++)
	for (int j=i+1;j<=n;j++)
	{
		if (n%2==0&&i+j==n+1) continue;
		if (n%2==1&&i+j==n) continue;
		printf("%d %d\n",i,j);
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

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

        var dict = new Dictionary<int, int>();
        for (int i = 0; i < n; i++)
        {
            var x = int.Parse(Console.ReadLine());
            if (dict.ContainsKey(x))
            {
                dict[x]++;
            }
            else
            {
                dict[x] = 1;
            }
        }

        var ans = 0;
        foreach (var item in dict)
        {
            if (item.Value % 2 == 1)
            {
                ans++;
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 20192
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int n = get<int>();
    vector<int> h(n);
    for (int i = 0; i < n; i++)
        h[i] = get<int>();
    vector<int> mins(h);
    for (int i = n-2; i >= 0; i--) {
        mins[i] = min(mins[i+1], mins[i]);
    }
    const char* ans = "Yes";
    for (int i = 0; i < n-1; i++) {
        if (h[i] - mins[i+1] >= 2) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
// スペルミス防止
#define al "Alice"
#define bo "Borys"
#define dr "Draw"

using namespace std;
// Problem https://atcoder.jp/contests/agc020/tasks/agc020_a

/**
 * 戦略:
 * <前提>互いに動かす度に二人の距離が+1か-1になる、つまり奇数・偶数を繰り返す 
 * <本文>最善手を取る(千日手にしない)とすれば
 *  A△B(△は1空白:距離2)→AB(空白無し:距離1)の盤面が発生
 *  この時どちらに手番が回っているかで勝敗が決まる
 *  もしこの盤面でAliceが手番ならBorysの頭を飛べない以上左へ一歩進むしか無い(距離2)、
 *  それをBorysが埋める(距離1)が繰り返される
 *  最終的にAliceが左端(マス1)、Borysがマス2になってAliceの負け
 *  逆にBorysの手番ならBorysが右へ一歩進む、先ほどの逆の動きが展開されて
 *  最終的にはBorysの負け
 *  <処理>
 *  <前提>に乗っ取れば、手番が来るタイミングが1(ABスタート),3,5,...になっていればBorysの勝ち
 *  2(A△Bスタート),4,6...になっていればAliceの勝ち
 *  これは最善手を取る場合は開始時の距離と同じ法則になる
 *  開始時の距離を求めて偶数ならAliceの勝ち奇数ならBorysの勝ちとすれば良い
 *  尚、Drawは千日手を狙う以外は無し
 **/
string solver(int alPlace,int boPlace){
    string result;
    result = dr;
    int dist;
    dist = boPlace-alPlace;
    if((dist%2)==0){
        result = al;
    }
    else{
        if((dist%2)==1){
            result = bo;
        }
        // 両方満たさない時のみ初期設定したDrawになる
    }
    return result;
}

int main(void){
    string answer;
    int N,A,B;
    cin >> N >> A >> B;
    answer = solver(A,B);
    cout << answer << endl;
    return 0;
}

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

using ll = long long;

int main(){
    ll n, x;
    std::cin >> n >> x;
    ll a, b = 0;
    std::cin >> a;
    ll cnt = 0;
    for(int i = 1; i < n; i++){
        std::cin >> b;
        // aとbをチェック
        if(a + b > x){
            // bから先に食べる
            ll tmp = std::min(a + b - x, b);
            cnt += tmp;
            b = b - tmp;
            // まだダメ
            if(a + b > x){
                tmp = a + b - x;
                cnt += tmp;
                a = a - tmp;
            }
        }
        a = b;
    }

    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
S = input()

p = [0] * (len(S) + 1)
m = [0] * (len(S) + 1)

for i in range(len(S)):
    if S[i] == '<':
        p[i + 1] = p[i] + 1

for i in range(len(S) - 1, -1, -1):
    if S[i] == '>':
        m[i] = m[i + 1] - 1

p = np.array(p, np.int64)
m = np.array(m, np.int64) * (-1)
answer = np.maximum(p, m)
print(answer.sum())

Measured memory_bytes: 43996
/* ex3_4
	kanon */

#include <stdio.h>

int main(void)
{

    //与えられる値を入れる変数を宣言
    int number;

    //変数に値を入力する
    scanf("%d", &number);

    //九九に含まれる値全てについてNと一致しないか調べる
    //一致すればflagを１にする、flagを使って答えの出力の場合分けをする
    int flag=0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==number){
                flag=1;
                break;
            }
        }

        if(flag){
            break;
        }
    }

    //答えの出力
    if(flag){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int N,Y;
  cin >> N >> Y;
  int init = Y / 1000;
  int Sa = init - N;
  int Sen = -1;
  int Gosen = -1;
  int Man = -1;
  for(int i = 0;i <= N;i++){
    for(int j = 0;j <= N;j++){
      if(i + j <= N && (i *4)+(j*9) == Sa ){
        Man = j;
        Gosen = i;
        Sen = N -j -i;
      }
    }
  }
  cout << Man << " " << Gosen << " " << Sen << endl;
  return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, a;
    cin >> h >> a;
    int ans = h / a;
    h = h - ans * a;
    if (h > 0) ++ans;
    cout << ans << endl;
    return 0;
}



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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl



int main(){
    ll h,w;
    cin >> h >> w;
    if(w==1||h==1)COUT(1);
    else COUT((h*w+1)/2);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
maxvalue = max(a)
maxindex = a.index(max(a))
for i in range(n):
    if i != maxindex:
        print(maxvalue)
    else:
        a_tmp = a[:]
        a_tmp.pop(maxindex) 
        print(max(a_tmp))

Measured memory_bytes: 14180
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

int main(void){
    int N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint sum=0;
    rep(i,N) sum+=A[i];
    sum%=MOD;
    lint ans=0;
    rep(i,N) ans=(ans+((sum-A[i]+MOD)*A[i]))%MOD;
    cout << (ans*500000004)%MOD << endl;
}

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

int main(){
	int n;
	cin >> n;
	long long int call=1,codd=1;
	for(int i=0; i<n; i++){
		int num;
		cin >> num;
		if(num%2==0){
			codd*=2;
		}
		call*=3;
	}
	cout << call-codd << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,i,j;
   string s;
   cin>>s;
   set<char>s1;
   for(i=0;i<s.length();i++) {
    s1.insert(s[i]);
   }
   if(s1.size() == 2) cout << "Yes";
   else cout << "No";
   cout << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

double r, g;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> r >> g;
	cout << g * 2 - r << "\n";
	return 0;
}

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

int main(){
	int m, f, r;
	
	while(1){
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1){
			break;
		}
		
		if(m == -1 || f == -1){
			cout << 'F' << endl;
		}else if(m + f >= 80){
			cout << 'A' << endl;
		}else if(m + f >= 65){
			cout << 'B' << endl;
		}else if(m + f >= 50){
			cout << 'C' << endl;
		}else if(m + f >= 30){
			if(r >= 50){
				cout << 'C' << endl;
			}else{
				cout << 'D' << endl;
			}
		}else{
			cout << 'F' << endl;
		}
	}
		
	return 0;	
}

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


int main() {
	int n, m; 
	while (cin >> n >> m, n) {
		P a[101];
		rep(i, n) {
			rep(j, m) {
				a[j].second = j + 1;
				int b; cin >> b;
				if (b)a[j].first++;
			}
		}
		stable_sort(a, a + m, [](P i, P j) {return i.first > j.first; });
		rep(i, m) {
			cout << a[i].second;
			if (i == m - 1)cout << endl;
			else cout << ' ';
		}
	}
	return 0;
}

Measured memory_bytes: 3016
#include<cstdio>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
const int N=200005;
int l,n,a[N]; long long pfx[N],sfx[N],ans;
int main()
{
	RI i; for (scanf("%d%d",&l,&n),i=1;i<=n;++i) scanf("%d",&a[i]);
	for (i=1;i<=n;++i) pfx[i]=pfx[i-1]+a[i]; for (i=n;i;--i) sfx[i]=sfx[i+1]+l-a[i];
	for (i=1;i<n;++i)
	ans=max(ans,2LL*a[i]+2LL*(pfx[i+n>>1]-pfx[i])+2LL*sfx[(i+n>>1)+1]-((n-i)&1?l-a[(i+n>>1)+1]:a[i+n>>1]));
	for (i=n;i>1;--i)
	ans=max(ans,2LL*(l-a[i])+2LL*(sfx[i+2>>1]-sfx[i])+2LL*pfx[(i+2>>1)-1]-((i-1)&1?a[(i+2>>1)-1]:l-a[i+2>>1]));
	return printf("%lld",max(ans,(long long)max(a[n],l-a[1]))),0;
}

Measured memory_bytes: 7696
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  inputStr = input[1].split(" ");
  var A = inputStr.map(inputStr => Number.parseInt(inputStr));  
  //回答格納用
  var ans = [];
  for(var i=0 ; i<N ; i++){
    ans.push(0);
  }
  //マップ処理
  for(var j=0 ; j<N ; j++){
    ans[A[j]-1] = j+1;
  }
  //引数に応じた結果を出力
  console.log(ans.join(" "));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

ll INF = 1LL << 60;

int 
main() {

  int N; cin >> N;
  vector<vector<int>> tree(N + 1);
  vector<map<int, int>> m(N + 1);
  rep(i, 0, N - 1){
    ll u, v, w; cin >> u >> v >> w;
    w = w % 2;
    tree[u].push_back(v);
    tree[v].push_back(u);
    m[u][v] = w;
    m[v][u] = w;
    m[u][u] = 0;
    m[v][v] = 0;
  }
  tree[0].push_back(1);
  tree[1].push_back(0);
  m[0][0] = 0;

  vector<bool> seen(N + 1, false);
  vector<int> ans(N + 1, 1);
  queue<int> q;
  q.push(0);
  seen[0] = true;
  while(!q.empty()){
    int node = q.front();
    q.pop();
    for(auto child : tree[node]){
      if(seen[child]) continue;
      m[child][child] += m[node][node];
      if(ans[child] != 0){
        if((m[node][child] + m[child][child]) %2 == 0)ans[child] = 0;
        else ans[child] = 1;
      }
      m[child][child] += m[node][child];
      seen[child] = true;
      q.push(child);
    }
  }

  rep(i, 1, N + 1){
    cout << ans[i] << endl;
  }

}

Measured memory_bytes: 27648
import Data.List.Split
data BoxKind = Box | Diamond | Rect deriving (Eq,Show)
check [a,b,c] = if a^2 + b^2 == c^2 then Rect
                                    else if a == b then Diamond
                                                   else Box

main = interact $ unlines.map show.countRectAndDiamond.map (check.map read.splitOn ",").lines

countRectAndDiamond list = cra [0,0] list

cra rd [] = rd
cra [r,d] (x:xs)
    | x == Rect = cra [r+1,d] xs
    | x == Diamond = cra [r,d+1] xs
    | x == Box  = cra [r,d] xs

Measured memory_bytes: 3772
<?php
fscanf(STDIN, "%d", $N);
$t = 1;
$ans = 0;
while (true) {
    if ($t * $t + $t < $N) {
        if (($N - $t) % $t === 0) {
            $ans += intdiv($N, $t) - 1;
        }
        $t++;
    } else {
        break;
    }
}
printf("%d", $ans);


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
 
	int in[2]={0};
	
	char tmp;
	int i,j;
	int count=0;
	int rev=0,num=0;
	scanf("%d %d",&in[0],&in[1]);
	
	for(i=in[0];i<=in[1];i++){
		
		num=i;
		rev=0;
		while(num>0){
			rev=rev*10+num%10;
			num/=10;
		}
		
		if(i==rev){
			count++;
		}
	}
	
	printf("%d",count);	
	
	return 0;
}

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

int n,resp=1e12+5;
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;

    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            resp=min(resp,i+(n/i));
        }
    }

    cout<<resp-2;



}

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


int block[20][20];
int memo[20][20];

int W,H;
int f(int x,int y){
	if( x > W || y > H ) return 0;
	if( block[x][y] ) return 0;
	if( x == W && y == H ) return 1;
	
	if( memo[x][y] != -1 ) return memo[x][y];
	else{
		int ans = 0;
		ans += f(x+1,y);
		ans += f(x,y+1);
		memo[x][y] = ans;
		return ans;
	}
}
int main(){
	while( cin >> W >> H && W ){
		for(int i = 0 ; i < 20 ; i++){
			for(int j = 0 ; j < 20 ; j++){
					block[i][j] = false;
					memo[i][j] = -1;
			}
		}
		int N;
		cin >> N;
		for(int i = 0 ; i < N ; i++){
			int x,y;
			cin >> x >> y;
			block[x][y] = true;
		}
		
		cout << f(1,1) << endl;
	}
}

Measured memory_bytes: 1164
from itertools import product

X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)

Measured memory_bytes: 147692
#include <algorithm>
 #include <iostream>
 #include <vector>
 using namespace std;
 typedef long long ll;
 const int INF = 1 << 30;
 const ll INFll = 1ll << 60;
 
 int main() {
   int a,b;
   cin >> a >> b;
   if(a%2 == 0 || b%2 == 0){
 	cout << "Even" << endl;
   }else {
     cout << "Odd" << endl;
   }
 	return 0;
 }

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

int main(){
    int n; string s;
    cin >> n >> s;
    
    int ans = 1;
    char c = s[0];
    for(int i = 1; i < s.size(); i++){
        if(s[i] == c) continue;
        c = s[i];
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512