akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    vector<string> s = {"MON" ,"TUE", "WED", "THU", "FRI", "SAT", "SUN"};
    vll res = {6, 5, 4, 3, 2, 1, 7};
    string x;
    cin >> x;
    REP(i, 7) {
        if (x == s[i]) {
            cout << res[i] << endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

int main() {
int k;
cin >> k;
int ans = 0;
for(int i = 1; i < 1e7; i++){
	ans = ((ans*10) + 7) % k;
	if(ans == 0){
		cout << i << endl;
		return 0;
	}
	
}
cout << -1 << endl;
return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		char[] str = scan.nextLine().toCharArray();
		int ans = 0;
		for (char s : str) {
			if (s == '1') ans++;
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new Main().run();
	}

}


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

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		while(true){
			String[] input = br.readLine().split(" ");
			int numNumbers = Integer.parseInt(input[0]);
			int sum = Integer.parseInt(input[1]);
			if(numNumbers == 0 && sum == 0)	break;
			int numCombinations = 0;
//				System.out.println(base + ":" + numCombinations);
			numCombinations += getCombinations(numNumbers, sum);
			System.out.println(numCombinations);
		}
	}
	/**
	 * 組み合わせの数を求める
	 * @param base			組み合わせで用いる最小値
	 * @param numNumbers	組み合わせに用いる数の個数
	 * @param sum			対象となる和
	 * @return	sumとなる組み合わせの数
	 */
	public static int getCombinations(int numNumbers, int sum, int min){
		if(sum < min || numNumbers <= 0)	return 0;
		else if(numNumbers == 1)	return (min <= sum && sum <= 9) ? 1 : 00;
		int combinations = 0;
		for(int value = min; value <= 9; value++){
			combinations += getCombinations(numNumbers - 1, sum - value, value + 1);
		}
		return combinations;
	}
	public static int getCombinations(int numNumbers, int sum){
		return getCombinations(numNumbers, sum, 0);
	}
}

Measured memory_bytes: 17764
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <cassert>

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

using namespace std;

void chmax(int& x, int y) { if (x < y) x = y; }
void chmin(int& x, int y) { if (x > y) x = y; }

int main() {
    while(true)  {
        int n; cin >> n;
        if (n == 0) break;
        vector<int> p(n);
        REP(i, n) cin >> p[i];
        // dp[store][500][spend1000]
        vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(n + 1, vector<int>(601, -1)));
        dp[0][0][0] = 0;
        int maxcoin = 0;
        REP(pi, n) {
            int price = p[pi];
            int oturi = 1000 - (price % 1000);
            int us = (price - 1) / 1000 + 1;
            if (oturi == 1000) oturi = 0;
            //cout << "pi: " << pi <<  " price: "<< price << " Use: " << us << " Oturi:" << oturi << endl;
            REP(i5, n) {
                REP(s, 600) {
                    int hav = dp[pi][i5][s];
                    if (hav == -1) continue;
                    //cout << "i5: " << i5 << " s: " << s << " hav : " << hav << endl;
                    chmax(dp[pi + 1][i5][s], hav); // 買わない
                    if (oturi >= 500) {
                        //cout <<"MUST" << endl;
                        chmax(dp[pi + 1][i5 + 1][s + us], hav + oturi - 500);
                        chmax(maxcoin, i5 + 1);
                    }else{
                        chmax(dp[pi + 1][i5][s + us], hav + oturi); //買う
                        if (500 - oturi <= hav) {
                            //cout <<"MORE BUY" << endl;
                            chmax(dp[pi + 1][i5 + 1][s + us], hav - (500 - oturi)); //余計に出して買う
                            chmax(maxcoin, i5 + 1);
                        }
                    }
                }
            }
        }
        int used = 100000000;

        cout << maxcoin << " ";
        REP(i, 601) {
            int hav = dp[n][maxcoin][i];
            if (hav != -1) {
                //cout << "S: " << i <<  " - " << hav << endl;
                chmin(used, 1000 * i - hav - maxcoin * 500);
            }
        }
        cout << used << endl;
    }
}


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

