akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll 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; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    VLL A(N),B(N),C(N);
    rep(i,N){
        cin >> A[i];
    }
    sort(all(A));
    rep(i,N){
        cin >> B[i];
    }   
    sort(all(B));
    rep(i,N){
        cin >> C[i];
    }
    sort(all(C));
    ll ans=0;
    rep(i,N){
        auto one=lower_bound(all(A),B[i]);
        auto three=upper_bound(all(C),B[i]);
        ans+=(one-A.begin())*(C.end()-three);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
   ll n;cin>>n;
   vector<ll> a(n),b(n);
   rep(i,n) cin>>a[i]>>b[i];
   sort(a.begin(),a.end());
   sort(b.begin(),b.end());
   if(n%2==0){
       ll res1=(b[n/2]+b[n/2-1])-(a[n/2-1]+a[n/2])+1;
       cout<<res1<<endl;
   }else{
       ll res1=b[n/2]-a[n/2]+1;
       cout<<res1<<endl;
   }
}


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

int main(){
  int N;
  cin >> N;
  int V[N];
  int C[N];
  int sum=0;
  for(int i = 0; i < N; i++){
    cin >> V[i];
  }
  for(int i = 0; i < N; i++){
    cin >> C[i];
    if(V[i] - C[i] > 0){
      sum += V[i] - C[i];
    }
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <bitset>

using namespace std;

const int MAX_R = 10;
const int MAX_C = 10000;

//input
int R, C;
bitset<MAX_C> a[MAX_R];

int ans;

void dfs(int k){
    if(k == R){
        //row certain
        int result = 0;            //cur max value
        for(int j = 0; j < C; j ++){
            int upNum = 0;            //up numbers without fliping
            for(int i = 0; i < R; i ++){
                if(a[i][j]) upNum ++;
            }
            result += max(upNum, R - upNum);    
        }
        ans = max(ans, result);
        return;
    }
    //without fliping
    dfs(k + 1);
    //&#183;flip
    a[k].flip();
    dfs(k + 1);
}

void solve(){
    ans = 0;
    dfs(0);
    printf("%d\n", ans);
}

int main(int argc, char const *argv[]){

    while(scanf("%d %d", &R, &C)){
        if(R == 0 && C == 0) break;

        for(int i = 0; i < R; i ++){
            for(int j = 0; j < C; j ++){
                bool tmp;
                scanf("%d", &tmp);
                a[i][j] = tmp;
            }
        }
        solve();
    }

    return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=1ll<<60,mod=1000000007;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	if (a==b){
		cout<<c;
	}
	else if (a==c){
		cout<<b;
	}
	else {
		cout<<a;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] lines = Console.ReadLine().Split(' ');
            int n = int.Parse(lines[0]);
            int m = int.Parse(lines[1]);
            lines = null;

            int[,] a = new int[n,m];
            int[] b = new int[m];
            int[] result = new int[n];

            for (int i = 0; i < n; i++)
            {
                int[] input = Console.ReadLine()
                    .Split(' ')
                    .Select(x => int.Parse(x))
                    .ToArray();
                for (int j = 0; j < m; j++)
                {
                    a[i, j] = input[j];
                }
            }

            for (int i = 0; i < m; i++)
            {
                b[i] = int.Parse(Console.ReadLine());
            }

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    result[i] += a[i, j] * b[j];
                }
            }

            StringBuilder output = new StringBuilder();
            for (int i = 0; i < n; i++)
            {
                output.Append(result[i]);
                output.Append("\n");
            }
            Console.Write(output);
        }
    }
}

Measured memory_bytes: 9804
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

