akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N;
    cin >> N;
    ll sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0 && i % 5 == 0) {
            // FizzBuzz
        } else if (i % 3 == 0) {
            // Fizz
        } else if (i % 5 == 0) {
            // Buzz
        } else {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;
ll mod = 1000000007;
#define SIZE 500000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit() {
    inv[1] = 1;
    for (int i = 2; i <= SIZE; i++) {
        inv[i] = mod - (mod / i)*inv[mod%i] % mod;
    }
    kai[0] = invkai[0] = 1;
    for (int i = 1; i <= SIZE; i++) {
        kai[i] = kai[i - 1] * i%mod;
        invkai[i] = invkai[i - 1] * inv[i] % mod;
    }
}

ll com(ll a, ll b) {
    if (b < 0 || a < b) return 0;
    return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}

ll po(ll a, ll b) {
    if (b == 0)return 1;
    ll z = po(a, b / 2);
    z = z*z%mod;
    if (b % 2 == 1) z = z*a%mod;
    return z;
}

int main() {
    invinit();
    int n,k;
    scanf("%d %d",&n,&k);
    for (int i = 1; i <= k; i++) {
        ll ans = (com(n - k + 1, i) * com(k - 1, i - 1) + mod) % mod;
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int to_digit(char c) {
  return (int)(c-'0') + 0;
}

int main() {
  string S;
  cin >> S;
  int N = S.size();

  vector<int> Rem(N+1);
  Rem[0] = 1;
  rep(i, N)
    Rem[i+1] = (Rem[i] * 10) % 13;

  vector<vector<ll> > A(13, vector<ll>(N+1));
  A[0][0] = 1;
  rep(i, N) {
    if(S[i] == '?') {
      rep(k, 10) {
        int rem = (k * Rem[N-1-i]) % 13;
        rep(j, 13) {
          A[(j+rem)%13][i+1] += A[j][i];
          A[(j+rem)%13][i+1] %= mod;
        }
      }
    } else {
      int rem = (to_digit(S[i]) * Rem[N-1-i]) % 13;
      rep(j, 13) {
        A[(j+rem)%13][i+1] += A[j][i];
        A[(j+rem)%13][i+1] %= mod;
      }
    }
  }
  cout << A[5][N] << endl;
  return 0;
}


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

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

fn main(){
    let n = read();
    let mut a: Vec<u32> = (0..n).map(|_| read()).collect();
    a.sort_by(|x, y| x.cmp(y).reverse());
    let mut alice = 0;
    let mut bob = 0;
    for (i, &x) in a.iter().enumerate() {
        if i % 2 == 0 {
            alice += x;
        } else {
            bob += x;
        }
    }
    println!("{}", alice - bob);
}

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

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    
    string S;
    cin >> S;
    
    vector<int> v;
    int c = 0;
    char S_tmp = '1';
    
    for (int j = 0; j < N; j++) {
        if ((S[j] == '0' && S_tmp == '0') || (S[j] == '1' && S_tmp == '1')) {
            c++;
            S_tmp = S[j];
        }
        else if (S[j] == '1' && S_tmp == '0') {
            v.push_back(c);
            c = 1;
            S_tmp = S[j];
        }
        else if (S[j] == '0' && S_tmp == '1') {
            v.push_back(c);
            c = 1;
            S_tmp = S[j];
        }
    }
    v.push_back(c);
    
    int res = 0, res_tmp = 0;
    int counter = 0;
    for (int i = 0; i < v.size(); i += 2) {
        // cout << v[i] << endl;
        res_tmp = 0;
        for (int j = i; j < i + K * 2 + 1 && j < v.size(); j++) {
            res_tmp += v[j];
        }
        res = max(res, res_tmp);
    }
    cout << res << endl;
}

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

int main()
{
    int n,i,flag=0,x;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        if(x%2==0)
        {
            if(x%3!=0 && x%5!=0)
                flag=1;
        }
    }
    if(flag==0)
    cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n, m;
	cin >> n >> m;
	cout << n*(n-1)/2 + m*(m-1)/2 << endl;
	return 0;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll INF64 = 1e18;

template <typename T>
string to_string(const vector<T> &v) {
  string ret = "<";
  for (auto it : v)
    ret += to_string(it) + ", ";
  ret.pop_back(); ret.pop_back();
  ret += ">";
  return ret;
}

string to_string(const string &s) {
  return '"' + s + '"';
}

string to_string(bool b) {
  return b ? "true" : "false";
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

void debug_print() { cerr << endl; }

template <typename T, typename ...U>
void debug_print(T t, U... u) {
  cerr << " " << to_string(t);
  debug_print(u...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_print(__VA_ARGS__)
const int N = 1e5 + 5;

ll grid[3005][3005];
ll dp[3005][3005][4];

ll solve(ll i, ll j, ll k) {
  if (i == 0 || j == 0)
    return 0;
  ll &ret = dp[i][j][k];
  if (~ret)
    return ret;
  ret = 0;
  for (int t = 0; t <= 3; t++) {
    ret = max(ret, solve(i - 1, j, t) + (k > 0 ? grid[i][j] : 0));
  }
  if (k != 0) {
    ret = max(ret, solve(i, j - 1, k));
    ret = max(ret, solve(i, j - 1, k - 1) + grid[i][j]);
  }
  return ret;
}

int main() {
  SET(dp, -1);
  SET(grid, 0);
  ll r, c, k;
  cin >> r >> c >> k;
  for (int i = 0; i < k; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    grid[a][b] = c;
  }
  ll ret = 0ll;
  for (int i = 0; i <= 3; i++)
    ret = max(ret, solve(r, c, i));
  cout << ret << endl;
  return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a+b)%2==0) {
    cout << (a+b)/2 << endl;
  }
  else {
    cout << (a+b+1)/2 << endl;
  }
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll a[maxn]; 

int gcd(int a,int b)
{
    return b>0?gcd(b,a%b):a;
}

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
using Graph = vector<vector<T>>;

constexpr int lim = 1e5;
Graph<int> g, ng;
vector<bool> vis;
vector<int> parent;

void dfs(int n){
  if(!vis[n]){
    vis[n] = true;

    for(int i=0; i<g[n].size(); i++){
      bool skip = false;
      for(int j=0; j<ng[g[n][i]].size(); j++){
        if(!vis[ng[g[n][i]][j]]){
          skip = true;
          break;
        }
      }
  
      if(skip) continue;
      if(parent[g[n][i]] == 0)
        parent[g[n][i]] = n+1;

      dfs(g[n][i]);
    }
  }
}

int main(){
  int n, m; cin >> n >> m;
  g.resize(n); ng.resize(n);
  vis.resize(n, false);
  parent.resize(n, 0);

  vector<bool> isRoot(n, true);
  REP(i, n+m-1){
    int a, b; cin >> a >> b;
    a--; b--;

    g[a].emplace_back(b);
    ng[b].emplace_back(a);
    isRoot[b] = false;
  }

  int root = -1;
  REP(i, n){
    if(isRoot[i]) root = i;
  }
  assert (root != -1);

  dfs(root);

  REP(i, n){
    cout << parent[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 18432
N = int(input())
c = 0
s_min = 100
for _ in range(N):
  s = int(input())
  c += s
  if s % 10:
    s_min = min(s_min, s)

if c % 10:
  print(c)
elif s_min < 100:
  print(c - s_min)
else:
  print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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++)
using ll = long long;
using P = pair<int,int>;
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;}
const ll INF = 1LL<<60;




int main()
{
    int K;
    string S;
    cin >> K >> S;
    string ans;

    if(K >= S.size()) ans = S;
    else{
        ans = S.substr(0,K);
        string s1 = "...";
        ans += s1;
    }

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 3636
#include<stdio.h>

int f(int x){
	return x*x;
}

int area(int d){
	int i,s=0;
	for(i=0;i<(600/d);i++){
		s += d*f(d*i);
	}
	return s;
}

int main(void){
	int d;
	while(scanf("%d",&d) != EOF){
	printf("%d\n",area(d));
	}
	return 0;
}




Measured memory_bytes: 1988
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
ll minB = LLONG_MAX;
ll ans = 0;

signed main(){
    cin >> N;
    rep(i, N){
        ll A, B;
        cin >> A >> B;
        ans += A+B;
        if(A > B) minB = min(minB, B);
    }
    if(minB == LLONG_MAX) cout << 0 << endl;
    else cout << ans/2-minB << endl;
}

Measured memory_bytes: 3680
from collections import Counter
mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def update(x, y, new_value, dp):
    if 0 <= x < len(dp) and 0 <= y < len(dp):
        dp[x][y] = min(dp[x][y], new_value)

def main():
    n=int(input())
    print(1 - (n // 2) / n)

main()


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

int main(void){
  int a,b;
  cin >> a >> b;
  if(a <= 8 && b <= 8){
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  set<string> st;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    st.insert(s);
  }
  int ans = st.size();
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 19228
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
	cin >> s;
	int l = -1, r = -1;
	for(int i = 1; i < s.size(); i++) {
		if(s[i - 1] == s[i]) l = i, r = i + 1;
	}
	for(int i = 2; i < s.size(); i++) {
		if(s[i - 2] == s[i]) l = i - 1, r = i + 1;
	}
	cout << l << ' ' << r << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct T{
    int w, s, v;
    bool operator<(const T &t) const{
        if(s + w == t.s + t.w){
            return s < t.s;
        }
        return s + w < t.s + t.w;
    }
};

int n;
T a[1010];
int dp[20010], nxt[20010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 0, n){
        cin >> a[i].w >> a[i].s >> a[i].v;
    }
    sort(a, a + n);
    // rep(i, 0, n){
    //     cout << a[i].w << ' ' << a[i].s << ' ' << a[i].v << endl;
    // }
    rep(i, 0, 20010) dp[i] = -1;
    dp[0] = 0;
    rep(i, 0, n){
        rep(j, 0, 20010) nxt[j] = dp[j];
        rep(j, 0, a[i].s + 1){
            if(dp[j] == -1) continue;
            nxt[j + a[i].w] = max(nxt[j + a[i].w], dp[j] + a[i].v);
        }
        swap(dp, nxt);
    }
    int ans = *max_element(dp, dp + 20001);
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int main(){
	int m,d;
	while(cin >> m >> d){
		int cnt=0;
		for(int i=22;i<=d;i++){
			int x=i%10,y=i/10;
			if(x>=2&&y>=2){
			//	cout << j << " " << i << endl;
				if(x*y<=m)
					cnt++;
			}					
		}
		cout << cnt << endl;					
	}
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int X, Y;
    cin >> X >> Y;
    cout << ( X % Y == 0 ? -1 : X ) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int N=cin.nextInt();
        Console.WriteLine(180*N-360);
    }

}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}


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

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

#ifdef ONLINE_JUDGE
#define debug //HEs
#define whats //HEs
#define file //freopen("in.HEs", "r", stdin);freopen("out.HEs", "w", stdout);
#else
#define debug(x,...) printf(x,__VA_ARGS__)
#define whats(i) cout<<#i<<" = "<<i<<endl;
#define file freopen("out.HEs", "w", stdout);freopen("in.HEs", "r", stdin);
#endif


int main() {

	fast //file;

	int x, y;
	scanf("%d %d", &x, &y);

	int rry[111];

	int j = 0, s = 0, rslt = 0;

	for (int i = 0; i < x; ++i) {
  		//debug("%d %d\n", s, j);
		rslt += (s <= y);
		scanf("%d", &j);
		s += j;
		//		scanf("%d", rry + i);
		//		rry[i] += rry[i - 1];
	}
	rslt += (s <= y);

	printf("%d", rslt);
	
	return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int h, w, d, value, q, l, r;
  long long int count = 0;
  array<pair<int,int>, 90001> coords;
  array<int, 90001> distances;
  
  cin >> h >> w >> d;
  for (int i=1; i<=h; i++) {
    for (int j=1; j<=w; j++) {
      cin >> value;
      coords[value] = make_pair(i, j);
    }
  }
  
  for (int i=1; i<90001-d; i++) {
    if (distances[i+d]>0) break;
    for (int j=i; j<90001-d; j+=d) {
      count += abs(coords[j].first-coords[j+d].first)+abs(coords[j].second-coords[j+d].second);
      distances[j+d] = count;
    }
    count=0;
  }
  
  cin >> q;
  for (int i=0; i<q; i++) {
    cin >> l >> r;
    cout << distances[r]-distances[l] << endl;
  }
  
  return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  vi b = a;
  sort(rall(b));
  int mx = b[0];
  int mx2 = b[1];
  rep(i,n) {
    if(mx != a[i]) cout << mx << endl;
    else cout << mx2 << endl;
  }
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll k,n;
    cin>>k>>n;
    ll s=0;
    vector<ll> a(n+1);
    repA(i,1,n) cin>>a[i];
    repA(i,2,n) s+=a[i]-a[i-1];
    s+=(a[1]+k-a[n]);
    ll ans=INF;
    repA(i,1,n)
    {
        if(i==1)
        {
            ll temp=min(s-a[2]+a[1],s-(k-a[n]+a[1]));
            ans=min(ans,temp);
            continue;
        }
        if(i==n)
        {
            ll temp=min(s-a[n]+a[n-1],s-(k-a[n]+a[1]));
            ans=min(ans,temp);
            continue;
        }
        ll temp=min(s-a[i+1]+a[i],s-a[i]+a[i-1]);
        ans=min(ans,temp);
    }
    cout<<ans<<'\n';   
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

int A,B,C,D,E,F,ansx,ansy=0;
double maxi=0,temp;

int main(){
    cin>>A>>B>>C>>D>>E>>F;
    ansx=100*A;
    for(int i=0;i<=F;i+=100*A){
        for(int j=0;j<=F;j+=100*B){
            if((i+j)<=F){
                for(int k=0;k<=(i+j)/100*E;k+=C){
                    for(int l=0;l<=(i+j)/100*E;l+=D){
                        if((i+j+k+l)<=F&&(k+l)<=(i+j)/100*E){
                            temp=(double)(100*(k+l))/(double)(i+j+k+l);
                            if(temp>maxi){
                                maxi=temp;
                                ansx=i+j+k+l;
                                ansy=k+l;
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<ansx<<" "<<ansy<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)

	var sum int
	arr := make([]int, n)
	for i := range arr {
		fmt.Scan(&arr[i])
		sum +=arr[i]
	}
	sort.Ints(arr)

	fmt.Println(len(arr) + (x-sum)/arr[0])
}


Measured memory_bytes: 512
N,K=map(int,input().split())

if K==0:
  print(N**2)
else:
  ans=0
  for i in range(K+1,N+1):
    ans+=(N-N%i)//i*(i-K)
    ans+=N%i-K+1if N%i>=K else 0
  print(ans)

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

int main() {
    int N, K;
    cin >> N >> K;
 
    vector<int> D;
    for(int i = 0; i < K; i++) {
        int temp;
        cin >> temp;
        D.push_back(temp);
    }

    int result = 0;

    for(int i = N; i < 100000; i++) {
        int current_num = i;
        bool find = true;
//      for(int j = 0; j < 5; j++) {
        while(current_num != 0) {
            int digit = current_num % 10;
            for(int k = 0; k < D.size(); k++) {
                if(digit == D.at(k)) {
                    find = false;
                    break;
                }
            }
            current_num /= 10;
        }
        if(find) {
            result = i;
            break;
        }
    }

    cout << result << endl;

    return 0;
}

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

using namespace std;
typedef long long int ll;
vector<vector<int>>v;
int w,h;

int dh[8] = {1,1,0,-1,-1,-1,0,1};
int dw[8] = {0,1,1,1,0,-1,-1,-1};

void dfs(int i, int j, int num)
{
    v[i][j] = 0;
    for(int k = 0; k < 8; k++)
    {
        int ni = i + dh[k];
        int nj = j + dw[k];
        if(ni >= h || ni < 0 || nj >= w || nj < 0) continue;
        if(!v[ni][nj]) continue;
        dfs(ni,nj,num);
    }
}

int main()
{
    while(cin >> w >> h)
    {
        if(w == 0 && h == 0) break;
        v.resize(h);
        for(int i = 0; i < h; i++)
        {
            v[i].resize(w);
            for(int j = 0; j < w; j++) cin >> v[i][j];
        }
        int num = 0;
        for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) if(v[i][j]) num++, dfs(i,j,num);
        cout << num << endl;
    }
}


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

ans = ["-1"]*3
for a in range(N+1):
    if a*10000 > Y:
        break
    else:
        for b in range(N+1):
            if Y == a*10000 + b*5000 + (N-a-b)*1000 and (N-a-b) >= 0:
                ans = [str(a), str(b), str(N-a-b)]
                break
                
print(" ".join(ans))

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

int main() {
  int x,y;
  
  while(1){
      cin>>x>>y;
      if(x==0&&y==0) break;
      if(x>y){
          cout << y << " " << x<<endl;
      }else{
          cout <<  x << " " << y<<endl;
      }
  }
  

}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;

int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
  
    lli n,m;
    cin>>n;
    lli a[n];
    for(lli i=0;i<n;i++)cin>>a[i];
    lli ani=0;
	lli maxi=n+1;
	for(lli i=0;i<n;i++){
		//cout<<maxi<<endl;
		if(a[i]<=maxi){ani++;}
		maxi=min(maxi,a[i]);
	}
	cout<<ani;
    
}

Measured memory_bytes: 1792
N = int(input())
C1 = [0 for i in range(60)]
C0 = [0 for i in range(60)]

V = list(map(int, input().split()))
for n in V:
    i = 0
    for i in range(60):
        if (n % 2 == 1):
            C1[i] += 1
        else:
            C0[i] += 1
        n //= 2
MOD = int(pow(10, 9) + 7)
total = 0;
for i in range(60):
    total += pow(2, i) * C1[i] * C0[i]
    total %= MOD
print(total)
    


Measured memory_bytes: 125872
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
// g++ -std=c++11 -o2 -Wall filename.cpp -o filename
#define hell 1000000009
#define bug1(x) cout<<"$ "<<x<<" $"<<endl
#define bug2(x) cout<<"% "<<x<<" %"<<endl
#define bug3(x) cout<<"# "<<x<<" #"<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define tr(z) for(auto it=z.begin(); it!=z.end(); it++)
#define rloop(i,a,b) for(long long i=a; i>=b;i--)
#define loop(i,a,b) for(long long i=a; i<b; i++)
#define vbool vector< bool >
#define vvbool  vector< vector<bool> >
#define vchar vector<char>
#define vi vector<int>
#define vvi vector< vector<int> >
#define pll pair<long long, long long>
#define vll vector<long long>
#define vvl vector< vector<long long> >
#define ninf numeric_limits<long long>::min()
#define pinf numeric_limits<long long>::max()
#define comp(a,b) (abs(a-b)<1e-9) // to compare doubles
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    vector<vector<int>> days(N, vector<int>(3));
    loop(i, 0, N) {
        loop(j, 0, 3) {
            cin >> days[i][j];
        }
    }

    vector<vector<int>> dp(N, vector<int>(3));
    dp[0][0] = days[0][0];
    dp[0][1] = days[0][1];
    dp[0][2] = days[0][2];
    for (int i = 1; i < N; ++i) {
        dp[i][0] = days[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = days[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = days[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
    }
    cout << *max_element(dp.back().begin(),dp.back().end()) << "\n";
    return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
//#define i_7 (long long)(1E9+7)
long long p;
long long i_7 = p;

long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

//typedef long long ll;
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE=3000;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
    inv[1]=1;
    for(int i=2;i<=SIZE;i++){
        inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
    }
    
    kai[0]=invkai[0]=1;
    for(int i=1;i<=SIZE;i++){
        kai[i]=(kai[i-1]*i)%MOD;
        invkai[i]=(invkai[i-1]*inv[i])%MOD;
    }
}

long long comb(long long a, long long b){
    if(b<0 || a<b){
        return 0;
    }
    return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}

int main(){
  cin>>p;
  i_7 = p;
  MOD = p;
  invinit();
  long long b[p] = {};
  int a[p];
  REP(i,p){
    cin>>a[i];
  }
  REP(i,p){
    if(a[i] == 0)continue;
    b[0]++;
    b[0] = mod(b[0]);
    if(i==0){
      b[p-1]--;
      b[p-1] = mod(b[p-1]);
      continue;
    }
    long long coef = 1;
    REP(k,p){
      long long temp;
      temp = comb(p-1, k);
      //temp *= po(-i, p-1-k);
      temp *= coef;
      temp = mod(temp);
      b[k] -= temp;
      b[k] = mod(b[k]);
      //if(i==0)continue;
      coef *= inv[p-i];
      coef = mod(coef);
    }
  }
  REP(i,p){
    cout<<b[i]<<' ';
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+7;
const ll mod = 998244353;
#define afdafafafdafaf y1;
int ar[maxn], n, m;
ll mn[maxn << 2], val;
int x, y;
void update(int l, int r, int o){
    if(l >= x && r <= y){
        mn[o] = min(mn[o], val);
    }
    else{
        int mid = l + r >> 1;
        if(x <= mid)update(l, mid, o << 1);
        if(y > mid)update(mid+1, r, o << 1 | 1);
    }
}
ll que(int x){
    int l = 1, r = n, o = 1;
    ll ans = mn[1];
    while(l < r){
        int mid = l + r >> 1;
        if(x <= mid)r = mid, o = o << 1;
        else l = mid + 1, o = o << 1 | 1;
        ans = min(ans, mn[o]);
    }
    return min(ans, mn[o]);
}
pair<pair<int,int>, int> p[maxn];
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= (n << 2); i++)mn[i] = 1e18;
    x = 1, y = 1, val = 0;
    update(1, n, 1);
    for(int i=1;i<=m;i++){
        scanf("%d%d%d", &p[i].first.first, &p[i].first.second, &p[i].second);
    }
    sort(p + 1, p + m + 1);
    for(int i=1;i<=m;i++){
        int a = p[i].first.first, b = p[i].first.second, c = p[i].second;
        ll mid = que(a);
        x = a + 1, y = b, val = c + mid;
        update(1, n, 1);
    }
    ll ans = que(n);
    if(ans == 1e18)ans = -1;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4480
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int n;
  cin >> n;
  int numc = 0;
  for(int i=1;i<=n;i+=2){
    int counter = 0;
    for(int j=1;j<=i;j++){
      if(i%j==0) counter ++;
    }
    if(counter == 8) numc ++;
  }
  cout << numc << endl;
  return 0;
}


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

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

int xgcd(int a, int b, int c){
    return gcd(a, gcd(b, c));
}

int main(){
    int k;  cin >> k;
    int sum = 0;
    for(int a = 1; a <= k; a++){
        for(int b = 1; b <= k; b++){
            for(int c = 1; c <= k; c++){
                sum += xgcd(a, b, c);
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3600
a = int(input())
b = int(input())
c = int(input())
x = int(input())

t = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == (500 * i + 100 * j + 50 * k):
                t += 1
print(t)

Measured memory_bytes: 39536
#include <iostream>

using namespace std;

int H,W;
int k=0;
char a[110][110]={};

int main(){
  cin >> H >> W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<H;i++){
    k=0;
    for(int j=0;j<W;j++){
      if(a[i][j]!='#'){
        k++;
      }
    }
    if(k==W){
      for(int I=i;I<H-1;I++){
        for(int j=0;j<W;j++){
          a[I][j]=a[I+1][j];
        }
      }
      H=H-1;
      i--;
    }
  }

  for(int i=0;i<W;i++){
    k=0;
    for(int j=0;j<H;j++){
      if(a[j][i]!='#'){
        k++;
      }
    }
    if(k==H){
      for(int I=i;I<W-1;I++){
        for(int j=0;j<H;j++){
          a[j][I]=a[j][I+1];
        }
      }
      W=W-1;
      i--;
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << a[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> p(n);
  vector <ll> q(n);
  rep(i, n) cin >> p.at(i);
  rep(i, n) cin >> q.at(i);
  vector <ll> v(n);
  rep(i, n) v.at(i) = i+1;
  ll i = 0, a, b;
  do {
    i++;
    if (v == p) a = i;
    if (v == q) b = i;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var k, x int
	fmt.Scan(&k, &x)

	min := x - k + 1
	var result []int
	for ; min < x+k; min++ {
		result = append(result, min)
	}

	for _, v := range result {
		fmt.Printf("%s ", strconv.Itoa(v))
	}
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  int q;
  cin >> q;
  vi b(q), c(q);
  rep(i,q) cin >> b[i] >> c[i];
  vi cnt(1e5+5);
  ll ans = 0;
  rep(i,n) cnt[a[i]]++;
  rep(i,1e5+2) ans += 1LL * i * cnt[i];
  rep(i,q) {
    ans -= 1LL * b[i] * cnt[b[i]];
    ans += 1LL * c[i] * cnt[b[i]];
    cout << ans << endl;
    cnt[c[i]] += cnt[b[i]];
    cnt[b[i]] = 0;
  }
}

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

do = 0.006

diff_dict = {}

for i,Hi in enumerate(H):
    diff_dict[i+1] = abs(A - (T - Hi * do) )

# print(diff_dict)

k,v = sorted(diff_dict.items(), key=lambda x: x[1])[0]  # value

print(k)


Measured memory_bytes: 3188
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(  a < b )
		if(b < c  ){
		if(c > a  )
			cout<<a<<" "<<b<<" "<<c<<endl;
		}
	if(  a > b ){
		if( b < c )
		if( c > a )

		    cout<<b<<" "<<a<<" "<<c<<endl;
		}
	if(  a > b ){
		if( b > c )
		if( c < a )
		    cout<<c<<" "<<b<<" "<<a<<endl;
	}
    if(  a > b ){
	    if( b < c )
        if( c < a )
            cout<<b<<" "<<c<<" "<<a<<endl;
    }
    if(  a < b ){
        if( b > c )
        if( c > a )
            cout<<a<<" "<<c<<" "<<b<<endl;
	}
	if(  a < b ){
        if( b > c )
        if( c < a )
            cout<<c<<" "<<a<<" "<<b<<endl;
	}
    if(  a == b ){
	    if( b < c )
	        cout<<b<<" "<<a<<" "<<c<<endl;
    }
	if(  a < b ){
	    if( b == c )
	        cout<<a<<" "<<c<<" "<<b<<endl;
	}
	if(  a < b ){
		if( a == c )
			cout<<c<<" "<<a<<" "<<b<<endl;
	}
	if( a > b ){
		if( b == c )
	        cout<<c<<" "<<b<<" "<<a<<endl;
	}
	if( a == b ){
		if( b > c )
			cout<<c<<" "<<b<<" "<<a<<endl;
	}
	if( a > b ){
		if( a == c )
			cout<<b<<" "<<c<<" "<<a<<endl;
	}
	return 0;
    }

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll r, D, x; cin >> r >> D >> x;
  REP(i, 10) {
    x = r * x - D;
    cout << x << endl;
  }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int n;
	static int[] x;
	static int[] y;
	static int[] r;
	static int[] c;
	static boolean[][] cover;
	static byte[] dp;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			n = sc.nextInt();
			if (n==0) {
				break;
			}
			x = new int[n];
			y = new int[n];
			r = new int[n];
			c = new int[n];
			cover = new boolean[n][n];
			dp = new byte[(1<<n)];
			Arrays.fill(dp, (byte)-1);
			for(int i=0;i<n;i++) {
				x[i] = sc.nextInt();
				y[i] = sc.nextInt();
				r[i] = sc.nextInt();
				c[i] = sc.nextInt()-1;
				for(int j=0;j<i;j++) {
					int dx = x[j] - x[i];
					int dy = y[j] - y[i];
					int rs = r[i] + r[j];
					if (dx*dx+dy*dy<rs*rs) {
						cover[j][i] = true;
					}
				}
			}
			System.out.println(dfs(0));
		}
	}

	public static int dfs(int used) {
		if (dp[used]!=-1) {
			return dp[used];
		}
		int[][] canuse = new int[4][6];
		int[] canusenum = new int[4];
		for(int i=0;i<n;i++) {
			if (((1<<i)&used) == 0) {
				boolean flag = true;
				for(int j=0;j<i;j++) {
					if (((1<<j)&used) == 0 && cover[j][i]) {
						flag = false;
						break;
					}
				}
				if (flag) {
					canuse[c[i]][canusenum[c[i]]++] = i;
				}
			}
		}
		int ret = 0;
		boolean flag = false;
		for(int i=0;i<4;i++) {
			if (canusenum[i] >= 2) {
				for(int j=0;j<canusenum[i]-1;j++) {
					for(int k=j+1;k<canusenum[i];k++) {
						int usednext = used | (1<<canuse[i][j]) | (1<<canuse[i][k]);
						ret = Math.max(ret, dfs(usednext));
						flag = true;
					}
				}
			}
		}
		ret = flag ? ret + 2 : 0;
		dp[used] = (byte) ret;
		return ret;
	}

}

Measured memory_bytes: 238268
#include<bits/stdc++.h>
using namespace std;
int con(int a) {
  int s = (a * (a - 1)) / 2;
  return s;
}

int main() {
  int N, M; cin >> N >> M;
  int s = 0;
  s += con(N);
  s += con(M);
  cout << s << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int main(){
    int a,b,c,d,e,f;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    int wmax=100*a,smax=0;
    for(int n1=0;100*a*n1<=f;n1++){
        for(int n2=0;100*(a*n1+b*n2)<=f;n2++){
            if(n1==0&&n2==0)continue;
            int w=100*(a*n1+b*n2);
            for(int n3=0;w+c*n3<=f&&c*n3<=e*(a*n1+b*n2);n3++){
                //n4は(総重量)<=fかつ(溶け残りがない)を満たす操作4の最多回数
                //(総重量)=w+c*n3+d*n4<=f
                //(溶け残りがない) \iff c*n3+d*n4<=e*(a*n1+b*n2)
                int n4=std::max(0,std::min((f-w-c*n3)/d,(e*(a*n1+b*n2)-c*n3)/d));
                int s=c*n3+d*n4;
                //(濃度がより大きい) \iff 100*s/(w+s)>100*smax/(wmax+smax)
                if(s*(wmax+smax)>smax*(w+s)){
                    wmax=w;
                    smax=s;
                }
            }
        }
    }
    printf("%d %d",wmax+smax,smax);
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, k;
	cin >> n >> k;

	vector<vector<int>> ds(n);
	for (int i = 0; i < n; i++) {
		int t, d;
		cin >> t >> d;
		t--;
		ds[t].push_back(d);
	}

	vector<int> y0, y1;
	for (int i = 0; i < n; i++) {
		if (ds[i].size() == 0) {
			continue;
		}

		sort(begin(ds[i]), end(ds[i]));

		y1.push_back(ds[i].back());
		ds[i].pop_back();

		y0.insert(y0.end(), begin(ds[i]), end(ds[i]));
	}

	sort(y0.rbegin(), y0.rend());
	sort(y1.rbegin(), y1.rend());
	ll ans = 0;
	int Y = max(0, k - int(y0.size()));
	ll X = 0;
	for (int i = 0; i < Y; i++) {
		X += y1[i];
	}
	for (int i = 0; i < k - Y; i++) {
		X += y0[i];
	}

	while (true) {
		ans = max(ans, X + (ll)Y * Y);
		if (Y >= k || Y >= y1.size()) {
			break;
		}

		X += y1[Y];
		X -= y0[k - Y - 1];
		Y++;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6396
/*
 _____ ____ _____   ___   ___   ___   ___ 
|_   _/ __ \_   _| |__ \ / _ \ |__ \ / _ \
  | || |  | || |      ) | | | |   ) | | | |
  | || |  | || |     / /| | | |  / /| | | |
 _| || |__| || |_   / /_| |_| | / /_| |_| |
|_____\____/_____| |____|\___/ |____|\___/ 
*/
#include <bits/stdc++.h>
#include <fstream>
#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 a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
// assert(x==y); gives run time when false
using namespace std;
int main()
{
    char s;
    cin >> s;
    cout << (char)(s+1); 
}

Measured memory_bytes: 256