int main(){
    long long ans = 0;
    string s;

    cin >> s;

    int w = 0;
    for(int i=0 ; i < s.size(); ++i){
        if(s[i] == 'W') {
            ans += i-w;
            w++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
A, B, C, X, Y = map(int, input().split())
all = A * X + B * Y
all_half = max(X, Y) * C * 2
best = (min(X, Y) * C * 2) + A * (X - min(X, Y)) + B * (Y - min(X, Y))
print(min(all, all_half, best))

Measured memory_bytes: 9124
import fractions
from functools import reduce
def gcd_list(numbers):
  return reduce(fractions.gcd, numbers)
N,X = map(int,input().split())
A = list(map(int,input().split()))
k = []
for i in range(N):
  k.append(abs(A[i]-X))
print(gcd_list(k))

Measured memory_bytes: 16280
using System;
using System.Linq;

class Program
{
    static long N;
    static long A;

    static void Main()
    {
        long[] inputs = Console.ReadLine().Split().Select(long.Parse).ToArray();
        N = inputs[0];
        A = inputs[1];

        long ans = long.MaxValue;

        long M = Math.Max((long)(Math.Log(N) / Math.Log(2)), 1);
        for (int i = 0; i <= M; i++)
            ans = Math.Min(ans, Min(i));

        Console.WriteLine(ans);
    }

    static long Min(long k) //k回クッキーを食べる場合にかかる時間の最小値
    {
        long t = (long)Math.Pow(N, 1.0 / (k + 1));
        int c = 0;
        long dis = N - (long)Math.Pow(t, k + 1);
        while (dis > 0)
        {
            c++;
            dis = N - (long)Math.Pow(t, k + 1 - c) * (long)Math.Pow(t + 1, c);
        }
        return t * (k + 1) + c + A * k;
    }
}

Measured memory_bytes: 13524
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
typedef vector<int> vi;

int main(){
    long long n,q, ans = 0;;
    cin >> n;
    vector<long long> cnt(100002);
    rep(i, n){
        int a;
        cin >> a;
        cnt[a]++;
        ans += a;
    }

    cin >> q;
    vector<long long> ver(q);
    rep(i, q){
        int b, c;
        cin >> b >> c;
        cnt[c] += cnt[b];
        ans += cnt[b] * (c - b);
        cnt[b] = 0;
        ver[i] = ans;
    }

    rep(i, q){
        cout << ver[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4764
object Main extends App {
  val sc = new java.util.Scanner(System.in) 
  sc.useDelimiter("\n")
  val n = sc.nextInt()
  val a = sc.next().split(' ').map(_.toInt).toList.sortBy(- _)
  var alice = for((x, i) <- a.zipWithIndex if i % 2 == 0) yield x
  var bob = for((x, i) <- a.zipWithIndex if i % 2 != 0) yield x
  println(alice.sum - bob.sum)
  
}

Measured memory_bytes: 55572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int h,w;
    cin>>h>>w;
    vs vec(h);
    cin>>vec;
    vvi d(h,vi(w,INF));
    queue<P> que;
    REP(i,h){
        REP(j,w){
            if(vec[i][j]=='#'){
                que.push({i,j});
                d[i][j]=0;
            }
        }
    }
    while(que.size()){
        P p=que.front();que.pop();
        int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
        REP(k,4){
            int x=dx[k]+p.fi;
            int y=dy[k]+p.se;
            if(0<=x&&x<h&&0<=y&&y<w){
                if(d[x][y]>d[p.fi][p.se]+1){
                    d[x][y]=d[p.fi][p.se]+1;
                    que.push({x,y});
                }
            }
        }
    }
    int ans=0;
    REP(i,h){
        REP(j,w){
            chmax(ans,d[i][j]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 21556
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int H, W;
char s[51][51];

int count(int w, int h){
	if(h < 0) return 0;
	if(w < 0) return 0;
	if(h > H - 1) return 0;
	if(w > W - 1) return 0;
	return (s[h][w] == '#');
}
bool isValid(int w, int h){
	int res = 0;
	res += count(w - 1, h);
	res += count(w + 1, h);
	res += count(w, h - 1);
	res += count(w, h + 1);
	return res;
}

int main(){
	cin >> H >> W;
	rep(i, H) {
		cin >> s[i];
	}

	bool ans = true;
	rep(h, H) {
		rep(w, W) {
			if(s[h][w] == '#' && !isValid(w, h)) ans = false;
		}
	}
	puts(ans ? "Yes" : "No");
	return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b, c;
    cin >> a >> b >> c;

    cout << min(a+b, min(b+c, c+a)) << endl;
    return 0;
}

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

int main() {
double N,K;
  cin >> N >> K;
  double a;
  vector<double> retu(N);
  for(int i = 0; i < N; i++){
  	cin >> a;
    retu[i] = a+1;
  }
  double mm = 0;
  for(int i = 0; i < K; i++){
  	mm += retu[i];
  }
  //これでmmはまずi = 0からK個の期待値の和
  vector<double> kitai(N);
  kitai[0] = mm;
  for(int i = 0; i < N-K; i++){
  	kitai[i+1] = kitai[i] - retu[i] + retu[i+K];
    mm = max(mm, kitai[i+1]);
  }


  cout << fixed << setprecision(3) << mm/2 << endl;
}

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

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> va(n, vector<int>(m)), vb(m, vector<int>(1)), vans(n, vector<int>(1));

    rep(i, n) {
        rep(j, m) {
            int x;
            cin >> x;
            va[i][j] = x;
        }
    }

    rep(i, m) {
        int y;
        cin >> y;
        vb[i][0] = y;
    }

    rep(i, n) {
        int sum = 0;
        rep(j, m) {
            sum += (va[i][j] * vb[j][0]);
        }
        vans[i][0] = sum;
    }

    rep(i, n) {
        cout << vans[i][0] << endl;
    }

    return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

vector <vector<ll>> graph;
stack <ll> t;
vector <bool> visited;

void tsort(ll v){
	if (visited[v]) return;
	visited[v] = true;
	for (int z=0;z<graph[v].size();z++){
		if (visited[graph[v][z]]) continue;
		tsort(graph[v][z]);
	}
	t.push(v);
}

int main(){
	ll n,m;
	cin >> n >> m;
	graph.resize(n+1);
	visited.resize(n+1,false);
	for (int z=0;z<m;z++){
		ll u,v;
		cin >> u >> v;
		graph[u].push_back(v);
	}
	for (int z=1;z<=n;z++){
		tsort(z);
	}
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		arr[z] = t.top();
		t.pop();
	}
	vector <ll> dp(n+1,0);
	for (int z=0;z<n;z++){
		for (int x=0;x<graph[arr[z]].size();x++){
			dp[graph[arr[z]][x]] = max(dp[graph[arr[z]][x]],dp[arr[z]]+1);
		}
	}
	ll ans = 0;
	for (int z=0;z<=n;z++){
		ans = max(ans,dp[z]);
	}
	cout << ans << endl;
	cin >> n;
}

Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5+5 , M = 1e3+5, OO = 0x3f3f3f3f;
typedef long long ll;
int a, b, c;
int main()
{
    cin >> a >> b >> c;
    cout << max(0, (b+c-a)) << endl;
	return 0;
}


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

int main()
{
    int n;  cin >> n;
    vector<int> a(n);

    int num = 0;
    vector<int> count(100000, 0);

    rep(i,n) {
        cin >> a[i];

        count[a[i]]++;
        count[a[i] + 1]++;
        count[a[i] + 2]++;
    }

    int ans = *max_element(count.begin(), count.end());

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define vii vector<int>
#define vll vector<ll>
#define vip vector<pair<int,int> >
#define pb push_back


int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w",stdout);
    //#endif

    /*int tc;
    cin>>tc;
    while(tc--)
    {

    }*/
    string s;
    cin>>s;
    int len=s.size();
    s.clear();
    s.resize(len,'x');
    cout<<s;

    return 0;
}


Measured memory_bytes: 256
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n;
  rd(n);
  struct E {
    int to;
    long cost;
  }

  auto g = new E[][](n);
  foreach (_; 0 .. n - 1) {
    int a, b;
    long c;
    rd(a, b, c);
    g[a - 1] ~= E(b - 1, c);
    g[b - 1] ~= E(a - 1, c);
  }
  int q, k;
  rd(q, k);
  auto dist = new long[](n);
  fill(dist, 10L ^^ 18);
  void dfs(int i, long d) {
    if (dist[i] < 10L ^^ 18)
      return;
    dist[i] = d;
    foreach (e; g[i]) {
      dfs(e.to, d + e.cost);
    }
  }

  dfs(k - 1, 0);
  while (q--) {
    int x, y;
    rd(x, y);
    writeln(dist[x - 1] + dist[y - 1]);
  }
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 33404
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;

int tobit(vector<string> &S) {
	int res = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 10; j++) {
			res <<= 1;
			if (S[i][j] == '.') {
				res++;
			}
		}
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	set<int> st;
	vector<vector<string> > A(4);
	for (int i = 0; i < 4; i++) {
		int h, w;
		cin >> h >> w;
		A[i].resize(h);
		for (int j = 0; j < h; j++) {
			cin >> A[i][j];
		}
	}
	vector<vector< vector<pair<int, int> > > > t(4);
	for (int i = 0; i < 4; i++) {
		vector<pair<int, int> > vp;
		for (int j = 0; j < A[i].size(); j++) {
			for (int k = 0; k < A[i][0].size(); k++) {
				if (A[i][j][k] == '#') {
					vp.emplace_back(j, k);
				}
			}
		}
	
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 10; k++) {
				bool ok = true;
				vector<pair<int, int> > tmp;
				for (int a = 0; a < 4; a++) {
					if (j + vp[a].first >= 4)ok = false;
					if (k + vp[a].second >= 10)ok = false;
					tmp.emplace_back(j + vp[a].first, k + vp[a].second);
				}
				if (ok) {
					t[i].push_back(tmp);
				}
			}
		}
	}
	//cerr << "OK" << endl;
	for (int i = 0; i < 4; i++) {
		vector<int> X;
		for (int j = 0; j < 4; j++) {
			if (i != j) {
				X.push_back(j);
			}
		}

		int a[3];
		int cnt = 0;
		for (a[0] = 0; a[0] < t[X[0]].size(); a[0]++) {
			for (a[1] = 0; a[1] < t[X[1]].size(); a[1]++) {
				for (a[2] = 0; a[2] < t[X[2]].size(); a[2]++) {
					vector<string> S(4, string(10, '#'));
					bool ok = true;
					for (int j = 0; j < 4; j++) {
						for (int k = 0; k < 3; k++) {
							if (S[t[X[k]][a[k]][j].first][t[X[k]][a[k]][j].second] == '#') {
								S[t[X[k]][a[k]][j].first][t[X[k]][a[k]][j].second] = '.';
							}
							else {
								ok = false;
								break;
							}
						}
						if (!ok)break;
					}
					if (ok) {
						/*cnt++;
						if (cnt <= 10) {
							for (int j = 0; j < 4; j++) {
								cerr << S[j] << endl;
							}
							cerr << endl;
						}*/
						st.insert(tobit(S));
					}

				}
			}
		}
	}

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		vector<string> S(4);
		for (int j = 0; j < 4; j++) {
			cin >> S[j];
		}
		int c = tobit(S);
		if (st.count(c) > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}



}


Measured memory_bytes: 4196
N = int(input())
X = {}

for i in range(N):
    A = int(input())
    tmp = [list(map(int, input().split())) for _ in range(A)]
    X[i] = tmp

ans = 0
for bit in range(2 ** N):
    tmp = bit
    flag = True
    for i in range(N):
        if not (bit >> i & 1):
            continue

        for x, y in X[i]:
            if (bit >> (x - 1) & 1) != y:
                flag = False
                break
                
    if flag:
        ans = max(ans, bin(bit).count("1"))

print(ans)


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

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return (int)(0);
}

segtree<int, op, e> seg(900900);

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

    int ans = 0;
    const int geta = 300300;
    for (int i = 0; i < n; ++i) {
        int l = a[i] - k, r = a[i] + k + 1;
        auto cur = seg.prod(geta + l, geta + r);
        cur++;
        ans = max(ans, cur);
        seg.set(geta + a[i], cur);
    }
    cout << ans << endl;
}




Measured memory_bytes: 14624
//AtCoder ABC053 B - A to Z String
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    string s;
    cin>>s;
    int st,ed;
    for(st=0;st<s.size();++st){
        if(s[st]=='A') break;
    }
    for(ed=s.size()-1;ed>=0;--ed){
        if(s[ed]=='Z') break;
    }
    cout<<ed-st+1<<endl;    
    return 0;
}

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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;
const double PI = acos(-1);

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> A(n+1), B(m+1);
    rep(i, n) {
        ll a;
        cin >> a;
        A[i+1] = a + A[i];
    }
    rep(i, m) {
        ll b;
        cin >> b;
        B[i+1] = b + B[i];
    }

    ll ans = 0;
    ll j = m;

    rep(i, n+1) {
        if (A[i] > k) {
            break;
        }

        while(j >= 0 and A[i] + B[j] > k) {
            j -= 1;
        }

        ans = max(ans, i + j);
    }

    cout << ans << endl;
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N, K;
  cin >> N >> K;
  vector<LL> A(N);
  
  REP(i,N){
    cin >> A[i];
  }
  
  REP(i,K){
    vector<LL> B(N + 1, 0);
    REP(j, N)
    {
      B[max(j-A[j],0LL)] += 1;
      B[min(j+A[j]+1,N)] -= 1;
    }
    LL cnt = 0;
    REP(j, N)
    {
      cnt += B[j];
      A[j] = cnt;
    }
    bool flag = true;
    REP(j, N)
    {
      if(A[j]!=N){
        flag = false;
        break;
      }
    }
    if(flag){
      break;
    }
  }
  
  REP(i,N){
    cout << A[i];
    if(i!=N-1){
      cout << " ";
    }else{
      cout << endl;
    }
  }
}


Measured memory_bytes: 6336
// SeeAlso: https://atcoder.jp/contests/abc051/tasks/abc051_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

string s;

int main() {
    
    cin >> s;

    replace(s.begin(), s.end(), ',', ' ');
    print(s);
    return 0;
}


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

int main(){
  int n;
  int m[40];
  int s[40];
  int p[21],d[21];
  int f,tmp;

  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++){
      cin >> m[i];
      s[i] = 0;
      for(int j=0;j<21;j++)p[j] = 0;
      for(int j=0;j<21;j++)d[j] = 1;
      f = 0;
      while(1){
	cin >> tmp;
	if(f<18){
	  if(!(f%2) && tmp==10){
	    p[f] = 10;
	    f+=2;
	  }else{
	    p[f] = tmp;
	    f++;
	  }
	}else{
	  if(f==18){
	    p[f] = tmp;
	    f++;
	  }else if(f==19){
	    p[f] = tmp;
	    if(p[f-1]+p[f] > 9){
	      cin >> tmp;
	      p[f+1] = tmp;
	    }
	    break;
	  }
	}
      }
     
      for(int j=0;j<18;j++){
	if(!(j%2) && p[j]==10){
	  d[j+2]++;
	  if(p[j+2]==10 && j+2 != 18)d[j+4]++;
	  else d[j+3]++;
	}else if(p[j] && j%2 && p[j-1]+p[j]==10){
	  d[j+1]++;
	}
      }
      
      for(int j=0;j<21;j++){
	s[i]+=d[j]*p[j];
      }
    }

    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	if(s[i]<s[j]){
	  swap(s[i],s[j]);
	  swap(m[i],m[j]);
	}else if(s[i]==s[j] && m[i]>m[j]){
	  swap(s[i],s[j]);
	  swap(m[i],m[j]); 
	}
      }
    }

    for(int i=0;i<n;i++){
      cout << m[i] << " " << s[i] << endl;
    }
  }
}

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