long long MOD = 1000000007;
int main(){
    long long s,c;
    cin >> s >> c;
    if(s * 2 > c){
        cout << c / 2 << endl;
        return 0;
    }
    long long answer = s;
    c -= s*2;
    cout << answer + c / 4 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<ll>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc ll t; cin >> t; while(t--)

using namespace std;
string repeat(string s, ll n) {
    string s1 = "";
    for (ll i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  int n;
  cin>>n;
  int a[n],b[n];
  vector<int> c(n,-1);
  rep(i,0,n)cin>>a[i];
  rep(i,0,n) cin>>b[i];
  sort(b,b+n,greater<int>());

  int l=-1,r=-1;
  rep(i,0,n){
    if(a[i]==b[i]){
      if(l==-1) l=i,r=i;
      else r=i;
    }
  }
  
  if(l!=-1){
    int l1=0;
    int i=l;
    for(;i<=r && l1<n;){
      if(a[l1]!=b[i] && b[l1]!=b[i]){
        swap(b[l1],b[i]);
        i++;
      }
      l1++;
    }
    
    if(i<=r){
      cout<<"No\n";
      return;
    }
  }
  
  cout<<"Yes\n";
  rep(i,0,n) cout<<b[i]<<" ";
  cout<<endl;
}
int main(){
    optimizeIO();
    solve();
}


Measured memory_bytes: 5552
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int H1, H2, K1, K2, a, b, c, d;
	cin >> H1 >> H2 >> K1 >> K2 >> a >> b >> c >> d;

	int hir = H1 * a + (H1 / 10)*c + H2 * b + (H2 / 20)*d;
	int ken = K1 * a + (K1 / 10)*c + K2 * b + (K2 / 20)*d;

	if (hir == ken) {
		cout << "even" << endl;
	}
	else if(hir>ken){
		cout << "hiroshi" << endl;
	}
	else {
		cout << "kenjiro" << endl;
	}

	return 0;
}




Measured memory_bytes: 3136
H,W =gets.split.map &:to_i
grid = Array.new(H).map{Array.new(W,"")}
for i in 0...H
  grid[i]=gets.strip.split("").map{|i|i.codepoints[0]}
end
E=".".codepoints[0]
U="#".codepoints[0]
dp = Array.new(H).map{Array.new(W,0)}
dp[0][0]=1
for i in 1...W
  dp[0][i]=grid[0][i]==U ? 0 :  dp[0][i-1]
end
for i in 1...H
  dp[i][0]=grid[i][0]==U ? 0 :  dp[i-1][0]
end
for i in 1...W
  for j in 1...H
    if grid[j][i]==E
      dp[j][i]=dp[j-1][i]+dp[j][i-1]
    else
      dp[j][i]=0
    end
  end
end
puts dp[H-1][W-1] %(1000000007)


Measured memory_bytes: 178044
#include <iostream>

using namespace std;

int main(){

    int a;
    int b;
    cin >> a >> b;

    if(a==b){
        cout << "a == b" << endl;

    }
    if(a<b){
        cout << "a < b" << endl;

    }
    if(a>b){
        cout << "a > b" << endl;
    }

    return 0;
}

Measured memory_bytes: 3092
heap_size = STDIN.gets().to_i
heap_keys = STDIN.gets().split(' ').map{ |i| i.to_i }

1.upto(heap_size) do |i|
  print "node #{i}: key = #{heap_keys[i-1]}, "
  print "parent key = #{heap_keys[i/2-1]}, " unless i==1
  print "left key = #{heap_keys[i*2-1]}, " unless i*2-1>=heap_size
  print "right key = #{heap_keys[i*2]}, " unless i*2>=heap_size
  print "\n"
end

Measured memory_bytes: 8628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int y,m,d;
  for(int i=0;i<n;i++){
    cin>>y>>m>>d;
    int ans=0;
    if(y%3==0){
      d=20-d;
    }else{
      if(m%2==0){
	d=19-d;
      }else{
	d=20-d;
      }
    }
    d++;
    m=10-m;
    if(m<0){
      m=0;
    }
    if(y%3==0){
      ans+=m*20;
    }else{
      ans+=(m/2)*20+(m-m/2)*19;
    }
    ans+=d;
    y++;
    
    //cout<<y<<" "<<m<<" "<<d<<endl;

    while(y<1000){
      if(y%3==0){
	ans+=200;
      }else{
	ans+=195;
      }
      y++;
    }
    cout<<ans<<endl;  }
  return 0;
}



Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int A, B, C, D;
		D = N % 10;
		N /= 10;
		C = N % 10;
		N /= 10;
		B = N % 10;
		N /= 10;
		A = N;

		if (A + B + C + D == 7) System.out.printf("%d+%d+%d+%d=7", A, B, C, D);
		else if (A + B + C - D == 7) System.out.printf("%d+%d+%d-%d=7", A, B, C, D);
		else if (A + B - C + D == 7) System.out.printf("%d+%d-%d+%d=7", A, B, C, D);
		else if (A + B - C - D == 7) System.out.printf("%d+%d-%d-%d=7", A, B, C, D);
		else if (A - B + C + D == 7) System.out.printf("%d-%d+%d+%d=7", A, B, C, D);
		else if (A - B + C - D == 7) System.out.printf("%d-%d+%d-%d=7", A, B, C, D);
		else if (A - B - C + D == 7) System.out.printf("%d-%d-%d+%d=7", A, B, C, D);
		else if (A - B - C - D == 7) System.out.printf("%d-%d-%d-%d=7", A, B, C, D);
 	}
}

Measured memory_bytes: 21844
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    
    if op=="?":
        break
    
    if op=="+":
        print(a+b)
    if op=="-":
        print(a-b)
    if op=="*":
        print(a*b)
    if op=="/":
        print(int(a/b))


Measured memory_bytes: 5596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#define N 305
using namespace std;

