akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

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

  int N;
  cin >> N;
  vector<int> L(N);
  REP(i, N) cin >> L[i];
  sort(L.begin(), L.end());
  int sum = 0;
  for(int i = 0; i < N - 1; i++) {
    sum += L[i];
  }
  if(L[N - 1] < sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
program answer
  implicit none
  integer :: i, N, ans
  integer, allocatable :: A(:), B(:), C(:)
  read(*,*) N
  allocate(A(N),B(N),C(n-1))
  read(*,*) A
  read(*,*) B
  read(*,*) C

  ans=sum(B)
  do i = 1, N-1
     if(A(i+1)==A(i)+1) then
        ans=ans+C(A(i))
     end if
  end do

  write(*,*) ans

  stop
 end program answer

Measured memory_bytes: 2788
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] weight = new int[n];
		
		for(int i = 0; i < n; i++) {
			weight[i] = stdIn.nextInt();
		}
		
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < n-1; i++) {
			int sum1 = 0;
			int sum2 = 0;
			int j = 0;
			for( j = 0; j < i+1; j++) {
				sum1 += weight[j];
				}
			for(int k = j; k < n; k++) {
				sum2 += weight[k];
			}
			ans = Math.min(ans, Math.abs(sum1-sum2));
		}
		
		
		System.out.println(ans);
		
		
	}

}


Measured memory_bytes: 21844
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

//Author: Jiangsu Nanjing Li Zongtai
//强壮标记*10000,手牌*10000,血量10000 lyl+hzj也打不死我哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈~~~~

const int inf=2147483647;

string s;
int main()
{
	cin>>s;
	
	if(s[0]==s[2]) puts("Yes");
	else puts("No");
	
	return 0;
}

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a%b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    long long i, j, k, n, m, t, x, y, z, s=999999999999, c=0, l;
    cin >> n >> k;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    for(i=0; i<=n-k; i++)
    {
        x=a[i+k-1]-a[i];
        if(x<s)
            s=x;
    }
    cout << s << endl;
}


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

using namespace std;

#define int long long int
#define test int tttt; cin>>tttt; while(tttt--)
#define mod 1000000007    
#define pb push_back
#define vi vector<int>
/*void messigoat(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); #endif }*/
int gcd(int a, int b){if(b==0)return a;return gcd(b,a%b);}
bool prime(int n){for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}
long long binexpm(long long a, long long b, long long m) {a %= m;long long res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
long long binexp(long long a, long long b) {long long res = 1;while (b > 0) {if (b & 1)res = res * a;a = a * a;b >>= 1;}return res;}

int32_t main()
{	
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);//messigoat();
	
	double d,t,s;
	cin>>d>>t>>s;
	double x=ceil(d/s);
	
	if(x<=t)
	cout<<"Yes"<<"\n";
	else
	cout<<"No"<<"\n";
	return 0;
}

Measured memory_bytes: 3756
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#define ll long long
#define INF 0x3f3f3f3f
#define N 100005
using namespace std;
long long ctnba[N],ctba[N],cta[N];
int main()
{
	vector<int>a,b,c;
	long long n,i,j;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>j;
		a.push_back(j);
	} 
	for(i=0;i<n;i++)
	{
		cin>>j;
		b.push_back(j);
	} 
	for(i=0;i<n;i++)
	{
		cin>>j;
		c.push_back(j);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	long long ct=0;
	for(i=0;i<n;i++)
	{
		long long l1=lower_bound(a.begin(),a.end(),b[i])-a.begin();
		long long l2=c.end()-upper_bound(c.begin(),c.end(),b[i]);
		ct+=l1*l2;
	} 
	cout<<ct<<endl;
} 

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