int main()
{
	int A, B;
	cin >> A >> B;
	int min, max;

	if(A > B){
		min = B;
		max = A;
	}else
	{
		min = A;
		max = B;
	}

	unsigned long int ans = 1;

	for (int i = 2; i <= min; i++)
	{
		if (min % i == 0 && max % i == 0)
		{
			while (min % i == 0 && max % i == 0){
				ans *= i;
				min /= i;
				max /= i;
			}
			// cout << i << " " << min << " " << max << endl;
		}
	}

	cout << ans * min * max << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 4e5 + 10;
const int M = (int) 1e6 + 10;
const ll LINF = (ll) 2e18;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-9;
const double PI =  3.14159265359;

int cnt[2];
int n, m;


int main() {
    #define fn "euler"
    #ifdef witch                                                            
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(fn".in", "r", stdin);
        //freopen(fn".out", "w", stdout);
    #endif      
    cin >> n >> m;
    for (int i = 1, x; i <= n; i++) {
        cin >> x;
        cnt[x % 2]++;
    }
    if (m % 2 && !cnt[1]) cout << 0, exit(0);
    cout << (1LL << cnt[0]) * (cnt[1] ? (1LL << (cnt[1])) / 2 : 1);
    return 0;
}

Measured memory_bytes: 256
using System;

namespace AOJ.ITP
{
    public class HowManyDivisors
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            int ans = 0;
            for (int i = a; i <= b; i++)
            {
                if (c % i == 0) { ans++; }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 15836
#include "bits/stdc++.h"
#include <random>

using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  ll D=365;
  cin>>ans;
  vi c(26);
  vi last(26);
  vvi data(D, vi(26));  // N * M の2次元配列
  for(ll i=0;i<26;i++){
    cin>>c[i];
  }
  for(ll i=0;i<D;i++){
    for(ll j=0;j<26;j++){
      cin>>data[i][j];
    }
  }


  ll sc=0;
  ll sct=0;
  ll maxid=-1;
  for(ll i=0;i<D;i++){
    sc=-922337203685477580LL;
    maxid=0;
    for(ll j=0;j<26;j++){
      ll l=i-last[j];
      sct=data[i][j]-(l*l-l)/2*c[j];
      if (sc<sct){
        sc=sct;
        maxid=j;
      }
    }
    last[maxid]=i;
    cout<<(maxid+1)<<endl;
  }




  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int A = 0; // 判定用
  
  for (int i =0; i < N; i++){
      
      string S;
      cin >> S;
      
      
      if (S == "Y"){
          A++;
      }

  }
        if (A == 0){
            cout << "Three"<<endl;
}
        else {
            cout <<" Four"<<endl;
        }
  
  

 
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int p=b;
	int x=1;
	while(p!=0)
	{
		x*=10;
		p/=10;
	}
	int c;
	c=a*x+b;
	if( ( int(sqrt(c))*int(sqrt(c)) ) == c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    string S , T;
    cin >> S;
    cin >> T;
    bool a = true;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) != T.at(i)){
            a = false;
    }
    }
    if(a && T.size() == S.size() + 1){
        cout << "Yes" << endl;
    }
    else{
            cout << "No" << endl;
    }
    
}

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

