akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222



ll a[MAX], b[MAX];



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


  
  cin >> n;
  rep(i, n) cin >> b[i];
  rep(i, n) {
    if (i % 2) a[0] -= b[i];
    else a[0] += b[i];
  }
  FOR(i, 1, n) {
    a[i] = 2 * b[i - 1] - a[i - 1];
  }
  rep(i, n) cout << a[i] << " ";
  cout << endl;



  return 0;
}

Measured memory_bytes: 2944
from random import randint
import sys
input = sys.stdin.readline
INF = 9223372036854775808


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    コンテストi 0-indexed
    d 0-indexed
    """
    score = 0
    last = [0]*26  # コンテストiを前回開催した日
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]
    return score


def update_score(D, C, S, T, score, ct, ci):
    """
    ct日目のコンテストをコンテストciに変更する
    スコアを差分更新する

    ct: change t 変更日 0-indexed
    ci: change i 変更コンテスト 0-indexed
    """
    last = [0]*26  # コンテストiを前回開催した日
    for d in range(ct):
        last[T[d]] = d + 1
    prei = T[ct]  # 変更前に開催する予定だったコンテストi
    score -= S[ct][prei]
    score += S[ct][ci]
    for d in range(ct, D):
        if d != ct and T[d] == prei:
            break
        score += C[prei]*(d + 1 - ct - 1)
        score -= C[prei]*(d + 1 - last[prei])
    for d in range(ct, D):
        if d != ct and T[d] == ci:
            break
        score += C[ci]*(d + 1 - last[ci])
        score -= C[ci]*(d + 1 - ct - 1)
    return score


def evaluate(D, C, S, T, k):
    """
    d日目終了時点での満足度を計算し，
    d + k日目終了時点での満足度の減少も考慮する
    """
    score = 0
    last = [0]*26
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]

    for d in range(len(T), min(len(T) + k, D)):
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
    return score


def greedy(D, C, S):
    Ts = []
    for k in range(5, 13):
        T = []  # 0-indexed
        max_score = -INF
        for d in range(D):
            # d+k日目終了時点で満足度が一番高くなるようなコンテストiを開催する
            max_score = -INF
            best_i = 0
            for i in range(26):
                T.append(i)
                score = evaluate(D, C, S, T, k)
                if max_score < score:
                    max_score = score
                    best_i = i
                T.pop()
            T.append(best_i)
        Ts.append((max_score, T))
    return max(Ts, key=lambda pair: pair[0])


def local_search(D, C, S, score, T):
    for _ in range(2000):
        ct = randint(0, D-1)
        ci = randint(0, 25)
        ori = T[ct]
        T[ct] = ci
        new_score = calc_score(D, C, S, T)
        # 差分更新がバグってそう
        if score < new_score:
            score = new_score
        else:
            T[ct] = ori

    return T


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    init_score, T = greedy(D, C, S)
    T = local_search(D, C, S, init_score, T)
    for t in T:
        print(t+1)


Measured memory_bytes: 80572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int M = ni();
        int[] count = new int[N];
        for (int i = 0; i < M; i++) {
            int a = ni()-1;
            int b = ni()-1;
            count[a]++;
            count[b]++;
        }

        for (int i = 0; i < M; i++) {
            if(count[i]%2==1){
                out.println("NO");
                return;
            }            
        }
 
        out.println("YES");
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 54552
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll H, W, ans[55][55]={0};
    char S[55][55];
    in2(H, W);
    rep(i, H) ins(S+i);
    rep(i, H){
        rep(j, W){
            if(S[i][j]=='#') ans[i][j] = -1;
            else {
                for(ll k=-1; k<=1; k++){
                    ll I=i+k;
                    for(ll l=-1; l<=1; l++){
                        ll J=j+l;
                        if(0<=I && I<H && 0<=J && J<W && S[I][J]=='#')
                            ans[i][j]++;
                    }
                }
            }
        }
    }
    rep(i, H){
        rep(j, W){
            if(ans[i][j]==-1) printf("#");
            else printf("%lld", ans[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << 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;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int ans = INF;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    chmin(ans, a + b);
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define RG register
#define LL long long
using namespace std;
const int N=9e5+10;
int n,cnt,num=1;
LL h,w,col[N],ans[12],zro;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
//	freopen("Snuke's Coloring.in","r",stdin);
	read(h,w,n); zro=(h-2)*(w-2);
	for(RG int i=1,a,b;i<=n;i++)
	{
		read(a,b);
		for(RG int x=-2;x<=0;x++)
		 for(RG int y=-2;y<=0;y++)
		  if(a+x>0 && a+x<=h-2 && b+y>0 && b+y<=w-2)
		   col[++cnt]=(a+x-1)*(w-2)+(b+y);
	}
	sort(col+1,col+cnt+1);
	for(RG int i=1;i<=cnt;i++)
	 if(col[i]==col[i+1]) num++;
	 else ans[num]++, zro--, num=1;
	printf("%lld\n",zro);
	for(RG int i=1;i<10;i++) printf("%lld\n",ans[i]);
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    ll n,x,t;
    cin >> n >> x >> t;
    cout << (ll)ceil((double)n/x)*t << endl;
}



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

int main() {
    vector<int> s(3);
    for (int i = 0; i < 3; i++) {
        cin >> s[i];
    }

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

    cout << (s[0] * s[1]) / 2 << endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

map<string,bool> dp;

bool cat(string s)
{
    if(s=="") return true;
    if(dp.find(s)!=dp.end()) return dp[s];

    bool ret=false;

    if(s.size()>2 && s[0]=='m' && s[s.size()-1])
    {
        string t=s.substr(1,s.size()-2);
        rep(i,t.size())
        {
            if(t[i]=='e')
            {
                string x=t.substr(0,i);
                string y=t.substr(i+1);
                ret|=cat(x)&cat(y);
            }
        }
    }

    return dp[s]=ret;
}

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

    dp.clear();

    string ans="Rabbit";
    if(cat(s)) ans="Cat";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=1000005;
char ch[N];
int f,ans;
int c(int x,int y){
	if((x&1)<(y&1))return 0;
	if(x==0)return 1;
	return c(x/2,y/2);
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read();
	scanf("%s",ch);
	For(i,0,n-1){
		ch[i]-='1';
		if(ch[i]&1)f=1;
	}
	if(!f)For(i,0,n-1)ch[i]/=2;
	For(i,0,n-1)if(c(n-1,i))ans+=ch[i];
	cout<<((ans%2)<<(1-f))<<endl;
}


Measured memory_bytes: 1280
while True:
  goukei=0
  max=0
  min=1000

  n=int(input())
  if n==0:
     break
  else:
   for i in range (n):
     i=int(input())
     if i>max:
         max=i
     if i<min:
         min=i
     goukei=goukei+i 
     heikin=(goukei-max-min)//(n-2)
   print(heikin)


Measured memory_bytes: 5596
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	
	Scanner sc = new Scanner(System.in);
	
	void run() {
		
		long x,y,z;
		long first,second;
		long tmp;
		
		while (sc.hasNext()) {
			
			first = sc.nextLong();
			second = sc.nextLong();
			
			x = first;
			y = second;
			
			if (x<y) {
				tmp = x;
				x = y;
				y = tmp;
			}
			
			do {
				z = x % y;
				x = y;
				y = z;
			} while (z!=0);
			
			System.out.println(x + " " + first * second / x );
			
		}
		
	}
	
	public static void main(String[] args) {
		
		new Main().run();
		
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll df(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b - (a % b < 0);
}

ll dc(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b + (a % b > 0);
}

int n;
ll a, b, h[100000];

bool f(ll k)
{
    ll ua = 0;
    for (int i = 0; i < n; ++i)
        if (h[i] > k * b)
            ua += dc(h[i] - k * b, a - b);
    return ua <= k;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> a >> b;
    for (int i = 0; i < n; ++i)
        cin >> h[i];

    int lo = 1, hi = 1e9;
    while (lo < hi)
    {
        int mid = (lo + hi) / 2;
        if (f(mid))
            hi = mid;
        else
            lo = mid + 1;
    }
    cout << lo;
}


Measured memory_bytes: 1024
n = int(input())

city_list =[]
shop_list = []

for i in range(n):
	restaurant = input().split()
	shop_list.append(restaurant+[str(i+1)])
	city = restaurant[0]
	if city not in city_list:
		city_list.append(city)


city_list = sorted(city_list)
b = len(city_list)
for i in range(n):
	shop_list[i][0] = (b - 1 - city_list.index(shop_list[i][0]))
	shop_list[i][0] = shop_list[i][0] * 100 + int(shop_list[i][1])
	del shop_list[i][1]

shop_list= sorted(shop_list,reverse = True)

for i in range(n):
	print(shop_list[i][1])

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string s; cin >> s;
  ll n = s.size();
  if (s[n-1] == 's') {
    cout << s << "es" << endl;
  }else {
    cout << s << "s" << endl;
  }

  return 0;
}



Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

ll S;

ll llSqrt(ll n) {
    ll i;
    for (i = 1; n > 0; i++) {
        n -= i * 2 + 1;
    }
    return i - 1;
}

int main() {
    cin >> S;
    ll sq = llSqrt(S);

    if (S != sq * sq) sq++;
    ll x1 = sq;
    ll y2 = sq;

    ll x2 = sq * sq - S;
    ll y1 = 1;

    cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
    return 0;
}


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

using i64 = int64_t;

using Graph = vector<vector<int>>;

vector<int> topological_sort(const Graph &graph){
    vector<int> indegree(graph.size());
    for(auto edges: graph){
        for(auto to: edges){
            indegree[to]++;
        }
    }

    stack<int> st;
    for(int i=0;i<graph.size();i++){
        if(indegree[i] == 0)
            st.push(i);
    }

    vector<int> res;
    while(!st.empty()){
        int idx = st.top(); st.pop();
        res.push_back(idx);
        for(auto to: graph[idx]){
            indegree[to]--;
            if(indegree[to] == 0){
                st.push(to);
            }
        }
    }

    return res;
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(n-1));
    for(int i=0;i<n;++i){
        for(int j=0;j<n-1;++j){
            cin >> v[i][j];
            v[i][j]--;
        }
    }
    map<pair<int, int>, int> mp;
    int num = 0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            mp[make_pair(i, j)] = num;
            num++;
        }
    }
    Graph graph(num, vector<int>());
    for(int i=0;i<n;++i){
        for(int j=0;j<n-2;++j){
            auto p = make_pair(min(i,v[i][j]), max(i,v[i][j]));
            auto p2 = make_pair(min(i,v[i][j+1]), max(i,v[i][j+1]));
            graph[mp[p]].push_back(mp[p2]);
        }
    }
    auto res = topological_sort(graph);
    if(res.size() != num){
        cout << -1 << endl;
        return 0;
    }
    vector<int> dp(num, 1);
    int ans = 0;
    for(auto node: res){
        for(auto to: graph[node]){
            dp[to] = max(dp[to], dp[node]+1);
        }
        ans = max(ans, dp[node]);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  int water = a*100;
  int sugar = 0;
  double per = 0;
  for(int i = 0; i < 30; i++){
    for(int j = 0; j < 31; j++){
      for(int k = 0; k < 40; k++){
        for(int l = 0; l < 750; l++){
          double w = a*100*i + b*100*j + c*k + d*l;
          double s = c*k + d*l;
          if(w > 0){
            double p = s / w * 100;
            if(w <= f && s <= ((w - s) * e / 100)){
              if(per <= p){
                water = w;
                sugar = s;
                per = p;
              }
            }
          }
        }
      }
    }
  }
  
  cout << water << " " << sugar << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	double l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,v1,v2;
	char c;
	while(cin>>l1>>c>>l2>>c>>l3>>c>>l4>>c>>l5>>c>>l6>>c>>l7>>c>>l8>>c>>l9>>c>>l10>>c>>v1>>c>>v2){
		double total_l=l1+l2+l3+l4+l5+l6+l7+l8+l9+l10;
		double t=total_l/(v1+v2);
		double pos=v1*t;
		if(pos<=l1) cout << 1 << endl;
		else if (pos<=l1+l2) cout << 2 << endl;
		else if (pos<=l1+l2+l3) cout << 3 << endl;
		else if (pos<=l1+l2+l3+l4) cout << 4 << endl;
		else if (pos<=l1+l2+l3+l4+l5) cout << 5 << endl;
		else if (pos<=l1+l2+l3+l4+l5+l6) cout << 6 << endl;
		else if (pos<=l1+l2+l3+l4+l5+l6+l7) cout << 7 << endl;
		else if (pos<=l1+l2+l3+l4+l5+l6+l7+l8) cout << 8 << endl;
		else if (pos<=l1+l2+l3+l4+l5+l6+l7+l8+l9) cout << 9 << endl;
		else if (pos<=total_l) cout << 10 << endl;
	}
	return 0; 
}

Measured memory_bytes: 1224
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int A[3][3], bingo[3][3] = {};
    int N;
    Fp(i, 0, 3){
        Fp(j, 0, 3){
            cin >> A[i][j];
        }
    }
    cin >> N;
    int b;
    Fp(i, 0, N){
        cin >> b;
        Fp(j, 0, 3){
            Fp(k, 0, 3){
                if(A[j][k] == b){
                    bingo[j][k] = 1;
                }
            }
        }
    }
    int judge = 0;
    Fp(i, 0, 3){
        if(bingo[i][0] && bingo[i][1] && bingo[i][2]) judge = 1;
        if(bingo[0][i] && bingo[1][i] && bingo[2][i]) judge = 1;
    }
    if(bingo[0][0] && bingo[1][1] && bingo[2][2]) judge = 1;
    if(bingo[0][2] && bingo[1][1] && bingo[2][0]) judge = 1;
    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define dcout cout<<fixed<<setprecision(20)
#define Accepted_MAGIC cin.tie(0);ios::sync_with_stdio(false);cerr << "compiled" << endl

// typedef long long ll;
using Real = long double;
#define int long long

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
constexpr Real eps = 1e-9, pi = acos(-1);

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

signed main(void){
  Accepted_MAGIC;
  
  int N, P; string S; cin >> N >> P >> S;
  if(P == 2){
    int ans = 0;
    REP(i, N){
      int d = S[i]-'0';
      if(d % 2 == 0) ans += i+1;
    }
    cout << ans << endl;
    return 0;
  }
  if(P == 5){
    int ans = 0;
    REP(i, N){
      int d = S[i]-'0';
      if(d % 5 == 0) ans += i+1;
    }
    cout << ans << endl;
    return 0;
  }
  int back[200000] = {};
  int pow[200000] = {};
  pow[0] = 1;
  RANGE(i, 1, N){
    pow[i] = (pow[i-1] * 10) % P;
  }
  int tmp = 0;
  RREP(i, N){
    tmp += (S[i]-'0') * pow[N-1-i];
    tmp %= P;
    back[i] = tmp;
    // cerr << i << ": " << back[i] << endl;
  }
  int cnt[10000] = {};
  REP(i, N) cnt[back[i]]++;
  int ans = 0;
  REP(i, P){
    if(cnt[i] >= 2){
      ans += cnt[i]*(cnt[i]-1) / 2;
    }
  }
  cout << ans + cnt[0] << endl;
}

Measured memory_bytes: 3732
#include <stdio.h>

int main(void)
{
	int a, b;
	int s, l;
	
	scanf("%d", &a);
	scanf("%d", &b);
	
	s = a * b;
	l = a * 2 + b * 2;
	
	printf("%d %d\n", s, l);
	
	return (0);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int a,b;

main(){
  cin>>a>>b;

  if(a<=5)
    b=0;
  else if(a<=12)
    b/=2;
  
  cout<<b<<endl;
}


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

using namespace std;
using ll = long long;

int main()
{
    ll count = 0;
    string n;
    cin >> n;
    for (char c : n)
        count += ((int)c - '0');
    if (count % 9 == 0)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';

    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    while(N--){
	ll x[9];
	for(int i = 0 ; i < 9 ; i++){
	    scanf("%llx",&x[i]);
	}
	ll K = 0LL;
	for(int i = 0 ; i < 32 ; i++){
	    ll sum = 0LL;
	    for(int j = 0 ; j < 8 ; j++){
		sum += (x[j]^K);
	    }
	    if((sum & (1LL<<i)) != ((x[8]^K) & (1LL<<i))){
		K |= (1LL<<i);
	    }
	}
	printf("%llx\n",K);
    }
    return 0;
}

Measured memory_bytes: 3084
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
s = ns()
t = [s[i] for i in range(n)]
t[k - 1] = t[k - 1].lower()

for i in range(n):
	print(t[i], end='')
print()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

ll dist(pii a, pii b) {
	return abs(a.first - b.first) + abs(a.second - b.second);
}

int main(void) {
	int n; cin >> n;
	vector<pair<int, pii>> A, B;
	for(int i=0;i<n;i++) {
		int x, y; cin >> x >> y;
		A.pb({x + y, {x, y}});
		B.pb({x - y, {x, y}});
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	pii p[4];
	p[0] = A[0].second, p[1] = A[n-1].second, p[2] = B[0].second, p[3] = B[n-1].second;
	ll maxi = 0;
	for(int i=0;i<4;i++) {
		for(int j=i+1;j<4;j++) {
			if(dist(p[i], p[j]) > maxi) {
				maxi = dist(p[i], p[j]);
			}
		}
	}
	cout << maxi << endl;
	return 0;
}



Measured memory_bytes: 8176
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,c,n) for(int i=c;i<n;i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s[3];
  cin >> n >> s[0] >> s[1] >> s[2];
  int count = 0;
  r(i,n){
      if(s[0][i]!=s[1][i] && s[1][i]!=s[2][i] && s[2][i]!=s[0][i]){
          count += 2;
          continue;
      }
      if(s[0][i]==s[1][i] && s[1][i]==s[2][i] && s[2][i]==s[0][i]){
          continue;
      }
      count ++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int point[] = new int[N];
		if(K>Q) {
			for(int i=0;i<point.length;i++) {
				System.out.println("Yes");
			}
		}else {
			for(int i=0;i<Q;i++) {
				int A_i = sc.nextInt();
				point[A_i-1]=point[A_i-1]+1;
			}
	
			for(int i=0;i<point.length;i++) {
				int p = point[i]+K-Q;
				if(p>0) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}
		}
			
	}

}


Measured memory_bytes: 62656
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int five_hundred_coin_count, hundred_coin_count, fifty_coin_count;
  int X_yen;
  cin >> five_hundred_coin_count >> hundred_coin_count >> fifty_coin_count;
  cin >> X_yen;

  int combination_count = 0;
  
  for(int i = 0; i <= five_hundred_coin_count; i++) {
	for(int j = 0; j <= hundred_coin_count; j++) {
      for(int k = 0; k <= fifty_coin_count; k++) {
        int sum_500 = 500 * i;
        if (sum_500 > X_yen) break;
        int sum_100 = 100 * j;
        if (sum_500 + sum_100 > X_yen) break;
        int sum_50 = 50 * k;
        
        int sum = sum_500 + sum_100 + sum_50;
        if (sum == X_yen) combination_count++;     
      }
    }
  }
  
  cout << combination_count << endl;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
    int N, K;
    cin >> N >> K;
    int ans = (N + 1) / 2;
    ans >= K ? YES : NO;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, u, v, A[112345], B[112345];
vector<vector<int>> E;

int main() {

	cin >> N >> u >> v;
	E.resize(N + 1);
	rep(i, N - 1) cin >> A[i] >> B[i];
	rep(i, N - 1) {
		E[A[i]].push_back(B[i]);
		E[B[i]].push_back(A[i]);
	}

	priority_queue<int> pq;
	vector<int> vcost(N + 1, 2100000000);
	pq.push(v);
	vcost[v] = 0;
	while (!pq.empty()) {
		int cur = pq.top();
		pq.pop();
		for (auto e : E[cur]) {
			if (e != v) {
				if (vcost[e] == 2100000000) pq.push(e);
				vcost[e] = min(vcost[e], vcost[cur] + 1);
			}
		}
	}

	vector<int> ucost(N + 1, 2100000000);
	pq.push(u);
	ucost[u] = 0;
	while (!pq.empty()) {
		int cur = pq.top();
		pq.pop();
		for (auto e : E[cur]) {
			if (e != v) {
				if (ucost[e] == 2100000000) pq.push(e);
				ucost[e] = min(ucost[e], ucost[cur] + 1);
			}
		}
	}

	int ans = 0;
	rep(i, N) {
		if (ucost[i + 1] <= vcost[i + 1]) {
			ans = max(ans, vcost[i + 1]);
		}
	}

	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  string a;
  cin>>a;
  int b;
  for(int i=0;i<a.size();i++){
    if(a.at(i)!='1'){
      b=i+1;
      break;
    }
  }
  ll k;
  cin>>k;
  if(k<b){
    cout<<1<<endl;
  }
  else{
    cout<<a.at(b-1)<<endl;
  }
  
  return 0;
}


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

int main() {
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  std::string S(N, ' ');
  scanf("%s", &S[0], S.size());
  S[K - 1] += 0x20;
  printf("%s", S.c_str());
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  string alphabets = "abcdefghijklmnopqrstuvwxyz", ans;
  unsigned long long n, q;
  cin >> n;
  
  while (n--) {
    ans = alphabets[n % 26] + ans;
    n /= 26;
  }
  
  cout << ans;
  
  return 0;
}

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

int main() {
  ll x,y,a,b,c,ans=0;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a),q(b),r(c);
  for(int i=0;i<a;i++) cin >> p[i];
  for(int i=0;i<b;i++) cin >> q[i];
  for(int i=0;i<c;i++) cin >> r[i];
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  for(int i=0;i<x;i++) r.push_back(p[i]);
  for(int i=0;i<y;i++) r.push_back(q[i]);
  sort(r.begin(),r.end());
  reverse(r.begin(),r.end());
  for(int i=0;i<x+y;i++) ans+=r[i];
  cout << ans << endl;
}


Measured memory_bytes: 6000
import java.util.Scanner;
//2-3
public class Main{
    public static void main(String [] args){
    	Scanner scan=new Scanner(System.in);
    	int n=scan.nextInt();
    	int k=scan.nextInt()-1;
    	String s=scan.next();
    	String ans="";
    	char a;
    	int b=0;
    	for(int i=0;i<n;i++) {
    		a=s.charAt(i);
    		if(i==k) {
    			b=a+32;
    			a=(char) b;
    		}
    		//System.out.println(a);
    		ans=ans+a;
    	}
    	System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<ll> v(n);
    rep(i, n) cin>>v[i];
    ll ans = 0;
    map<ll, ll> minus;
    map<ll, ll> plus;
    rep(i, n){
        minus[v[i]-i]++;
        plus[-v[i]-i]++;
    }
    for(auto p : minus){
        ans += p.second*plus[p.first];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 38980
import java.util.Scanner;

//A Figure on Surface
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char[][] map = new char[8][8];
			for(int i=0;i<8;i++)map[i]=sc.next().toCharArray();
			boolean f = false;
			int s = 0;
			int t = 0;
			for(int i=0;i<8;i++){
				for(int j=0;j<8;j++){
					if(map[i][j]=='1'){
						f = true;
						s += t;
					}
					if(f)t++;
				}
			}
			char ch = ' ';
			switch(s){
			case 18:ch='A';break;
			case 48:ch='B';break;
			case 6:ch='C';break;
			case 30:ch='D';break;
			case 20:ch='E';break;
			case 34:ch='F';break;
			case 16:ch='G';break;
			default :ch='?';
			}
			System.out.println(ch);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> D(N);
    rep(i, 0, N) cin >> D[i];
    ll ans = 0;
    rep(i, 0, N) rep(j, i + 1, N) {
        ans += D[i] * D[j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

int a[1000009];
set<int>st;

signed main(){
  int s;
  cin>>s;
  a[1]=s;
  st.insert(s);
  for(int i=2;i<1000009;i++){

    if(a[i-1]%2==0)a[i]=(a[i-1])/2;
    else a[i]=(a[i-1])*3+1;

    if(st.count(a[i])){
      cout<<i<<endl;
      return 0;
    }
    st.insert(a[i]);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int>op(N);
  for(int i=0;i<N;i++)
  {
  int y;
    cin>>y;
    op.at(i)=y;
  }
  int M=0;
  sort(op.begin(), op.end());
   
 for(int i=0;i<N-1;i++)
 {if(op.at(i+1)-op.at(i)==0) 
 {
 M=1;
   break;
 }
 }
  
  if(M==1) cout<<"NO";
  else cout<<"YES";
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <math.h>
#include <algorithm>
#define rep(i,n) for(int i=0; i < (n); i++)
#define INF 1001001
using namespace std;
 
int main(){
  int n;
  long long count = 0;
  long long m;
  cin >> n;
  for(int i=1;i<n+1;i++){
    m=n/i;
    count += m*(2*i+(m-1)*i)/2;
  }
  cout << count << endl;
 
  
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int count[26] = {};
    for(int i = 0;i < n;i++)
    {
        count[s[i] - 'a']++;
    }
    long long int ans = 1;
    for(int i = 0;i < 26;i++)
    {
        ans *= (count[i] + 1);
        ans = ans % MOD;
    }
    cout << (ans % MOD) - 1 << "\n";

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

// Problema atcoder

public class Main {


	public static void main(String args[])  {
		
		
		int n;
		String[] array = {"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"};
		Scanner input = new Scanner(System.in);
		n = input.nextInt();
		
		
	    input.close();
	    
	    
		System.out.println(array[n-1]);
	
}
}



Measured memory_bytes: 35808
while True:
	n = int(input())
	if n == 0:
		break
	m = []
	for i in range(n):
		m.append(set(list(map(int, input().split()))[1:]))
	k = set(list(map(int, input().split()))[1:])
	c = 0
	f = [i+1 for i in range(n) if k <= m[i]]
	if len(f) == 1:
		print(f[0])
	else:
		print(-1)

Measured memory_bytes: 8392
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        Integer n = sc.nextInt();
        Integer[] a = new Integer[n];
        Integer[] idx = new Integer[n];

        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }

        Arrays.setAll(idx, i -> i);
        Arrays.sort(idx, Comparator.comparingInt(i -> a[i]));
        
        for(int i = 0; i < n; i++){
            if(i == idx[n-1]){
                System.out.println(a[idx[n-2]]);
            } else {
                System.out.println(a[idx[n-1]]);
            }

        }


    }
}

Measured memory_bytes: 99544
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007

int W;
string field[2];

int dp[55][3][3];

int main(){
  cin >> W;
  cin >> field[0];
  cin >> field[1];

  rep(i,55) rep(j,3) rep(k,3) dp[i][j][k] = 0;
  if(field[0][0] == field[1][0]){
    rep(j,3) rep(k,3){
      if(j == k) dp[0][j][k] = 1;
    }
  }else{
    rep(j,3) rep(k,3){
      if(j != k) dp[0][j][k] = 1;
    }
  }

  
  REP(i,1,W){
    if(field[0][i-1] == field[0][i]){
      rep(j,3) rep(k,3){
        dp[i][j][k] = dp[i-1][j][k];
      }
    }
    else if(field[0][i] == field[1][i]){
      rep(a,3) rep(j,3) rep(k,3){
        if(a != j && a != k){
          dp[i][a][a] += dp[i-1][j][k];
          dp[i][a][a] %= MOD;
        }
      }
    }
    else {
      rep(a,3) rep(b,3) rep(j,3) rep(k,3){
        if(a != b && a != j && b != k){
          dp[i][a][b] += dp[i-1][j][k];
          dp[i][a][b] %= MOD;
        }
      }
    }
  }

  int ret = 0;
  rep(j,3) rep(k,3){
    ret += dp[W-1][j][k];
    ret %= MOD;
  }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define fo(i,a,b) for(int i=a;i<b;i++)
#define all(c) (c).rbegin(),(c).rend()
#define ll long long
const int M=1e9+7;
#define endl "\n"
const double pyi=3.14159265358979323846;

const int mod=2019;


int main() 
{ 
	string st;
	cin>>st;

	int l=st.size();
    

    ll ans=0;
    int suf=0,pot=1;
    unordered_map<int,int> ump;
    ump[suf]++;
	for(int i=l-1;i>=0;i--)
	{
        int digit=st[i]-'0';
        suf=(suf+pot*digit)%mod;
        pot=(pot*10)%mod;
        ans+=ump[suf];
        ump[suf]++;
	}
	pfln(ans);
    return(0);
}

Measured memory_bytes: 3812
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(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 main(){ 
    ll n, x, m; cin >> n >> x >> m;
    
    ll res = 0;
    vector<int> memo, index(m, INF); //index:その数が何番目に出てきたか
    int i = 0;
    for(i; i<n; i++){
        if(index[x]!=INF)break; //既出の数が出たらループを抜ける
        memo.push_back(x);
        index[x] = i;
        res += x;
        x = (x*x)%m;
    }
    if(i<n){
        ll rsiz = i - index[x];
        ll sum = 0;
        rept(j, index[x], memo.size()){
            sum += memo[j];
        }
        ll count = n - i;
        res += sum * (count / rsiz);
        rep(j, count % rsiz){
            res += memo[j + index[x]];
        }
    }
    
    cout << res << ln;
}



Measured memory_bytes: 3972
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(int argc, char** args) {
	int n = 0, a[100005] = {0}, k = 0;
	scanf("%d %d", &n, &k);
	for(int i = 1;i <= n;i++) {
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + n + 1); int ans = 0;
	for(int i = n;i > n - k;i--) {
		ans += a[i];
	}
	printf("%d", ans);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll> >pr(m);
    map<ll,pair<ll,ll> >mp;
    vector<ll>v(m);
    for(ll i=0;i<m;++i)
    {
        cin>>pr[i].first>>pr[i].second;
        v[i] = pr[i].second;
    }
    sort(pr.begin(),pr.end());
    ll c=1;

    for(ll i=0;i<m;++i)
    {
        mp.insert({pr[i].second,{pr[i].first,c}});
        ++c;
    if(pr[i].first!=pr[i+1].first)
            c = 1;
    }

    for(ll i=0;i<m;++i)
    {
        printf("%.6lld%.6lld\n",mp[v[i]].first,mp[v[i]].second);
    }
}


Measured memory_bytes: 10112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reg096C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var A = s[0] < s[1] ? s[0] : s[1];
            var B = s[0] < s[1] ? s[1] : s[0];
            var C = s[2];
            var X = s[0] < s[1] ? s[3] : s[4];
            var Y = s[0] < s[1] ? s[4] : s[3];

            var ans = 0;
            int k, l, m;
            var isCAdvAB = 2 * C < A + B;
            var isCAdvA = 2 * C < A;
            var isCAdvB = 2 * C < B;
            if (!isCAdvAB)
                ans = A * X + B * Y;
            else if (isCAdvA || (isCAdvB && X<Y))
            {
                m = Math.Max(2 * X, 2 * Y);
                ans = m * C;
            }
            else
            {
                m = 2 * Math.Min(X, Y);
                k = X - m / 2;
                l = Y - m / 2;
                ans = A * k + B * l + C * m;
            }
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<string.h>

int main(void){
	char s[100001];
	int K;
	scanf("%s",s);
	scanf("%d",&K);
	int len=strlen(s);
	int i=0;
	for(i=0;i<len&&K!=0;i++){
		if(s[i]=='a'){
			continue;
		}
		if(('z'-s[i]+1)<=K){
			K=K-('z'-s[i]+1);
			s[i]='a';
		}else
		continue;
	}
	if(K!=0){
		if(s[len-1]=='a'){
			K=K%26;
			s[len-1]=s[len-1]+K;
		}else{
			s[len-1]=s[len-1]+K;
		}
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int h,w,n,sr,sc;
    cin>>h>>w>>n>>sr>>sc;
    string s, t;
    cin >> s >> t;
    long long int r = sc, l = sc,u=sr,d=sr;

    REP(i,n){
        if(s[i]=='R'){
            r++;
        }else if(s[i]=='L'){
            l--;
        }else if(s[i]=='U'){
            u--;
        }else if(s[i]=='D'){
            d++;
        }
        
        if(r>w){
            cout << "NO" << endl;
            return 0;
        }else if(d>h){
            cout << "NO" << endl;
            return 0;
        }else if(l<=0){
            cout << "NO" << endl;
            return 0;
        }else if(u<=0){
            cout << "NO" << endl;
            return 0;
        }

        if(t[i]=='R'){
            l=min(l+1,w);
        }else if(t[i]=='L'){
            r = max(r - 1, 1ll);
        }else if(t[i]=='U'){
            d = max(d - 1, 1ll);
        }else if(t[i]=='D'){
            u = min(u + 1, h);
        }

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


Measured memory_bytes: 1020