akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll number1,ll number2){
	return number1 * number2 / gcd(number1,number2);	
}

int main() {
	
	int n;
	scanf("%d", &n);
	vector<int> a(n), b(n);
	rep(i, n)scanf("%d", &a[i]);
	rep(i, n)scanf("%d", &b[i]);
	ll ans = 0;
	rep(i, n){
	  ans += max(0, a[i] - b[i]);
	}
	printf("%lld\n", ans);
	
	Please AC;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  string s;
  cin >> s;
  ll n = s.size();
  ll k;
  cin >> k;

  // dp[i][j][l] .. i=0: smaller, i=1: equal. j .. use [0, j). l .. count of not 0 is k.
  vector<vector<vector<ll>>> dp(2, vector<vector<ll>>(n+1, vector<ll>(k+2)));
  dp[1][0][0] = 1;
  rep(j, n) {
    ll digit = s[j] - '0';
    rep(i, 2) {
      rep(l, k+1) {
        rep(m, 10) { // consider number m
          if (i == 1 && m > digit) { continue; } // skip

          ll ni = (i==0) ? 0 : ((m < digit) ? 0 : 1);
          ll nl = (m == 0) ? l : (l+1); // the next count of not-0
          dp[ni][j+1][nl] += dp[i][j][l];
        }
      }
    }
  }

  cout << dp[0][n][k] + dp[1][n][k] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, m;
    cin >> n >> m;
    int sum=0;
    for(int i=0; i<m; i++){
        int a;
        cin >> a;
        sum += a;
    }
    n -= sum;
    if(n < 0) out(-1);
    else out(n);
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

bool find(string s){

int n=s.length();
int k=n-1;
  
  for(int i=0;i<n/2;i++){
         if(s[i]!=s[k]) {
           return false;
         }
        k--; 
  }
  return true;

}






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

   if(!find(s)){
     cout<<"No";
     return 0;
   }
 int n=s.length();

  string t=s.substr(0,((n-1)/2));

 if(!find(t)){
   cout<<"No";
   return 0;
 } 
 
 string f=s.substr(0,(n+3/2));

 if(!find(f)){
   cout<<"No";
   return 0;
 }

 cout<<"Yes";
 

}

Measured memory_bytes: 256
INTEGER A,B,ANS
CHARACTER(5) X
READ*,A,B
ANS=0
DO I=A,B
  WRITE(X,"(I0)")I
  IF(X(1:1)==X(5:5).AND.X(2:2)==X(4:4))ANS=ANS+1
END DO
PRINT"(I0)",ANS
END

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

int N, A, B, C, D;
string s;
bool dfs(int cur, vector<bool>& mark) {
    if (s[cur] == '#') return false;

    if (cur == C)
        mark[cur] = true;
    else if (cur > C)
        return false;
    else
        mark[cur] = dfs(cur+1, mark) || dfs(cur+2, mark);
    return mark[cur];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    
    int P, Q, R;
    cin >> P >> Q >> R;

    cout << min(P+Q, min(P+R, Q+R)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1||j==0||j==w-1)
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

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

  if (s[a] != '-') {
    cout << "No";
    return 0;
  }

  if (s.substr(0, a).find("-") != string::npos) {
    cout << "No";
    return 0;
  }

  if (s.substr(a+1, b).find("-") != string::npos) {
    cout << "No";
    return 0;
  }

  cout << "Yes";
}


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

using namespace std;

typedef complex<double> P;

int W,H,N,R;
int x1[123],y_1[123],x2[123],y2[123],t[123];
double eps=1e-9;

double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

pair<pair<P,P>,pair<P,P> > sl(P a1,P a2,double dd){
  P a=a2-a1;
  P d=a/abs(a)*P(0,1)*dd;
  return make_pair(make_pair(a1+d,a2+d),make_pair(a1-d,a2-d));
}

bool safe(pair<P,P> a,pair<P,P> b){
  P ad=a.second-a.first;
  P bd=b.second-b.first;
  double aa=cross(ad,bd);
  if(fabs(aa)<eps)return false;
  P is=a.first+ad/aa*cross(b.first-a.first,bd);
  //    cout<<is<<endl;
  if(is.real()<R-eps||W-R+eps<is.real()||is.imag()<R-eps||H-R+eps<is.imag())return false;
  for(int i=0;i<N;i++){
    P p1=P(x1[i],y_1[i]);
    P p=P(x2[i],y2[i])-p1;
    //    cout<<cross(is-p1,p)/abs(p)<<endl;
    if(fabs(cross(is-p1,p))/abs(p)<R+t[i]-eps)return false;
  }
  //  cout<<is<<endl;
  return true;
}