int main(){
  ll n, ans, divisor = 1, fin;
  cin >> n;
  fin = sqrt(n);
  for (ll i = 2; i <= fin; i++){
    if (n % i == 0){
      divisor = i;
    }
  }
  ans = max(divisor, n / divisor);
  cout << (to_string(ans)).size() << endl;
  return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	if((n+1)/2>=k) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            //入力
            string input = Console.ReadLine();
            int n = int.Parse(input);
            string[] input_P = Console.ReadLine().Split(' ');
            int[] P = new int[n];
            for(int i = 0;i < n;i++)
                P[i] = int.Parse(input_P[i]);
            string[] input_Q = Console.ReadLine().Split(' ');
            int[] Q = new int[n];
            for(int i = 0;i < n;i++)
                Q[i] = int.Parse(input_Q[i]);

            int sum = 1;
            for(int i = 0; i < n;i++)
                sum *= i + 1;

             
            int a = 0;
            int b = 0;

            for(int i = 0; i < n - 1;i++)
            {
                int temp = P[i];
                sum /= (n - i);
                if(i == 0)
                {
                    a = (P[i] - 1)* sum + 1;
                    b = (Q[i] - 1)* sum + 1;
                }
                else
                {
                    for(int j = i; j < n ;j++)
                    {
                        if(P[j] > P[i - 1])
                            P[j]--;
                    }
                    for(int j = i; j < n ;j++)
                    {
                        if(Q[j] > Q[i - 1])
                            Q[j]--;
                    }
                    
                    
                    a += (P[i] - 1)* sum + 1;
                    b += (Q[i] - 1)* sum + 1;
                }
                
            }
                
            //答え出力
            Console.WriteLine(Math.Abs(a - b));
          
        } 
    }