int n, m, k, Q, tc, ans, v[N], w[N][N];
vector<int> a[N], b[N];
struct str {
	int z, s, c;
};

bool operator < (str p, str q) {
	if (p.s != q.s) return p.s > q.s;
	else return p.c < q.c;
}
priority_queue<str> qu;

void f(str p, int e) {
	if (v[p.z] == tc) return;
	if (p.c < 0) {
		p.c = k - e;
		p.s++;
	}
	qu.push(p);
}
int main()
{
	int i, j, t1, t2, t3, st, en;
	str t;
	cin >> n >> m >> k;
	for (i = 0; i < m; i++) {
		scanf ("%d %d %d", &t1, &t2, &t3);
		if (t3 > k) continue;
		a[t1].push_back(t2);
		a[t2].push_back(t1);
		b[t1].push_back(t3);
		b[t2].push_back(t3);
	}
	memset(w, -1, sizeof(w));
	for (tc = 1; tc <= n; tc++) {
		f({tc, 0, k}, 0);
		while (!qu.empty()) {
			t = qu.top(); qu.pop();
			if (v[t.z] == tc) continue;
			v[t.z] = tc;
			w[tc][t.z] = t.s;
			for (i = 0; i < a[t.z].size(); i++) {
				f({a[t.z][i], t.s, t.c - b[t.z][i]}, b[t.z][i]);
			}
		}

	}
	cin >> Q;
	for (tc = 1; tc <= Q; tc++) {
		scanf ("%d %d", &st, &en);
//		f({st, 0, k}, 0);
//		ans = -1;
//		while (!qu.empty()) {
//			t = qu.top(); qu.pop();
//			if (v[t.z] == tc) continue;
//			v[t.z] = tc;
//			if (t.z == en) {
//				ans = t.s;
//				break;
//			}
//			for (i = 0; i < a[t.z].size(); i++) {
//				f({a[t.z][i], t.s, t.c - b[t.z][i]}, b[t.z][i]);
//			}
//		}
		printf("%d\n", w[st][en]);
	}
    return 0;
}


Measured memory_bytes: 2816
#include <stdio.h>
#include <string.h>
int main(){
    char s[10],t[10],u[10];
    int a,b;
    scanf("%s %s", &s[10], &t[10]);
    scanf("%d %d", &a, &b);
    scanf("%s", &u[10]);
    if(!strcmp(&s[10],&u[10])){
        a--;
    }else if(!strcmp(&t[10],&u[10])){
        b--;
    }
    printf("%d %d", a, b);
}

Measured memory_bytes: 128
import java.util.Scanner;

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

		if(K == 0) {
			System.out.println("Yes");
			return;
		}
		for(int i = 0 ; i <= N ; i ++) {
			for(int j = 0 ; j <= M ; j ++) {
				if(i * (M - j) + j * (N - i) == K) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int p[n];
	rep(i, n) {
		cin >> p[i];
		p[i]--;
	}
	
	int a[n], b[n];
	rep(i, n) a[i] = i * n;
	rep(i, n) b[i] = (n - i - 1) * n;
	rep(i, n) {
		int j = p[i];
		a[j] += i;
		b[j] += i;
	}
	
	rep(i, n) {
		cout << a[i] + 1;
		if (i == n - 1) {
			cout << endl;
		} else {
			cout << " ";
		}
	}
	rep(i, n) {
		cout << b[i] + 1;
		if (i == n - 1) {
			cout << endl;
		} else {
			cout << " ";
		}
	}
	
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  int x = 1;
  while((int) (double(x) * 1.08) <= n) {
    if((int) (double(x) * 1.08) == n) {
      cout << x << '\n';
      return 0;
    }
    x++;
  }
  cout << ":(\n";
  return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N = ni()
    var A = na(N)
    Sorting.quickSort(A)

    def calc(i: Int, l: Int, r: Int, sum: Long): Long = {
      if (i == N) sum
      else {
        val a = if (i % 2 == 0) {
          A(i / 2)
        } else {
          A(N - 1 - i / 2)
        }
        val lr = (i + 1) / 2 % 2
        if (lr == 0) {
          calc(i + 1, a, r, sum + abs(a - l))
        } else {
          calc(i + 1, l, a, sum + abs(a - r))
        }
      }
    }

    val sum1 = calc(1, A(0), A(0), 0)
    A = A.reverse
    val sum2 = calc(1, A(0), A(0),0)
    val ans = max(sum1, sum2)
    out.println(ans)
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}

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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }



