akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 3;
    if (a == b || a == c || b == c) ans = 2;
    if (a == b && a == c) ans = 1;
    cout << ans << 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;
using ll = long long;

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

  if (a + b == 15)
    cout << '+' << endl;
  else if (a * b == 15)
    cout << '*' << endl;
  else
    cout << 'x' << endl;
  return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan =new java.util.Scanner(System.in);
		int n = scan.nextInt();
		String str = scan.next();
		if(n%2==0) {
			for(int i=0;i < n/2; i++) {
				if(str.charAt(i)!=str.charAt((n/2)+i)) {
					System.out.println("No");
					System.exit(0);
				}
			}
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

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

int main() {
  

    int n;
    float new_ing,avg;
    cin>>n;
    float v[n];
    for(int i=0;i<n;i++)
    {
    	cin>>v[i];
    }
     sort(v,v+n);
     if(n>2){
    new_ing=(v[0]+v[1])/2;
    for(int i=2;i<n;i++)
    {
    	avg=(new_ing+v[i])/2;
    	new_ing=avg;
    }
    cout<<avg;}
    if(n<=2)
    	cout<<(v[0]+v[1])/2<<endl;

    return 0;
}

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

A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans=0

k = min(A[0],B[0])
A[0] -= k
B[0] -= k
ans +=k
for i in range(1, n+1):
    kk = min(B[i-1],A[i])
    A[i] -= kk
    B[i-1] -= kk
    ans += kk
    if i!=n:
        mm=min(B[i],A[i])
        A[i] -= mm
        B[i] -= mm
        ans += mm
    #print(ans)
    #print(A,B)
print(ans)

Measured memory_bytes: 82148
def grand_garden(N: int, H: list) -> int:
    before = 0
    op = 0
    for h in H:
        if before < h:
            op += h - before
        before = h

    return op


if __name__ == "__main__":
    N = int(input())
    H = [int(s) for s in input().split()]

    ans = grand_garden(N, H)
    print(ans)


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

int main(){
    int a, b, ans;
    cin >> a >> b;
    ans = max(a+b,a-b);
    ans = max(ans,a*b);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    ll x; cin >> x; ll ans=0;
    if(x%11>6) ans+=2;
    else if(x%11>0) ans++;
    ans+=x/11*2;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

const int MAXN = 1e5;
vector<bool> isprime(MAXN + 10, true);

bool f(int n) {
  return isprime[n] && isprime[(n + 1) / 2];
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int Q;
  cin >> Q;
  isprime[0] = false, isprime[1] = false;
  for (int i = 2; i * i <= MAXN; i++) {
    if (!isprime[i]) continue;
    int k = 2;
    while (i * k <= MAXN) {
      isprime[i * k++] = false;
    }
  }
  vector<int> cs(MAXN + 10, 0);
  for (int i = 1; i <= MAXN; i++) {
    if (f(i)) cs[i]++;
    cs[i + 1] += cs[i];
  }
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << cs[r] - cs[l - 1] << '\n';
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  int h,w;cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  vector<vector<char>> ans(0,vector<char>(0));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  int high=h;
  int width=w;
  VI yoko(w,0);
  VI tate(h,0);
  for(int i=0;i<h;i++){
    int key=0;
    for(int j=0;j<w;j++){
      if(a[i][j]=='#'){key=1;}
    }
    if(key==0){tate[i]=1;}
  }
  for(int i=0;i<w;i++){
    int key=0;
    for(int j=0;j<h;j++){
      if(a[j][i]=='#'){key=1;}
    }
    if(key==0){yoko[i]=1;}
  }
  for(int i=0;i<h;i++){
    if(tate[i]==0){
      vector<char> tmp(0);
      for(int j=0;j<w;j++){
        if(yoko[j]==0){
          tmp.push_back(a[i][j]);
        }
      }
      ans.push_back(tmp);
    }
  }
  for(int i=0;i<ans.size();i++){
    for(int j=0;j<ans[i].size();j++){
      cout<<ans[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3112
#include <iostream>

int main() {
	int a;
	std::cin >> a;
	switch (a) {
	case 7:
		std::cout << "YES" << std::endl; return 0;
			break;
		case 5:
			std::cout << "YES" << std::endl; return 0;
			break;
		case 3:
			std::cout << "YES" << std::endl; return 0;
			break;
		default:
			std::cout << "NO" << std::endl; return 0;
			break;
	}
}

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

int main() {
    int A, B;
    cin >> A >> B;
    cout << (A + B) % 24 << endl;
    return 0;
}

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

int main(){
	
	
	int x,y;
	cin>>x>>y;
	
	int sol_x,sol_y;
	if((y-2*x)%2==1){
		cout<<"No\n";
	}else{
		sol_y = (y-2*x)/2;
		sol_x = x - sol_y;
		if(sol_y <0 || sol_x<0){
			cout<<"No\n";
		}else{
			cout<<"Yes\n";
		}	
	}
						
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  vector<ll> f(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>f[i];

  ll l=0;
  ll r=(ll)(1.0e18);

  sort(begin(a),end(a));
  sort(begin(f),end(f),greater<ll>());

  /*
  for(auto x:a) cout << x << " ";
  cout << endl;
  for(auto x:f) cout << x << " ";
  cout << endl;
  */
  ll cost;
  while(r-l>1){

    ll p=l+(r-l)/2;
    cost=0;

    rep(i,n){
      ll c;
      //if( p%f[i] ==0 ) c=a[i]-p/f[i];
      //else c=a[i]-p/f[i]+1;
      c=a[i]-p/f[i];
      cost+=max( c ,0LL);
    }
    //cout << p << "," << cost << endl;
    if(cost>k){
      l=p;
    }
    else{
      r=p;
    }

  }

  //cout << l << "," << r << endl;

  ll p=l;
  cost=0;

  rep(i,n){
    ll c;
    //if( p%f[i] ==0 ) c=a[i]-p/f[i];
    //else c=a[i]-p/f[i]+1;
    c=a[i]-p/f[i];
    cost+=max( c ,0LL);
  }
  //cout << p << "," << cost << endl;
  if(cost>k){
    cout << r << endl;
  }
  else{
    cout << l << endl;
  }
  

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 3328
n = int(input())
a = list(map(int,input().split()))
m = 1000000007
d = [0,0,0]
ans = 1
for i in range(n):
    if d[0] == d[1] == d[2] == a[i]:
        ans *= 3
        d[0] += 1
    elif (d[0] == d[1] or d[1] == d[2]) and a[i] == d[1]:
        ans *= 2
        d[1] += 1
    elif a[i] == d[0]:
        d[0] += 1
    elif a[i] == d[1]:
        d[1] += 1
    elif a[i] == d[2]:
        d[2] += 1
    
    else:
        ans = 0
        break
      
    ans %= m
    d = sorted(d,reverse=True)
print(ans)

Measured memory_bytes: 20888
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>

int main()
{
	int n, min = 100000;
	const int six_expo[6] = {6, 36,  216, 1296, 7776, 46656 };
	scanf("%d", &n);

	for (int i = 0; i < 26656; i++)
	{
		int tmp = n, tmp_count{};
		for (int j = 0; j < 6; j++)
		{
			tmp -= six_expo[j] * (i * 6 / six_expo[j] % 6);
			tmp_count += i * 6 / six_expo[j] % 6;
		}
		if (tmp < 0) continue;
		for (int j = 0; j <= 5 && tmp != 0; j++)
		{
			tmp_count += tmp % 9;
			tmp /= 9;
		}
		if (tmp_count < min) min = tmp_count;
	}
	printf("%d", min);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(a,j,k) for(int i = a ; i < j ; i += k)
#define f1(a,j,k) for(int i = a ; i > j ; i -= k)
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
typedef pair<int,int> pri;
typedef pair<long long,long long> prl;
bool cmp(ll a , ll b){
	return a > b;
}
int main() {
	std::ios::sync_with_stdio(false);
	ll a , b , c , x , y;
	cin >> x >> y >> a >> b >> c;
	ll aa[a] , bb[b] , cc[c];
	ll q[a+b];
	f(0,a,1) cin >> aa[i];
	f(0,b,1) cin >> bb[i];
	f(0,c,1) cin >> cc[i];
	sort(aa,aa+a,cmp);
	sort(bb,bb+b,cmp);
	sort(cc,cc+c,cmp);
	ll sum = 0;
  f(0,x,1) q[i] = aa[i];
	f(x,x+y,1) q[i] = bb[i-x];
	sort(q,q+x+y);
	f(0,c,1) if(i == x + y) break;
	else sum += max(cc[i],q[i]);
	f(c,x+y,1) sum += q[i];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4224
package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		s, t string
	)
	fmt.Scan(&s, &t)
	S := strings.Split(s, "")
	T := strings.Split(t, "")
	a := 0
	for i := 0; i < 3; i++ {
		if S[i] == T[i] {
			a++
		}
	}
	fmt.Println(a)
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String s = br.readLine();
    	String p = br.readLine();
    	out.println((s+s).contains(p)?"Yes":"No");
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
}

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

int main(){
    char a;
    cin >> a;
    if('A' <= a && a <= 'Z') {
        cout << "A" << endl;
    } else if('a' <= a && a <= 'z') {
        cout << "a" << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int a, b, k; cin >> a >> b >> k;
  int i, sum = 0;
  vector<int> v;
  for(i = 1; i <= 100; i++){
    if(a % i == 0 && b % i == 0){
      v.push_back(i);
    }
  }
  sort(v.begin(), v.end());
  cout << v[v.size() - k] << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(a*c,max(a*d,max(b*c,b*d)));
return 0;
}

Measured memory_bytes: 3632
def grader(mid, fin, re):
    """ 
    -1 <= mid <= 50
    -1 <= fin <= 50
    0 <= re <= 100

    >>> grader(40, 42, -1)
    'A'
    >>> grader(20, 30, -1)
    'C'
    >>> grader(0, 2, -1)
    'F'
    """
    score = mid + fin 
    if mid == -1 or fin == -1 or score < 30: 
        return 'F' 
    elif score < 50: 
        if re >= 50: 
            return 'C' 
        else:
            return 'D' 
    elif score < 65: 
        return 'C' 
    elif score < 80: 
        return 'B' 
    else:
        return 'A' 


def run():
    while True:
        m, f, r = [int(x) for x in input().split()]

        if m == -1 and f == -1 and r == -1: 
            break
        else:
            print(grader(m, f, r)) 

run()


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 4000005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}


int main()
{	boost
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif

ll a,b;
cin>>a>>b;
cout<<a*b;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,t;
    cin >> n >> t;
    int ans = 1001;
    REP(i,n){
        int a,b;
        cin >> a >> b;
        if(b<=t){
            ans = min(ans,a);
        }
    }
    if(ans==1001){
        cout << "TLE\n";
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import heapq

n = int(input())
adj = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b, c = list(map(int, input().split()))
    adj[a].append((c,b))
    adj[b].append((c,a))
#print(adj)
q, k = list(map(int, input().split()))

# Djkstra
distance = [10**15]*(n+1)
distance[k] = 0
h = []
heapq.heappush(h,[0,k])
while h:
    dist, node = heapq.heappop(h)
    for ndist, nnode in adj[node]:
        if distance[nnode] > distance[node] + ndist:
            distance[nnode] = distance[node] + ndist
            heapq.heappush(h, [distance[nnode],nnode])
#print(distance)

for _ in range(q):
    x, y = list(map(int, input().split()))
    print(distance[x]+distance[y])

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

int simulate(string S){
  char cur = 'A';
  for ( int i = 0; i < S.size(); i++ ){
    int u = S[i]-'0';
    if ( cur == 'A' ) cur = u ? 'Y' : 'X';
    else if ( cur == 'W' ) cur = u ? 'Y' : 'B';
    else if ( cur == 'X' ) cur = u ? 'Z' : ' ';
    else if ( cur == 'Y' ) cur = u ? ' ' : 'X';
    else if ( cur == 'Z' ) cur = u ? 'B' : 'W';
    else if ( cur == 'B' ) cur = u ? 'X' : 'Y';
    if ( cur == ' ' ) return 0;
  }
  return cur == 'B';
}

int main(){
  string S;
  while(1){
    cin >> S;
    if ( S[0] == '#' ) break;
    if (simulate(S)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1180
let n = 1000000007
let ( *^ ) x y = x * y mod n
let ( +^ ) x y = (x + y) mod n

let () =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m) in
  let xs = Array.init n (fun i -> Scanf.scanf "%d " (fun x -> (2 * i + 1 - n) *^ x)) in
  let ys = Array.init m (fun i -> Scanf.scanf "%d " (fun y -> (2 * i + 1 - m) *^ y)) in
  Printf.printf "%d\n" @@ Array.fold_left ( +^ ) 0 xs *^ Array.fold_left ( +^ ) 0 ys

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string num;
    cin >> num;
    int a,b,c,d;
    a=num[0]-'0';b=num[1]-'0';c=num[2]-'0';d=num[3]-'0';
    vector<char> op(3);
    for(int bit=0;bit < (1<<3);bit++){
        int v = a;
        if(bit & (1<<2)){
            v+=b;
            op[0] = '+';
        }else{
            v-=b;
            op[0] = '-';
        }

        if(bit & (1<<1)){
            v+=c;
            op[1] = '+';
        }else{
            v-=c;
            op[1] = '-';
        }

        if(bit & 1){
            v+=d;
            op[2] = '+';
        }else{
            v-=d;
            op[2] = '-';
        }

        if(v==7) break;
    }
    cout << a<<op[0]<<b<<op[1]<<c<<op[2]<<d<<"=7"<< endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program{
	static bool[] b;
	static int[] arr,s,r;
	static long ans=long.MaxValue,k=0;
	static long[,] dp;
	static void Main(){
		s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		r=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		b=new bool[s[2]];
		arr=new int[s[2]];
		dp=new long[s[0]+1,s[0]+1];
		for(int i=1;i<=s[0];i++){
			for(int j=1;j<=s[0];j++){
				if(i!=j){dp[i,j]=long.MaxValue/2;}
			}
		}
		for(int i=0;i<s[1];i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			dp[q[0],q[1]]=q[2];
			dp[q[1],q[0]]=q[2];
		}
		for(int i=1;i<=s[0];i++){
			for(int j=1;j<=s[0];j++){
				for(int k=1;k<=s[0];k++){
					dp[j,k]=Math.Min(dp[j,k],dp[j,i]+dp[i,k]);
				}
			}
		}
		fu1(0,0);
		Console.WriteLine("{0}",ans);
	}
	static void fu1(int a,int m){
		for(int i=0;i<s[2];i++){
			if(!b[i]){
				if(a!=0){k+=dp[m,r[i]];}
				if(a==s[2]-1){ans=Math.Min(ans,k);}
				else{
					b[i]=true;
					fu1(a+1,r[i]);
					b[i]=false;
				}
				if(a!=0){k-=dp[m,r[i]];}
			}
		}
	}
}

Measured memory_bytes: 15568
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++)
            cin >> a[i];

        sort(a.begin(), a.end(), greater<int>());

        int tot = a[0], cnt = 1;
        for(int i = 1; i < n; i++) {
            if(cnt < n - 1) {
                cnt++;
                tot += a[i];
            }
            if(cnt < n - 1) {
                cnt++;
                tot += a[i];
            }
        }

        cout << tot << '\n';

        
    }
    
    return 0;
}



Measured memory_bytes: 4784
import sys
import math

N = sys.stdin.readline().strip()
N = int(N)

L = sys.stdin.readline().strip().split()
L = [int(x) for x in L]

d0={}
d1={}


for i in range(0,N,2):
  a = L[i]
  c = d0.get(a)
  if c is None:
    d0[a] = 1
  else:
    d0[a] = c+1
  a = L[i+1]
  c = d1.get(a)
  if c is None:
    d1[a] = 1
  else:
    d1[a] = c+1

d01 = sorted(d0.items(), key=lambda x: -x[1])[0:2]
d11 = sorted(d1.items(), key=lambda x: -x[1])[0:2]


#print(d01)
#print(d11)


res = 0

if (d01[0][0] != d11[0][0]):
  res = N - (d01[0][1] + d11[0][1])
else:
  # ずらしたらそろえられる。どっちにそろえたほうが得？
  flag = 0
  if (len(d01)<=1):
    flag = 1
  if (len(d11)<=1):
    flag = flag + 2

  temp = 0
  if flag == 3:
    # 全部同じなら一方をすべてずらす
    temp = int(N/2)
  elif flag == 1:
    temp = d01[0][1] + d11[1][1]
  elif flag == 2:
    temp = d01[1][1] + d11[0][1]
  else:
    temp = max(d01[0][1] + d11[1][1], d01[1][1] + d11[0][1])
  res = N - temp

print(res)
  

Measured memory_bytes: 63596
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int a, b, c, k; cin >> a >> b >> c >> k;
  int ans = 0;
  while(a > 0 && k > 0){
    ans += 1;
    a--;
    k--;
  }
  while(b > 0 && k > 0){
    b--;
    k--;
  }
  while(c > 0 && k > 0){
    ans += -1;
    c--;
    k--;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int SIZE = 1e5 + 34;

int dp[SIZE];
int n, w, wi, val;

    void prepro(){
        for(int i = 0; i < n; i++)
            dp[i] = -1;
        dp[w] = 0;
    }

signed main(){


    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> w;
    prepro();

    while(n--){
        cin >> wi >> val;
        for(int i = 0; i <= w; i++)
            if(dp[i] != -1 && i - wi >= 0)
                dp[i - wi] = max(dp[i - wi], dp[i] + val);
    }

    for(int i = 0; i < w; i++)
        if(dp[i] != -1){
            cout << dp[i];
            return 0;
        }
}

Measured memory_bytes: 1024
#include<stdio.h>
void HN(int l[],int n,int k){
  int i,j;
  int tmp=0;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(l[i]<l[j]){
        tmp=l[i];
        l[i]=l[j];
        l[j]=tmp;
      }
    }
  }
  int count=0;
  for(i=0;i<k;i++){
    count+=l[i];
  }
  printf("%d",count);
}
int main(){
  int N,K;
  scanf("%d %d",&N,&K);
  int l[N];
  int i;
  for(i=0;i<N;i++){
    scanf("%d",&l[i]);
  }
  HN(l,N,K);
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S;
	cin >> S;
	if (S == "AAA" || S == "BBB") {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n, a[MAXN];
map < int, int > cnt;

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> n;
	rep(i, 1, n) cin >> a[i];
	rep(i, 1, n) cnt[a[i]]++;
	ll res = 0;
	int last = -1;
	for(auto &to : cnt) {
		if(to.second > 3) updmax(res, to.first * 1ll * to.first);
		if(to.second < 2) continue;
		if(last != -1) updmax(res, last * 1ll * to.first);
		last = to.first;
	}
	cout << res << nxtl;
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int a[100010];
long long sum[100010];
map<long long int ,long long int >mapp;
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        while(!mapp.empty()) mapp.clear();
        sum[0]=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            sum[i]=(sum[i-1]+a[i])%m;
        }
        long long ans=0;
        for(int i=1;i<=n;i++)
        {
            if(sum[i]==0) ans++;
            ans+=mapp[sum[i]];
            mapp[sum[i]]++;
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 5376
#include<stdio.h>

int main(void){
  int n,dm;
  long int sum=0;
  int a[200000];
  scanf("%d", &n);
  scanf("%d", &a[0]);
  dm = a[0];
  for(int i = 1;i < n;i++){
    scanf("%d", &a[i]);
    if(dm<=a[i]){
      dm=a[i];
    }
    else{
      sum+=dm-a[i];
    }
  }
  printf("%ld", sum);
  
  return 0;
}

Measured memory_bytes: 2500
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	s := getNextString(scanner)
	n := len(s)
	counter := make([]int, 26)
	for i := 0; i < n; i++ {
		counter[s[i]-'a']++
	}

	c := 0
	sum := 0
	for i := 0; i < 26; i++ {
		if counter[i] == 0 {
			continue
		}
		c++
		sum += counter[i]
	}
	ans := "Second"
	if c > 2 {
		if s[0] != s[n-1] {
			if sum%2 == 1 {
				ans = "First"
			}
		} else {
			if sum%2 == 0 {
				ans = "First"
			}
		}
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}


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

int main(){
    string a, b, c;
    cin >> a >> b >> c;

    char dif = 'A' - 'a';
 
    cout << (char)(a[0] + dif) << (char)(b[0] + dif) << (char)(c[0] + dif) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int M,N,m,n;
int main(){
	scanf("%d%d%d%d",&N,&M,&n,&m);
	// cout<<(1ll*n*m+1)*(M/m)*(N/n)<<endl;
	if((N%n==0)&&(M%m==0))puts("No");
	else{
		puts("Yes");
		for(int i=1;i<=N;++i){
			for(int j=1;j<=M;++j){
				printf("%d ",((i%n==0)&&(j%m==0))?-1000*m*n+1000-1:1000);
			}putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 1536
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <list>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

int dp[3001][3001];
bool visited[3001][3001];
int N;
int A[3001];

int rec(int left, int right) {
    if (left > right) return 0;
    if (visited[left][right]) return dp[left][right];
    visited[left][right] = true;

    int diff = N - (right - left + 1);
    if (diff % 2 == 0) {
        dp[left][right] = max(rec(left + 1, right) + A[left], rec(left, right - 1) + A[right]);
    } else {
        dp[left][right] = min(rec(left + 1, right) - A[left], rec(left, right - 1) - A[right]);
    }

    return dp[left][right];
}

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    cout << rec(0, N - 1) << endl;
}

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

int main()
{
    long long n, min = 1000000, max = -1000000, sum = 0;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (min > a)
            min = a;
        if (max < a)
            max = a;
        sum += a;
    }
    cout << min << " " << max << " " << sum << endl;
    ;
}


Measured memory_bytes: 3100
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

int main(){
	int N; cin >> N;
	vector<int> P(N);
	vector<int> Q(N);
	rep(i,N){	
		cin >> P[i];
	}
	rep(i,N){
		cin >> Q[i];
	}
	vector<int> R(N);
	R = P;
	sort(R.begin(),R.end());
    int a,b,cnt;
	cnt = 0;
	do{
		cnt++;
        if(R == P){
			a = cnt;
		}
		if(R == Q){
			b = cnt;
		}
    }while(next_permutation(R.begin(),R.end()));
	cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;

    string ans = "";

    rep(i,0,s.length()-1)
    {
        if ( s[i] != s[i+1] )
        {
            ans += s[i];
        }
    }

    if ( ans[ans.length()-1] != s[s.length()-1] )
    {
        ans += s[s.length()-1];
    }

    cout<<ans.length()<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 592
n, m, l = map(int, input().split())

A = [0]*n
B = [0]*m

for i in range(n):
    A[i] = list(map(int, input().split()))

for i in range(m):
    B[i] = list(map(int, input().split()))

C = [0]*n

for i in range(n):
    C[i] = [0] * l
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for i in range(n):
    temp = []
    for j in range(l):
        temp.append(str(C[i][j]))
    line = " ".join(temp)
    print(line)


Measured memory_bytes: 6868
import java.util.*;
import static java.util.Arrays.*;

public class Main {

	int[] as;

	void run(){
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> arr = new ArrayList<Integer>();
		for(int i=1; i<=1111; i++){
			for(int j=i; j<=1111; j++){
				arr.add(i*i*i + j*j*j);
			}
		}
		as = new int[arr.size()];
		for(int i=0; i<as.length; i++)
			as[i] = arr.get(i);
		sort(as);
		for(;;){
			int n = in.nextInt();
			if(n == 0) return ;
			System.out.println(solve(n));
		}
	}

	int solve(int z){
		int id = -2 - binarySearch(as, z*z*z);
		return z*z*z - as[id];
	}

	public static void main(String args[]){
		new Main().run();
	}
}

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

int main()
{
    int n;
    cin>>n;
    string s1,s2;
    int i,j,x1,x2;
    cin>>s1>>s2;
    
    x1=s1.size()-1;
    x2=s2.size()-1;
    
    for(i=0;i<=x1;i++)
    {
        int t=i;
        
        for(j=0;j<=x2;j++)
        {   if(j+t<=x1)
            if(s1[j+t]!=s2[j])break;
        }
        if(j==x2+1)break;
    }
    cout<<2*n-(n-i)<<endl;
    return 0;
}


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

using namespace std;

int main(void)
{
    int N, x=0, max=0, i;
    string S;

    cin >> N;
    cin >> S;

    for(i=0; i<N; i++){
        if(S[i] == 'I'){
            x++;
        }

        else{
            x--;
        }

        if(max < x){
            max = x;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, a[100005], tab[100005][5], b[100005], c[100005];
int knap(int obj, int qual){
    if(tab[obj][qual]!=-1){
        return tab[obj][qual];
    }
    if(obj>n){
        return tab[obj][qual]=0;
    }
    if(qual==1){
        return tab[obj][qual]=max(a[obj]+knap(obj+1, 2),a[obj]+knap(obj+1, 3));
    }
    if(qual==2){
        return tab[obj][qual]=max(b[obj]+knap(obj+1, 1),b[obj]+knap(obj+1, 3));
    }
    if(qual==3){
        return tab[obj][qual]=max(c[obj]+knap(obj+1, 1),c[obj]+knap(obj+1, 2));
    }

}
int main()
{
    memset(tab, -1, sizeof(tab));
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    cout << max(max(knap(1, 1), knap(1, 2)), knap(1, 3)) << endl;
    return 0;
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 10000005;
bool isPrime[MAXN];
vector<int> pr;
vector<int> ans;
void sieve()
{
    memset(isPrime, 1, sizeof isPrime);
    isPrime[0] = isPrime[1] = 0;

    for (int i = 2; i * i <= MAXN; i += 1 + (i & 1))
    {
        if (isPrime[i])
        {

            for (int j = i * i; j < MAXN; j += i)
                isPrime[j] = 0;
        }
    }
    for(int i=0; i<MAXN; i++)
    {
        if(isPrime[i])
        {

                    ans.push_back(i);
        }
    }
}

ld power(ld x, ll y)
{
    ll temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
        return x * temp * temp;
}

void debug_out()
{
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
ll d[MAXN];
int main()
{
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++){
        for(ll j=i;j<=n;j+=i)
        {
            d[j]++;
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
     ans = ans + (i * d[i]);
     cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 81748
#include<stdio.h>
 int main()
{
 int n,i,x;
 scanf("%d",&n);
 for(i=1;i<=n;i++){
         x=i;
         if(i%3==0||i%10==3||i/10%10==3||i/100%10==3||i/1000==3)
               printf(" %d",i);
                   }
  printf("\n");
 return 0;

}
               



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

int main(){
  int k;
  string S;
  cin >> k;
  cin >> S;
  if(S.size() <= k){
    cout << S << endl;
  }else{
    S.erase(k);
    cout << S << "..." << endl;
  }
}

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

using namespace std;

#define int long long

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}

#define FOR(a,b,c) for(int a=b, __c=c; a<=__c; ++a)
#define FORD(a,b,c) for(int a=b, __c=c; a>=__c; --a)
#define forv(a,b) for(auto &a:b)

#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define reset(f,x) memset(f,x,sizeof(f))
#define fasty ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)

#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))

const int N=17;
int n,a[N][N],f[1<<N],c[1<<N];
int cur;

void dfs(int i,int x){
   if(i>n) f[cur]=max(f[cur], f[x]+c[cur^x]);
   else{
      dfs(i+1, x);
      if(bit(cur,i)) dfs(i+1, on(x,i));
   }
}

int32_t main(){
   fasty;

   cin>>n;
   FOR(i,1,n) FOR(j,1,n) cin>>a[i][j];

   FOR(p,1,(1ll<<n)-1){
      FOR(i,1,n) if(bit(p,i)){
         FOR(j,i+1,n) if(bit(p,j)){
            c[p]+=a[i][j];
         }
      }
   }

   reset(f,-127);
   f[0]=0;
   FOR(i,1,(1ll<<(n))-1){
      cur=i;
      dfs(1,0);
   }
   cout<<f[(1ll<<n)-1]<<'\n';
}


Measured memory_bytes: 5148
#pragma GCC target("avx2")
#pragma GCC optimize("O3")

# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
   SpeedForce;
	cin >> n;
	cout << n * (ll)n;
   return Accepted;
}

// B...a

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll XOR(ll a){
    if(a % 4 == 1)return 1;
    else if(a % 4 == 3)return 0;
    else if(a == 0)return 0;
    else return (XOR(a-1)^a);
}
signed main()
{   
    gearup;
    ll a,b; cin >> a >> b;
    cout << (XOR(max(0*1LL,a-1)) ^ XOR(b)) << endl;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

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

    vector<int> A(N);
    for(int i = 0; i< N; i++){
        cin >> A[i];
        A[i]--;
    }

    int sum = 0;

    vector<int> B(N);
    for(int i = 0; i< N; i++){
        cin >> B[i];
        sum+= B[i];
    }

    vector<int> C(N-1);
    for(int i = 0; i< N-1; i++) cin >> C[i];

    for(int i = 1; i < N; i++){
        if(A[i]- A[i-1] == 1){
            sum+= C[A[i-1]];
        } 
    }
    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define mkp make_pair
#define cerr if (0) cerr

const int N = 3007, MOD = 998244353, REV2 = 499122177;

int dp[N][N], a[N], two[N] = { 1 };

void solve() {
    loop1(i, N - 1)
        two[i] = two[i - 1] * 2 % MOD;
    int n, s;
    cin >> n >> s;
    loop1(i, n)
        cin >> a[i];
    dp[0][0] = two[n];
    for (int i = 1; i <= n; ++i)
        for (int W = 0; W <= s; ++W)
            dp[i][W] = (dp[i - 1][W] + (W >= a[i] ? dp[i - 1][W - a[i]] * REV2 : 0)) % MOD;
    cout << dp[n][s];
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


Measured memory_bytes: 74144
#include <iostream>

using namespace std;

int main ( ){

  int w,h,x,y,r;

  cin >> w >> h >> x >> y >> r ;

  if ( x >= r && y >= r && x+r <= w && y+r <= h ) {
    cout << "Yes" << endl; 
  }  else {
      cout << "No" << endl;
  } return 0;
  }

Measured memory_bytes: 1156