Measured memory_bytes: 11092
$r=0..8
def f;$r.map{|i|(?1..?9).map{|d|$r.map{|j|$m[yield(i,j)+1]}.count(d)>1&&$r.map{|j|$m[x=yield(i,j)+1]==d&&$m[x-1]=?*}}}end
puts ("1\n"..gets).map{$m=$r.map{" "+gets}*""
f{|i,j|i*19+j*2}
f{|i,j|j*19+i*2}
f{|i,j|(i-i%3+j/3)*19+(j%3+i%3*3)*2}
$m}*?\n

Measured memory_bytes: 6116
from sys import stdin,stdout,setrecursionlimit
from collections import Counter as C
setrecursionlimit(10**6)
M = 1000000007
input = stdin.readline
def write(n,sep="\n"):
	stdout.write(str(n))
	stdout.write(sep)
def gil():
	return list(map(int, input().split()))
	
n = int(input())
h = gil()
dp = [1e18]*(n+1)
dp[0] = 0
for i in range(n):
    for j in [i+1, i+2]:
        if j < n:
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
print(dp[n-1])


Measured memory_bytes: 86280
#include<cstdio>
using namespace std;
int main()
{
	int n,m,x,sum=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&x);
		sum+=x;
	}
	if(n-sum<0)
	{
		printf("-1\n");
	}
	else
	{
		printf("%d\n",n-sum);
	}
	return 0;
} 