int main() {
  string s, ans = "No";
  cin >> s;
  for (int i = 0; i < 2; i++)
    if (s.at(i) == s.at(i + 1) && s.at(i) == s.at(i + 2))
      ans = "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define mod 1000000007
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inp_vecN for(int i=0;i<n;i++)cin>>v[i]; 
vector<int> get_Factors(ll n)
{
      vector <int> v;
      for(ll i=1; i<=sqrt(n)+1; i++)
      {
            if(n%i==0)
            {
                  v.push_back(i);
                  v.push_back(n/i);
            }
      }

      return v;
}
string get_bin(ll n)
{
    string s = "";
    while(n > 0)
    {
        s += ('0' + n%2);
        n /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}

ll bin_to_dec(string s)
{
    ll ans = 0;
    for(auto ch: s)
    {
        ans *= 2;
        ans += (ch - '0');
    }
    return ans;
}
void PrintVector(vector<int> v,int n)
{

    for(int i=0;i<n;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
int no_of_primeFactors(int n)  
{ 
    int count=0;
    while (n % 2 == 0)  
    {  
        count++;
        n = n/2;  
    }  
   
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    { 
        while (n % i == 0)  
        {  
           count++;
            n = n/i;  
        }  
        
    }  
    if (n > 2)  
        count++;
    return count;
} 
 ll gcd(int a, int b)
{ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
} 
   
  ll lcm(int a, int b)  
{  
    return (a/gcd(a, b)*b);  
}  



ll pwr(ll base,ll expo,ll m)
{
    if(base==0) return 0LL;
    if(expo==0) return (1LL%m);
    if((expo&1)==0) {ll temp=pwr(base,expo>>1,m); return (temp*temp)%m;}
    return ((base%m)*pwr(base,expo-1,m))%m;
}

int main(int argc, char const *argv[])
{
    ios;
    
    int n,x;
    cin>>x>>n;
    if(n==0)
    {
      cout<<x;
      return 0;
    }
    std::vector<int> v(n);

    for(int i=0;i<n;i++)
    {
      cin>>v[i];

    }
    sort(v.begin(),v.end());
    int left=x,right=x,times=0;
    bool flag=true;
    while(flag)
    {
      int p1=left-times;
      bool b1=binary_search(v.begin(),v.end(),p1);
      if(b1==false)
      {
            cout<<p1;
            return 0;
      }
      int p2=right+times;
      bool b2=binary_search(v.begin(),v.end(),p2);

      if(b2==false)
      {
            cout<<p2;
            return 0;
      }
      times++;

    }


    return 0;
}

Measured memory_bytes: 3624
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n = onem()


ans = 0

for i in range(n):
	ans += (i+1)*(n-i)

for i in range(n-1):
	a = l()
	a.sort()
	a,b = a

	ans -= (a) * (n - b + 1)
print(ans)



Measured memory_bytes: 74856
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
    double x,y,a,b,c,d,e;
    cin>>x>>y>>a>>b;
    c=(x-a)*(x-a);
    d=(y-b)*(y-b);
    e=sqrt((c+d));

    printf("%.8f\n",e);



    return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;
 
typedef long long LL;
typedef set <LL> SET;
 
const int size = 51;
const string YES = "YES";
const string NO = "NO";

int bek[size];
int vol[size];
int n;

SET visited[size];
 
bool dist( int now );
bool solve( int now );
 
bool dist( int now ) {
    if ( vol[now] == 0 ) return solve( now + 1 );

    LL state = 0;
    for ( LL i = now; i < n; ++ i ) {
        state <<= 1;
        if ( vol[i] == bek[i] ) state ++;
    }
    
    if ( visited[now].find( state ) != visited[now].end() ) return false;
    visited[now].insert( state );
    if ( vol[now] == 0 ) return false;
    
    for ( int i = now + 1; i < n; ++ i ) {
        if ( vol[i] != 0 ) continue;
        if ( vol[now] < bek[i] ) continue;
        if ( i - 1 >= now + 1 && bek[i-1] == bek[i] && vol[i-1] == 0 ) continue;
        vol[now] -= bek[i];
        vol[i] = bek[i];
        if ( dist( now ) ) return true;
        vol[i] = 0;
        vol[now] += bek[i];
    }
    return false;
}
 
bool solve( int now ) {
    if ( now == n ) return true;
    if ( vol[now] == 0 ) return false;
    if ( solve( now + 1 ) ) return true;
    if ( dist( now ) ) return true;
    return false;
}
 
int main() {
    while ( cin >> n && n ) {
        for ( int i = 0; i < n; ++ i ) {
            cin >> bek[i];
            vol[i] = 0;
            visited[i].clear();
        }
        sort( bek, bek + n, greater<int>() );
        vol[0] = bek[0];
        cout << ( solve( 0 ) ? YES : NO ) << endl;
    }
    return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>
int main ( )
{
       int n,i,odd=0;
       float p;
        scanf ("%d",&n);
        for (i=1; i<=n; i++)
        {
                if (i%2!=0)
                         odd++;
         }
         p=odd/(float)n;
         printf ("%f\n",p);
         return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	stack<int> st;

	string in = "";
	while (cin >> in ){
		if (isdigit(in[0]) ){
			st.push (atoi (in.c_str() ) );
		}else{
			char op = in[0];
			int b = st.top(); st.pop();
			int a = st.top(); st.pop();
			int c;
			switch (op ){
				case '+':
					c = a + b; st.push(c);
					break;
				case '-':
					c = a - b; st.push(c);
					break;
				case '*':
					c = a * b; st.push(c);
					break;
				case '/':
					c = a / b; st.push(c);
					break;
			} // end switch
		} // end if
	} // end while
	int res = st.top();
	cout << res << endl;
		
	return 0;
}

Measured memory_bytes: 1204
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

ll d;
vector<ll> c(26,0),last(26,-1);
vector<vector<ll>> s;

ll score(vector<ll> &t){
    last.assign(26,-1);
    ll ans=0;
    rep(i,d){
        ans+=s[i][t[i]];
        last[t[i]]=i;
        rep(j,26) ans-=c[j]*(i-last[j]);
        //cout<<ans<<endl;
    }
    return ans;
}

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

    scanf("%lld",&d);
    vector<set<ll>> st(26);
    rep(i,26){
        st[i].insert(-1);
        st[i].insert(d);
    }
    vector<ll> t(d,0);
    rep(i,d){
        t[i]=i%26;
        st[i%26].insert(i);
    }
    rep(i,26) scanf("%lld",&c[i]);
    s.assign(d,vector<ll>(26,0));
    rep(i,d)rep(j,26){
        scanf("%lld",&s[i][j]);
    }
    /*
    rep(i,d){
        scanf("%d",&t[i]);
        t[i]--;
        st[t[i]].insert(i);
    }
    */
    ll ans=score(t);
    //printf("%lld\n",ans);
    //cout<<ans<<endl;
    
    ll m=1000; //scanf("%d",&m);
    ll p,di=0,q=0,ddi=18,dq=17,pans;
    rep(i,m){
        if(t[di]==q) q=(q+1)%26;
        pans=ans;
         //scanf("%d",&di); scanf("%d",&q);
        //di--; q--;
        p=t[di];
        ans+=s[di][q]-s[di][p];
        ll dd=*st[p].upper_bound(di)-di;
        ll du=di-*(--st[p].lower_bound(di));
        //printf("%lld %lld\n",dd,du);
        ans-=du*dd*c[p];
        dd=*st[q].upper_bound(di)-di;
        du=di-*(--st[q].upper_bound(di));
        //printf("%lld %lld\n",dd,du);
        ans+=du*dd*c[q];
        di=(di+ddi)%d;
        q=(q+dq)%26;
        if(pans<ans){
            st[p].erase(di);
            st[q].insert(di);
            t[di]=q;
        }
        else ans=pans;
        //printf("%lld %lld\n",ans,score(t));
    }
    rep(i,d) printf("%lld\n",t[i]+1);
    //printf("%lld\n",ans);
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

vector<pair<Int, Int>> G[100001];
Int d[100001];

int main() {
    Int k;
    cin >> k;
    for (Int i = 1; i < k; i++) {
        if ((i + 1) % 10 != 0) {
            G[i].emplace_back((i + 1) % k, 1);
        }
        G[i].emplace_back(i * 10 % k, 0);
    }
    for (Int i = 0; i < (Int)k; i++) {
        d[i] = INF;
    }
    d[1] = 0;
    deque<Int> q;
    q.push_back(1);
    while (not q.empty()) {
        Int x = q.front();
        q.pop_front();
        for (Int i = 0; i < (Int)G[x].size(); i++) {
            Int to = G[x][i].first;
            Int cost = G[x][i].second;
            if (d[to] > d[x] + cost) {
                d[to] = d[x] + cost;
                if (cost == 0) {
                    q.push_front(to);
                } else {
                    q.push_back(to);
                }
            }
        }
    }
    print(d[0] + 1);
    return 0;
}

Measured memory_bytes: 11676
object Main extends App{
import scala.io.StdIn.readInt
val a = readInt()
val b = readInt()
val c = readInt()
val x = readInt()

var cnt = 0
for (i <- 0 to a) {
    for (j <- 0 to b){
        for (k <- 0 to c){
           if (x==500*i+100*j+50*k) cnt += 1
        }
    }
}

println(cnt)
}

Measured memory_bytes: 27192
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  int n; cin >> n;
  string s; cin >> s;

  int ans = 0;
  ans++;
  rep(i, n - 1) if (s[i] != s[i + 1]) ans++;

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <math.h>
#include <stdio.h>

int rel_l_l( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 ) {
	int rel;

	rel = 0;
	if ( fabs( ( x1 - x2 ) * ( x3 - x4 ) + ( y1 - y2 ) * ( y3 - y4 ) ) < 1e-10 )
		rel = 1;
	else if ( fabs( ( x1 - x2 ) * ( y3 - y4 ) - ( y1 - y2 ) * ( x3 - x4 ) ) < 1e-10 ) {
		rel = 2;
		if ( fabs( ( x1 - x3 ) * ( y3 - y4 ) - ( y1 - y3 ) * ( x3 - x4 ) ) < 1e-10 )
			rel = 3;
	}

	return rel;
}

int main( void ) {
	int n;

	scanf( "%d", &n );
	while ( n-- ) {
		double x1, y1, x2, y2, x3, y3, x4, y4;

		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4 );
		puts( rel_l_l( x1, y1, x2, y2, x3, y3, x4, y4 ) >= 2 ? "YES" : "NO" );
	}

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i = 0; i < 26; i++) cin >> c.at(i);
    vector<vector<int>> s(D, vector<int>(26));
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) cin >> s.at(i).at(j);
    }
    vector<int> t(D);
    //for (int i = 0; i < D; i++) cin >> t.at(i);
    vector<int> dp(26, 0);
    int ans = 0, ans_c = 0;

    for (int i = 0; i < D; i++) {
        int ans_pre = ans;
        for (int j = 0; j < 26; j++) {
            int satisfy = s.at(i).at(j);
            int tmp = ans_pre;
            tmp += satisfy;
            for (int k = 0; k < 26; k++) {
                if (k == j) continue;
                else tmp -= c.at(k) * (i + 1 - dp.at(k));
            }
            if (tmp > ans) {
                ans = tmp;
                ans_c = j;
            }
        }
        dp.at(ans_c) = i + 1;
        t.at(i) = ans_c + 1;
    }

    for (int i = 0; i < D; i++) cout << t.at(i) << endl;
    
    return 0;
}

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

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


int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> gcd_L(N+3), gcd_R(N+3);
    
    rep(i,N){
        cin >> A[i];
    }
    
    gcd_L[0]=0;
    gcd_R[N]=0;
    //i番目をかえる
    for(int i=0; i<N; i++){
        gcd_L[i+1] = gcd(A[i], gcd_L[i]);
    }
    
    for(int i=N-1; i>=0; i--){
        gcd_R[i] = gcd(A[i], gcd_R[i+1]);
    }
    
    
    int ans=0;
    for(int i=0; i<N; i++){
        ans = max(ans,gcd(gcd_L[i],gcd_R[i+1]));
    }
    
    cout << ans << endl;
    
    /*
    rep(i,N){
        cout << A[i] << " ";
    }cout << endl;
    */
    
    
}


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