int n;
tuple<int, int, ll> val[1005];
ll dp[10005];
void solve() {
    cin >> n;
    rep(i, n) {
        int w, s; ll v;
        cin >> w >> s >> v;
        val[i] = make_tuple(s + w, w, v);
    }

    sort(val, val + n);
    ll ans = 0;
    rep(i, n) {
        int w, s; ll v;
        tie(s, w, v) = val[i]; s -= w;
        repd(j, s + 1) {
            maxs(ans, dp[j] + v);
            if (j + w <= 10001) maxs(dp[j + w], dp[j] + v);
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b, c, d, e, f;
  in3(n, a, b);
  string s;
  in3(c, d, s);
  a--;
  b--;
  c--;
  d--;
  bool h, k, l;
  h = true;
  k = false;
  l = true;
  if(c < d)
    k = true;
  rep2(i, b - 1, d){
    if(s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
      k = true;
  }
  rep2(i, a, c - 1){
    if(s[i + 1] == '#' && s[i + 2] == '#')
      h = false;
  }
  rep2(i, b, d - 1){
    if(s[i + 1] == '#' && s[i + 2] == '#')
      l = false;
  }
  if(k && h && l)
    out("Yes");
  else
    out("No");
  memi;
}

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

using namespace std;

int main(){
	int N, T; cin >> N >> T;
	vector< pair< int, int > > ct;
	for(int i = 0; i < N; ++i){
		int a, b; cin >> a >> b;
		if(b <= T){
			ct.push_back(make_pair(a, b));
		}
	}
	sort(ct.begin(), ct.end());
	if(!ct.empty()){
		cout << ct[0].first << endl;
	}else{
		cout << "TLE" << endl;
	}
}

Measured memory_bytes: 256
// list(map(int, input().rstrip().split()))
//' '.join(map(str, res)) 

#include<bits/stdc++.h>
#include<stdio.h> //per fare input output con scanf and printf
#include<stdlib.h> //per fare qsort e bsearch
#include<string.h> // per fare strcpy(sarrivo, spartenza) strcat(str, aggiungo) strcmp(a,b) che da 0 se sono uguali
#include<math.h>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<map>
 
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector <ll> 
#define pi pair <int, int>
#define binary(v, el) binary_search((v).begin(), (v).end(), (el))
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(n, t) get<(n)>((t)) // get element of a tuple
#define F first
#define S second
#define input(type, n) type n; cin >> n
#define FORN(n) for (ll i=0;i<(n); i++)
#define print(x) cout << x << endl
#include <iomanip>      // std::setprecision



struct missione {
        int s;
        int g;
    };
missione v[1000000];
 
bool Ordina (missione a, missione b) {
    return a.s < b.s;    
}

int main () {
    int n;
    cin >> n;
    int v[n];
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        v[i] = a;
    }
    --v[0];
    for (int i = 1; i < n;++i) {
        if (v[i] > v[i-1]) {
            --v[i];
        }
    }
    bool flag = true;
    for (int i = 1; i < n; ++i) {
        if (v[i-1] > v[i]) {
            flag = false;
        }
    }
    if (flag) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    
}

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

using namespace std;

#define ll long long
#define ull unsigned long long

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

    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;

namespace DPL3_B
{
    class Program
    {
        struct Rec
        {
            public int h;
            public int p;
            public Rec(int h, int p)
            {
                this.h = h;
                this.p= p;
            }
        }
        static void Main(string[] args)
        {
            var a = scan;
            int H = a[0];
            int W = a[1];
            var dp = new int[H, W+1];
            int max = 0;
            for (int i = 0; i < H; i++)
            {
                var k = scan;
                for (int j = 0; j < W; j++)
                {
                    dp[i, j] = k[j] == 1 ? 0 : i == 0 ? 1 : dp[i - 1, j] + 1;
                }
            }
            for (int i = 0; i < H; i++)
            {
                var S = new Stack<Rec>();
                for (int j  = 0; j <= W; j++)
                {
                    var rec = new Rec();
                    rec.h = dp[i, j];
                    rec.p = j;
                    if (S.Any())
                    {
                        if (S.Peek().h < rec.h) S.Push(rec);
                        else if(S.Peek().h > rec.h)
                        {
                            int target = j;
                            while (S.Any() && S.Peek().h > rec.h)
                            {
                                Rec pre = S.Pop();
                                int area = pre.h * (j - pre.p);
                                max = Math.Max(max,area);
                                target = pre.p;
                            }
                            rec.p = target;
                            S.Push(rec);
                        }
                    }
                    else S.Push(rec);
                }
            }
            Console.WriteLine(max);
        }

        static int[] scan
        {
            get { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
        }
    }
}

Measured memory_bytes: 24548
import java.util.Scanner;

public class Main {

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

		// ラベル入力・ダイスの生成
		Dice dice1 = new Dice(CreateIntLabel(sc.nextLine()));
		Dice dice2 = new Dice(CreateIntLabel(sc.nextLine()));

		// 同じダイスであるか判定・出力
		if (DiceComparison(dice1, dice2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

	// ラベル配列の生成
	public static int[] CreateIntLabel(String str) {
		String[] input = str.split("[\\s]+");
		int[] label = new int[input.length];
		for (int i = 0; i < input.length; i++) {
			label[i] = Integer.parseInt(input[i]);
		}
		return label;
	}

	// 2つのダイスが同じかを判定
	public static boolean DiceComparison(Dice dice1, Dice dice2) {
		// ダイス1の0番目と同じラベルをダイス2から探す
		for (int i = 0; i < dice2.label.length; i++) {
			if (dice1.label[0] == dice2.label[i]) {

				// 側面4つの並びが同じか判定
				if (ComparisonNumberSequence(dice1.getCorrespondingAspectsLabel(0),
						dice2.getCorrespondingAspectsLabel(i))) {
					return true;
				}
			}
		}
		return false;

	}

	// 配列(ダイスの側面4つ)を2つを受け取り、同じ順序ができるか判定
	public static boolean ComparisonNumberSequence(int[] array1, int[] array2) {
		// 0番目の値が同じになるまでarray2を回転させる
		while (array1[0] != array2[0]) {
			int work = array2[0];
			for (int i = 1; i < array2.length; i++) {
				array2[i - 1] = array2[i];
			}
			array2[array2.length - 1] = work;
		}

		// 内容が同じになったかを見る
		for (int i = 0; i < array1.length; i++) {
			if (array1[i] != array2[i]) {
				return false;
			}
		}
		return true;

	}

	static class Dice {
		// 回転方向上にある4つの面の添え字、対応する右の面の添え字
		enum Direction {
			Roll			(new int[] { 0, 1, 5, 4 }, 2),
			Pitch			(new int[] { 0, 3, 5, 2 }, 1),
			Yaw				(new int[] { 4, 2, 1, 3 }, 5),
			ReverseRoll	(new int[] { 0, 4, 5, 1 }, 3),
			ReversePitch	(new int[] { 0, 2, 5, 3 }, 4),
			ReverseYaw		(new int[] { 4, 3, 1, 2 }, 0);

			// 回転軸方向の4つの面
			private int[] Rotat;
			// 回転軸方向に対応する右の面
			private int rightNum;

			Direction(int[] nums, int num) {
				this.Rotat = nums;
				this.rightNum = num;
			}
		}

		// ラベル
		int[] label;

		// コンストラクタ
		Dice(int[] label) {
			this.label = label;
		}

		// 右の面の添え字を受け取り、回転方向の4面の添え字配列を返す
		int[] getCorrespondingAspects(int num) {
			for (Direction dir : Direction.values()) {
				if (dir.rightNum == num) {
					return dir.Rotat;
				}
			}
			return null;
		}

		// 右の面の添え字を受け取り、回転方向の4面のラベル配列を返す
		int[] getCorrespondingAspectsLabel(int num) {
			int[] pointers = getCorrespondingAspects(num);
			int[] CorrespondingAspectsLabel = new int[pointers.length];
			for (int i = 0; i < CorrespondingAspectsLabel.length; i++) {
				CorrespondingAspectsLabel[i] = this.label[pointers[i]];
			}
			return CorrespondingAspectsLabel;

		}

	}

}



Measured memory_bytes: 26396
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;


ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


const int BASE = 2001;
int n;
ll DP[2*BASE+5][2*BASE+5], A[200005], B[200005], fac[8002];


ll C(int n, int r){
    ll ans = fac[n];
    ans = (ans * pwr(fac[r], MOD-2)) % MOD;
    ans = (ans * pwr(fac[n-r], MOD-2)) % MOD;
    return ans;
}



int main(){

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

    fac[0] = 1;
    for(int i=1;i<=8000;i++)
        fac[i] = (i * fac[i-1]) % MOD;

    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld", &A[i], &B[i]);
        DP[BASE-A[i]][BASE-B[i]]++;
    }

    for(int i=-2000;i<=2000;i++)
        for(int j=-2000;j<=2000;j++){
            DP[BASE+i][BASE+j] = (DP[BASE+i][BASE+j] + DP[BASE+i-1][BASE+j] + DP[BASE+i][BASE+j-1]) % MOD;
        }

    ll ans = 0;
    for(int i=1;i<=n;i++){
        ans = (ans + DP[BASE+A[i]][BASE+B[i]]) % MOD;
        ans = (ans - C(2*A[i]+2*B[i], 2*A[i])) % MOD;
    }

    ans = (ans * pwr(2, MOD-2)) % MOD;
    ans += MOD;
    ans %= MOD;
    printf("%lld\n", ans);
    return 0;
}








Measured memory_bytes: 128768
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define DBG(v) REP(i, LEN((v))) cout<<(v)[i]<<(i==LEN((v))-1 ? '\n' : ' ')
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;

class BResistorsInParallel {
public:
    int N;
    void input(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in>>N;
    }

    void solve(std::istream& in, std::ostream& out) {
        input(in, out);
        double ans = 0;
        REP(i, N){
            double a;
            in>>a;
            ans += 1 / a;
        }
        out<<fixed<<setprecision(12)<<1 / ans<<'\n';
    }
};


int main() {
	BResistorsInParallel solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
def insertionSort(a, n, g)
	g.upto(n-1) do |i|
		v = a[i]
		j = i-g
		
		while j >= 0 && v < a[j]
			a[j+g] = a[j]
			j -= g
			
			$cnt += 1
		end
		
		a[j+g] = v
	end
	
	return a
end

def shellSort(a, n)
	$cnt = 0
	$g = [1]
	
	h = 1
	loop do
		h = h*3 + 1
		break if h > n
		$g.unshift(h)
	end

	$m = $g.size

	0.upto($m-1) do |i|
		insertionSort(a, n, $g[i])
	end
end

# 標準入力
N = gets.to_i
A = []
N.times do |i|
	A[i] = gets.to_i
end

# 標準出力
a = shellSort(A, N)

puts $m
puts $g.join(" ")
puts $cnt
puts A



Measured memory_bytes: 14792
#include<cstdio>
#include<cstring>
using namespace std;
long long  n,m;
long long PD(long long  x,long long  y)
{
	if(x==1&&y==1)return 1;
	if(x==1) return y-2;
	if(y==1) return x-2;
	return (x-2)*(y-2);
}
int main()
{
	scanf("%lld %lld",&n,&m);
	printf("%lld",PD(n,m));
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N, A;
    cin >> N >> A;
    vector<int> X(N+1);
    for(int i = 1; i <= N; i++){
        cin >> X[i];
    } 

    vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vector<ll>(N * A + 1, 0)));
    dp[0][0][0] = 1;

    for(int j = 0; j <= N; j++){
        for(int k = 0; k <= N; k++){
            for(int s = 0; s <= N * A; s++){
                if(j >= 1 && s < X[j]){
                    dp[j][k][s] = dp[j-1][k][s];
                } else if(j >= 1 && k >= 1 && s >= X[j]){
                    dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-X[j]];
                }
            }
        }
    }

    ll ans = 0;
    for(int i = 1; i <= N; i++){
        ans += dp[N][i][i*A];
    }

    cout << ans << endl;
}

Measured memory_bytes: 52224
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define inf 1000000000
#define MOD 1000000007
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
inline ll readl(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
inline ll power(ll a,ll b){ll ans=1;while(b){if(b&1){ans=ans*a%MOD;--b;}b>>=1;a=a*a%MOD;}return ans%MOD;}
/*================Header Template==============*/
void dfs(int a,int b,int c){
	
}
int main(){
	int a[4];for(int i=1;i<=3;i++) a[i]=read();sort(a+1,a+4);
	printf("%d\n",((a[2]-a[1])&1)?(a[3]-a[2]+(a[2]-a[1])/2+2):(a[3]-a[2]+(a[2]-a[1])/2));
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#define llint long long
const llint inf = 1e18;

using namespace std;

struct SegTree{
	llint size;
	vector<llint> seg;
	
	SegTree(){}
	SegTree(llint size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(llint i = 0; i < (1<<(size+1)); i++) seg[i] = inf;
	}
	
	void update(llint i, llint val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}

	llint query(llint a, llint b, llint k, llint l, llint r)
	{
		if(b < l || r < a) return inf;
		if(a <= l && r <= b) return seg[k];
		llint lval = query(a, b, k*2, l, (l+r)/2);
		llint rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	llint query(llint a, llint b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint N, Q, A, B;
llint x[200005];
llint dp[200005];
SegTree up(18), down(18);
llint add;

int main(void)
{
	cin >> N >> Q >> A >> B;
	for(int i = 1; i <= Q; i++) cin >> x[i];
	for(int i = 1; i <= N; i++) dp[i] = inf;
	x[0] = A, dp[B] = 0;
	
	for(int i = 1; i <= N; i++){
		up.update(i, dp[i] - i);
		down.update(i, dp[i] - (N-i+1));
	}
	
	llint lmin, rmin, cost;
	for(int i = 1; i <= Q; i++){
		
		int t = x[i-1], nt = x[i];
		cost = abs(t - nt);
		add += cost;
		lmin = rmin = inf;
		if(nt >= 1) lmin = up.query(1, nt) + nt;
		if(nt < N) rmin = down.query(nt+1, N) + (N-nt+1);
		dp[t] = min(dp[t], min(lmin, rmin) - cost);
		up.update(t, dp[t] - t);
		down.update(t, dp[t] - (N-t+1));
		
	}
	
	llint ans = inf;
	for(int i = 1; i <= N; i++){
		ans = min(ans, add + dp[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int l = 0;
    for(int i = 1;; i++){
        if(n <= i * (i + 1) / 2){
            l = i; break;
        }
    }
    vector<int> ans;
    for(int i = l; i >= 1; i--){
        if(n >= i){
            ans. push_back(i);
            n -= i;
        }
    }
    for(int ii = 0; ii < ans.size(); ii++){
        cout << ans[ii] << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<vector>
#include <map>
#include<cstring>
#include<algorithm>
#include<list>

using namespace std;

short node[10001];
short state_before[10001];
short map_before[10001];


map<int,list<pair<int,int>>> points;



void read_points(int tate){
    memcpy(map_before,node,sizeof node);
    memset(node,0,sizeof(node));    
    for(auto tmp:points[tate]){
        node[tmp.first]+=tmp.second;
    }
}
int main(){
    int n,r;
    int S=0;
    int L=0;
    ios::sync_with_stdio(false);
  
    while(1){
        cin>>n>>r;
        if(n==0&&r==0)break;
        
        points.clear();
        int x1,y1,x2,y2;
        int max_x=0,min_x=10000,max_y=0,min_y=10000;
        for(int i=0;i<n;i++){
            cin>>x1>>y1>>x2>>y2;
 
            if(points.find(y1)==points.end()){
                list<pair<int,int> > tmp;
                points[y1]=tmp;
            }
            if(points.find(y2)==points.end()){
                list<pair<int,int> > tmp;
                points[y2]=tmp;
            }
            points[y1].push_back(make_pair(x1,1));
            points[y1].push_back(make_pair(x2,-1));
            points[y2].push_back(make_pair(x1,-1));
            points[y2].push_back(make_pair(x2,1));
            if(max_x<x2)max_x=x2;
            if(max_y<y2)max_y=y2;
            if(min_x>x1)min_x=x1;
            if(min_y>y1)min_y=y1;
            
        }
        
        
        S=0;
        L=0;
        for(int h=min_y;h<=max_y;h++){
            
            read_points(h);
            int yoko_state=0;
            for(int w=min_x;w<=max_x;w++){
                
                yoko_state+=node[w];
                node[w]=yoko_state;
                if(h!=0){
                    node[w]+=state_before[w];
                }
                state_before[w]=node[w];
                if(node[w]>0){
                   S++;
                   if(w==0)L+=2;
                   else if(node[w-1]==0)L+=2;
                   if(h==0)L+=2;
                   else if(map_before[w]==0)L+=2;
                }
                
                
            }
            
        }


        cout<<S<<endl;
        if(r==2){
            cout<<L<<endl;
        }
        
        

    }

    

}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
int main() {
	int a,b,ans;
	cin >> a >> b;
	ans=(b-1)/(a-1);
	if((b-1)%(a-1)!=0) ans++;
  cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    string a, b; cin >> a >> b;
    int x = stoi(a + b);
    double root = sqrt(x);
    int rooot = sqrt(x);
    if(root == rooot) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll,ll,ll,ll> T;
#define MAX 1e9
struct block { ll sum, w, s, v; };
bool comp(block a, block b) { return a.sum > b.sum; }
int main(){
  int N;cin>>N;
  block Block[N];
  rep(i,N){
    ll w,s,v,sum;
    cin>>w>>s>>v;
    sum=w+s;
    Block[i]=block{sum,w,s,v};
  }
  sort(Block, Block + N, comp);
  ll dp[N+1][20005];
  rep(i,N+1){rep(j,20001){dp[i][j]=0ll;}}
  for(int i = 0; i < N; i++) {
        for(int j = 0; j < 20001; j++) {
          dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
          ll W,S,V;
          W=Block[i].w;
          S=Block[i].s;
          V=Block[i].v;
          if(j-W<0){continue;}
          dp[i+1][min(S,j-W)]=max(dp[i+1][min(S,j-W)],dp[i][j]+V);
        }
    }
  ll ans=0ll;
  rep(i,20001){
  	ans=max(dp[N][i],ans);
  }
  cout<<ans;
  
}


Measured memory_bytes: 160080
S = input()
N = len(S)
cnt_list = [0, 0, 0]
for s in S:
    if s == 'a':
        cnt_list[0] += 1
    elif s == 'b':
        cnt_list[1] += 1
    else:
        cnt_list[2] += 1
tmp = N % 3 
if tmp == 0:
    if N // 3 == max(cnt_list) and N // 3 == min(cnt_list):
        ans = "YES"
    else:
        ans = "NO"
elif tmp == 1:
    cnt_list.sort()
    if cnt_list[0] == cnt_list[1] and cnt_list[2] == N//3+1:
        ans = "YES"
    else:
        ans = "NO"
else:
    cnt_list.sort()
    if cnt_list[0] == N//3 and cnt_list[1] == cnt_list[2]:
        ans = "YES"
    else:
        ans = "NO"
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{
       if(a.first!=b.first) return(a.first > b.first);
       else return (a.second<b.second);
} 
ll power(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
        x=(x*x);
        n=n/2;
    }
    return result;
}
bool isPrime(ll k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    ll i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}


int main(){
   IOS;
ll t;t=1;//cin>>t;
while(t--){
ll n;cin>>n;
if(n>=30) cout<<"Yes\n";
else cout<<"No\n";

}


    
    
    
    





return 0;}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char c;
    
    cin>>c;
    

        if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')
        cout<<"vowel"<<endl;
        else
        cout<<"consonant"<<endl;
    
    

    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
//struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } }_io;
int main(){
	double d, t, s;
	cin>>d>>t>>s;
	if(d/s<=t) cout<<"Yes"<<'\n';
	else cout<<"No"<<'\n';
}


Measured memory_bytes: 3724
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<unordered_map>
#include <cmath>
#include<climits>
using namespace std;

int main()
{
    unsigned long long n; cin >> n;
    unsigned long long a; cin >> a;
    unsigned long long b; cin >> b;
    unsigned long long c; cin >> c;
    unsigned long long d; cin >> d;
    unsigned long long e; cin >> e;

    vector<unsigned long long> paths {a, b, c, d, e};

    unsigned long long min = 0xffffffffffffffff;
    for(int i = 0; i < 5; ++i){
        if(min > paths[i]){
            min = paths[i];
        }
    }
    unsigned long long answer = 0;
    unsigned long long tmp = (unsigned long long) ceil((double) n / (double)min);
    answer = 4 + tmp;  
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i

def factorial(n)
  arr = [*1..n]
  loop do
    return arr[0] if arr.length == 1
    arr = arr.each_slice(2).map { |a, b| b ? a * b : a }
  end
end

puts factorial(N) % (10 ** 9 + 7)



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int a, b;
  cin >> a >> b;
  if (a < 10 && b < 10) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }
}

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

dp = [[0] * 3 for i in range(N)]

# i日目にjを選択した時の最大値を計算する
for i in range(N):
    for j in range(3):
        if i == 0:
            dp[i][j] = array[i][j]
            continue
        for k in range(3):
            if j != k:
                sum = dp[i - 1][k] + array[i][j]
                dp[i][j] = sum if sum > dp[i][j] else dp[i][j]

print(max(dp[N - 1]))


Measured memory_bytes: 100516
A,B,C = map(int,input().split())
cnt=0

if A==B==C:
  if A%2==0:
    cnt=-1
  else:
    cnt=0
else:
  while A%2==0 and B%2==0 and C%2==0:
    s=A//2
    t=B//2
    u=C//2
    A=t+u
    B=u+s
    C=s+t
    cnt +=1
    
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
    string s;
    cin >> s;
    rep(i,s.size()){
        if(i%2){
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N = int(input())
    Edge = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        Edge[a-1].append(b-1)
        Edge[b-1].append(a-1)
    C = [int(c) for c in input().split()]
    C.sort(reverse  = True)
    Color = [None] * N
    Color[0] = C[0]
    q = deque()
    for e in Edge[0]:
        q.append((e, 0))
    ans = 0
    for i in range(1, N):
        nowN, preN = q.popleft()
        ans += C[i]
        Color[nowN] = C[i]
        for e in Edge[nowN]:
            if e != preN: q.append((e, nowN))
    print(ans)
    print(" ".join(map(str, Color)))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 6380
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

#define reep(i,n,m) for(int i=(n);i<(m);i++)
#define rep(i,n) reep(i,0,n)

using namespace std;

char road[100][2] = {0};

int main(){
    string str;
    road['A'][0] = 'X';
    road['A'][1] = 'Y';

    road['X'][1] = 'Z';

    road['Z'][0] = 'W';
    road['Z'][1] = 'B';

    road['B'][0] = 'Y';
    road['B'][1] = 'X';

    road['W'][0] = 'B';
    road['W'][1] = 'Y';

    road['Y'][0] = 'X';
    while(cin>>str,str!="#"){
        char now_town = 'A';
        bool flg=true;
        rep(i,str.length()){
            int d = str[i]-'0';
            now_town = road[now_town][d];
            if(now_town==0){
                flg=false;
                break;
            }
        }

        if(now_town!='B'){
            flg=false;
        }

        if(flg){
            puts("Yes");
        }else{
            puts("No");
        }
    }
    return 0;
}

Measured memory_bytes: 1168