bool check(P a1,P a2,P b1,P b2){
  auto as=sl(a1,a2,R);
  auto bs=sl(b1,b2,R);
  return safe(as.first,bs.first)||safe(as.first,bs.second)||safe(as.second,bs.first)||safe(as.second,bs.second);
}
  
int main(){
  for(;cin>>W>>H>>N>>R,W|H|N|R;){
    bool f=!N;
    P p1[123][2],p2[123][2];
    for(int i=0;i<N;i++){
      cin>>x1[i]>>y_1[i]>>x2[i]>>y2[i]>>t[i];
      auto s=sl(P(x1[i],y_1[i]),P(x2[i],y2[i]),t[i]);
      p1[i][0]=s.first.first;
      p2[i][0]=s.first.second;
      p1[i][1]=s.second.first;
      p2[i][1]=s.second.second;
    }
    for(int i=0;i<N;i++){
      for(int j=0;j<2;j++){
	f|=check(p1[i][j],p2[i][j],P(0,0),P(W,0));
	f|=check(p1[i][j],p2[i][j],P(W,0),P(W,H));
	f|=check(p1[i][j],p2[i][j],P(W,H),P(0,H));
	f|=check(p1[i][j],p2[i][j],P(0,H),P(0,0));
	for(int k=0;k<i;k++){
	  for(int l=0;l<2;l++){
	    f|=check(p1[i][j],p2[i][j],p1[k][l],p2[k][l]);
	  }
	}
      }
    }
    cout<<(f?"Yes":"No")<<endl;
  }
}

Measured memory_bytes: 3068
#include<iostream>

using namespace std;

int main() {
	char x[3];
	int i, a = 0, b = 0, c = 0;

	for (i = 0; i < 3; i++) {
		cin >> x[i];
	}
	for (i = 0; i < 3; i++) {
		if (x[i] == 'a') {
			a += 1;
		}
		if (x[i] == 'b') {
			b += 1;
		}
		if (x[i] == 'c') {
			c += 1;
		}
	}
	if (a == 1 && b == 1 && c == 1) {
		cout << "Yes";
	}
	else { cout << "No"; }
	return 0;
}

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

#define SZ 200009

int main()
{
    int n, i;
    string s;
    set<string> mp;

    cin >> n;
    for(i=0; i<n; i++){
        cin >> s;
        mp.insert(s);
    }
    cout << mp.size() << endl;

    return 0;
}
/**


*/


Measured memory_bytes: 19124
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int n;
int G[101][101];
const int INF=100000000;
int dist[101];
bool used[101];

int main(){
cin>>n;
rep(i,n)rep(j,n)cin>>G[i][j];
long long  ans=0;
for(int i=0;i<n;i++){
	int ret=INF;
	for(int j=i;j<n;j++){
		ans+=min(G[i][j],G[j][i]);
	}
}
cout<<ans<<endl;
	return 0;
}









Measured memory_bytes: 3136
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	switch n % 10 {
	case 2, 4, 5, 7, 9:
		fmt.Println("hon")
	case 0, 1, 6, 8:
		fmt.Println("pon")
	case 3:
		fmt.Println("bon")
	}
}

Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    int A, B, T;
    cin >> A >> B >> T;
    cout << T / A * B << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

int dp[10001];
bool isPrime[10001];