Measured memory_bytes: 1688
#include <algorithm>
#include <deque>
#include <iostream>
#include <type_traits>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  deque<int> colors;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    auto itr = lower_bound(colors.begin(), colors.end(), a);
    if (itr == colors.begin()) {
      colors.push_front(a);
      continue;
    }
    itr--;
    *itr = a;
  }
  cout << colors.size() << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s = scan.next();
		String ans = "No";
		if(n % 2 == 0) {
			if(s.substring(0,n/2).equals(s.substring(n/2))) {
				ans = "Yes";
			}
		}
		System.out.print(ans);

	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
   int n, i;
   cin >> n >> i;
   cout << n-i+1 << endl;

   return 0;
}

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

int main() {
  int n;cin >> n;
  int a[n] = {};
  int b[n-1];
  for(int i = 0; i < n-1; i++){
    cin >> b[i];
  }
  a[0] = b[0];
  a[n-1] = b[n-2];
  for(int i = 1; i < n-1; i++){
    a[i] = min(b[i-1], b[i]);
  }
  long long ans = 0;
  for(int i = 0; i < n; i++){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int M = 1000000000 + 7;

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

  vector<int> C(N);
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    ++C[a];
  }
  
  int y = 1;
  int a = (N - 1) & 1;
  if (a == 0) {
    if (C[a] != 1) {
      cout << "0\n";
      return 0;
    }
    a += 2;
  }
  for (int i = a; i < N; i += 2) {
    if (C[i] != 2) {
      cout << "0\n";
      return 0;
    }
    y <<= 1;
    if (y > M) {
      y %= M;
    }
  }
  cout << y << "\n";

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int tmp = N;
  int S = 0;
  while(N){
    S += N % 10;
    N /= 10;
  }
  if(tmp % S == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

string rate(int a){
  if(a<400) return "gray";
  if(a<800) return "brown";
  if(a<1200) return "green";
  if(a<1600) return "cyan";
  if(a<2000) return "blue";
  if(a<2400) return "yellow";
  if(a<2800) return "oragen";
  if(a<3200) return "red";
}

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  int tourist = 0;
  rep(i,n){
    int x;
    cin >> x;
    if(x<3200) mp[rate(x)] ++;
    else tourist ++;
  }
  int ans1 = mp.size();
  int ans2 = ans1 + tourist;
  cout << max(ans1,1) << " " << ans2 << endl;
}

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

int main(int argc, char **argv)
{
    int N, K;
    std::cin >> N >> K;

    std::vector<bool> have(N, false);

    for(int i = 0; i < K; i++){
        int d;
        std::cin >> d;
        for(int j = 0; j < d; j++){
            int dd;
            std::cin >> dd;
            have.at(dd-1) = true;
        }
    }

    int sum = 0;
    for(int i = 0; i < N; i++){
        if(have.at(i) == false) sum++;
    }

    std::cout << sum << std::endl;
    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

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

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

const ll c[10]={2,5,5,4,5,6,3,7,6};

void solve(){
 ll n,m;
  cin >> n >> m;
  vll a(m);
  rep(i,0,m){
    cin >> a[i];
    a[i]--;
    }
 sort(all(a),gll); 
    
  vll dp(10010,-1);
  dp[0]=0;
  
   rep(i,0,n){ 
     if(dp[i]==-1) continue;
     repr(j,9,0){
     if(find(all(a),j)==a.end()) continue;  
     chmax(dp[i+c[j]],dp[i]+1);
     }
   }
  
  string ans="";
  
  ll now=n;
  while(now>0){
   repr(i,9,0){
    if(find(all(a),i)==a.end()) continue;
    if(now-c[i]>=0&&dp[now]==dp[now-c[i]]+1){
     now-=c[i];
     ans+=char(i+1+'0'); 
      break;
    }
   }
  }
  cout << ans << endl;

}

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

Measured memory_bytes: 3720
// https://atcoder.jp/contests/abc100/tasks/abc100_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)

// 二乗法によるべき乗
int ipow(int base, int exp) {
    int result = 1;
    while (exp) {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        base *= base;
    }

    return result;
}
int main(void) {
    int a, b;
    cin >> a >> b;
    b += (b / 100);
    cout << ipow(100, a) * b << endl;

    return 0;
}


Measured memory_bytes: 256
while True:
    s1 = input().split('"')
    if s1[0] == '.':
        exit()
    s2 = input().split('"')
    if len(s1) != len(s2):
        print('DIFFERENT')
        continue
    ans = 1
    for i in range(len(s1)):
        if i % 2 == 0:
            if s1[i] != s2[i]:
                ans = -1
        else:
            if s1[i] != s2[i]:
                ans -= 1
    if ans == 1:
        print('IDENTICAL')
    elif ans == 0:
        print('CLOSE')
    else:
        print('DIFFERENT')



Measured memory_bytes: 5572
from copy import deepcopy


def make_multi_list(initial, degree):
    ans = [initial for _ in range(degree[-1])]
    for d in reversed(degree[:-1]):
        ans = [deepcopy(ans) for _ in range(d)]
    return ans


dp = make_multi_list(initial=0, degree=[105, 4, 2])
dp[0][0][0] = 1

S = input().strip()
K = int(input())
n = len(S)

for i in range(n):
    for j in range(4):
        for k in range(2):
            nd = int(S[i])
            for d in range(10):
                ni = i + 1
                nj = j
                nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]

ans = dp[n][K][0] + dp[n][K][1]
print(ans)


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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &c : a) cin >> c;
    sort(all(a));
    reverse(all(a));
    multiset<int> s;
    s.insert(a[0]);
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        ans += *s.rbegin();
        s.erase(s.find(*s.rbegin()));
        s.insert(a[i]);
        s.insert(a[i]);
    }
    cout << ans;
    return 0;
}


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