int main()
{
	int H, W;
	do
	{
		cin >> H >> W;
		for (int x = 0; x < H; x++)
		{
			for (int y = 0; y < W; y++)
			{
				if (x == 0 || x == H - 1)
				{
					if (y == W - 1) cout << "#" << endl;
					else cout << "#";
					if (y == W - 1 && x == H - 1)
					{
						cout << endl;
					}
				}
				else
				{
					if (y == 0) cout << "#";
					else if (y == W - 1)cout << "#" << endl;
					else cout << ".";
				}
			}
		}
	} while (H != 0 || W != 0);
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;string s;
  cin>>n>>s;
  ll a=0,b=0,c=0;
  ll sum1,sum2=0;
  rep(i,n){
    if(s[i]=='R')
      a++;
    else if(s[i]=='G')
      b++;
    else
      c++;
  }
  sum1=a*b*c;
  rep(i,n){
    for(int j=i+1;j<n;j++){
      if(s[i]==s[j]) continue;
      int k=2*j-i;
      if(s[i]==s[k]||s[j]==s[k]||k>=n)
        continue;
      sum2++;
    }
  }
  cout<<sum1-sum2<<endl;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = a+b;
    if(a%3==0 || b%3==0 || c%3==0){
      System.out.println("Possible");
    }else{
      System.out.println("Impossible");
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, m;
	string s;
	cin >> n >> m >> s;
	vector<int> p;
	rep(i, n + 1) if (s[i] == '0') p.push_back(i);
	vector<int> ans;
	int now = n;
	while (now) {
		auto itr = lower_bound(all(p), now - m);
		if (itr == p.end()) {
			cout << -1 << endl;
			return 0;
		}
		if (*itr >= now) {
			cout << -1 << endl;
			return 0;
		}
		ans.push_back(now - *itr);
		now = *itr;
	}
	int N = ans.size();
	for (int i = N - 1; i >= 0; i--) {
		if (i < N - 1) cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1480
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = []
for i in range(N+1):
    dp.append([0] * 3)

for j in range(1, N+1):
    for k in range(3):
        if j == 1:
            dp[j][k] = abc[0][k]
        else:
            box = []
            for l in range(3):
                if l == k:
                    continue
                else:
                    box.append(dp[j-1][l] + abc[j-1][k])
            dp[j][k] = max(dp[j][k], max(box))
print(max(dp[N]))


Measured memory_bytes: 74968
# 2019-11-24 20:59:47(JST)
import sys

def main():
    n = int(sys.stdin.readline().rstrip())
    m = map(int, sys.stdin.read().split())
    ab = list(zip(m, m)) # 2回以上使えるようにlist化

    graph = [[] for _ in range(n + 1)]
    for a, b in ab:
        graph[a].append(b)
        graph[b].append(a)

    root = 1
    parent = [None] * (n + 1)
    # treeなのでループがないため、parentが定義できる
    checked = []
    to_check = [root]
    # dfs: depth first search では stack
    # bfs: breadth first search では queueを使う
    # 今回は stack

    while to_check:
        x = to_check.pop()
        # stackから要素を取り除き、xにset
        for y in graph[x]: # xから直接つながっているverticesについて
            if y == parent[x]: 
                continue
            # yがxの親でなければ
            parent[y] = x # xを親にして
            to_check.append(y) # 子であるyをto_checkにstackしていく
        checked.append(x) # 探索が終わったらvertexを記録

    color = [None] * (n + 1) # 初期状態ではなにも塗らないのがNG
    # vertexに色を、色1から始めて一つ塗ったら色2, 色3,...と変えて塗っていく
    # その際、色iがngだったらその色iを跳ばして色i+1,色i+2,...と塗っていく(ngは親の色)
    for x in checked: # checkされた順になっている
        ng = color[x]
        c = 1
        for y in graph[x]:
            if y == parent[x]:
                continue
            if c == ng:
                c += 1
            color[y] = c 
            c += 1

    res = []
    for a, b in ab:
        if a == parent[b]:
            res.append(color[b])
        else: # 木なので parent[a] == b
            res.append(color[a])

    print(max(res))
    print('\n'.join(map(str, res)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38204
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    ans="".join(c for c in input()[::2])
    print(ans)

main()

Measured memory_bytes: 3620
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(1000000)

def main():
    s = readline().rstrip().decode()
    K = int(readline())
    #sに含まれる文字を一文字ずつ抽出する.
    #ここで抽出した文字を組み合わせて辞書順に文字列を構成していく
    #K<=5だから高々26^5個の文字列を構成することになる
    l = sorted(list(set(s)))
    #cnd:=構成した文字列を辞書順に格納するリスト
    cnd = []
    #f(sub):=subから構成可能なK文字以下のSの部分文字列を構成する関数
    def f(sub):
        cnd.append(sub)
        if len(sub) < K: 
            #lから選んでsubに一文字追加する
            for i in l:
                nx = sub+i
                if nx in s:
                    f(nx)
    for i in l:
        f(i) 
    print(cnd[K-1])
if __name__ == '__main__':
    main()


Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100000+5];
long long ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        ans=ans+a[i]/2;
        a[i]=a[i]%2;
        if(i<n&&a[i]&&a[i+1])
        {
            ++ans;
            --a[i];
            --a[i+1];
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 640
object Main{
  def main(args: Array[String]){
    val in = new java.util.Scanner(System.in)
    val a = in.nextInt
    var count = 0;

    var arr = new Array[Int](a)
    for(i <- 0 to a-1){
      arr(i) = in.nextInt
    }

    for(i <- 0 to a-2){
      var minpos = i;
      var minval = arr(i);

      for(j <- i+1 to a-1){
        if(arr(j) < minval){
          minpos = j;
          minval = arr(j)
        }
      }

      if(minpos != i){
        var tmp = arr(minpos)
        arr(minpos) = arr(i)
        arr(i) = tmp
        count = count + 1
      }
    }

    println(arr.mkString(" "))
    println(count)
  }
}

Measured memory_bytes: 42356
object Main {
  def main(args:Array[String]): Unit = {
    Iterator.continually(readLine())
      .map(s => {
        val xs = s.split(" ").map(_.toInt) 
        (xs(0), xs(1))
      })
      .takeWhile{
        case (0, 0) => false
        case _ => true
      }
      .foreach(xs => {
        val res = printRepeat(1 to xs._1)(printRepeat(1 to xs._2)("#") + "\n")
        println(res)
      })
  }
  
  def printRepeat(r:Range)(s:String): String = {
    r.foldLeft("")((a, _) => a + s )
  }
}

Measured memory_bytes: 79780
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

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

	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;

	int kokunai = 0;
	int kaigai = 0;
	int tuka = 0;
	for (int i = 0; i < N; i++) {
		if(S[i]=='a'){
			if(tuka<A+B){
				cout << "Yes" << endl;
				tuka++;
			}else{
				cout << "No" << endl;
			}
		}else if(S[i]=='b'){
			if(tuka<A+B&&kaigai<B){
				cout << "Yes" << endl;
				kaigai++;
				tuka++;
			}else{
				cout << "No" << endl;
			}
		}else{
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  string s;
  cin >> s;
  ll ans = 1000;

  rep(i, int(s.size()-2)) {
    ll tmp = abs(753 - stoi(s.substr(i,3)));
    if (tmp < ans)
      ans = tmp;
  }

  cout << ans << endl;


  return 0;
}


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

int main(){
    char str[4];

    scanf("%s", &str);
    for (int i = 0; i < 3; i++){
        if(str[i] == str[i+1]){
            printf("Bad\n");
            return 0;
        }
    }
    printf("Good\n");

    return 0;    
}


Measured memory_bytes: 1556
#include<stdio.h>

int main(){

  double max,min, in;

  scanf("%lf",&in);

  max = in;
  min = in;

  while(scanf("%lf",&in) != EOF){

    if(max < in){
      max = in;
    }
    if(min > in){
      min = in;
    }
  }

  printf("%f\n",max-min);

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
int main()
{
	ll n,m,i,j,a,b,c;
	cin>>a>>b>>c;
	printf("%lld %lld %lld",c,a,b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool pri( int k)
{ if( k == 1) return false;
    for(int i = 2; i * i <= k; i++)
    {

        if( k % i == 0) return false;
    }
    return true;
}
int main()
{
    long long ans = 1;
    int n;
    cin >> n;
    for(int i = 2; i <= n; i++)
    {

      if(pri(i))
        {
           int k = i;
           long long cnt = n / i;
            while(i * k <= n)
            {
             i = i * k;
             cnt += n /i;
            }
            i = k;
         //   cout << i << " " << cnt << endl;
          ans = (ans * (cnt + 1))% 1000000007;
        }

    }
cout << ans;

}


Measured memory_bytes: 256
#include<cstdio>
int len(char *s){
    int i=0;
    while(s[i]!='\0')i++;
    return i;
}
int main(){
    char s[51];
    scanf("%s",s);
    for(int i=0;i<len(s)-8;i++)printf("%c",s[i]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld n, i;
	cin >> n;
	dbl A[n];
	dbl s, x;
	s = 0;
	foi(i,n){
		cin >> A[i];
		s += 1/A[i];
	}
	cout << fixed << setprecision(14) << (1/s);
	return 0;
}

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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<int> x(N);
        for(auto& t : x) cin >> t;
        int L; cin >> L;
        vector<int> next(N, 0);
        int dst = 0;
        for(int i=0;i<N;i++){
            while(dst != N-1 && x[i] + L >= x[dst+1]) ++dst;
            next[i] = dst;
        }
        vector<vector<int>> step;
        step.push_back(next);
        while(true){
            if(step.back().front() == N-1) break;
            for(int i=0;i<N;i++) next[i] = step.back()[step.back()[i]];
            step.push_back(next);
        }
        int Q; cin >> Q;
        for(int i=0;i<Q;i++){
            int a, b; cin >> a >> b;
            --a; --b;
            if(a > b) swap(a, b);
            int res = 1;
            for(int j=step.size()-1;j>=0;j--){
                if(step[j][a] < b){
                    a = step[j][a];
                    res += 1 << j;
                }
            }
            cout << res << endl;
        }
    }
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    int count = 0;
    cin >> N;
    for(int i = 1; i < 10; i++){
        if(N%i == 0){
            if((N/i) /10 > 0){
                continue;
            }
            else count++;
        }
    }
    if(count > 0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
import math
import collections
from operator import mul
from functools import reduce
import bisect
import string

numbers = "0123456789"
alphabets = string.ascii_letters # a-z+A-Zをロード
characters = numbers + alphabets
def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result

n,a,b,c=map(int,input().split())
l=[0]*n
for i in range(n):
    l[i]=int(input())

def zeropad(s,i):
    while len(s)<i:
        s="0"+s
    return s


mp=10000000000000000
for i in range(4**n):
    A=0
    B=0
    C=0
    ai=0
    bi=0
    ci=0
    s=base_cvt(str(i),4)
    s=zeropad(s,n)
    for j in range(n):
        if s[j]=='1':
            A+=l[j]
            ai+=1
        elif s[j]=='2':
            B+=l[j]
            bi+=1
        elif s[j]=='3':
            C+=l[j]
            ci+=1
    if ai>0 and bi>0 and ci>0:
        mp=min(mp,10*((ai-1)+(bi-1)+(ci-1))+abs(A-a)+abs(B-b)+abs(C-c))


print(mp)











Measured memory_bytes: 54108
#include<bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
set<ll> a;
int main(){_;
  ll l,r;cin>>l>>r;
  if(r-l>=2019LL) {
    cout<<0<<endl;
    return 0;
  }
  for(ll i=l;i<=r;i++) a.insert(i%2019LL);
  ll result=2020;
  for(auto li=a.begin();li!=a.end();li++){
    for(auto ri=next(li);ri!=a.end();ri++){
      result=min(result,(*li)*(*ri)%2019LL);
    }
  }
  cout<<result<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint  = long long;
vector<vector<lint> > G;
vector<lint> ans;

void dfs(lint now, lint ago){
  for(lint i = 0; i < G[now].size(); i++){
    lint next = G[now][i];
    if(next == ago) continue;
    ans[next] += ans[now];
    dfs(next, now);
  }
}

signed main(){
  lint N, Q; cin >> N >> Q;
  G.resize(N);
  ans.resize(N);
  for(lint i = 1; i < N; i++){
    lint a, b; cin >> a >> b;
    G[a - 1].push_back(b - 1); G[b - 1].push_back(a - 1);
  }
  for(lint i = 0; i < Q; i++){
    lint p, x; cin >> p >> x;
    ans[p - 1] += x;
  }
  dfs(0, -1);
  for(lint i = 0; i < N; i++) cout << ans[i] << '\n';
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    unordered_map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if(mp[x] % 2) {
            mp[x]--;
        } else {
            mp[x]++;
        }
    }
    int ans = 0;
    for (auto p : mp) {
        if (p.second > 0) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 7292
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100010;

int a[MAXN];
bool sol[MAXN];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    memset(a, 0, sizeof(a));
    memset(sol, false, sizeof(sol));
    int x;
    char s[5];
    int ans = 0, tot = 0;
    for (int i = 1; i <= m; i ++)
    {
        scanf("%d%s", &x, &s);
        if (s[0] == 'A')
        {
            if (sol[x] == false)
            {
                ans ++;
                sol[x] = true;
                tot += a[x];
            }
        }
        else
        {
            if (sol[x] == false)
            {
                a[x] ++;
            }
        }
    }
    printf("%d %d\n", ans, tot);
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int n;
long long sum[202020],ans=1e18+10;
void get(int l,int r,long long &f,long long &s)
{
	long long res=1e18+10;
	int ll=1,rr=r-1;
	while(ll<=rr)
	{
		int mid=ll+rr>>1;
		long long a=sum[mid]-sum[l-1],b=sum[r]-sum[mid];
		if(abs(a-b)<res)
		{
			res=abs(a-b);
			f=a;
			s=b;
		}
		if(a<=b)
		{
			ll=mid+1;
		}
		else
		{
			rr=mid-1;
		}
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		sum[i]=a+sum[i-1];
	}
	for(int i=2;i<=n-2;i++)
	{
		long long a,b,c,d,can;
		get(1,i,a,b);
		get(i+1,n,c,d);
		can=max(max(a,b),max(c,d))-min(min(a,b),min(c,d));
		ans=min(ans,can);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
lst_ab = sorted([tuple(map(int, input().split())) for _ in range(N)])
length = 0


for i in range(N):
    ai, bi = lst_ab[i][0], lst_ab[i][1]
    length += bi
    if length >= K:
        ans = ai
        print(ans)
        break


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	vector<int> arr (n);
	for(int i=0;i<n;i++)
	{
	    cin>>arr[i];
	}
	sort(arr.begin(),arr.end(),greater<int>());
	long long int ans=arr[0];
	int i=0;
	int k=1;
	int j=2;
	while(j<n &&k<n)
	{
	    while(i<2 && j<n && k<n)
	    {
	        ans+=arr[k];
	        i++;
	        j++;
	    }
	    i=0;
	    k++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4044
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()

digit = 1

alphabets = "abcdefghijklmnopqrstuvwxyz"
ans = ""

while(1):
    if N > pow(26, digit):
        N -= pow(26, digit)
        digit += 1
        continue
    N -= 1
    for j in range(digit):
        ans += alphabets[N // pow(26, digit - j - 1)]
        N = N % pow(26, digit - j - 1)
    break
print(ans)


Measured memory_bytes: 61988
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b-B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + L[cur], b, c) + 10
  ret2 = dfs(cur + 1, a , b + L[cur], c) + 10
  ret3 = dfs(cur + 1, a , b, c + L[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<long long> a(x);
    vector<long long> b(y);
    vector<long long> c(z);
    // long long a[x];
    // long long b[y];
    // long long c[z];
    for(int i=0;i<x;i++){
        cin >> a[i];
    }
    for(int i=0;i<y;i++){
        cin >> b[i];
    }
    for(int i=0;i<z;i++){
        cin >> c[i];
    }
    sort(a.begin(), a.end(), greater<long long>());
    sort(b.begin(), b.end(), greater<long long>());
    sort(c.begin(), c.end(), greater<long long>());
    priority_queue<long long, vector<long long>, greater<long long> > pq;
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            for(int l=0;l<z;l++){
                if(pq.size() < 3000)
                    pq.push(a[i]+b[j]+c[l]);
                else{
                    if(pq.top() >= a[i]+b[j]+c[l])
                        break;
                    else{
                        pq.pop();
                        pq.push(a[i]+b[j]+c[l]);
                    }
                }
            }
        }
    }
    int size = pq.size();
    vector<long long> ans(size);
    for(int i=0;i<size;i++){
        ans[size-i-1] = pq.top();
        pq.pop();
    }
    for(int i=0;i<k;i++){
        cout << ans[i] << endl;
    }
}


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

int main(){
    char ch;
    cin >> ch;
    if(ch=='A') cout << 'T' << endl;
    if(ch=='T') cout << 'A' << endl;
    if(ch=='G') cout << 'C' << endl;
    if(ch=='C') cout <<'G' <<endl;

}

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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		char[] ch = str.toCharArray();

		for(int i = 0; i < str.length(); i++){
			if(Character.isUpperCase(ch[i])){
				ch[i] = Character.toLowerCase(ch[i]);
			}else{
				ch[i] = Character.toUpperCase(ch[i]);
			}

		}
		System.out.println(ch);
	}
}

Measured memory_bytes: 24220
#include <bits/stdc++.h>
#define PB push_back
#define FT first
#define SD second
#define MP make_pair
#define INF 0x7fffffff
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>  P;
typedef vector<int> VI;
typedef map<int,int> MII;
const int N = 305, MOD = 7+1e9;
int n, c1[2*N][2*N], c2[2*N][2*N];
void init(int D, vector<P>& V)
{
    V.clear();
    for(int i = 0;i * i <= D;i ++)
    {
        int j = sqrt(D - i * i);
        if(j * j + i * i == D)
        {
            V.PB({i, j});
        }
    }
}
bool check(int x, int y)
{
    return x >= 0 && x < 2*n && y >= 0 && y < 2*n;
}
void dfs(int x, int y, const vector<pair<int, int>>& q, int C[][2*N], int cur = 0) 
{
    C[x][y] = cur;
    for (auto p : q) 
    {
        for (int s1 : {-1, 1}) 
        {
            for (int s2 : {-1, 1}) 
            {
                int nx = x + p.first * s1;
                int ny = y + p.second * s2;
                if(!check(nx, ny) || C[nx][ny] != -1) continue;
                dfs(nx, ny, q, C, !cur);
            }
        }
    }
}
int main()
{
#ifdef YUUKILP
    freopen("in.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d1, d2;
    vector<P> v1, v2, V[4];
    cin >> n >> d1 >> d2;
    init(d1, v1);
    init(d2, v2);
    memset(c1, -1, sizeof c1);
    memset(c2, -1, sizeof c2);
    for(int i = 0;i < 2*n;i ++)
    {
        for(int j = 0;j < 2*n;j ++)
        {
            if(c1[i][j] == -1) dfs(i, j, v1, c1, 0);
            if(c2[i][j] == -1) dfs(i, j, v2, c2, 0);
            V[(c1[i][j]<<1) + c2[i][j]].PB(MP(i, j));
        }
    }
    for(int i = 0;i < 4;i ++)
    {
        if(V[i].size() >= n*n)
        {
            for(int j = 0;j < n*n;j ++)
                cout << V[i][j].FT << " " << V[i][j].SD << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 46168
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L
const int mxN = 2e2;

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    long long tmp = 0;
    long long ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            tmp = a[i] - a[i + 1];
            ans += tmp;
            a[i + 1] += tmp;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4756
n,k = map(int,input().split())
A = list(map(int,input().split()))

hant = [0 for i in range(n)]
add = [1]
now = 1
hant[0]= 1
count = 1
for i in range(max(n,k)):
    now = A[now-1]
    add.append(now)
    #print(now)
    count+=1
    if hant[now-1] == 0:
        hant[now-1] = count
    else:
        syuki = count-hant[now-1]
        amari = hant[now-1]-1
        break

rep = add[amari:syuki+amari]

#print(syuki,amari,add,rep)

if k>=amari:
    ind = (k-amari)%syuki
    print(rep[ind])
elif k<amari:
    print(add[k])

Measured memory_bytes: 32252
#include <bits/stdc++.h>
using namespace std;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

#define SORT(arr) sort(arr, arr + ARRAY_LENGTH(arr))

int N;
int bucket[200001]={0};
int main(){
	cin >> N;
	int a[N],b[N];
	int mi=(N-1)/2;
	for (int i=0;i<N;i++){
		cin >> a[i];
		b[i] = a[i];
	}
	SORT(b);
	int md0=b[mi+1],md1=b[mi];

	for(int i=0;i<N;i++){
		if(a[i]<md0) cout << md0 << endl;
		else cout << md1 << endl;
	}

	return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>

void swap(int*, int*);

int main(){
    
    int a[3];
    int cost = 0;
    int i, j;
    for(i = 0; i < 3; i++){
        scanf("%d",&a[i]);
    }
    for(i=0; i<3; i++){
        for(j=i; j<3; j++){
            if(a[i] > a[j]){
                swap(&a[i], &a[j]);
            }
        }
    }
    cost = a[2] - a[0];
    printf("%d\n",cost);
    return 0;
}

void swap(int *a, int *b){
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int d = sc.nextInt();  
      	int[] c = new int[26];
      	int[][] s = new int[d][26];
      	for(int i=0;i<26;i++){
          c[i] = sc.nextInt();
        }
      	for(int i=0;i<d;i++){
          for(int j=0;j<26;j++){
            s[i][j] = sc.nextInt();
          }
        }
      	for(int i=0;i<d;i++){
          System.out.println(i%26+1);
        }
    }
}


Measured memory_bytes: 38112
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  int n,l;
  cin>>n>>l;
  int m=99999,ans=0;
  for(int i=1;i<=n;i++) {
    ans+=l+i-1;
    if(abs(m)>abs(l+i-1)){
      m=l+i-1;
    }
  //  cout<<l+i-1<<endl;
  }
//  cout<<ans<<" "<<m<<endl;
  ans-=m;
  cout<<ans<<endl;
}


Measured memory_bytes: 384
h, w = map(lambda x: int(x)+2, input().split())
MOD = 10**9+7
MAZE = ['#'*w]
for _ in range(h-2):
    MAZE.append('#'+input()+'#')
else:
    MAZE.append('#'*w)

route = [[0]*w for _ in range(h)]
route[1][1] = 1
for i in range(1, h-1):
    for j in range(1, w-1):
        for x, y in [(i+1, j), (i, j+1)]:
            if MAZE[x][y] == '#':
                continue
            route[x][y] += route[i][j]
            route[x][y] %= MOD

print(route[-2][-2])

Measured memory_bytes: 43636