int main(){
	memset(isPrime,-1,sizeof(isPrime));
	isPrime[0] = false;
	isPrime[1] = false;
	for(int i=2;i*i<=10000;i++){
		if(isPrime[i]){
			for(int j=i+i;j<=10000;j+=i){
				isPrime[j]=false;
			}
		}
	}

	vector<int> prime;
	for(int i=2;i<=10000;i++){
		if(isPrime[i]){
			prime.push_back(i);
		}
	}

	int n;

	while(~scanf("%d",&n)){
		if(n==0) break;

		memset(dp,0,sizeof(dp));

		for(int i=0;i<prime.size();i++){
			if(prime[i] > n) break;
			for(int j=i;j<prime.size();j++){
				int sum = 0;
				for(int k=i;k<j;k++){
					sum += prime[k];
				}
				if(sum > n) break;
				dp[sum]++;
			}
		}

		printf("%d\n",dp[n]);
	}
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define int long long
//Ques D AtCoder Caracal vs Monster
int32_t main()
{
    int n,numofattac=1;
    cin>>n;
    int i=1;
    while(n!=1)
    {
        numofattac+=pow(2,i);
        i++;
        n=n/2;
    }
    cout<<numofattac;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Area of Polygon
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			double sa = 0;
			int s = 360;
			while(--n!=0){
				int t = sc.nextInt();
				s -= t;
				sa += Math.sin(t*Math.PI/180);
			}
			sa += Math.sin(s*Math.PI/180);
			n = sc.nextInt();
			s = 360;
			double sb = 0;
			while(--n!=0){
				int t = sc.nextInt();
				s -= t;
				sb += Math.sin(t*Math.PI/180);
			}
			sb += Math.sin(s*Math.PI/180);
			if(Math.abs(sa-sb)<1e-8)System.out.println(0);
			else System.out.println(sb<sa?1:sa<sb?2:0);
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t,a,b;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s.compare(t)<0){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  return 0;
}


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

using namespace std;

int main(void)
{
    int n, p = 0;
    cin >> n;
    vector<int> x(n);
    vector<int> s(100);

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

    for (int pi = 0; pi < 100; pi++) {
        s[pi] = 0;
        for (int i = 0; i < n; i++) {
            s[pi] += (x[i] - pi - 1) * (x[i] - pi - 1);
        }
    }

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

    cout << s[0] << endl;

    return 0;
}


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


int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  rep(i,ty-sy) cout << 'U';
  rep(i,tx-sx) cout << 'R';
  rep(i,ty-sy) cout << 'D';
  rep(i,tx-sx) cout << 'L';
  cout << 'L';
  rep(i,ty-sy+1) cout << 'U';
  rep(i,tx-sx+1) cout << 'R';
  cout << 'D';
  cout << 'R';
  rep(i,ty-sy+1) cout << 'D';
  rep(i,tx-sx+1) cout << 'L';
  cout << 'U';

  return 0;
}

Measured memory_bytes: 3600
/**
 *    author:  tourist
 *    created: 26.11.2019 09:33:48       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n - 1; i++) {
    if (a[i][0] > a[i + 1][0] || (m == 1 && a[i][0] == a[i + 1][0])) {
      cout << -1 << '\n';
      return 0;
    }
  }
  if (m == 1) {
    cout << 0 << '\n';
    return 0;
  }
  const long long inf = (long long) 1.01e9;
  auto Transform = [&](vector<long long>& v, long long x) {
    if (x < 42) {
      while (x --> 0) {
        for (int j = 1; j < m; j++) {
          v[j] = min(v[j] + v[j - 1], inf);
        }
      }
    } else {
      for (int i = m - 1; i >= 1; i--) {
        long long c = 1;
        for (int j = 0; j < i; j++) {
          c *= x + j;
          c /= j + 1;
          v[i] = (c > inf ? inf : min(v[i] + v[i - 1 - j] * c, inf));
          if (v[i] == inf) {
            break;
          }
        }
      }
    }
  };
  auto Compare = [&](int i, long long p, long long q) {
    vector<long long> b(a[i].begin(), a[i].end());
    vector<long long> c(a[i + 1].begin(), a[i + 1].end());
    Transform(b, p - min(p, q));
    Transform(c, q - min(p, q));
    return (b == c ? 0 : (b > c ? 1 : -1));
  };
  long long ans = 0;
  long long last = 0;
  for (int i = 1; i < n; i++) {
    if (a[i][0] > a[i - 1][0]) {
      last = 0;
      continue;
    }
    long long val = a[i - 1][1] + a[i - 1][0] * last;
    long long steps = 0;
    if (val > a[i][1]) {
      steps = (val - a[i][1] + a[i][0] - 1) / a[i][0];
    }
    if (a[i][1] + a[i][0] * steps == val) {
      if (Compare(i - 1, last, steps) >= 0) {
        ++steps;
      }
    }
    last = steps;
    ans += last;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4224
import java.util.Scanner;

/**
 * Main
 */