using namespace std;

using ll = long long;

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

    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
        cout << "vowel\n";
    else
        cout << "consonant\n";

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main() 
{
	int a, b, c;

	cin >> a >> b >> c;

	if (a == b) {
		cout << c << endl;
	}
	else if (b == c) {
		cout << a << endl;
	}
	else {
		cout << b << endl;
	}

	return 0;
}

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

int INF = 1e+9;
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};
int w, h;
string s[20];
vector<P> tile;
int startId;
int distTile[11][11];
int dp[1 << 11][11];

void chmin(int &a, int b) { a = min(a, b); }
void bfs(P start, int dist[20][20]) {
	int i, j;
	queue<P> que;
	
	rep(i, h) rep(j, w) dist[i][j] = INF;
	dist[start.first][start.second] = 0;
	que.push(P(start.first, start.second));
	
	while (!que.empty()) {
		P now = que.front(); que.pop();
		int y = now.first;
		int x = now.second;
		
		rep(i, 4) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if (s[ny][nx] == 'x') continue;
			if (dist[ny][nx] > dist[y][x] + 1) {
				dist[ny][nx] = dist[y][x] + 1;
				que.push(P(ny, nx));
			}
		}
	}
}

int main() {
	while (cin >> w >> h) {
		if (!w) break;
		int i, j, k;
		
		rep(i, h) cin >> s[i];
		
		tile.clear();
		rep(i, h) {
			rep(j, w) {
				if (s[i][j] == '*') {
					tile.push_back(P(i, j));
				}
				if (s[i][j] == 'o') {
					startId = tile.size();
					tile.push_back(P(i, j));
				}
			}
		}
		
		rep(i, tile.size()) {
			int dist[20][20];
			bfs(tile[i], dist);
			rep(j, tile.size()) {
				distTile[i][j] = dist[tile[j].first][tile[j].second];
			}
		}
		
		rep(i, (1 << 11)) rep(j, 11) dp[i][j] = INF;
		
		dp[1 << startId][startId] = 0;
		
		int sz = tile.size();
		rep(i, (1 << sz)) {
			rep(j, sz) {
				rep(k, sz) {
					if ((i >> k) & 1) continue;
					chmin(dp[i + (1 << k)][k], dp[i][j] + distTile[j][k]);
				}
			}
		}
		
		int ans = INF;
		rep(i, sz) chmin(ans, dp[(1 << sz) - 1][i]);
		if (ans == INF) cout << -1 << endl;
		else cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>

int main(void){
    using namespace  std;

    double a, b, x;
    cin >> a >> b >> x;

    double theta;
    double S = x / a;
    if(S<=a*b/2){
        theta = atan(2 * S / (b * b));
    }
    else{
        theta = atan(a * a / (2 * (a * b - S)));
    }
    cout << setprecision(8) << 90 -theta * 180 / M_PI << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
    using namespace std;
    signed main(){
      string s;
      cin>>s;
      if(s=="Sunny") cout<<"Cloudy"<<'\n';
      else if(s=="Cloudy") cout<<"Rainy"<<'\n';
      else cout<<"Sunny"<<'\n';
      return 0;
    }

Measured memory_bytes: 256
// Aizu Vol-1 0102: Matrix-like Computation
// 2017.8.2

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

char *gets(char *);
char buf[100], *p;

#define MAX 10
int a[MAX+5][MAX+5];

int getInt(void)
{
	int minus = 0;
	int n = 0;
	while (isspace(*p)) p++;
	if (*p == '-') minus = 1, p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	if (minus) n = -n;
	return n;
}

int main()
{
	int n, r, c, s, t;

	while (1) {
		gets(p = buf), n = getInt();
		if (n <= 0) break;
		for (r = 0; r < n; r++) {
			gets(p = buf);
			for (c = s = 0; c < n; c++) a[r][c] = getInt(), s += a[r][c];
			a[r][c] = s;
		}
		for (c = t = 0; c < n; c++) {
			for (r = s = 0; r < n; r++) s += a[r][c];
			a[r][c] = s, t += s;
		}
		a[n][n] = t;
		for (r = 0; r <= n; r++) {
			for (c = 0; c <= n; c++) printf("%5d", a[r][c]);
			putchar('\n');
		}

	}
	return 0;
}

Measured memory_bytes: 528
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){

	int n;cin>>n;
	vi a(n+1);
	// inputarr(a,n);
	rep(1,n+1) cin>>a[i];
	sort(a.begin()+1,a.end());
	int ans=0;
	// int last=1;
	int pow[n+1];
	// memset(pow,0,sizeof(po));
	pow[0]=1;
	rep(1,n+1) pow[i]=(pow[i-1]*2)%M; 
	for(int i=1;i<=n;i++){
		int res=0;
		if(n!=i){
			res=(n-i)*pow[n-i-1];
		}
		res+=pow[n-i];
		res%=M;
		res*=pow[i-1];
		res%=M;

		res*=a[i];
		res%=M;
		ans+=res;
		ans%=M;
		// trace(i,res,ans,a[i],pow[n-i],(n-i)*pow[n-i-1]);
	}
	ans*=pow[n];
	ans%=M;
	cout<<ans<<endl;


    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef pair <int, int> pii;
typedef vector <int> vii;
typedef complex <double> Point;

#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mp make_pair
#define fst first
#define snd second

long long t, n, m, u, v, q, k;
const int N = 2e5 + 500;
const int LN = 21;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 61LL;
long long arr[N];

bool state[N];
vector <int> adj[N];
void dfs(int v, int p) {
  
  for (int u : adj[v]) {
    if (u == p) continue;
    if (arr[u] >= arr[v]) continue;
    dfs(u, v);
    if (state[u] == 0) state[v] = 1;
  }
}
int main() {
  csl;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
  }
  for (int i = 1; i <= n - 1; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) state[j] = 0;
    dfs(i, 0);
    if (state[i]) cout << i << " ";
  }
  cout << '\n';
  return 0;
}


















Measured memory_bytes: 5120
main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*77+r*51+g*4-c-3*t+18*b+12*r+3*g+3*c+3*s));exit(0);}

Measured memory_bytes: 0