akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public int n, w;
	public int[][] array;
	public int[][] dp;
	
	public static void main(String[] args){
		Main q2 = new Main();
		q2.solve();
	}
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		w = sc.nextInt();
		array = new int[n][2];
		for(int i = 0;i < n;++i){
			int[] hoge = new int[2];
			hoge[0] = sc.nextInt();
			hoge[1] = sc.nextInt();
			array[i] = hoge;
		}
		dp = new int[n][w+1];
		System.out.println(calc(0, 0));
	}
	
	public int calc(int n, int w){
		if(n >= this.n) return 0;
		
		if(dp[n][w] > 0) return dp[n][w];
		
		if(w + array[n][1] > this.w){
			return dp[n][w] = calc(n+1, w);
		}else{
			return dp[n][w] = Math.max(calc(n+1, w+array[n][1]) + array[n][0], calc(n+1, w));
		}
	}
}

Measured memory_bytes: 32332
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const ll inf = 1ll<<50;



const int mxn = 55560;
int b[mxn];
vector<int> v;
vector<int> w;
int main()
{
	int n;
	scanf("%d",&n);
	int f = 55555;
	for(int i=2;i<=f;i++)
	{
		if(b[i] == 0)
		{
			v.push_back(i);
			for(int m = i*2;m<=f;m+=i)
			{
				b[m] = 1;
			}
		}
	}
	for(int i=0;i<v.size();i++)
	{
		int x=v[i];
		if(x%5 == 1)
		{
			w.push_back(x);
		}
	}
	for(int i=0;i<n-1;i++)
	{
		printf("%d ",w[i]);
	}
	printf("%d\n",w[n-1]);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, N;
    cin >> H >> N;
    long long sum = 0;
    for(int i = 0; i < N; i++) {
        int A;
        cin >> A;
        sum += A;
    }
    cout << (H <= sum ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, W;
  cin >> n >> W;
  vector<int> value(n + 1), weight(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> weight[i] >> value[i];
  }
  int sum = 0;
  for (int i = 1; i <= n; ++i) sum += value[i];
  vector<long long> dp(sum + 1, 1e18L);
  dp[0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int v = sum - value[i]; v >= 0; --v) {
      dp[v + value[i]] = min(dp[v + value[i]], dp[v] + weight[i]);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= sum; ++i) {
    if (dp[i] <= W) {
      ans = max(ans, (long long)i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{   ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long t,n,m,x,y,c,k;
    cin >> x >> y;
    if(y%2==1)
    {
        cout << "No" <<endl;
    }
    else if(x*2<=y && y<=x*4)
    {
        cout << "Yes" <<endl;
    }
    else
    {
        cout << "No" <<endl;
    }
    return 0;
}

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

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = 1<<30;
const ll MOD = 1e9+7;

vector<ull> generator(int digit, int start){
	vector<ull> v, ans;
	if(digit == 1){
		ans.pb(start);
		return ans;
	}
	ull num = 1;
	for(int j=1;j<=digit-1;j++){
		num = num*10;
	}
	num = num*start;
	if(start>0){
		v = generator(digit-1, start-1);
		for(int i=0;i<v.size();i++){
			ans.pb(num+v[i]);
		}
	}
	v = generator(digit-1, start);
	for(int i=0;i<v.size();i++){
		ans.pb(num+v[i]);
	}
	if(start<9){
		v = generator(digit-1, start+1);
		for(int i=0;i<v.size();i++){
			ans.pb(num+v[i]);
		}
	}
	v.clear();
	return ans;	
}

int main(){
	int k;
	vector<ull> ans;
	cin>>k;
	for(int digit=1;digit<=10;digit++){
		for(int i=1;i<=9;i++){
			vector<ull> tmp = generator(digit, i);
			for(int j=0;j<tmp.size();j++){
				ans.pb(tmp[j]);
				if(ans.size()>k){
					i=9;
					digit=10;
					break;
				}
			}
		}
	}
	cout<<ans[k-1];
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 1524
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
    ll n;
    cin>>n;
    ll nac=0,nwa=0,ntl=0,nre=0;
    vector<string> a(n);
    rep(i,n){cin>>a[i];
        if(a[i]=="AC")nac++;
        else if(a[i]=="WA")nwa++;
        else if(a[i]=="TLE")ntl++;
        else if(a[i]=="RE")nre++;
    }
cout<<"AC x "<<nac<<endl;
cout<<"WA x "<<nwa<<endl;
cout<<"TLE x "<<ntl<<endl;
cout<<"RE x "<<nre<<endl;
}

Measured memory_bytes: 6436
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
//typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x, int y):x(x), y(y){}
	P(){}
};

/** Problem2024 : Blackjack **/
int main()
{
	int N;
	cin>>N;
	rep(z, N) {
		char c1, c2;
		vector<char> card(8);
		int A = 0;
		int idx=0;
		
		cin>>c1>>c2;
		rep(i, 8) cin>>card[i];
		
		int sum=0;
		
		if (isdigit(c1)) sum+=c1-'0';
		else if (c1=='A') {
			if (sum+11>21) sum++;
			else {A++; sum+=11;}
		} else sum+=10;
		
		if (isdigit(c2)) sum+=c2-'0';
		else if (c2=='A') 	{
			if (sum+11>21) sum++;
			else {A++; sum+=11;}
		} else sum+=10;
		
		if (sum==21) {
			cout << "blackjack" << endl;
			continue;
		}
		
		while (1) {
			while (sum>21 && A) {
				sum-=10;
				A--;
			}
			
			if ((sum==17 && A) || sum<=16) {
				int nc = card[idx++];
				if (isdigit(nc)) sum+=nc-'0';
				else if (nc=='A') {
					if (sum+11>21) sum++;
					else {A++; sum+=11;}
				}
				else sum+=10;
			} else if (sum>16) break;
		}
		
		if (sum>21) cout << "bust" << endl;
		else cout << sum << endl;
	}
}

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

int main(){
  long  long res=0,a,b,n,m;
  vector<pair<long long,long long>> c;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    c.push_back({a,b});
  }

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

  for(int i=0;i<n;i++){
    long long mn=min(m,c[i].second);
    m-=mn;
    res+=mn*c[i].first;

  }

  cout<<res<<endl;
  return 0;

}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

constexpr int P = 1'000'000'007;
void solve(std::istream &in, std::ostream &out) {
  int n, m;
  in >> n >> m;
  if (m == 1) {
    out << m << '\n';
    return;
  }
  vector<int> factors;
  for (int i = 2; i * i <= m; ++i) {
    if (m % i == 0) {
      factors.push_back(i);
      if (i != m / i) {
        factors.push_back(m / i);
      }
    }
  }
  factors.push_back(m);
  sort(factors.begin(), factors.end());
  vector<vector<int>> dp(50, vector<int>(factors.size(), 0));
  for (int i = 0; i < factors.size(); ++i) {
    dp[1][i] = 1;
  }
  for (int count = 2; count < 50; ++count) {
    int cc = 0;
    for (int f1 = 0; f1 < (int) factors.size(); ++f1) {
      if (!dp[count - 1][f1]) continue;
      for (int f : factors) {
        if ((int64_t) factors[f1] * f <= m) {
          auto it = lower_bound(factors.begin(), factors.end(), factors[f1] * f);
          if (*it == factors[f1] * f) {
            ++cc;
            (dp[count][it - factors.begin()] += dp[count - 1][f1]) %= P;
          }
        }
      }
    }
    if (!cc) {
      assert(count < 40);
      break;
    }
  }
  vector<int> fa(n + 1, 1), ifa(n + 1, 1), rev(n+1,0);
  rev[1] = 1;
  for (int i = 2; i <= n; ++i) {
    rev[i] = (P - (int64_t) (P / i) * rev[P % i] % P) % P;
    fa[i] = (int64_t) fa[i - 1] * i % P;
    ifa[i] = (int64_t) ifa[i - 1] * rev[i] % P;
  }
  int ans = 0;
  for (int count = 1; count <= min(n, 49); ++count) {
    (ans += (int64_t) fa[n] * ifa[count] % P * ifa[n - count] % P * dp[count].back() % P) %= P;
  }
  out << ans;
}

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

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);

        String s=scan.next();
        int []cnt=new int [26];
        for(int i=0;i<s.length();i++){
            cnt[s.charAt(i)-'a']++;
        }

        String ans="Yes";
        for(int i=0;i<cnt.length;i++){
            if(cnt[i]%2!=0){
                ans="No";
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 9420
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N,X ;
  cin >> N >> X;
  int m[110] ;
  cinf(N,m) ;
  int sum=0 ;
  int min = m[0] ;
  for(int i=0;i<N;i++){
    sum += m[i] ;
    if(m[i] <min )
      min = m[i] ;
  }
  cout << N+(X- sum)/min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    deque<char> a,b,c;

    string al,bb,cc;
    cin>>al>>bb>>cc;

    for(auto c:al)
        a.push_back(c);

    for(auto c:bb)
        b.push_back(c);
    for(auto ch:cc)
        c.push_back(ch);

    int turn = 0;
    while(true)
    {
        if(turn == 0)
        {
            if(a.size() == 0)
            {
                cout<<"A\n";
                break;
            }
            else{
                turn = a.front()-'a';
                a.pop_front();
            }
        }
        else if(turn  == 1)
        {
            if(b.size() == 0)
            {
                cout<<"B\n";
                break;
            }
            else
            {
                turn = b.front()-'a';
                b.pop_front();
            }
        }

        else
        {
            if(c.size() == 0)
            {
                cout<<"C\n";
                break;
            }
            else
            {
                turn = c.front() - 'a';
                c.pop_front();
            }
        }

    }
    return 0;
}


Measured memory_bytes: 256
/*
 * Aizu Online Judge
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 *
 * @author yoshkur
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			InputData inputData = new InputData();
			inputData.setDataFromLine(br);
			inputData.setValues();
			Processing processing = new Processing(inputData);
			System.out.println(processing.getResult());

		} catch (IOException | NumberFormatException e) {
			System.err.println(e.getLocalizedMessage());
		}
	}
}

class InputData {

	private static final String SEPARATOR = " ";

	private List<String> rows = new ArrayList<>();
	private String row;
	private Integer a;
	private Integer b;
	private Integer c;

	public InputData() {
	}
	
	public void setDataFromLine(BufferedReader br) throws IOException {
		this.row = br.readLine().trim();
	}
	
	public void setDataFromLines(BufferedReader br) throws IOException {
		String line;
		while((line = br.readLine()) != null) {
			this.rows.add(line.trim());
		}
	}

	public void setValues() {
		String[] values = this.row.split(SEPARATOR);
		this.setA(Integer.valueOf(values[0]));
		this.setB(Integer.valueOf(values[1]));
		this.setC(Integer.valueOf(values[2]));
	}

	public Integer getA() {
		return a;
	}

	public void setA(Integer a) {
		this.a = a;
	}

	public Integer getB() {
		return b;
	}

	public void setB(Integer b) {
		this.b = b;
	}

	public Integer getC() {
		return c;
	}

	public void setC(Integer c) {
		this.c = c;
	}
}

class Processing {
	private static final String RETCODE = System.getProperty("line.separator");

	private InputData inputData;

	public Processing(InputData inputData) {
		this.inputData = inputData;
	}

	public String getResult() {
		String result = null;
		int counter = 0;
		for (int i = this.inputData.getA(); i <= this.inputData.getB() ; i++) {
			if (this.inputData.getC() % i == 0) {
				counter++;
			}
		}
		result = String.valueOf(counter);
		return result;
	}
}

Measured memory_bytes: 24152
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(void){
int n;
int tanku[]={5,7,5,7,7};
while(1){
cin>>n;
if(n==0)break;
string a;
vector<int> w(n);
for(int i=0;i<n;i++){
	cin>>a;
	w[i]=a.size();
}
int plase;
for(int i=0;i<n;i++){
plase=i;
int sum=0;
int k=0;
bool flag=false;
for(int j=i;j<n;j++){
sum+=w[j];
if(sum>tanku[k])break;
if(sum==tanku[k]){
	k++;
	sum=0;
}
if(k==5){
	flag=true;
	break;
}
}
if(flag){
	cout<<i+1<<endl;
	break;
}
}
}	
return 0;
}

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

int main() {
  int N, R; cin >> N >> R;
  int ans;
  if (N >= 10){
    ans = R;
  }
  else{
    ans = R + 100*(10 - N);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>


#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
	int X, A, B, C;
	cin >> A >> B >> C >> X;
	int cnt = 0;
	REP(a, A+1){
		REP(b, B + 1) {
			int r = X - 500 * a - 100 * b;
			if (r >=0 && r / 50 <= C && r % 50 == 0) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
		
}





Measured memory_bytes: 256
import sys

def main():
    
    # sys.stdin = open('input155a.txt')
    
    a, b, c = map(int, input().split())

    if a == b & b == c:
        print('No')
        
    elif a != b & b != c & c != a:
        print('No')
    
    else:
        print('Yes')
     

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second

ll n, p;

const int upp = 1e6 + 50;
bool vis[upp];
vector<int> primes;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> p;
    if (n == 1) {
        cout << p;
        return 0;
    }
    if (n >= 100) {
        cout << 1;
        return 0;
    }
    FOR(i, 2, upp - 25) {
        if (vis[i]) continue;
        primes.pb(i);
        for (ll j = ll(i) * i; j <= upp - 25; j += i)
            vis[j] = true;
    }
    map<ll, int> cnt;
    for (int val : primes) {
        while (p % val == 0) {
            cnt[val]++;
            p /= val;
        }
    }
    if (p > 1) cnt[p]++;
    ll ans = 1;
    for (auto pi : cnt)
        if (pi._2 >= n) FOR(i, 1, pi._2 / n) ans *= pi._1;
    cout << ans;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	vector<int> a( N );
	for( auto& v: a ) { cin >> v; }

	sort( a.begin(), a.end() );
	cout << a.back() - a.front() << endl;
	return 0;
}


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

typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll val=0;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0) val=i;
  }
  val=n/val;
  int ans=0;
  while(val>0){
    val/=10;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  unsigned long long int n;
  cin >> n;
  if (n % 2 == 1){
    cout << 0 << endl;
  }else{
    unsigned long long int t=0;
    REP(i,28){
      if (i > 0){
        unsigned long long int  p = pow(5,i) * 2;
        unsigned long long int c = n / p;
        if (c > 0){
          t += c;
        }
      }
    }
    cout << t << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n, j=0;
    string s;
    cin >> n >> s;
    for( int i = 0; i < n; i++ ){
        if( s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' ){
            j++;
        }
    }
    cout << j;
   return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func marked(ss []string, i, j int) bool {
	if i < 0 || i >= len(ss) {
		return false
	}
	if j < 0 || j >= len(ss[i]) {
		return false
	}
	return ss[i][j] == '#'
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	ss := make([]string, h)
	for i := range ss {
		fmt.Scan(&ss[i])
	}

	for i := 0; i < len(ss); i++ {
		for j := 0; j < len(ss[i]); j++ {
			if (marked(ss, i-1, j) && marked(ss, i, j-1)) ||
				(marked(ss, i+1, j) && marked(ss, i, j+1)) {
				fmt.Println("Impossible")
				return
			}
		}
	}
	fmt.Println("Possible")
}


Measured memory_bytes: 512
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextLong

  val res =
    if( n % 2 != 0) 0
    else {
      (1 to 26).foldLeft(0L){ case (sum, i) =>
        sum + (n / Math.pow(5, i).toLong) / 2L
      }
    }

  println(res)

}


Measured memory_bytes: 25540
#include<stdio.h>

int main(){
	int i,h[10];
	for(i=0;i<10;i++){
		scanf("%d",&h[i]);
	}
	int temp=0,j;
	for(j=0;j<10;j++){
		for(i=0;i<9;i++){
			if(h[i]<h[i+1]){
				temp=h[i];
				h[i]=h[i+1];
				h[i+1]=temp;
			}
		}
	}
	for(j=0;j<3;j++){
		printf("%d\n",h[j]);
	}
	return 0;
}


Measured memory_bytes: 2668
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define p_b push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 2e5;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());

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

template <typename T> void vout(T s){cout << s << endl;exit(0);}

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

    ll n, k, ans;
    cin >> n >> k;
    ans = 0;
    char last;
    cin >> last;

    bool f, F;
    f = 1;
    F = 0;

    vector <char> fv, ft;

    for(int i = 1; i < n; i++){
        char a;
        cin >> a;
        if(a == last){
            ans++;
        }else{
            F = 1;
            fv.p_b(last);
            f = 0;
        }
        last = a;
    }

    fv.p_b(last);

    ll x = k;

    ft = fv;

    for(int i = 1; i < fv.size(); i++)if(fv[i] == 'L' && x){
        x--;
        fv[i] = 'R';
    }

    ll res = 0, sc = 0;

    if(fv[0] == 'L' && x){
        fv[0] = 'R';
    }

    for(int i = 1; i < fv.size(); i++)if(fv[i] == fv[i - 1])sc++;
    res = max(res, sc);
    sc = 0;

    x = k;

    fv = ft;

    for(int i = 1; i < fv.size(); i++)if(fv[i] == 'R' && x){
        x--;
        fv[i] = 'L';
    }

    sc = 0;

    if(fv[0] == 'R' && x){
        fv[0] = 'L';
    }

    for(int i = 1; i < fv.size(); i++)if(fv[i] == fv[i - 1])sc++;
    res = max(res, sc);

    cout << ans + res << "\n";

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class BIT{
	public:
	//[1,i]
	int n;
	vi bit;
//	int bit[MAZ_N+1];
	BIT(int size){
		n=size;
		bit=vi(n+1);
	}
	int query(int i){//sum
		int s=0;
		while(i>0){
			s+=bit[i];
			i-=i&-i;
		}
		return s;
	}
	void add(int i,int x){
		while(i<=n){
			bit[i]+=x;
			i+=i&-i;
		}
	}
};
int main(){
	ll n,m;
	cin>>n>>m;
	vp in(n+1);
	rep(i,n)cin>>in[i+1].first;
	rep(i,n+1)in[i].second=i;
	rep(i,n)in[i+1].first+=in[i].first;
	rep(i,n)in[i+1].first-=(i+1)*m;
	vp t=in;
	sort(all(t));
	vi w(n+1);
	rep(i,n+1)w[lower_bound(all(t),in[i])-t.begin()]=i;
//	rep(i,n+1)cout<<" "<<w[i];cout<<endl;
	BIT bit(n+1);
	ll out=0;
	rep(i,n+1){
		out+=bit.query(1+w[i]);
		bit.add(1+w[i],1);
	}
	cout<<out<<endl;
}











Measured memory_bytes: 9600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

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

  private void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int heapSize = Integer.parseInt(br.readLine());
      String[] keys = br.readLine().split(" ");
      long[] heap = new long[heapSize+1];
      Arrays.fill(heap, Long.MIN_VALUE);
      for(int i=1; i<=heapSize; i++)
        heap[i] = Integer.parseInt( keys[i-1] );

      StringBuilder buf = new StringBuilder();
      for(int i=1; i<=heapSize; i++){
        buf.append("node " + i + ": key = " + heap[i] + ", ");
        if( i != 1 ) buf.append("parent key = " + heap[i/2] + ", ");
        if( i*2 <= heapSize) {
          buf.append("left key = " + heap[i*2] + ", ");
          if( i*2+1 <= heapSize) {
            buf.append("right key = " + heap[i*2+1] + ", ");
          }
        }
        buf.append("\n");
      }

      System.out.print(buf);
    } catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 24612
from collections import defaultdict

max_phrases = defaultdict(int)
n = int(input())
for _ in range(n):
    s, l, p = map(int, input().split())
    for length in range(s, l + 1):
        max_phrases[length] = max(max_phrases[length], p)

m = int(input())
melodies = [int(input()) for _ in range(m)]

max_length = max(melodies)
dp = [-1] * (max_length + max(max_phrases))
dp[0] = 0

for i in range(max_length):
    c = dp[i]
    if c == -1:
        continue
    for length, p in max_phrases.items():
        dp[i + length] = max(dp[i + length], c + p)

results = [dp[melody] for melody in melodies]
print(-1 if -1 in results else '\n'.join(map(str, results)))

Measured memory_bytes: 8136
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  string s;
  int n;//桁数
  cin>>s;
  n = s.size();
  vector<int> coeff;
  int num;
  int power=1;
  int resid=0;
  for(int i=n-1;i>=0;i--){
    if('0'<=s[i] && s[i]<='9'){
      num = s[i]-'0';
      resid = (resid + (num*power)%13)%13;
    }else{
      coeff.push_back(power);
    }
    power = (power*10)%13;
  }
  if(coeff.empty()){
    if(resid==5){
      cout<<1<<endl;
    }else{
      cout<<0<<endl;
    }
    return 0;
  }
  sort(coeff.begin(),coeff.end());
  
  int target = ((5-resid)%13+13)%13;
  //coeffの各要素に0~9を掛けた和がmod13でtargetになる場合の数を考える。
  int m = coeff.size();
  long long dp[m][13]={};
  REP(i,m){
    if(i==0){
      REP(k,10){
        dp[i][(coeff[i]*k)%13]++;
      }
      continue;
    }
    REP(k,10){
      REP(j,13){
        dp[i][(j+coeff[i]*k)%13] = mod(dp[i][(j+coeff[i]*k)%13]+dp[i-1][j]);
      }
    }
  }
  
  long long ans;
  ans = dp[m-1][target];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11128
from string import ascii_lowercase
N = int(input())

k = [0, 26]
for i in range(1, 13):
    k.append(26 * (k[i] + 1))

for i in range(13):
    if k[i] + 1 <= N <= k[i+1]:
        n = N - (k[i] + 1)

        for j in range(i, -1, -1):
            print(ascii_lowercase[(n//26**j) % 26], end="")

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

int main(void){
	int a,b,c,d;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	
	if((int)fabs(a-c) <= d ){
		printf("Yes");
	}else if( (int)fabs(b-a) <= d && (int)fabs(c-b) <= d  ){
		printf("Yes");
	}else{
	printf("No");
	}
	
	return 0;}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    int d, x;
    cin >> d >> x;
    int ans = x;
    REP(i,n) {
        int a; cin >> a;
        ans += (d-1) / a + 1;
    }

    cout << ans << endl;

    return 0;
}

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

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

Measured memory_bytes: 1024
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
B = ILI()
A = []
for i in range(N-1):
    if i == 0:
        A.append(B[i])
    else:
        A.append(min(B[i],B[i-1]))
A.append(B[-1])
print(sum(A))

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{

int n, a[10000], min, max, i, j;
long sum;

scanf ("%d", &n);

for ( i = 0; i < n; i++)
scanf ("%d", &a[i]);

max = a[0];
min = a[0];
sum = a[0];

for (j = 1; j < n; j++) {

if (a[j] > max)
max = a[j];

if (a[j] < min)
min = a[j];

sum = sum + a[j];

}

printf ("%d %d %ld\n", min, max, sum);

return 0;
}

Measured memory_bytes: 640
N = int(input())
S = list(input()) #１文字ずつ
#print('S',S)

hidari, migi = 0,0
for i in range(1,N):
    if S[i]=='E':
        migi+=1

#print('count:',hidari,migi)
out=hidari+migi
#print('out0:', out)
ld=1  #leader

while ld<N:
    if S[ld-1]=='W' and S[ld]=='E':
        hidari+=1
        migi-=1
    elif S[ld-1]=='W' and S[ld]=='W':
        hidari+=1
    elif S[ld-1]=='E' and S[ld]=='E':
        #print('kokoda!')
        migi-=1
    #print('ld,hidari,migi,out:',ld,hidari,migi,migi+hidari)
    out = min(out,hidari+migi)
    ld+=1

print(out)

Measured memory_bytes: 82708
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll INF=1e18;


int main(){
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>> to(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,n){
        cout << to[i].size() << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll ;

const ll inf = 1e12 + 17;
const int maxn = 1e5 + 10;
const int maxq = 1e2 + 10;
const int alf = 26;
const ll dlm = 1e9 + 7;
const int del = 998244353 ;
const int eps = 1e-7 ;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    ll ans = 1;
    ll n,p;
    cin>>n>>p;
    if(n==1)return cout<<p,0;
    ll y = p;
    ll ta = sqrt(y);
    for(int i=2;i<=ta;i++){
        ll re = 0;
        while(y%i==0){
            y/=i;
            re++;
        }
        ans*= pow(i,re/n);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 2e5 + 5;
int n, a[M];
 
int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	cin >> n;
	map <int, int> add, sub;
	for(int i = 1; i <= n; i++)	
	{
		cin >> a[i];
		sub[i - a[i]]++;
		add[a[i] + i]++;
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ans += add[i - a[i]];
		ans += sub[a[i] + i];
	}
	cout << ans / 2;
    	return 0;
}

Measured memory_bytes: 50564
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        for (int i = 0; i < s.length(); i++) {
            if (Character.isUpperCase(s.charAt(i))) {
                System.out.print(Character.toLowerCase(s.charAt(i)));
            } else {
                System.out.print(Character.toUpperCase(s.charAt(i)));
            }
        }
        System.out.println("");
    }
}


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

int main(int argc, const char * argv[]) {
    int N, K;
    cin >> N >> K;
    
    vector<int> p;
    for (int i=0;i<N;++i) {
        int current;
        cin >> current;
        p.push_back(current);
    }
    
    sort(p.begin(), p.end());
    int sum = 0;
    for (int i=0; i<K; ++i) {
        sum += p[i];
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
	int A,B,C;
	cin >> A >> B >> C;
	if (A + B >= C)
		cout << "Yes" << endl;
	else
		cout << "No";
}

Measured memory_bytes: 256
#dfs
n,m = map(int,input().split())
graph = {i+1:[] for i in range(n)}
for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)

def func(path,p,count):
  if len(path) == n:
    return count + 1
  for i in graph[p]:
    if i in path:
      continue
    count = func(path+[i],i,count)
  return count
print(func([1],1,0))




Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)
int main()
{
        fast;

        int t=1;
        //cin>>t;
        while(t--)
        {
                 int n,x,ans=0;
                 cin>>n;
                 map<int,int> m1,m2;//count of each elements at odd and even positions
                 vector<int> a,b;//just store the occurrence of(not the elements themselves) each elements at odd and even positions
                 a.push_back(0);
                 b.push_back(0);//incase vector has only one elements after performing the below operations
                 for(int i=0;i<n;i++)
                 {
                         cin>>x;
                         if((i+1)%2!=0)//odd element
                                m1[x]++;
                        else
                                m2[x]++;
                 }
                 int max1=0,max2=0;
                 int c1=0,c2=0;
                 for(auto it=m1.begin();it!=m1.end();it++)
                 {
                         if(it->second > c1)
                           {
                                c1=it->second;
                                max1=it->first;//maximum occurring element in odd map
                            }
                           a.push_back(it->second);
                 }
                 for(auto it=m2.begin();it!=m2.end();it++)
                 {
                         if(it->second > c2)
                           {
                                c2=it->second;
                                max2=it->first;//maximum occurring element in even map
                           }
                           b.push_back(it->second);
                 }
                 sort(a.begin(),a.end(),greater<int>());
                 sort(b.begin(),b.end(),greater<int>());
                if(max1==max2)//case 1: maximum occuring elements in both vectors are same
                {
                        int maxi1=a[0]+b[1];
                        int maxi2=a[1]+b[0];
                        ans=n-((maxi1>=maxi2)?maxi1:maxi2);
                }
                else//otherwise
                        ans=n-a[0]-b[0];
                cout<<ans<<endl;

        }
}


Measured memory_bytes: 8500
import static java.lang.System.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(in);

        int n = sc.nextInt();
		int k = sc.nextInt();
		
		int[] mul = new int[20];
		double[] prob = new double[20];
		mul[0] = 1; prob[0] = 1;
		for(int i=1; i<20; i++) {
			mul[i] = mul[i-1] * 2;
			prob[i] = prob[i-1] / 2;
		}
		
		double ans = 0.0;
		for(int i=1; i<=n; i++) 
			for(int j=0; j<20; j++) 
				if(i * mul[j] >= k) {
					ans += prob[j];
					//if(i < 10) out.println(i + " " + j + " " + mul[j] + " " + prob[j]);
					break;
				}
			
		out.println(ans/n);
    }
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong N;
	vector<llong> a;

	cin >> N;
	a.resize(N+1);
	for (int i = 1; i <= N; ++i)
		cin >> a[i];


	vector<llong> ans(N+1, 1), ret;
	llong cnt = 0;
	for (int i = N; i >= 1; --i) {
		llong sum = 0;
		for (int j = i; j <= N; j += i)
			sum += ans[j];

		if (sum%2 == a[i]%2)
			ret.push_back(i);
		else
			ans[i] = 0;
	}

	cout << ret.size() << endl;
	for (int i = ret.size()-1; i >= 0; --i)
		cout << ret[i] << " ";

	cout << endl;

	return 0;
}

Measured memory_bytes: 4980
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int A, B, C;
    cin >> A >> B >> C;
    if (A == 7) {
        if (B == 5 & C == 5) {
            cout << "YES" << "\n";
        } else {
            cout << "NO" << "\n";
        }
    } else if (B == 7) {
        if (A == 5 & C == 5) {
            cout << "YES" << "\n";
        } else {
            cout << "NO" << "\n";
        }
    } else if (C == 7) {
        if (A == 5 & B == 5) {
            cout << "YES" << "\n";
        } else {
            cout << "NO" << "\n";
        }
    } else {
        cout << "NO" << "\n";
    }
    
    
    return 0;
}


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

int main()
{
  int n;
  scanf("%d", &n);
  vector<int> a(n), b(n);
  for(int i = 0; i < n; ++i){
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  int c = 0;
  for(int i = 0; i < n; ++i)
    	c += a[i] != b[i];
  if (c <= 2) printf("YES");
  else printf("NO");
  return 0;
}

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

int main() {
    cin.tie(NULL);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    long long int la=0,lb=0;
    for(int i=0;i<n;i++){
        long long int a,b;
        cin>>a>>b;
        if(a<la||b<lb){
            long long int da=la/a;
            long long int db=lb/b;
            if(la%a)da++;
            if(lb%b)db++;
            a*=max(da,db);
            b*=max(da,db);
        }
        la=a;
        lb=b;
    }
    cout<<la+lb;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> con(N), edges(N);
    rep(i, N-1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        con[u].push_back(v);
        con[v].push_back(u);
        edges[u].push_back(w);
        edges[v].push_back(w);
    }

    vector<int> ans(N, -1);
    queue<int> q;
    ans[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int tv = q.front();
        q.pop();
        rep(i, con[tv].size()) {
            int tu = con[tv][i];
            int tw = edges[tv][i];
            if(ans[tu] != -1) continue;
            ans[tu] = (ans[tv] + tw)%2;
            q.push(tu);
        }
    }

    rep(i, N) {
        cout << ans[i] << endl;
    }
    return 0;

}

Measured memory_bytes: 11904
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <cstring>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

#define m0(x) memset(x,0,sizeof(x))

int N;
string s, t;

int main(){
  int dp[30];
  m0(dp);

  cin >> N;
  cin >> s >> t;
  REP(i, N) {
    int l = N - i;
    if(s.substr(i, l) == t.substr(0, l)) {
      cout << 2 * N - l << endl;
      return 0;
    }
  }
  cout << 2 * N << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] arrayv=new int[n];
		String[] arrayc=new String[n];
		int[] arrayj=new int[n];
		int sum=0;

		for(int i=0;i<n;i++) {
			arrayc[i]=sc.next();
			arrayv[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if(i==j)continue;
				if(arrayc[i].compareTo(arrayc[j])>0) {
					arrayj[i]++;
				}else if(arrayc[i].equals(arrayc[j])) {
					if(arrayv[i]<arrayv[j]) {
						arrayj[i]++;
					}
				}
				//System.out.print(arrayc[i].compareTo(arrayc[j])+" ");
			}
			//System.out.println();
			arrayj[i]++;
		}
		for(int i=1;i<=n;i++) {
			for(int j=0;j<n;j++) {
				if(arrayj[j]==i) {
					System.out.println(j+1);
					break;
				}
			}
		}

	}
}
/*
 6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
 */

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




Measured memory_bytes: 22868
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
			int n = Integer.parseInt( kb.readLine() );
			String[] nums = kb.readLine().split( " " );
			int len = nums.length;
			int[] A = new int[ len ];
			
			for( int i=0; i<len; i++ ) {
				A[i] = Integer.parseInt( nums[i] );
				System.out.print( i<(len-1)? A[i]+" ": A[i]+"\n" );
			}
			
			int key;
			int j;
 			for( int i=1; i<len; i++ ) {
				key = A[i];
				j = i - 1;
				while( 0 <= j && key < A[j] ) {
					A[ j+1 ] = A[j];
					j--;
				}
				A[ j+1 ] = key;
				for( int k=0; k<len; k++ ) {
					System.out.print( k<(len-1)? A[k]+" ": A[k]+"\n" );
				}
			}

 			kb.close();
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 23800
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
vector<int> dir = { 0, 1, 0, -1 };
int H, W;
int main() {
	while (cin >> W >> H, H) {
		vector<vector<int> > x(H, vector<int>(W));
		int p2 = -1, p3 = -1, p4 = -1;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> x[i][j];
				if (x[i][j] == 2) p2 = i * W + j;
				if (x[i][j] == 3) p3 = i * W + j;
				if (x[i][j] == 4) p4 = i * W + j;
			}
		}
		priority_queue<vector<int> > que; que.push({ 0, p4, p2 });
		vector<vector<int> > dp(H * W, vector<int>(H * W, 999999999)); dp[p4][p2] = 0;
		while (!que.empty()) {
			vector<int> u = que.top(); que.pop();
			int sx = u[1] % W, sy = u[1] / W, fx = u[2] % W, fy = u[2] / W;
			for (int i = 0; i < 4; i++) {
				int tx = sx + dir[i], ty = sy + dir[i ^ 1];
				if (0 <= tx && tx < W && 0 <= ty && ty < H && x[ty][tx] != 1) {
					if (tx != fx || ty != fy) {
						if (dp[ty * W + tx][u[2]] > dp[u[1]][u[2]]) {
							dp[ty * W + tx][u[2]] = dp[u[1]][u[2]];
							que.push({ -dp[ty * W + tx][u[2]], ty * W + tx, u[2] });
						}
					}
					else {
						int zx = tx + dir[i], zy = ty + dir[i ^ 1];
						if (0 <= zx && zx < W && 0 <= zy && zy < H && x[zy][zx] != 1) {
							if (dp[ty * W + tx][zy * W + zx] > dp[u[1]][u[2]] + 1) {
								dp[ty * W + tx][zy * W + zx] = dp[u[1]][u[2]] + 1;
								que.push({ -dp[ty * W + tx][zy * W + zx], ty * W + tx, zy * W + zx });
							}
						}
					}
				}
			}
		}
		int ret = 999999999;
		for (int i = 0; i < H * W; i++) ret = min(ret, dp[i][p3]);
		cout << (ret != 999999999 ? ret : -1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3176