public class Main {

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        int restT = A;
        int restA = C;

        while(restT > 0 && restA > 0){
            restA -= B;
            if(restA <= 0){
                System.out.println("Yes");
                break;
            }
            restT -= D;
            if(restT <= 0){
                System.out.println("No");
                break;
            }
        }
    }
}


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

int a, b, c;

int check(){
	if(a*a+b*b == c*c || a*a+c*c == b*b || b*b+c*c == a*a)
		return 1;
	return 0;
}

int main(){
	int t;
	cin >> t;
	for(int i = 0; i < t; i++){
		cin >> a >> b >> c;
		if(check())
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int mod = 1000000007;

P front_tail(int a);

int main() {

    int N; cin >> N;

    map<P, int> freq;
    for (int i = 1; i <= N; i++)
        freq[front_tail(i)]++;

    ll ans = 0;
    for (auto iter = freq.begin(); iter != freq.end(); iter++) {

        P key = iter->first;
        int value = iter->second;
        P rev(key.second, key.first);
        ll value_rev = freq[rev];
        ans += value * value_rev;
    }

    cout << ans << '\n';

}

P front_tail(int a) {

    string s = to_string(a);
    P p(int(s.front()), int(s.back()));
    return p;

}


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

int main(){
  long long int n,a,b;
  cin >> n >> a >> b;
  long long int k=(n-(n%(a+b)))/(a+b);
  long long int l=n%(a+b);
  long long int ans=k*a;
  if(l>=a){
    ans+=a;
  }else{
    ans+=l;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    if (a <= 9 && b <= 9) {
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
#define endl cout << "\n"
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s1;
    string s2;
    cin >> s1 >> s2;
    s2.pop_back();

    if(s1==s2) Yes;
    else No;



  bye;
}

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

int main(){
	int k;
    cin>>k;
  	vector<pair<int, int> > v;
  
  	for(int i=1;i<=9;i++){
      	v.push_back(make_pair(-1, i));
    }
  	int p=0;
  	int ct=0;
  	while(1){
    	int t=v[p].second;
      	if(t==0){
        	v.push_back(make_pair(p, 0));
          	v.push_back(make_pair(p, 1));
          	ct+=2;
        }else if(t==9){
        	v.push_back(make_pair(p, 8));
          	v.push_back(make_pair(p, 9));
          	ct+=2;
        }else{
        	v.push_back(make_pair(p, t-1));
          	v.push_back(make_pair(p, t));
          	v.push_back(make_pair(p, t+1));
          	ct+=3;
        }
      	p++;
      	if(ct>k) break;
    }
  	
  	
  	int q=k-1;
  	long int num=0, ten=1;
  	while(q!=-1){
    	num+=(long int)v[q].second*ten;
      	q=v[q].first;
      	ten*=10;
    }
  
  	cout<<num<<endl;
  
  	return 0;
}


Measured memory_bytes: 4236
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <ctime>
#include <climits>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <cstdlib>

using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
long int limit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//最大limit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//

int jage(int x){
    if((x % 2 == 1 && x >= 1 && x <= 7) || (x % 2 == 0 && x >= 8 && x <= 12))
        return 0;
    if(x == 4 || x == 6 || x == 9 || x == 11)
        return 1;
    if(x == 2)
        return 2;
}

int main(){
    long int x,y;
    cin >> x >> y;
    if(jage(x) == jage(y)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
using System;

namespace ABC151
{
	class Program
	{
		static void Main(string[] args)
		{
			//int a = int.Parse(Console.ReadLine());

			//string[] input = Console.ReadLine().Split(' ');
			//int b = int.Parse(input[0]);
			//int c = int.Parse(input[1]);

			//string s = Console.ReadLine();
			//Console.WriteLine(a + b + c + " " + s);

			//Console.ReadLine();

			string[] words = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z" };

			string input = Console.ReadLine();

			var i = Array.IndexOf(words,input);

			//for(int j =0;j <words.Length;j++)
			//{
				if (i != 25)
				{
					Console.WriteLine(words[i + 1]);
				}
			//}

			//if (i != 25)
			//{
			//	Console.WriteLine(words[i + 1]);
			//}
			Console.ReadLine();

		}
	}
}


Measured memory_bytes: 10976
#include <stdio.h>

int main() {
    int a, b, c;
    
    scanf("%d%d%d", &a, &b, &c);
    
    if ((a == b && a == c) || (a != b && a != c && b != c)) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    
    return 0;
}









Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	long long n,a[5],k;
	scanf("%lld",&n);
	scanf("%lld",&a[0]);
	scanf("%lld",&a[1]);
	scanf("%lld",&a[2]);
	scanf("%lld",&a[3]);
	scanf("%lld",&a[4]);
	long long min=a[0];
	int i=0;
	for(i=0;i<5;i++)
	{
		if(min>a[i])
		{
			min=a[i];
		}
	 } 
	 if(min>n)
	 {
	 	printf("5\n");
	 }
	 else
	 {
	 	k=n/min;
	 	if(n%min!=0)
	 	{
	 		k++;
		 }
		 k=k+4;
		 printf("%lld\n",k);
	}
	return 0;
	
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N, K;
	cin >> N >> K;
	ll x[60], y[60];
	vector<P> v(N);
	rep(i, N) {
		cin >> x[i] >> y[i];
		v[i] = P(x[i], y[i]);
	}
	sort(x, x + N);
	sort(y, y + N);
	ll ans = LLONG_MAX;
	for (int a = 0; a < N; a++) {
		for (int aa = a; aa < N; aa++) {
			for (int b = 0; b < N; b++) {
				for (int bb = b; bb < N; bb++){
					int k = 0;
					for (int i = 0; i < N; i++) {
						if (x[a] <= v[i].first && v[i].first <= x[aa] && y[b] <= v[i].second && v[i].second <= y[bb]) {
							k++;
						}
					}
					if (k >= K) {
						ans = min(ans, (x[aa] - x[a]) * (y[bb] - y[b]));
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	int n,m,k;
	cin>>n>>m>>k;
	int a[n],b[m];
	int mn1=1e18,mn2=1e18;
	pair<pair<int,int>,int> p[k];
	for(int i=0;i<n;i++){
		cin>>a[i];
		mn1=min(mn1,a[i]);
	} 	
	for(int i=0;i<m;i++){
		cin>>b[i];
		mn2=min(mn2,b[i]);
	}
	int ans=mn1+mn2;
	for(int i=0;i<k;i++){
		int x,y,z;
		cin>>x>>y>>z;
		x--,y--;
		ans=min(ans,a[x]+b[y]-z);
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main(){
    int n,i,j=0,k,l,r;
    cin>>k>>l>>r;
    for(i=l;i<=r;i++){
        if(i%k==0){cout<<"OK";j=1;break;}
    }
    if(j==0){cout<<"NG";}

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
  int a, b, c;
  std::cin >> a >> b >> c;
  std::vector<int> abc = {a,b,c};
  std::sort(abc.begin(), abc.end());
  bool ok = abc[0]==5 && abc[1]==5 && abc[2]==7;

  std::cout << (ok ? "YES" : "NO");
}


Measured memory_bytes: 256
n=input()
l=map(int,raw_input().split())
s=sorted(l)
c=0
for i in range(n):
    a=l.index(s[i])
    j=0
    while a>i:
        j+=1
        b=l.index(s[a])
        c+=l[b]
        l[a],l[b]=l[b],l[a]
        a=b
    c+=min(s[i]*j,s[i]*2+s[0]*(j+2))
print c

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

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

  double half = a * b / 2;
  double s = x / a;
  double rad;
  if (s <= half) {
    double w = 2 * s / b;
    rad = atan2(b, w);
  } else {
    double h = (a * b - s) * 2 / a;
    rad = atan2(h, a);
  }
  double deg = rad * 180 / M_PI;
  printf("%0.10f\n", deg);
  return 0;
}

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

typedef pair<int,int>P;

int n,dis[100005],ans[100009];
vector<P>v[100005];

void dfs1(int idx,int pre){
  for(int i=0;i<v[idx].size();i++){
    int next=v[idx][i].first;
    int cost=v[idx][i].second;
    if(next==pre)continue;
    dfs1(next,idx);
    dis[idx]=max(dis[idx],dis[next]+cost);
  }
}

int dfs2(int idx,int d_pre,int pre){
  vector<P>child;
  child.push_back(P(0,-1));
  for(int i=0;i<v[idx].size();i++){
    int next=v[idx][i].first;
    int cost=v[idx][i].second;
    if(next==pre)child.push_back(P(d_pre+cost,next));
    else child.push_back(P(dis[next]+cost,next));
  }
  sort(child.begin(),child.end(),greater<P>());
  int res=child[0].first+child[1].first;
  ans[idx]=max(child[0].first,child[1].first);
  for(int i=0;i<v[idx].size();i++){
    int next=v[idx][i].first;
    int cost=v[idx][i].second;
    if(next==pre)continue;
    res=max(res,dfs2(next,child[next==child[0].second].first,idx));
  }
  return res;
}

int main(){
  cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b,w;
    cin>>a>>b;a--;b--;
    v[a].push_back(P(b,1));
    v[b].push_back(P(a,1));
  }
  dfs1(n/2,-1);
  dfs2(n/2,0,-1);
  for(int i=0;i<n;i++)cout<<(n-1)*2-ans[i]<<endl;
}


Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
int a[55],b[55],c[55],d[55];
int ans[12];
int n,m,q;
int res=0;
void cal(){
	int ress=0;
	for(int i=1;i<=q;i++){
		if(ans[b[i]]-ans[a[i]]==c[i]) ress+=d[i];
	}
	res=max(res,ress);
}
void dfs(int id){
	if(id==0){
		//for(int i=1;i<=n;i++) printf("%d ",ans[i]);
		//printf("\n");
		cal();return;
	}
	int tmp1=ans[id-1],tmp2=ans[id+1],tmp3=ans[id];
	for(int i=tmp1;i<=tmp2;i++){
		ans[id]=i;
		dfs(id-1);
		
	}
	ans[id]=tmp3;
}
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=q;i++){
		scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
	}
	for(int i=1;i<=n;i++) ans[i]=1;
	ans[0]=1;
	ans[n+1]=m;
	dfs(n);
	printf("%d\n",res);
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c;
    cin >> a >> b;

    if(a==1) {
        if(b==2) {
            c = 3;
        }
        if(b==3) {
            c = 2;
        }
    }

    if(a==2) {
        if(b==1) {
            c = 3;
        }
        if(b==3) {
            c = 1;
        }
    }

    if(a==3) {
        if(b==1) {
            c = 2;
        }
        if(b==2) {
            c = 1;
        }
    }

    cout << c << endl;
  

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define l long int
#define endl '\n'
#define pb push_back
#define pf pop.front()
using namespace std;

long int divisor[1000001];

void solve()
{
l n;

cin>>n;
for(l i=1;i<n;i++)
{
	for(l j=i;j<=n;j+=i)
	{
		divisor[j]++;
	}
}

ll ans=0;

for(l i=1;i<n;i++)
ans+=divisor[n-i];

cout<<ans<<endl;
}


int32_t main()
{
FAST
l T=1;

while(T--)
{
solve();
}
}










Measured memory_bytes: 11444
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var ans = 0;
            for (int i = 0; i < N - 2; i++)
            {
                if (S.Substring(i, 3) == "ABC") ans++;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    vector<int> A(3);
    rep(i, 0, 3) cin >> A[i];
    sort(ALL(A));
    if((A[0] == A[1] && A[1] != A[2]) || (A[0] !=A[1] && A[1] == A[2])){
        cout << "Yes\n";
    }else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
n,d,a=map(int,input().split())

xh=[list(map(int, input().split())) for _ in range(n)]
xh.sort()

cnt=0

import heapq  # heapqライブラリのimport
#heapq.heapify(a)  # リストを優先度付きキューへ
#heapq.heappop(a)  # 最小値の取り出し
#heapq.heappush(a, -2)

bomb=0
he=[]
heapq.heapify(he)
dic={}

for i in range(n):
    #print(xh[i],bomb,he)
    (x,h)=xh[i]

    if bomb==0:
        secchi=x+d
        count=((-1*h)//a)*(-1)
        damage=count*a
        cnt+=count
        dic[secchi]=damage
        bomb+=damage
        heapq.heappush(he, secchi)
    else:
        while a:
            tmp=heapq.heappop(he)  
            if tmp+d<x:
                bomb-=dic[tmp]
            else:
                heapq.heappush(he, tmp)
                break
            if bomb==0:
                break

        if bomb<h:
            h-=bomb
            secchi=x+d
            count=((-1*h)//a)*(-1)
            damage=count*a
            cnt+=count
            dic[secchi]=damage
            bomb+=damage
            heapq.heappush(he, secchi)



print(cnt)



Measured memory_bytes: 81556
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int cnt=0,ans=s.size();
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='S') {
      cnt++;
    }
    else if(s[i]=='T'&&cnt>0) {
      ans-=2;
      cnt--;
    }
  }
  cout << ans << endl;
}

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

int main(){
    long long int n;
    cin >> n;

    long long int div;
    for (long long int i=1; i*i<=n; i++){
        if (n % i == 0) div = n/i;
    }
    int count = 0;
    while(div > 0){
        div /= 10;
        count += 1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,aa=0,bb=0;
  char c;
  cin>>n>>a>>b;
  for(int i=0;i<n;i++){
    cin>>c;
    if(c=='a'){
      if(aa+bb<a+b){
        cout<<"Yes"<<endl;
        aa++;
      }else{
        cout<<"No"<<endl;
      }
    }else if(c=='b'){
      if(aa+bb<a+b&&bb<b){
        cout<<"Yes"<<endl;
        bb++;
      }else{
        cout<<"No"<<endl;
      }
    }else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 640
const vals = [1,2,3]
           
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function(line) {
  lines.push(line);
});
reader.on('close', function() {
  	var ret = vals.filter(function(x) {
    	for (var i = 0; i<lines.length; i++) {
        	if (lines[i] == x)
              return false;
        }
      	return true;
    })[0]
    console.log(ret);
});

Measured memory_bytes: 7756
import sys
import itertools


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    f = [list(map(int, readline().split())) for _ in range(n)]
    p = [list(map(int, readline().split())) for _ in range(n)]
    mt = - (10 ** 10)
    for it in itertools.product([True, False], repeat=10):
        if sum(it) != 0:
            ls = [0] * n
            for i, iv in enumerate(it):
                for j in range(n):
                    ls[j] += 1 if f[j][i] == 1 and iv else 0
            t = 0
            for i in range(n):
                t += p[i][ls[i]]
            mt = max(mt, t)
    print(mt)


if __name__ == '__main__':
    solve()


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


//生徒iとポイントjのdistance

int distance(int i,int j,vector<vector<int>> vecstudent, vector<vector<int>> veccheck){
  return abs(vecstudent.at(i).at(0)-veccheck.at(j).at(0))+abs(vecstudent.at(i).at(1)-veccheck.at(j).at(1));
   }
  




int main() {
  
int N,M;
  cin>>N>>M;
  vector<vector<int>> vecstudent(N,vector<int>(2));
  vector<vector<int>> veccheck(M,vector<int>(2));
  for (int i=0;i<N;i++){
    cin>>vecstudent.at(i).at(0)>>vecstudent.at(i).at(1);
  }
  for (int i=0;i<M;i++){
    cin>>veccheck.at(i).at(0)>>veccheck.at(i).at(1);
  }
  
  //各生徒の答えを求める
  //行列の座標とポイントの番号のズレに注意
  
  for (int i=0;i<N;i++){
    int answer=0;
    int mindis=distance(i,0,vecstudent,veccheck);
    for (int j=0;j<M;j++){
      if (distance(i,j,vecstudent,veccheck)<mindis){
        answer=j;
        mindis=distance(i,j,vecstudent,veccheck);
    }
    }
    cout<<answer+1<<endl;
  }
  
}










Measured memory_bytes: 256
import copy

n = int(input())
p_list = list(map(int, input().split()))

q_list = copy.copy(p_list)
p_list.sort()

cnt = 0
for i in range(n):
  if p_list[i] != q_list[i]:
    cnt += 1

if cnt <= 2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3444
#include <functional>
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include <numeric>
using ll = long long;
using namespace std;
# define maxn 50
# define maxm 50

int main() {
  int x;
  cin>>x;
  for (int i(0);i*i/3<x;i++){
    if(i*(i+1)/2>=x){
      cout<<i;
      return 0;
    }
  }
}


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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n), b(n,0);
	rep(i,n) cin >> a[i];
	ll ans = 0;
	rep(i,n-1) {
		if (a[i]+b[i] > a[i+1]){
			b[i+1] = a[i]+b[i] - a[i+1];
			ans += b[i+1];
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
    long long X, Y;
    vector<long long> a;

    cin >> X >> Y;

    a.push_back(X);

    while(true){
        if(a[a.size() - 1] * 2 <= Y){
            a.push_back(a[a.size() - 1] * 2);
        }else{
            break;
        }
    }

    cout << a.size() << endl;
}

        

Measured memory_bytes: 256
main::IO()
main = do
    [s,t] <- words <$> getLine
    [a,b] <- map read . words <$> getLine
    u     <- getLine
    putStrLn $ if s==u 
        then (show (a-1) ++ " " ++ show b    )
        else (show a     ++ " " ++ show (b-1))

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

struct graph {

	int V;
	vector<int> *adj;

	graph(int x) {
		V = x;
		adj = new vector<int>[x];
	}

	void AddEdge (int a, int b) {

		adj[a].pb(b);
		adj[b].pb(a);
	}
};

int main()
{
	int n, m, x, y;
	cin >> n >> m;

	int value[n];
	rep(i, n)
		cin >> value[i];

	graph g(n);

	rep(i, m) {

		cin >> x >> y;
		x--;
		y--;
		g.AddEdge(x, y);
	}

	int count = 0;

	rep(i, n) {

		bool flag = true;

		for (auto it = g.adj[i].begin(); it != g.adj[i].end(); it++){

			if (*it != i && value[*it] >= value[i]) {
				flag = false;
				break;
			}
		}
		if (flag)
			count++;
	}

	cout << count << "\n";

	return 0;
}


Measured memory_bytes: 9152
n = int(input())
d = [int(i) for i in input().split(" ")]
if d[0]!=0:
    print(0)
else:
    te = [1] + [0 for i in range(max(d))]
    co = [0 for i in range(max(d)+1)]
    for i in d:
        co[i] += 1
    if 0 in co[1:]:
        print(0)
    elif co[0] != 1:
        print(0)
    elif len(co)==2:
        print(1)
    else:
        for i in range(1,len(co)):
            te[i] = te[i-1]*(co[i-1]**co[i]) % 998244353

        print(te[-1])

Measured memory_bytes: 14036
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{   double k,a,b,m,h,c;
    string s;
    cout.precision(20);
    cin>>a>>b>>h>>m;
    c=a*a+b*b-2*a*b*cos((5*((((int)h%12))+m/60)-m)*(M_PI/180)*6);
    cout<<sqrt(c);
    return 0;
}


Measured memory_bytes: 4200
//You can die anytime, but living takes true courage.
//Every journey begins with a single step. We just have to have patience.
//Life is not a game of luck. If you wanna win, work hard.
//It’s more important to master the cards you’re holding 
//than to complain about the ones your opponent was dealt.
//If you just submit yourself to fate, then that’s the end of it.




/*

struct P {
int x, y;
bool operator<(const P &p) {
if (x != p.x) return x < p.x;
else return y < p.y;
}
};


bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}

*/





/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Akshay Vashishtha 

//It’s just pathetic to give up on something before you even give it a shot.
//Knowing you’re different is only the beginning. If you accept these differences 
you’ll be able to get past them and grow even closer.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#define lld long long int 
#define vll vector<long long int>
#define vs vector<string> 
#define vint vector<int> 
#define vp vector<pair<int,int>>
//#define tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
#define forl(i,a,b) for(int i = a ; i <= b ; i++)
#define forln(i,a,b) for(int i = a; i < b ; i++)
lld mod = 1e9 + 7;
#define ps push_back
#define mk make_pair
#define F first 
#define S second 
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;


//I too will obtain everything that I desire. Not because someone asked me to do it, 
//but because I know in my heart that I have something worth fighting for. 
//Whatever you do, enjoy it to the fullest. That is the secret of life.

int main()
{
	lld c = 0ll ,res = 0ll,n;
  cin>>n;
  forl(i,1,n){
    if(i%3 == 0)
      res += i;
    else if(i % 5 == 0)
      res += i;
  }
  cout<<((n*(n+1))/2) - res;
	return 0;
}




Measured memory_bytes: 3632
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int ans = 0;

        char[] C = S.toCharArray();
        for(int i = 0; i < (C.length+1)/2; i++) {
            if(C[i] != C[C.length-i-1]) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23636